MCPcopy Create free account
hub / github.com/numpy/numpy / check_function

Method check_function

numpy/f2py/tests/test_callback.py:52–85  ·  view source on GitHub ↗
(self, name)

Source from the content-addressed store, hash-verified

50 assert self.module.t.__doc__ == expected
51
52 def check_function(self, name):
53 t = getattr(self.module, name)
54 r = t(lambda: 4)
55 assert r == 4
56 r = t(lambda a: 5, fun_extra_args=(6, ))
57 assert r == 5
58 r = t(lambda a: a, fun_extra_args=(6, ))
59 assert r == 6
60 r = t(lambda a: 5 + a, fun_extra_args=(7, ))
61 assert r == 12
62 r = t(lambda a: math.degrees(a), fun_extra_args=(math.pi, ))
63 assert r == 180
64 r = t(math.degrees, fun_extra_args=(math.pi, ))
65 assert r == 180
66
67 r = t(self.module.func, fun_extra_args=(6, ))
68 assert r == 17
69 r = t(self.module.func0)
70 assert r == 11
71 r = t(self.module.func0._cpointer)
72 assert r == 11
73
74 class A:
75 def __call__(self):
76 return 7
77
78 def mth(self):
79 return 9
80
81 a = A()
82 r = t(a)
83 assert r == 7
84 r = t(a.mth)
85 assert r == 9
86
87 @pytest.mark.skipif(sys.platform == 'win32',
88 reason='Fails with MinGW64 Gfortran (Issue #9673)')

Callers 2

test_allMethod · 0.95
runnerMethod · 0.95

Calls 2

tFunction · 0.85
AClass · 0.70

Tested by

no test coverage detected