def testPickled(self): array = np.array([str, object]) fp = io.BytesIO() np.save(fp, array) fp.seek(0) with assert_raises(ValueError): read_array(fp)
def _truncate_and_fail_to_read(self, *args): fp = io.BytesIO() np.save(fp, np.arange(20)) fp.seek(*args) fp.truncate() fp.seek(0) with assert_raises(TruncatedRead): read_array(fp)
def _test(self, array): fp = io.BytesIO() np.save(fp, array) fp.seek(0) out = read_array(fp) np.testing.assert_equal(array, out) # Check that Fortran order was preserved assert_equal(array.strides, out.strides)
def testBadVersion(self): data = b'\x93NUMPY\x03\x04' # Version 3.4 fp = io.BytesIO(data) with assert_raises(ValueError): read_array(fp)