MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_numpy_scalars

Function test_numpy_scalars

tests/test_numpy_scalars.py:31–47  ·  view source on GitHub ↗
(npy_scalar_type, expected_value)

Source from the content-addressed store, hash-verified

29 ("npy_scalar_type", "expected_value"), NPY_SCALAR_TYPES.items()
30)
31def test_numpy_scalars(npy_scalar_type, expected_value):
32 tpnm = npy_scalar_type.__name__.rstrip("_")
33 test_tpnm = getattr(m, "test_" + tpnm)
34 assert (
35 test_tpnm.__doc__
36 == f"test_{tpnm}(x: numpy.{tpnm}) -> tuple[str, numpy.{tpnm}]\n"
37 )
38 for tp in ALL_SCALAR_TYPES:
39 value = tp(1)
40 if tp is npy_scalar_type:
41 result_tpnm, result_value = test_tpnm(value)
42 assert result_tpnm == tpnm
43 assert isinstance(result_value, npy_scalar_type)
44 assert result_value == tp(expected_value)
45 else:
46 with pytest.raises(TypeError):
47 test_tpnm(value)
48
49
50def test_eq_ne():

Callers

nothing calls this directly

Calls 2

getattrFunction · 0.85
isinstanceFunction · 0.85

Tested by

no test coverage detected