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

Function assert_references

tests/test_numpy_array.py:231–248  ·  view source on GitHub ↗
(a, b, base=None)

Source from the content-addressed store, hash-verified

229
230def test_wrap():
231 def assert_references(a, b, base=None):
232 if base is None:
233 base = a
234 assert a is not b
235 assert a.__array_interface__["data"][0] == b.__array_interface__["data"][0]
236 assert a.shape == b.shape
237 assert a.strides == b.strides
238 assert a.flags.c_contiguous == b.flags.c_contiguous
239 assert a.flags.f_contiguous == b.flags.f_contiguous
240 assert a.flags.writeable == b.flags.writeable
241 assert a.flags.aligned == b.flags.aligned
242 assert a.flags.writebackifcopy == b.flags.writebackifcopy
243 assert np.all(a == b)
244 assert not b.flags.owndata
245 assert b.base is base
246 if a.flags.writeable and a.ndim == 2:
247 a[0, 0] = 1234
248 assert b[0, 0] == 1234
249
250 a1 = np.array([1, 2], dtype=np.int16)
251 assert a1.flags.owndata

Callers 1

test_wrapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected