[python-hdf5storage] 08/13: Added tests for the writing and reading back of empty numpy string arrays with different character numbers as well as fixed a typo in some comments.
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:25:24 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 0.1.12
in repository python-hdf5storage.
commit b0987937529b4acabb228a5aa04dedf4ca252074
Author: Freja Nordsiek <fnordsie at gmail.com>
Date: Sat Feb 13 21:24:14 2016 +0100
Added tests for the writing and reading back of empty numpy string arrays with different character numbers as well as fixed a typo in some comments.
---
tests/test_write_readback.py | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/tests/test_write_readback.py b/tests/test_write_readback.py
index 70b7ad7..5c06f24 100644
--- a/tests/test_write_readback.py
+++ b/tests/test_write_readback.py
@@ -111,6 +111,14 @@ class TestPythonMatlabFormat(object):
out = self.write_readback(data, random_name(),
self.options)
self.assert_equal(out, data)
+
+ def check_numpy_stringlike_empty(self, dtype, num_chars):
+ # Makes an empty stringlike numpy array of the given type and
+ # size, writes it and reads it back, and then compares it.
+ data = np.array([], dtype + str(num_chars))
+ out = self.write_readback(data, random_name(),
+ self.options)
+ self.assert_equal(out, data)
def check_numpy_structured_array(self, dimensions):
# Makes a random structured ndarray of the given type, writes it
@@ -208,8 +216,9 @@ class TestPythonMatlabFormat(object):
self.assert_equal(out, data)
def check_numpy_chararray_empty(self, num_chars):
- # Makes an empty numpy array of the given type, writes it and
- # reads it back, and then compares it.
+ # Makes an empty numpy array of bytes of the given number of
+ # characters, converts it to a chararray, writes it and reads it
+ # back, and then compares it.
data = np.array([], 'S' + str(num_chars)).view(np.chararray).copy()
out = self.write_readback(data, random_name(),
self.options)
@@ -397,6 +406,12 @@ class TestPythonMatlabFormat(object):
def test_numpy_empty(self):
for dt in self.dtypes:
yield self.check_numpy_empty, dt
+
+ def test_numpy_stringlike_empty(self):
+ dts = ['S', 'U']
+ for dt in dts:
+ for n in range(1,10):
+ yield self.check_numpy_stringlike_empty, dt, n
def test_numpy_structured_array(self):
for i in range(1, 4):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-hdf5storage.git
More information about the debian-science-commits
mailing list