MCPcopy Create free account
hub / github.com/deshaw/versioned-hdf5 / assert_object_array_equal

Function assert_object_array_equal

tests/test_npystrings.py:26–39  ·  view source on GitHub ↗

Assert that actual is an object array of either bytes or str. The exact contents (bytes or str) are allowed to diverge between h5py and versioned_hdf5.

(actual, expect)

Source from the content-addressed store, hash-verified

24
25
26def assert_object_array_equal(actual, expect):
27 """Assert that actual is an object array of either bytes or str.
28 The exact contents (bytes or str) are allowed to diverge between h5py and
29 versioned_hdf5.
30 """
31 actual = np.asarray(actual)
32 expect = np.asarray(expect, dtype=object)
33 assert actual.dtype.kind == "O"
34 assert actual.shape == expect.shape
35
36 for a, b in zip(actual.flat, expect.flat, strict=True):
37 if isinstance(a, bytes):
38 a = a.decode("utf-8")
39 assert a == b, (actual, expect)
40
41
42def assert_swaps_counter(ds, expect):

Callers 2

any_datasetFunction · 0.85
test_match_behaviourFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected