Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 def testBadVersion(self):
     data = b'\x93NUMPY\x03\x04'  # Version 3.4
     fp = io.BytesIO(data)
     with assert_raises(ValueError):
         read_array(fp)