MCPcopy Index your code
hub / github.com/numpy/numpy / test_largish_file

Method test_largish_file

numpy/_core/tests/test_multiarray.py:6224–6243  ·  view source on GitHub ↗
(self, tmp_path, param_filename)

Source from the content-addressed store, hash-verified

6222 assert_array_equal(y, x.flat)
6223
6224 def test_largish_file(self, tmp_path, param_filename):
6225 # check the fallocate path on files > 16MB
6226 tmp_filename = normalize_filename(tmp_path, param_filename)
6227 d = np.zeros(4 * 1024 ** 2)
6228 d.tofile(tmp_filename)
6229 assert_equal(os.path.getsize(tmp_filename), d.nbytes)
6230 assert_array_equal(d, np.fromfile(tmp_filename))
6231 # check offset
6232 with open(tmp_filename, "r+b") as f:
6233 f.seek(d.nbytes)
6234 d.tofile(f)
6235 assert_equal(os.path.getsize(tmp_filename), d.nbytes * 2)
6236 # check append mode (gh-8329)
6237 open(tmp_filename, "w").close() # delete file contents
6238 with open(tmp_filename, "ab") as f:
6239 d.tofile(f)
6240 assert_array_equal(d, np.fromfile(tmp_filename))
6241 with open(tmp_filename, "ab") as f:
6242 d.tofile(f)
6243 assert_equal(os.path.getsize(tmp_filename), d.nbytes * 2)
6244
6245 def test_io_open_buffered_fromfile(self, tmp_path, param_filename):
6246 # gh-6632

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected