test_isoc.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. def test_c_double(self):
  11. out = self.module.coddity.c_add(1, 2)
  12. exp_out = 3
  13. assert out == exp_out
  14. # gh-9693
  15. def test_bindc_function(self):
  16. out = self.module.coddity.wat(1, 20)
  17. exp_out = 8
  18. assert out == exp_out
  19. # gh-25207
  20. def test_bindc_kinds(self):
  21. out = self.module.coddity.c_add_int64(1, 20)
  22. exp_out = 21
  23. assert out == exp_out
  24. # gh-25207
  25. def test_bindc_add_arr(self):
  26. a = np.array([1,2,3])
  27. b = np.array([1,2,3])
  28. out = self.module.coddity.add_arr(a, b)
  29. exp_out = a*2
  30. assert_allclose(out, exp_out)
  31. def test_process_f2cmap_dict():
  32. from numpy.f2py.auxfuncs import process_f2cmap_dict
  33. f2cmap_all = {"integer": {"8": "rubbish_type"}}
  34. new_map = {"INTEGER": {"4": "int"}}
  35. c2py_map = {"int": "int", "rubbish_type": "long"}
  36. exp_map, exp_maptyp = ({"integer": {"8": "rubbish_type", "4": "int"}}, ["int"])
  37. # Call the function
  38. res_map, res_maptyp = process_f2cmap_dict(f2cmap_all, new_map, c2py_map)
  39. # Assert the result is as expected
  40. assert res_map == exp_map
  41. assert res_maptyp == exp_maptyp