Source: json-tricks
Version: 3.17.3-1
Severity: serious
Tags: patch ftbfs
X-Debbugs-CC: cjwat...@debian.org, debian-s...@lists.debian.org

Hi,

json-tricks currently is blocked from migration to testing, see #1101381. This is because its autopkgtests fail on s390x. Indeed, trying a build of json-tricks on s390x also shows a FTBFS.

The embedded data in test_np.py assumes the tests are running on systems where the native arch is little-endian. Obviously thats wrong on s390x.

Just to reiterate, the test failures are as follows:

 35s =================================== FAILURES 
===================================
 35s ____________________ test_decode_compact_mixed_compactness 
_____________________
35s 35s def test_decode_compact_mixed_compactness():
 35s            json = '[{"__ndarray__": 
"b64:AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAA' \
 35s                    'UQAAAAAAAABhAAAAAAAAAHEAAAAAAAAAgQA==", "dtype": "float64", 
"shape": [2, 4], "Corder": ' \
 35s                    'true}, {"__ndarray__": [3.141592653589793, 2.718281828459045], "dtype": 
"float64", "shape": [2]}]'
 35s            data = loads(json)
 35s >       assert_equal(data[0], array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 
8.0]]), array([pi, exp(1)]))
35s E AssertionError: 35s E Arrays are not equal
 35s E    [3.14159265 2.71828183]
 35s E    Mismatched elements: 8 / 8 (100%)
 35s E    Max absolute difference among violations: 8.
 35s E    Max relative difference among violations: 1.
 35s E     ACTUAL: array([[3.03865e-319, 3.16202e-322, 1.04347e-320, 
2.05531e-320],
 35s E           [2.56124e-320, 3.06716e-320, 3.57308e-320, 4.07901e-320]])
 35s E     DESIRED: array([[1., 2., 3., 4.],
 35s E           [5., 6., 7., 8.]])
35s 35s tests/test_np.py:316: AssertionError
 35s ____________________ test_decode_compact_inline_compression 
____________________
35s 35s def test_decode_compact_inline_compression():
 35s            json = '[{"__ndarray__": 
"b64.gz:H4sIAAAAAAAC/2NgAIEP9gwQ4AChOKC0AJQWgdISUFoGSitAaSUorQKl1aC0BpTWgtI6UFoPShs4AABmfqWAgAAAAA==", "dtype": 
"float64", "shape": [4, 4], "Corder": true}]'
 35s            data = loads(json)
 35s >       assert_equal(data[0], array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 
8.0], [9.0, 10.0, 11.0, 12.0], [13.0, 14.0, 15.0, 16.0]]))
35s E AssertionError: 35s E Arrays are not equal 35s E 35s E Mismatched elements: 16 / 16 (100%)
 35s E    Max absolute difference among violations: 16.
 35s E    Max relative difference among violations: 1.
 35s E     ACTUAL: array([[3.03865e-319, 3.16202e-322, 1.04347e-320, 
2.05531e-320],
 35s E           [2.56124e-320, 3.06716e-320, 3.57308e-320, 4.07901e-320],
 35s E           [4.33197e-320, 4.58493e-320, 4.83789e-320, 5.09085e-320],
 35s E           [5.34381e-320, 5.59678e-320, 5.84974e-320, 6.10270e-320]])
 35s E     DESIRED: array([[ 1.,  2.,  3.,  4.],
 35s E           [ 5.,  6.,  7.,  8.],
 35s E           [ 9., 10., 11., 12.],
 35s E           [13., 14., 15., 16.]])
35s 35s tests/test_np.py:348: AssertionError
 35s __________________ test_decode_compact_no_inline_compression 
___________________
35s 35s def test_decode_compact_no_inline_compression():
 35s            json = '[{"__ndarray__": 
"b64:AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEA=", ' \
 35s                    '"dtype": "float64", "shape": [2, 2], "Corder": true}]'
 35s            data = loads(json)
 35s >       assert_equal(data[0], array([[1.0, 2.0], [3.0, 4.0]]))
35s E AssertionError: 35s E Arrays are not equal 35s E 35s E Mismatched elements: 4 / 4 (100%)
 35s E    Max absolute difference among violations: 4.
 35s E    Max relative difference among violations: 1.
 35s E     ACTUAL: array([[3.03865e-319, 3.16202e-322],
 35s E           [1.04347e-320, 2.05531e-320]])
 35s E     DESIRED: array([[1., 2.],
 35s E           [3., 4.]])
35s 35s tests/test_np.py:355: AssertionError

Attached is a patch that can be dropped into debian/patches, which fixes the
FTBFS on s390x. TBH I have not tested the patch on non-s390x, but I assume
it should be fine on little-endian archs.

There are probably other ways of fixing this, but adding "endian": "little" to the test data seems straightforward.

Best,
Chris

From: Chris Hofstaedtler <z...@debian.org>

Test data assumes tests are running on little-endian systems, or at least
that the native endianness is little. Obviously this breaks on big-endian
systems like s390x. Make the assumption explicit by adding "endian": "little"
to the to-decoded test-data.

Fixes FTBFS and CI test failures on s390x.

--- json-tricks-3.17.3.orig/tests/test_np.py
+++ json-tricks-3.17.3/tests/test_np.py
@@ -310,7 +310,7 @@ def test_encode_compact_no_inline_compre
 
 def test_decode_compact_mixed_compactness():
        json = '[{"__ndarray__": 
"b64:AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAA' \
-               'UQAAAAAAAABhAAAAAAAAAHEAAAAAAAAAgQA==", "dtype": "float64", 
"shape": [2, 4], "Corder": ' \
+               'UQAAAAAAAABhAAAAAAAAAHEAAAAAAAAAgQA==", "dtype": "float64", 
"shape": [2, 4], "endian": "little", "Corder": ' \
                'true}, {"__ndarray__": [3.141592653589793, 2.718281828459045], 
"dtype": "float64", "shape": [2]}]'
        data = loads(json)
        assert_equal(data[0], array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 
8.0]]), array([pi, exp(1)]))
@@ -343,14 +343,14 @@ def test_decode_without_endianness():
 
 
 def test_decode_compact_inline_compression():
-       json = '[{"__ndarray__": 
"b64.gz:H4sIAAAAAAAC/2NgAIEP9gwQ4AChOKC0AJQWgdISUFoGSitAaSUorQKl1aC0BpTWgtI6UFoPShs4AABmfqWAgAAAAA==",
 "dtype": "float64", "shape": [4, 4], "Corder": true}]'
+       json = '[{"__ndarray__": 
"b64.gz:H4sIAAAAAAAC/2NgAIEP9gwQ4AChOKC0AJQWgdISUFoGSitAaSUorQKl1aC0BpTWgtI6UFoPShs4AABmfqWAgAAAAA==",
 "dtype": "float64", "shape": [4, 4], "Corder": true, "endian": "little"}]'
        data = loads(json)
        assert_equal(data[0], array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 
8.0], [9.0, 10.0, 11.0, 12.0], [13.0, 14.0, 15.0, 16.0]]))
 
 
 def test_decode_compact_no_inline_compression():
        json = '[{"__ndarray__": 
"b64:AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEA=", ' \
-               '"dtype": "float64", "shape": [2, 2], "Corder": true}]'
+               '"dtype": "float64", "shape": [2, 2], "Corder": true, "endian": 
"little"}]'
        data = loads(json)
        assert_equal(data[0], array([[1.0, 2.0], [3.0, 4.0]]))
 

Reply via email to