summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2008-05-15 09:50:58 +0000
committerStefan van der Walt <stefan@sun.ac.za>2008-05-15 09:50:58 +0000
commitd5519c47944bf553e63f85bbeed28436cc6cd10a (patch)
tree8cff9c033f7e4c2eb1244708a5cf5d09685f4cc8
parentf968b1845073819cf812991436c5968d5a47df1d (diff)
downloadnumpy-d5519c47944bf553e63f85bbeed28436cc6cd10a.tar.gz
Add test for #788 [patch by Eric Firing].
-rw-r--r--numpy/core/setup.py2
-rw-r--r--numpy/core/tests/data/astype_copy.pklbin0 -> 716 bytes
-rw-r--r--numpy/core/tests/data/recarray_from_file.fits (renamed from numpy/core/tests/testdata.fits)bin8640 -> 8640 bytes
-rw-r--r--numpy/core/tests/test_records.py6
-rw-r--r--numpy/core/tests/test_regression.py13
5 files changed, 18 insertions, 3 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index 232d27ca1..10c7ff979 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -307,6 +307,8 @@ def configuration(parent_package='',top_path=None):
config.add_data_dir('tests')
+ config.add_data_dir('tests/data')
+
config.make_svn_version_py()
return config
diff --git a/numpy/core/tests/data/astype_copy.pkl b/numpy/core/tests/data/astype_copy.pkl
new file mode 100644
index 000000000..7397c9782
--- /dev/null
+++ b/numpy/core/tests/data/astype_copy.pkl
Binary files differ
diff --git a/numpy/core/tests/testdata.fits b/numpy/core/tests/data/recarray_from_file.fits
index ca48ee851..ca48ee851 100644
--- a/numpy/core/tests/testdata.fits
+++ b/numpy/core/tests/data/recarray_from_file.fits
Binary files differ
diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py
index 431852ce4..7f8aeb70c 100644
--- a/numpy/core/tests/test_records.py
+++ b/numpy/core/tests/test_records.py
@@ -1,7 +1,7 @@
from numpy.testing import *
set_package_path()
-import os as _os
+from os import path
import numpy.core;reload(numpy.core)
from numpy.core import *
restore_path()
@@ -33,8 +33,8 @@ class TestFromrecords(NumpyTestCase):
assert_equal(r.a,array([1,2,3,4]))
def check_recarray_fromfile(self):
- __path__ = _os.path.split(__file__)
- filename = _os.path.join(__path__[0], "testdata.fits")
+ data_dir = path.join(path.dirname(__file__),'data')
+ filename = path.join(data_dir,'recarray_from_file.fits')
fd = open(filename)
fd.seek(2880*2)
r = rec.fromfile(fd, formats='f8,i4,a5', shape=3, byteorder='big')
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index d0fe5f6c0..3765d20c8 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -1,7 +1,9 @@
from numpy.testing import *
+
from StringIO import StringIO
import pickle
import sys
+from os import path
set_local_path()
import numpy as np
@@ -1025,5 +1027,16 @@ class TestRegression(NumpyTestCase):
# This shouldn't cause a segmentation fault:
np.dot(z, y)
+ def check_astype_copy(self, level=rlevel):
+ """Ticket 788, changeset r5155"""
+ # The test data file was generated by scipy.io.savemat.
+ # The dtype is float64, but the isbuiltin attribute is 0.
+ data_dir = path.join(path.dirname(__file__), 'data')
+ filename = path.join(data_dir, "astype_copy.pkl")
+ xp = pickle.load(open(filename))
+ xpd = xp.astype(np.float64)
+ assert (xp.__array_interface__['data'][0] !=
+ xpd.__array_interface__['data'][0])
+
if __name__ == "__main__":
NumpyTest().run()