[python-hdf5storage] 50/84: Added to the tests a check for preservaation of the ordering of the fields for structured numpy.ndarrays.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:25:02 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag 0.1.10
in repository python-hdf5storage.

commit 1addbf5de280751c19c9beac08825cf2d0f34d4b
Author: Freja Nordsiek <fnordsie at gmail.com>
Date:   Sun May 17 19:05:51 2015 -0400

    Added to the tests a check for preservaation of the ordering of the fields for structured numpy.ndarrays.
---
 tests/asserts.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tests/asserts.py b/tests/asserts.py
index 2d76482..98a4b58 100644
--- a/tests/asserts.py
+++ b/tests/asserts.py
@@ -249,7 +249,18 @@ def assert_equal_matlab_format(a, b):
                     assert a.dtype.names is not None
                     assert b.dtype.names is not None
                     assert set(a.dtype.names) == set(b.dtype.names)
-                    assert a.dtype.names == b.dtype.names
+                    # The ordering of fields must be preserved if the
+                    # MATLAB_fields attribute could be used, which can
+                    # only be done if there are no non-ascii characters
+                    # in any of the field names.
+                    if sys.hexversion >= 0x03000000:
+                        allfields = ''.join(b.dtype.names)
+                    else:
+                        allfields = u''.join([nm.decode('UTF-8')
+                                             for nm in b.dtype.names])
+                    if np.all(np.array([ord(ch) < 128 \
+                            for ch in allfields])):
+                        assert a.dtype.names == b.dtype.names
                     a = a.flatten()
                     b = b.flatten()
                     for k in b.dtype.names:

-- 
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