MCPcopy Index your code
hub / github.com/numpy/numpy / test_object_indirect

Method test_object_indirect

numpy/_core/tests/test_umath.py:4377–4387  ·  view source on GitHub ↗

test implementations via __float__

(self)

Source from the content-addressed store, hash-verified

4375 assert_equal(np.trunc(arr), [3, 3])
4376
4377 def test_object_indirect(self):
4378 """ test implementations via __float__ """
4379 class C:
4380 def __float__(self):
4381 return -2.5
4382
4383 arr = np.array([C(), C()])
4384 assert_equal(np.floor(arr), [-3, -3])
4385 assert_equal(np.ceil(arr), [-2, -2])
4386 with pytest.raises(TypeError):
4387 np.trunc(arr) # consistent with math.trunc
4388
4389 def test_fraction(self):
4390 f = Fraction(-4, 3)

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected