gpt4 book ai didi

python - np.fromfile 文件大小的最大限制?

转载 作者:太空宇宙 更新时间:2023-11-03 15:21:48 25 4
gpt4 key购买 nike

np.fromfile() 是否有最大文件大小?我正在尝试读取一个 48GB 的​​文件,其中包含大约 2.1e9 条记录(每条记录有 5 个值)。

当我将计数限制为 8e7 时它起作用了:

fromfile(filename, dtp, int(8e7))
Out[69]:
array([(1, 244025.0, 1.1666666269302368, 360.1666564941406, 50.0),
(2, 244025.0, 1.1666666269302368, 360.5, 50.0),
(3, 244025.0, 1.1666666269302368, 360.8333435058594, 50.0), ...,
(255138, 244131.0, 1128.9346923828125, 461.38494873046875, 49.5),
(255139, 244131.0, 1143.77783203125, 473.2532958984375, 49.5),
(255140, 244131.0, 1150.4803466796875, 464.6799011230469, 49.5)],
dtype=[('ntrac', '<i4'), ('ints', '<f8'), ('x', '<f4'), ('y', '<f4'), ('z', '<f4')])

但是当计数设置为 9e7 时,所有值都被读取为零:

In [70]: fromfile(filename, dtp, int(9e7))
Out[70]:
array([(0, 0.0, 0.0, 0.0, 0.0), (0, 0.0, 0.0, 0.0, 0.0),
(0, 0.0, 0.0, 0.0, 0.0), ..., (0, 0.0, 0.0, 0.0, 0.0),
(0, 0.0, 0.0, 0.0, 0.0), (0, 0.0, 0.0, 0.0, 0.0)],
dtype=[('ntrac', '<i4'), ('ints', '<f8'), ('x', '<f4'), ('y', '<f4'), ('z', '<f4')])

最佳答案

看起来确实是 Mac OS X 的一个 bug。

请参阅 numpy 中的以下错误:https://github.com/numpy/numpy/issues/2806

我在我的分支分支中提出了一个修复建议,可以帮助某人验证它,请参阅: https://github.com/sauliusl/numpy/tree/bug_large_save

关于python - np.fromfile 文件大小的最大限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13769545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com