test_isoc.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from . import util
  2. import numpy as np
  3. import pytest
  4. from numpy.testing import assert_allclose
  5. class TestISOC(util.F2PyTest):
  6. sources = [
  7. util.getpath("tests", "src", "isocintrin", "isoCtests.f90"),
  8. ]
  9. # gh-24553
  10. @pytest.mark.slow
  11. def test_c_double(self):
  12. out = self.module.coddity.c_add(1, 2)
  13. exp_out = 3
  14. assert out == exp_out
  15. # gh-9693
  16. def test_bindc_function(self):
  17. out = self.module.coddity.wat(1, 20)
  18. exp_out = 8
  19. assert out == exp_out
  20. # gh-25207
  21. def test_bindc_kinds(self):
  22. out = self.module.coddity.c_add_int64(1, 20)
  23. exp_out = 21
  24. assert out == exp_out
  25. # gh-25207
  26. def test_bindc_add_arr(self):
  27. a = np.array([1,2,3])
  28. b = np.array([1,2,3])
  29. out = self.module.coddity.add_arr(a, b)
  30. exp_out = a*2
  31. assert_allclose(out, exp_out)
  32. def test_process_f2cmap_dict():
  33. from numpy.f2py.auxfuncs import process_f2cmap_dict
  34. f2cmap_all = {"integer": {"8": "rubbish_type"}}
  35. new_map = {"INTEGER": {"4": "int"}}
  36. c2py_map = {"int": "int", "rubbish_type": "long"}
  37. exp_map, exp_maptyp = ({"integer": {"8": "rubbish_type", "4": "int"}}, ["int"])
  38. # Call the function
  39. res_map, res_maptyp = process_f2cmap_dict(f2cmap_all, new_map, c2py_map)
  40. # Assert the result is as expected
  41. assert res_map == exp_map
  42. assert res_maptyp == exp_maptyp