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

Method test_roundtrip

numpy/core/tests/test_multiarray.py:4302–4321  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4300 assert_equal(non_contiguous_array, depickled_non_contiguous_array)
4301
4302 def test_roundtrip(self):
4303 for proto in range(2, pickle.HIGHEST_PROTOCOL + 1):
4304 carray = np.array([[2, 9], [7, 0], [3, 8]])
4305 DATA = [
4306 carray,
4307 np.transpose(carray),
4308 np.array([('xxx', 1, 2.0)], dtype=[('a', (str, 3)), ('b', int),
4309 ('c', float)])
4310 ]
4311
4312 refs = [weakref.ref(a) for a in DATA]
4313 for a in DATA:
4314 assert_equal(
4315 a, pickle.loads(pickle.dumps(a, protocol=proto)),
4316 err_msg="%r" % a)
4317 del a, DATA, carray
4318 break_cycles()
4319 # check for reference leaks (gh-12793)
4320 for ref in refs:
4321 assert ref() is None
4322
4323 def _loads(self, obj):
4324 return pickle.loads(obj, encoding='latin1')

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
break_cyclesFunction · 0.90

Tested by

no test coverage detected