[python-hdf5storage] 77/152: Added write readback unit tests for list, tuple, set, frozenset, and collection.deque.
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:24:36 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 0.1
in repository python-hdf5storage.
commit 9e7b15a746394364b36517ace80ffd75d5ddaf7f
Author: Freja Nordsiek <fnordsie at gmail.com>
Date: Sun Feb 2 00:59:12 2014 -0500
Added write readback unit tests for list, tuple, set, frozenset, and collection.deque.
---
tests/test_write_readback.py | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/tests/test_write_readback.py b/tests/test_write_readback.py
index 8781651..9838c02 100644
--- a/tests/test_write_readback.py
+++ b/tests/test_write_readback.py
@@ -7,6 +7,7 @@ import posixpath
import string
import math
import random
+import collections
import numpy as np
import numpy.testing as npt
@@ -95,6 +96,15 @@ class TestPythonMatlabFormat(object):
return tuple([random.randint(1, max_length) for x in range(0,
dimensions)])
+ def random_list(self, N, python_or_numpy='numpy'):
+ if python_or_numpy == 'numpy':
+ return self.random_numpy((N,), dtype='object').tolist()
+ else:
+ data = []
+ for i in range(0, N):
+ data.append(self.random_bytes(random.randint(1, 100)))
+ return data
+
def random_name(self):
depth = random.randint(1, 5)
path = '/'
@@ -124,6 +134,20 @@ class TestPythonMatlabFormat(object):
def assert_equal(self, a, b):
assert a == b
+ def assert_equal_python_collection(self, a, b, tp):
+ assert type(a) == tp
+ assert type(b) == tp
+ assert len(a) == len(b)
+ if type(b) in (set, frozenset):
+ assert a == b
+ else:
+ for index in range(0, len(a)):
+ assert type(a[index]) == type(b[index])
+ if isinstance(b[index], (np.generic, np.ndarray)):
+ self.assert_equal_numpy(a[index], b[index])
+ else:
+ self.assert_equal(a[index], b[index])
+
def assert_equal_numpy(self, a, b):
assert type(a) == type(b)
assert a.dtype == b.dtype
@@ -273,6 +297,19 @@ class TestPythonMatlabFormat(object):
for dt in self.dtypes:
yield self.check_numpy_empty, dt
+ def check_python_collection(self, tp):
+ if tp in (set, frozenset):
+ data = tp(self.random_list(11, python_or_numpy='python'))
+ else:
+ data = tp(self.random_list(11, python_or_numpy='numpy'))
+ out = self.write_readback(data, self.random_name(),
+ self.options)
+ self.assert_equal_python_collection(out, data, tp)
+
+ def test_python_collection(self):
+ for tp in (list, tuple, set, frozenset, collections.deque):
+ yield self.check_python_collection, tp
+
class TestPythonFormat(TestPythonMatlabFormat):
def __init__(self):
--
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