summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/bscript6
-rw-r--r--numpy/lib/tests/test_format.py24
2 files changed, 29 insertions, 1 deletions
diff --git a/numpy/lib/bscript b/numpy/lib/bscript
index a9200d043..61debfe41 100644
--- a/numpy/lib/bscript
+++ b/numpy/lib/bscript
@@ -4,4 +4,8 @@ from bento.commands import hooks
def build(context):
context.tweak_extension("_compiled_base",
includes=["../core/include", "../core/include/numpy", "../core",
- "../core/src/private"])
+ "../core/src/private"],
+ defines=['_FILE_OFFSET_BITS=64',
+ '_LARGEFILE_SOURCE=1',
+ '_LARGEFILE64_SOURCE=1']
+ )
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py
index b9be643c8..73b1e7c12 100644
--- a/numpy/lib/tests/test_format.py
+++ b/numpy/lib/tests/test_format.py
@@ -620,5 +620,29 @@ def test_bad_header():
format.write_array_header_1_0(s, d)
assert_raises(ValueError, format.read_array_header_1_0, s)
+
+def test_large_file_support():
+ from nose import SkipTest
+ # try creating a large sparse file
+ with tempfile.NamedTemporaryFile() as tf:
+ try:
+ import subprocess as sp
+ sp.check_call(["truncate", "-s", "5368709120", tf.name])
+ except:
+ raise SkipTest("Could not create 5GB large file")
+ # write a small array to the end
+ f = open(tf.name, "wb")
+ f.seek(5368709120)
+ d = np.arange(5)
+ np.save(f, d)
+ f.close()
+ # read it back
+ f = open(tf.name, "rb")
+ f.seek(5368709120)
+ r = np.load(f)
+ f.close()
+ assert_array_equal(r, d)
+
+
if __name__ == "__main__":
run_module_suite()