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

Function test_format_descriptor_format_buffer_info_equiv

tests/test_buffers.py:54–70  ·  view source on GitHub ↗
(cpp_name, np_dtype)

Source from the content-addressed store, hash-verified

52
53@pytest.mark.parametrize(("cpp_name", "np_dtype"), CPP_NAME_NP_DTYPE_TABLE)
54def test_format_descriptor_format_buffer_info_equiv(cpp_name, np_dtype):
55 if np_dtype is None:
56 pytest.skip(
57 f"cpp_name=`{cpp_name}`: `long double` and `double` have same size."
58 )
59 if isinstance(np_dtype, str):
60 pytest.skip(f"np.{np_dtype} does not exist.")
61 np_array = np.array([], dtype=np_dtype)
62 for other_cpp_name, expected_format in CPP_NAME_FORMAT_TABLE:
63 format, np_array_is_matching = m.format_descriptor_format_buffer_info_equiv(
64 other_cpp_name, np_array
65 )
66 assert format == expected_format
67 if other_cpp_name == cpp_name:
68 assert np_array_is_matching
69 else:
70 assert not np_array_is_matching
71
72
73def test_from_python():

Callers

nothing calls this directly

Calls 2

isinstanceFunction · 0.85
arrayMethod · 0.80

Tested by

no test coverage detected