<commit_before>import os

import numpy as np
import tables as tb

from nose.tools import assert_equal, assert_not_equal, assert_almost_equal, assert_true, \
                       assert_raises
from numpy.testing import assert_array_equal, assert_array_almost_equal

import pyne.data
import pyne.xs.models
from pyne.xs.cache import xs_cache
from pyne.xs.channels import sigma_f, sigma_s_gh, sigma_s, sigma_a_reaction, \
    metastable_ratio, sigma_a, chi, sigma_t, _atom_weight_channel
from pyne.pyne_config import pyne_conf
from pyne.material import Material

np.seterr(divide='ignore')

#
# Test helper functions
#

def test_atom_weight_channel1():
    E_n = xs_cache['E_n']
    xs_cache['E_g'] = np.array([3, 2, 1.0])

    chanfunc = lambda nuc: np.array([1.0, nuc], float)

    # Test dict
    nucspec = {1: 1, 10: 2}
    obs = _atom_weight_channel(chanfunc, nucspec)
    exp = np.array([1.0, 7.0])
    assert_array_equal(obs, exp)

    # Test list of tuples
    nucspec = [(1, 1), (10, 2)]
    obs = _atom_weight_channel(chanfunc, nucspec)
    exp = np.array([1.0, 7.0])
    assert_array_equal(obs, exp)

    # test material<commit_msg>Added setup method to xs.channels testing to fix running tests as a suite.<commit_after>import os

import numpy as np
import tables as tb

from nose.tools import assert_equal, assert_not_equal, assert_almost_equal, assert_true, \
                       assert_raises
from numpy.testing import assert_array_equal, assert_array_almost_equal

import pyne.data
import pyne.xs.models
from pyne.xs.cache import xs_cache
from pyne.xs.channels import sigma_f, sigma_s_gh, sigma_s, sigma_a_reaction, \
    metastable_ratio, sigma_a, chi, sigma_t, _atom_weight_channel
from pyne.pyne_config import pyne_conf
from pyne.material import Material

np.seterr(divide='ignore')

def setup():
    xs_cache.clear()

#
# Test helper functions
#
def test_atom_weight_channel1():
    E_n = xs_cache['E_n']
    xs_cache['E_g'] = np.array([3, 2, 1.0])

    chanfunc = lambda nuc: np.array([1.0, nuc], float)

    # Test dict
    nucspec = {1: 1, 10: 2}
    obs = _atom_weight_channel(chanfunc, nucspec)
    exp = np.array([1.0, 7.0])
    assert_array_equal(obs, exp)

    # Test list of tuples
    nucspec = [(1, 1), (10, 2)]
    obs = _atom_weight_channel(chanfunc, nucspec)
    exp = np.array([1.0, 7.0])
    assert_array_equal(obs, exp)

    # test material
{'fraction_non_alphanumeric': 0.10433319310054691, 'fraction_numerical': 0.02103491796381994, 'mean_word_length': 3.804040404040404, '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': '5261922', 'n_tokens_mistral': 899, 'n_tokens_neox': 848, 'n_words': 220}