<commit_before>from sympy import symbols
from sympy.utilities.autowrap import autowrap

def test_autowrap_f2py_f95():

    a, b, c = symbols('a b c')

    f = autowrap((((a + b)/c)**5).expand(), language='f95', backend='f2py')
    assert f(1, -2, 1) == -1.0
    assert f(1.0, -2.0, 1.0) == -1.0
    assert f(3, -4, 1) == -1.0
    assert f(-3, 4, 1) ==  1.0

    # check that autowrap updates the module name.  If not, the next line
    # will calculate the above expression again and assertion will fail:
    g = autowrap((((a + b)/ c)**4).expand(), language='f95', backend='f2py')
    assert g(1, -2, 1) ==  1.0


def test_autowrap_cython_C():
    a, b, c = symbols('a b c')
    f = autowrap(((a + b)/c).expand(), language='C', backend='cython')
    assert f(1, -2, 1) == -1.0<commit_msg>autowrap: better organization of tests<commit_after>from sympy import symbols
from sympy.utilities.autowrap import autowrap

#
# test runners used by several language-backend combinations
#

def runtest_autowrap_twice(language, backend):
    a, b, c = symbols('a b c')
    f = autowrap((((a + b)/c)**5).expand(), language, backend)
    g = autowrap((((a + b)/c)**4).expand(), language, backend)

    # check that autowrap updates the module name.  Else, g gives the same as f
    assert f(1, -2, 1) == -1.0
    assert g(1, -2, 1) ==  1.0

#
# tests of language-backend combinations
#

def test_wrap_twice_c_cython():
    runtest_autowrap_twice('C', 'cython')

def test_wrap_twice_f95_f2py():
    runtest_autowrap_twice('f95', 'f2py')
{'fraction_non_alphanumeric': 0.16688567674113008, 'fraction_numerical': 0.040735873850197106, 'mean_word_length': 3.5059171597633134, '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': '2632088', 'n_tokens_mistral': 602, 'n_tokens_neox': 581, 'n_words': 165}