<commit_before>"""
    SESANS reader (based on ASCII reader)

    Reader for .ses or .sesans file format

    <NAME>
"""
import numpy as np
import os
from sas.sascalc.dataloader.data_info import Data1D

# Check whether we have a converter available
has_converter = True
try:
    from sas.sascalc.data_util.nxsunit import Converter
except:
    has_converter = False
_ZERO = 1e-16


class Reader:
    """
    Class to load sesans files (6 columns).
    """
    # File type
    type_name = "SESANS"

    # Wildcards
    type = ["SESANS files (*.ses)|*.ses",
            "SESANS files (*..sesans)|*.sesans"]
    # List of allowed extensions
    ext = ['.ses', '.SES', '.sesans', '.SESANS']

    # Flag to bypass extension check
    allow_all = True

    def read(self, path):
        """
        Load data file

        :param path: file path

        :return: SESANSData1D object, or None

        :raise RuntimeError: when the file can't be opened
        :raise ValueError: when the length of the data vectors are inconsistent
        """
        if os.path.isfile(path):
            basename = os.path.basename(path)
            _, extension = os.path.splitext(basename)
            if self.allow_all or extension.lower() in self.ext:
                with open(path, 'r') as input_f:
                    # Read in binary mode since GRASP frequently has no-ascii
                    # characters that brakes the open operation
                    line = input_f.readline()
                    params = {}
                    while line.strip() != "":
                        if line.strip() == "":
                            break
                        terms = line.strip().split("\t")
                        params[terms[0].strip()] = " ".join(terms[1:]).strip()
                        line = input_f.readline()
                    headers_temp = input_f.readline().strip().split("\t")
                    headers = {}
                    for h in headers_temp:
                        temp = h.strip().split()
                        headers[h[:-1].strip()] = temp[-1][1:-1]
                    data = np.loadtxt(input_f)
                    x = data[:, 0]
                    dx = data[:, 3]
                    lam = data[:, 4]
                    dlam = data[:, 5]
                    y = data[:, 1]
                    dy = data[:, 2]

                    lam_unit = self._header_fetch(headers, "wavelength")
                    if lam_unit == "AA":
                        lam_unit = "A"<commit_msg>Remove redundant code from sesans_reader<commit_after>"""
    SESANS reader (based on ASCII reader)

    Reader for .ses or .sesans file format

    <NAME>
"""
import numpy as np
import os
from sas.sascalc.dataloader.data_info import Data1D

# Check whether we have a converter available
has_converter = True
try:
    from sas.sascalc.data_util.nxsunit import Converter
except:
    has_converter = False
_ZERO = 1e-16


class Reader:
    """
    Class to load sesans files (6 columns).
    """
    # File type
    type_name = "SESANS"

    # Wildcards
    type = ["SESANS files (*.ses)|*.ses",
            "SESANS files (*..sesans)|*.sesans"]
    # List of allowed extensions
    ext = ['.ses', '.SES', '.sesans', '.SESANS']

    # Flag to bypass extension check
    allow_all = True

    def read(self, path):
        """
        Load data file

        :param path: file path

        :return: SESANSData1D object, or None

        :raise RuntimeError: when the file can't be opened
        :raise ValueError: when the length of the data vectors are inconsistent
        """
        if os.path.isfile(path):
            basename = os.path.basename(path)
            _, extension = os.path.splitext(basename)
            if self.allow_all or extension.lower() in self.ext:
                with open(path, 'r') as input_f:
                    # Read in binary mode since GRASP frequently has no-ascii
                    # characters that brakes the open operation
                    line = input_f.readline()
                    params = {}
                    while line.strip() != "":
                        terms = line.strip().split("\t")
                        params[terms[0].strip()] = " ".join(terms[1:]).strip()
                        line = input_f.readline()
                    headers_temp = input_f.readline().strip().split("\t")
                    headers = {}
                    for h in headers_temp:
                        temp = h.strip().split()
                        headers[h[:-1].strip()] = temp[-1][1:-1]
                    data = np.loadtxt(input_f)
                    x = data[:, 0]
                    dx = data[:, 3]
                    lam = data[:, 4]
                    dlam = data[:, 5]
                    y = data[:, 1]
                    dy = data[:, 2]

                    lam_unit = self._header_fetch(headers, "wavelength")
                    if lam_unit == "AA":
                        lam_unit = "A"
{'fraction_non_alphanumeric': 0.11276681433749497, 'fraction_numerical': 0.00724929520741039, 'mean_word_length': 1.4455933037912359, 'pattern_counts': {'":': 5, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4327412', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1341, 'n_words': 400}