<commit_before># -*- coding: utf-8 -*-
#
'''
I/O for Ansys's msh format, cf.
<http://www.afs.enea.it/fluent/Public/Fluent-Doc/PDF/chp03.pdf>.
'''
from . __about__ import __version__

from itertools import islice
import numpy
import re
import struct
import warnings


def _skip_till_two_closing_brackets(f):
    line = next(islice(f, 1)).decode('utf-8')
    while line.strip() == '':
        line = next(islice(f, 1)).decode('utf-8')

    if re.match('\s*\)\s*\)\s*$', line):
        # Two closing brackets: alright, continue.
        return

    # One closing bracket: skip ahead for the other one.
    assert line.strip() == ')'
    line = next(islice(f, 1)).decode('utf-8')
    while line.strip() == '':
        line = next(islice(f, 1)).decode('utf-8')
    assert line.strip() == ')'
    return


def _read_binary_points(f, line, first_point_index_overall, last_point_index):
    # points
    # (3010 (zone-id first-index last-index type ND)

    # If the line is self-contained, it is merely a declaration of
    # the total number of points.
    if re.match('^\s*\(\s*\d010\s*\([^\)]+\)\s*\)\s*$', line):
        return None, first_point_index_overall, last_point_index

    out = re.match('\s*\(\s*(\d0)10\s*\(([^\)]*)\).*', line)
    if out.group(1) == '20':
        dchar = 'f'
        dtype = numpy.float32
        bytes_per_item = 4
    else:
        assert out.group(1) == '30'
        dchar = 'd'
        dtype = numpy.float64
        bytes_per_item = 8

    a = [int(num, 16) for num in out.group(2).split()]<commit_msg>ansys: simpler bracket skip<commit_after># -*- coding: utf-8 -*-
#
'''
I/O for Ansys's msh format, cf.
<http://www.afs.enea.it/fluent/Public/Fluent-Doc/PDF/chp03.pdf>.
'''
from . __about__ import __version__

from itertools import islice
import numpy
import re
import warnings


def _skip_till_two_closing_brackets(f):
    bracket_count = 0
    while bracket_count < 2:
        if f.read(1).decode('utf-8') == ')':
            bracket_count += 1
    return


def _read_binary_points(f, line, first_point_index_overall, last_point_index):
    # points
    # (3010 (zone-id first-index last-index type ND)

    # If the line is self-contained, it is merely a declaration of
    # the total number of points.
    if re.match('^\s*\(\s*\d010\s*\([^\)]+\)\s*\)\s*$', line):
        return None, first_point_index_overall, last_point_index

    out = re.match('\s*\(\s*(\d0)10\s*\(([^\)]*)\).*', line)
    if out.group(1) == '20':
        dchar = 'f'
        dtype = numpy.float32
        bytes_per_item = 4
    else:
        assert out.group(1) == '30'
        dchar = 'd'
        dtype = numpy.float64
        bytes_per_item = 8

    a = [int(num, 16) for num in out.group(2).split()]
{'fraction_non_alphanumeric': 0.17176557316623664, 'fraction_numerical': 0.025433099889421305, 'mean_word_length': 2.6626180836707154, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2051692', 'n_tokens_mistral': 1038, 'n_tokens_neox': 982, 'n_words': 233}