<commit_before># tests for the config reader module
from tardis.io import config_reader
from astropy import units as u
import os
import pytest
import yaml
import numpy as np

from numpy.testing import assert_almost_equal, assert_array_almost_equal
from tardis.util import parse_quantity

def data_path(filename):
    data_dir = os.path.dirname(__file__)
    return os.path.join(data_dir, 'data', filename)

def test_config_namespace_attribute_test():
    namespace = config_reader.ConfigurationNameSpace({'param1':1})
    assert namespace.param1 == 1

def test_config_namespace_attribute_test():
    namespace = config_reader.ConfigurationNameSpace({'param1':1})
    with pytest.raises(AttributeError):
        assert namespace.param2 == 1

def test_quantity_linspace():
    quantity_linspace_dict = dict(start='1.1e4 km/s', stop='2e4 cm/h', num=1000)
    quantity_linspace = config_reader.quantity_linspace(**quantity_linspace_dict)
    assert_almost_equal(quantity_linspace[0].value, 1.1e4)
    assert_almost_equal(quantity_linspace[-1].to('cm/h').value, 2e4)
    assert len(quantity_linspace) == 1001


def test_spectrum_list2_dict():
    spectrum_dict = config_reader.parse_spectrum_list2dict(
        [200*u.angstrom, 10000 * u.angstrom, 100])
    assert_almost_equal(spectrum_dict['start'].to(u.angstrom).value, 200)
    assert_almost_equal(spectrum_dict['end'].to(u.angstrom).value, 10000)<commit_msg>another small fix to the test<commit_after># tests for the config reader module
from tardis.io import config_reader
from astropy import units as u
import os
import pytest
import yaml
import numpy as np

from numpy.testing import assert_almost_equal, assert_array_almost_equal
from tardis.util import parse_quantity

def data_path(filename):
    data_dir = os.path.dirname(__file__)
    return os.path.join(data_dir, 'data', filename)

def test_config_namespace_attribute_test():
    namespace = config_reader.ConfigurationNameSpace({'param1':1})
    assert namespace.param1 == 1

def test_config_namespace_attribute_test():
    namespace = config_reader.ConfigurationNameSpace({'param1':1})
    with pytest.raises(AttributeError):
        assert namespace.param2 == 1

def test_quantity_linspace():
    quantity_linspace_dict = dict(start=1.1e4 * u.Unit('km/s'), stop=2e4 * u.Unit('cm/h'), num=1000)
    quantity_linspace = config_reader.quantity_linspace(**quantity_linspace_dict)
    assert_almost_equal(quantity_linspace[0].value, 1.1e4)
    assert_almost_equal(quantity_linspace[-1].to('cm/h').value, 2e4)
    assert len(quantity_linspace) == 1001


def test_spectrum_list2_dict():
    spectrum_dict = config_reader.parse_spectrum_list2dict(
        [200*u.angstrom, 10000 * u.angstrom, 100])
    assert_almost_equal(spectrum_dict['start'].to(u.angstrom).value, 200)
    assert_almost_equal(spectrum_dict['end'].to(u.angstrom).value, 10000)
{'fraction_non_alphanumeric': 0.10448807854137447, 'fraction_numerical': 0.034361851332398316, 'mean_word_length': 5.697183098591549, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4807910', 'n_tokens_mistral': 1003, 'n_tokens_neox': 916, 'n_words': 182}