<commit_before>"""Test module for chemkin."""

import numpy
import pytest
import warnings
from chemkin import *
from Parser import ReactionParser

# Treat warnings like errors (for testing purposes)
warnings.simplefilter("error")


# ======================= TESTS FOR REACTIONSYSTEM OBJECT ====================== #

@pytest.fixture
def test_base_reaction_system():
    """Returns a valid reaction system"""
    # rxn1 = Reaction(rxn_type="Elementary",
    #                 is_reversible=False,
    #                 rxn_equation="H2 + OH =] H2O + H",
    #                 species_list=['H', 'O', 'OH', 'H2', 'H2O', 'O2'],
    #                 rate_coeffs_components={'k': 10},
    #                 reactant_stoich_coeffs={'H2' :1, 'OH':1},
    #                 product_stoich_coeffs={'H2O' :1, 'H':1})
    # rxn2 = Reaction(rxn_type="Elementary",
    #                 is_reversible=True,
    #                 rxn_equation="O2 + H =] H2O",
    #                 species_list=['H', 'O', 'OH', 'H2', 'H2O', 'O2'],
    #                 rate_coeffs_components={'k': 10},
    #                 reactant_stoich_coeffs={'O2' :1, 'H':1},
    #                 product_stoich_coeffs={'H2O' :1})
    # reaction_list = [rxn1, rxn2]
    # return ReactionSystem(reaction_list)

    xml_filename = "rxns_mixed.xml"
    parser = ReactionParser(xml_filename)
    reaction_list = parser.get_reaction_list()
    concentrations = {'H':1, 'O2':2, 'OH':1, 'O':4, 'H2O':0, 'H2':1}
    temp = 100
    rxnsys = ReactionSystem(parser.reaction_list, parser.NASA_poly_coefs, temp, concentrations)
    return rxnsys

def test_rxn_sys_invalid_temperature():
    """Tests setting up reaction system with invalid temperatures."""
    xml_filename = "rxns_mixed.xml"
    parser = ReactionParser(xml_filename)
    reaction_list = parser.get_reaction_list()
    concentrations = {'H':1, 'O2':2, 'OH':1, 'O':4, 'H2O':0, 'H2':1}
    temp = 0
    with pytest.raises(ValueError):
        rxnsys = ReactionSystem(parser.reaction_list, parser.NASA_poly_coefs, temp, concentrations)
    temp = -100
    with pytest.raises(ValueError):
        rxnsys = ReactionSystem(parser.reaction_list, parser.NASA_poly_coefs, temp, concentrations)


def test_rxn_sys_get_reaction_rate():
    """Tests function to get reaction rate for a given system of reactions."""
    pass

# def test_rxn_sys_get_nasa_matrix():
#     pass
<commit_msg>Update test_chemkin.py<commit_after>"""Test module for chemkin."""

import numpy
import pytest
import warnings
from chemkin import *
from Parser import ReactionParser

# Treat warnings like errors (for testing purposes)
warnings.simplefilter("error")


# ======================= TESTS FOR REACTIONSYSTEM OBJECT ====================== #

@pytest.fixture
def test_base_reaction_system():
    """Returns a valid reaction system"""
    # rxn1 = Reaction(rxn_type="Elementary",
    #                 is_reversible=False,
    #                 rxn_equation="H2 + OH =] H2O + H",
    #                 species_list=['H', 'O', 'OH', 'H2', 'H2O', 'O2'],
    #                 rate_coeffs_components={'k': 10},
    #                 reactant_stoich_coeffs={'H2' :1, 'OH':1},
    #                 product_stoich_coeffs={'H2O' :1, 'H':1})
    # rxn2 = Reaction(rxn_type="Elementary",
    #                 is_reversible=True,
    #                 rxn_equation="O2 + H =] H2O",
    #                 species_list=['H', 'O', 'OH', 'H2', 'H2O', 'O2'],
    #                 rate_coeffs_components={'k': 10},
    #                 reactant_stoich_coeffs={'O2' :1, 'H':1},
    #                 product_stoich_coeffs={'H2O' :1})
    # reaction_list = [rxn1, rxn2]
    # return ReactionSystem(reaction_list)

    xml_filename = "rxns_mixed.xml"
    parser = ReactionParser(xml_filename)
    concentrations = {'H':1, 'O2':2, 'OH':1, 'O':4, 'H2O':0, 'H2':1}
    temp = 100
    rxnsys = ReactionSystem(parser.reaction_list, parser.NASA_poly_coefs, temp, concentrations)
    return rxnsys

def test_rxn_sys_invalid_temperature():
    """Tests setting up reaction system with invalid temperatures."""
    xml_filename = "rxns_mixed.xml"
    parser = ReactionParser(xml_filename)
    concentrations = {'H':1, 'O2':2, 'OH':1, 'O':4, 'H2O':0, 'H2':1}
    temp = 0
    with pytest.raises(ValueError):
        rxnsys = ReactionSystem(parser.reaction_list, parser.NASA_poly_coefs, temp, concentrations)
    temp = -100
    with pytest.raises(ValueError):
        rxnsys = ReactionSystem(parser.reaction_list, parser.NASA_poly_coefs, temp, concentrations)


def test_rxn_sys_get_reaction_rate():
    """Tests function to get reaction rate for a given system of reactions."""
    pass

# def test_rxn_sys_get_nasa_matrix():
#     pass

{'fraction_non_alphanumeric': 0.1522248243559719, 'fraction_numerical': 0.02299340004258037, 'mean_word_length': 3.032618025751073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '6838252', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1574, 'n_words': 323}