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

Method test_object_direct

numpy/core/tests/test_umath.py:4063–4076  ·  view source on GitHub ↗

test direct implementation of these magic methods

(self)

Source from the content-addressed store, hash-verified

4061class TestRoundingFunctions:
4062
4063 def test_object_direct(self):
4064 """ test direct implementation of these magic methods """
4065 class C:
4066 def __floor__(self):
4067 return 1
4068 def __ceil__(self):
4069 return 2
4070 def __trunc__(self):
4071 return 3
4072
4073 arr = np.array([C(), C()])
4074 assert_equal(np.floor(arr), [1, 1])
4075 assert_equal(np.ceil(arr), [2, 2])
4076 assert_equal(np.trunc(arr), [3, 3])
4077
4078 def test_object_indirect(self):
4079 """ test implementations via __float__ """

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected