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

Method test_largish_file

numpy/core/tests/test_multiarray.py:5383–5401  ·  view source on GitHub ↗
(self, tmp_filename)

Source from the content-addressed store, hash-verified

5381 assert_array_equal(y, x.flat)
5382
5383 def test_largish_file(self, tmp_filename):
5384 # check the fallocate path on files > 16MB
5385 d = np.zeros(4 * 1024 ** 2)
5386 d.tofile(tmp_filename)
5387 assert_equal(os.path.getsize(tmp_filename), d.nbytes)
5388 assert_array_equal(d, np.fromfile(tmp_filename))
5389 # check offset
5390 with open(tmp_filename, "r+b") as f:
5391 f.seek(d.nbytes)
5392 d.tofile(f)
5393 assert_equal(os.path.getsize(tmp_filename), d.nbytes * 2)
5394 # check append mode (gh-8329)
5395 open(tmp_filename, "w").close() # delete file contents
5396 with open(tmp_filename, "ab") as f:
5397 d.tofile(f)
5398 assert_array_equal(d, np.fromfile(tmp_filename))
5399 with open(tmp_filename, "ab") as f:
5400 d.tofile(f)
5401 assert_equal(os.path.getsize(tmp_filename), d.nbytes * 2)
5402
5403 def test_io_open_buffered_fromfile(self, x, tmp_filename):
5404 # gh-6632

Callers

nothing calls this directly

Calls 6

assert_equalFunction · 0.90
assert_array_equalFunction · 0.90
openFunction · 0.85
tofileMethod · 0.80
seekMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected