test_regression.py 764 B

1234567891011121314151617181920212223242526272829
  1. from __future__ import division, absolute_import, print_function
  2. import os
  3. import pytest
  4. import numpy as np
  5. from numpy.testing import assert_raises, assert_equal
  6. from . import util
  7. def _path(*a):
  8. return os.path.join(*((os.path.dirname(__file__),) + a))
  9. class TestIntentInOut(util.F2PyTest):
  10. # Check that intent(in out) translates as intent(inout)
  11. sources = [_path('src', 'regression', 'inout.f90')]
  12. @pytest.mark.slow
  13. def test_inout(self):
  14. # non-contiguous should raise error
  15. x = np.arange(6, dtype=np.float32)[::2]
  16. assert_raises(ValueError, self.module.foo, x)
  17. # check values with contiguous array
  18. x = np.arange(3, dtype=np.float32)
  19. self.module.foo(x)
  20. assert_equal(x, [3, 1, 2])