summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_io.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 720f2e74e..3b0b83712 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -1869,7 +1869,7 @@ class TestPathUsage(TestCase):
data = np.load(path)
assert_array_equal(data['lab'], 'place holder')
data.close()
-
+
@np.testing.dec.skipif(Path is None, "No pathlib.Path")
def test_genfromtxt(self):
with temppath(suffix='.txt') as path:
@@ -1878,49 +1878,52 @@ class TestPathUsage(TestCase):
np.savetxt(path, a)
data = np.genfromtxt(path)
assert_array_equal(a, data)
-
+
@np.testing.dec.skipif(Path is None, "No pathlib.Path")
def test_ndfromtxt(self):
# Test outputing a standard ndarray
with temppath(suffix='.txt') as path:
path = Path(path)
with path.open('w') as f:
- f.write('1 2\n3 4')
+ f.write(u'1 2\n3 4')
+
control = np.array([[1, 2], [3, 4]], dtype=int)
test = np.ndfromtxt(path, dtype=int)
assert_array_equal(test, control)
-
+
@np.testing.dec.skipif(Path is None, "No pathlib.Path")
def test_mafromtxt(self):
# From `test_fancy_dtype_alt` above
with temppath(suffix='.txt') as path:
path = Path(path)
with path.open('w') as f:
- f.write('1,2,3.0\n4,5,6.0\n')
-
+ f.write(u'1,2,3.0\n4,5,6.0\n')
+
test = np.mafromtxt(path, delimiter=',')
control = ma.array([(1.0, 2.0, 3.0), (4.0, 5.0, 6.0)])
assert_equal(test, control)
-
+
@np.testing.dec.skipif(Path is None, "No pathlib.Path")
def test_recfromtxt(self):
with temppath(suffix='.txt') as path:
path = Path(path)
with path.open('w') as f:
- f.write('A,B\n0,1\n2,3')
+ f.write(u'A,B\n0,1\n2,3')
+
kwargs = dict(delimiter=",", missing_values="N/A", names=True)
test = np.recfromtxt(path, **kwargs)
control = np.array([(0, 1), (2, 3)],
dtype=[('A', np.int), ('B', np.int)])
self.assertTrue(isinstance(test, np.recarray))
assert_equal(test, control)
-
+
@np.testing.dec.skipif(Path is None, "No pathlib.Path")
def test_recfromcsv(self):
with temppath(suffix='.txt') as path:
path = Path(path)
with path.open('w') as f:
- f.write('A,B\n0,1\n2,3')
+ f.write(u'A,B\n0,1\n2,3')
+
kwargs = dict(missing_values="N/A", names=True, case_sensitive=True)
test = np.recfromcsv(path, dtype=None, **kwargs)
control = np.array([(0, 1), (2, 3)],