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

Method test_object_indirect

numpy/core/tests/test_umath.py:4078–4088  ·  view source on GitHub ↗

test implementations via __float__

(self)

Source from the content-addressed store, hash-verified

4076 assert_equal(np.trunc(arr), [3, 3])
4077
4078 def test_object_indirect(self):
4079 """ test implementations via __float__ """
4080 class C:
4081 def __float__(self):
4082 return -2.5
4083
4084 arr = np.array([C(), C()])
4085 assert_equal(np.floor(arr), [-3, -3])
4086 assert_equal(np.ceil(arr), [-2, -2])
4087 with pytest.raises(TypeError):
4088 np.trunc(arr) # consistent with math.trunc
4089
4090 def test_fraction(self):
4091 f = Fraction(-4, 3)

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected