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

Method test_scalar_interface

numpy/core/tests/test_multiarray.py:8562–8577  ·  view source on GitHub ↗
(self, val, iface, expected)

Source from the content-addressed store, hash-verified

8560 (f, {'strides': 16}, TypeError),
8561 ])
8562 def test_scalar_interface(self, val, iface, expected):
8563 # Test scalar coercion within the array interface
8564 self.f.iface = {'typestr': 'f8'}
8565 self.f.iface.update(iface)
8566 if HAS_REFCOUNT:
8567 pre_cnt = sys.getrefcount(np.dtype('f8'))
8568 if isinstance(expected, type):
8569 assert_raises(expected, np.array, val)
8570 else:
8571 result = np.array(val)
8572 assert_equal(np.array(val), expected)
8573 assert result.dtype == 'f8'
8574 del result
8575 if HAS_REFCOUNT:
8576 post_cnt = sys.getrefcount(np.dtype('f8'))
8577 assert_equal(pre_cnt, post_cnt)
8578
8579def test_interface_no_shape():
8580 class ArrayLike:

Callers

nothing calls this directly

Calls 4

assert_raisesFunction · 0.90
assert_equalFunction · 0.90
updateMethod · 0.80
dtypeMethod · 0.45

Tested by

no test coverage detected