Skip to content

Test failures on big-endian systems #181

Closed

Description

@QuLogic

Minimal, reproducible code sample, a copy-pastable example if possible

$ pytest

Problem description

There are two failures, that appear to be reading from the wrong end of a multi-byte integer:

_________________________ test_backwards_compatibility _________________________

    def test_backwards_compatibility():
    
        # integers
        arrs = [
            np.arange(1000, dtype='<i4'),
            np.random.randint(0, 200, size=1000, dtype='<i4').reshape(100, 10, order='F'),
        ]
        codec = AsType(encode_dtype='<i2', decode_dtype='<i4')
>       check_backwards_compatibility(AsType.codec_id, arrs, [codec], prefix='i')

../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/test_astype.py:69: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

codec_id = 'astype'
arrays = [array([  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,
        13,  14,  15,  16,  17,  18,  19,  20...176,  88,   1,  65, 165, 173,  13, 100, 140],
       [177, 163,  49, 184, 165, 148,   3,  91,  75,   3]], dtype=int32)]
codecs = [AsType(encode_dtype='<i2', decode_dtype='<i4')], precision = None
prefix = 'i'

    def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, prefix=None):
    
        # setup directory to hold data fixture
        if prefix:
            fixture_dir = os.path.join('fixture', codec_id, prefix)
        else:
            fixture_dir = os.path.join('fixture', codec_id)
        if not os.path.exists(fixture_dir):  # pragma: no cover
            os.makedirs(fixture_dir)
    
        # save fixture data
        for i, arr in enumerate(arrays):
            arr_fn = os.path.join(fixture_dir, 'array.{:02d}.npy'.format(i))
            if not os.path.exists(arr_fn):  # pragma: no cover
                np.save(arr_fn, arr)
    
        # load fixture data
        for arr_fn in glob(os.path.join(fixture_dir, 'array.*.npy')):
    
            # setup
            i = int(arr_fn.split('.')[-2])
            arr = np.load(arr_fn)
            arr_bytes = arr.tobytes(order='A')
            if arr.flags.f_contiguous:
                order = 'F'
            else:
                order = 'C'
    
            for j, codec in enumerate(codecs):
    
                # setup a directory to hold encoded data
                codec_dir = os.path.join(fixture_dir, 'codec.{:02d}'.format(j))
                if not os.path.exists(codec_dir):  # pragma: no cover
                    os.makedirs(codec_dir)
    
                # file with codec configuration information
                codec_fn = os.path.join(codec_dir, 'config.json')
    
                # one time save config
                if not os.path.exists(codec_fn):  # pragma: no cover
                    with open(codec_fn, mode='w') as cf:
                        _json.dump(codec.get_config(), cf, sort_keys=True, indent=4)
    
                # load config and compare with expectation
                with open(codec_fn, mode='r') as cf:
                    config = _json.load(cf)
                    assert codec == get_codec(config)
    
                enc_fn = os.path.join(codec_dir, 'encoded.{:02d}.dat'.format(i))
    
                # one time encode and save array
                if not os.path.exists(enc_fn):  # pragma: no cover
                    enc = codec.encode(arr)
                    enc = ensure_bytes(enc)
                    with open(enc_fn, mode='wb') as ef:
                        ef.write(enc)
    
                # load and decode data
                with open(enc_fn, mode='rb') as ef:
                    enc = ef.read()
                    dec = codec.decode(enc)
                    dec_arr = ensure_ndarray(dec).reshape(-1, order='A')
                    dec_arr = dec_arr.view(dtype=arr.dtype).reshape(arr.shape, order=order)
                    if precision and precision[j] is not None:
                        assert_array_almost_equal(arr, dec_arr, decimal=precision[j])
                    elif arr.dtype == 'object':
                        assert_array_items_equal(arr, dec_arr)
                    else:
>                       assert_array_equal(arr, dec_arr)
E                       AssertionError: 
E                       Arrays are not equal
E                       
E                       (mismatch 99.5%)
E                        x: array([107, 120, 121, 197,  18, 117, 126, 191, 126,  52, 143, 184, 129,
E                              113, 175, 118, 168, 101, 106, 125,  13, 130,  70, 196, 113,  72,
E                                2, 133, 101, 191, 169,  75, 146, 143,  31, 199, 145, 189,  61,...
E                        y: array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
E                              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
E                              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...

../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/common.py:237: AssertionError
_________________________ test_backwards_compatibility _________________________

    def test_backwards_compatibility():
        codec = Categorize(labels=labels, dtype='<U4', astype='u1')
        check_backwards_compatibility(Categorize.codec_id, arrays, [codec],
>                                     prefix='U')

../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/test_categorize.py:93: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

codec_id = 'categorize'
arrays = [array(['ßàř', 'ßàř', 'ƒöõ', 'ßāẑ', 'ƪùüx', 'ƒöõ', 'ßāẑ', 'ßàř', 'ƪùüx',
       'ßāẑ', 'ƪùüx', 'ßàř', 'ßàř', 'ßàř', 'ƒ...,
        'ƒöõ'],
       ['ßàř', 'ƒöõ', 'ßàř', 'ƒöõ', 'ßāẑ', 'ßāẑ', 'ßāẑ', 'ƒöõ', 'ßàř',
        'ƒöõ']], dtype='>U4')]
codecs = [Categorize(dtype='<U4', astype='|u1', labels=['ƒöõ', 'ßàř', 'ßāẑ', ...])]
precision = None, prefix = 'U'

    def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, prefix=None):
    
        # setup directory to hold data fixture
        if prefix:
            fixture_dir = os.path.join('fixture', codec_id, prefix)
        else:
            fixture_dir = os.path.join('fixture', codec_id)
        if not os.path.exists(fixture_dir):  # pragma: no cover
            os.makedirs(fixture_dir)
    
        # save fixture data
        for i, arr in enumerate(arrays):
            arr_fn = os.path.join(fixture_dir, 'array.{:02d}.npy'.format(i))
            if not os.path.exists(arr_fn):  # pragma: no cover
                np.save(arr_fn, arr)
    
        # load fixture data
        for arr_fn in glob(os.path.join(fixture_dir, 'array.*.npy')):
    
            # setup
            i = int(arr_fn.split('.')[-2])
            arr = np.load(arr_fn)
            arr_bytes = arr.tobytes(order='A')
            if arr.flags.f_contiguous:
                order = 'F'
            else:
                order = 'C'
    
            for j, codec in enumerate(codecs):
    
                # setup a directory to hold encoded data
                codec_dir = os.path.join(fixture_dir, 'codec.{:02d}'.format(j))
                if not os.path.exists(codec_dir):  # pragma: no cover
                    os.makedirs(codec_dir)
    
                # file with codec configuration information
                codec_fn = os.path.join(codec_dir, 'config.json')
    
                # one time save config
                if not os.path.exists(codec_fn):  # pragma: no cover
                    with open(codec_fn, mode='w') as cf:
                        _json.dump(codec.get_config(), cf, sort_keys=True, indent=4)
    
                # load config and compare with expectation
                with open(codec_fn, mode='r') as cf:
                    config = _json.load(cf)
                    assert codec == get_codec(config)
    
                enc_fn = os.path.join(codec_dir, 'encoded.{:02d}.dat'.format(i))
    
                # one time encode and save array
                if not os.path.exists(enc_fn):  # pragma: no cover
                    enc = codec.encode(arr)
                    enc = ensure_bytes(enc)
                    with open(enc_fn, mode='wb') as ef:
                        ef.write(enc)
    
                # load and decode data
                with open(enc_fn, mode='rb') as ef:
                    enc = ef.read()
                    dec = codec.decode(enc)
                    dec_arr = ensure_ndarray(dec).reshape(-1, order='A')
                    dec_arr = dec_arr.view(dtype=arr.dtype).reshape(arr.shape, order=order)
                    if precision and precision[j] is not None:
                        assert_array_almost_equal(arr, dec_arr, decimal=precision[j])
                    elif arr.dtype == 'object':
                        assert_array_items_equal(arr, dec_arr)
                    else:
>                       assert_array_equal(arr, dec_arr)
E                       AssertionError: 
E                       Arrays are not equal
E                       
E                       (mismatch 100.0%)
E                        x: array([[['ƒöõ', 'ßāẑ', 'ƪùüx', 'ƪùüx', 'ßàř', 'ƪùüx', 'ßàř', 'ßàř',
E                                'ßāẑ', 'ƒöõ'],
E                               ['ƪùüx', 'ßāẑ', 'ßāẑ', 'ßāẑ', 'ßàř', 'ƒöõ', 'ßāẑ', 'ßàř',...
E                        y: array([[['', '', '', '', '', '', '', '', '', ''],
E                               ['', '', '', '', '', '', '', '', '', ''],
E                               ['', '', '', '', '', '', '', '', '', ''],...

../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/common.py:237: AssertionError

Version and installation information

  • Value of numcodecs.__version__: 0.6.3
  • Version of Python interpreter: 3.7.2
  • Operating system (Linux/Windows/Mac): Fedora 29
  • How NumCodecs was installed (e.g., "using pip into virtual environment", or "using conda"): building a package, so none of the above

Activity

  1. QuLogic commented on Mar 20, 2019

    @QuLogic
    ContributorAuthor

    Actually, I just noticed I didn't correctly have the fixture or data due to #182, so there are actually 4 failures:

    ____________________________________________________________ test_backwards_compatibility ____________________________________________________________
    
        def test_backwards_compatibility():
            for arr in arrays:
                codec = Delta(dtype=arr.dtype)
    >           check_backwards_compatibility(Delta.codec_id, [arr], [codec], prefix=str(arr.dtype))
    
    ../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/test_delta.py:55: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    codec_id = 'delta'
    arrays = [array([  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,
            13,  14,  15,  16,  17,  18,  19,  20..., 982, 983, 984, 985, 986, 987,
           988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999],
          dtype=int32)]
    codecs = [Delta(dtype='>i4')], precision = None, prefix = 'int32'
    
        def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, prefix=None):
        
            # setup directory to hold data fixture
            if prefix:
                fixture_dir = os.path.join('fixture', codec_id, prefix)
            else:
                fixture_dir = os.path.join('fixture', codec_id)
            if not os.path.exists(fixture_dir):  # pragma: no cover
                os.makedirs(fixture_dir)
        
            # save fixture data
            for i, arr in enumerate(arrays):
                arr_fn = os.path.join(fixture_dir, 'array.{:02d}.npy'.format(i))
                if not os.path.exists(arr_fn):  # pragma: no cover
                    np.save(arr_fn, arr)
        
            # load fixture data
            for arr_fn in glob(os.path.join(fixture_dir, 'array.*.npy')):
        
                # setup
                i = int(arr_fn.split('.')[-2])
                arr = np.load(arr_fn)
                arr_bytes = arr.tobytes(order='A')
                if arr.flags.f_contiguous:
                    order = 'F'
                else:
                    order = 'C'
        
                for j, codec in enumerate(codecs):
        
                    # setup a directory to hold encoded data
                    codec_dir = os.path.join(fixture_dir, 'codec.{:02d}'.format(j))
                    if not os.path.exists(codec_dir):  # pragma: no cover
                        os.makedirs(codec_dir)
        
                    # file with codec configuration information
                    codec_fn = os.path.join(codec_dir, 'config.json')
        
                    # one time save config
                    if not os.path.exists(codec_fn):  # pragma: no cover
                        with open(codec_fn, mode='w') as cf:
                            _json.dump(codec.get_config(), cf, sort_keys=True, indent=4)
        
                    # load config and compare with expectation
                    with open(codec_fn, mode='r') as cf:
                        config = _json.load(cf)
    >                   assert codec == get_codec(config)
    E                   AssertionError
    
    ../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/common.py:215: AssertionError
    ____________________________________________________________ test_backwards_compatibility ____________________________________________________________
    
        def test_backwards_compatibility():
            precision = [int(np.log10(codec.scale)) for codec in codecs]
    >       check_backwards_compatibility(FixedScaleOffset.codec_id, arrays, codecs, precision=precision)
    
    ../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/test_fixedscaleoffset.py:63: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    codec_id = 'fixedscaleoffset'
    arrays = [array([1000.        , 1000.001001  , 1000.002002  , 1000.003003  ,
           1000.004004  , 1000.00500501, 1000.00600601...399399,
             1000.99499499, 1000.995996  , 1000.996997  , 1000.997998  ,
             1000.998999  , 1001.        ]]])]
    codecs = [FixedScaleOffset(scale=10, offset=1000, dtype='>f8', astype='|i1'), FixedScaleOffset(scale=100, offset=1000, dtype='>...000000000000, offset=1000, dtype='>f8', astype='>i8'), FixedScaleOffset(scale=1000000000000, offset=1000, dtype='>f8')]
    precision = [1, 2, 6, 12, 12], prefix = None
    
        def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, prefix=None):
        
            # setup directory to hold data fixture
            if prefix:
                fixture_dir = os.path.join('fixture', codec_id, prefix)
            else:
                fixture_dir = os.path.join('fixture', codec_id)
            if not os.path.exists(fixture_dir):  # pragma: no cover
                os.makedirs(fixture_dir)
        
            # save fixture data
            for i, arr in enumerate(arrays):
                arr_fn = os.path.join(fixture_dir, 'array.{:02d}.npy'.format(i))
                if not os.path.exists(arr_fn):  # pragma: no cover
                    np.save(arr_fn, arr)
        
            # load fixture data
            for arr_fn in glob(os.path.join(fixture_dir, 'array.*.npy')):
        
                # setup
                i = int(arr_fn.split('.')[-2])
                arr = np.load(arr_fn)
                arr_bytes = arr.tobytes(order='A')
                if arr.flags.f_contiguous:
                    order = 'F'
                else:
                    order = 'C'
        
                for j, codec in enumerate(codecs):
        
                    # setup a directory to hold encoded data
                    codec_dir = os.path.join(fixture_dir, 'codec.{:02d}'.format(j))
                    if not os.path.exists(codec_dir):  # pragma: no cover
                        os.makedirs(codec_dir)
        
                    # file with codec configuration information
                    codec_fn = os.path.join(codec_dir, 'config.json')
        
                    # one time save config
                    if not os.path.exists(codec_fn):  # pragma: no cover
                        with open(codec_fn, mode='w') as cf:
                            _json.dump(codec.get_config(), cf, sort_keys=True, indent=4)
        
                    # load config and compare with expectation
                    with open(codec_fn, mode='r') as cf:
                        config = _json.load(cf)
    >                   assert codec == get_codec(config)
    E                   AssertionError
    
    ../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/common.py:215: AssertionError
    ____________________________________________________________ test_backwards_compatibility ____________________________________________________________
    
        def test_backwards_compatibility():
    >       check_backwards_compatibility(Pickle.codec_id, arrays, codecs)
    
    ../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/test_pickles.py:58: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    codec_id = 'pickle'
    arrays = [array(['foo', 'bar', 'baz', 'foo', 'bar', 'baz', 'foo', 'bar', 'baz',
           'foo', 'bar', 'baz', 'foo', 'bar', 'baz'...t(['bar', 1.0, 2]), {'a': 'b', 'c': 42}, 'foo',
           list(['bar', 1.0, 2]), {'a': 'b', 'c': 42}], dtype=object), ...]
    codecs = [Pickle(protocol=0), Pickle(protocol=1), Pickle(protocol=2), Pickle(protocol=3), Pickle(protocol=4)], precision = None, prefix = None
    
        def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, prefix=None):
        
            # setup directory to hold data fixture
            if prefix:
                fixture_dir = os.path.join('fixture', codec_id, prefix)
            else:
                fixture_dir = os.path.join('fixture', codec_id)
            if not os.path.exists(fixture_dir):  # pragma: no cover
                os.makedirs(fixture_dir)
        
            # save fixture data
            for i, arr in enumerate(arrays):
                arr_fn = os.path.join(fixture_dir, 'array.{:02d}.npy'.format(i))
                if not os.path.exists(arr_fn):  # pragma: no cover
                    np.save(arr_fn, arr)
        
            # load fixture data
            for arr_fn in glob(os.path.join(fixture_dir, 'array.*.npy')):
        
                # setup
                i = int(arr_fn.split('.')[-2])
                arr = np.load(arr_fn)
                arr_bytes = arr.tobytes(order='A')
                if arr.flags.f_contiguous:
                    order = 'F'
                else:
                    order = 'C'
        
                for j, codec in enumerate(codecs):
        
                    # setup a directory to hold encoded data
                    codec_dir = os.path.join(fixture_dir, 'codec.{:02d}'.format(j))
                    if not os.path.exists(codec_dir):  # pragma: no cover
                        os.makedirs(codec_dir)
        
                    # file with codec configuration information
                    codec_fn = os.path.join(codec_dir, 'config.json')
        
                    # one time save config
                    if not os.path.exists(codec_fn):  # pragma: no cover
                        with open(codec_fn, mode='w') as cf:
                            _json.dump(codec.get_config(), cf, sort_keys=True, indent=4)
        
                    # load config and compare with expectation
                    with open(codec_fn, mode='r') as cf:
                        config = _json.load(cf)
                        assert codec == get_codec(config)
        
                    enc_fn = os.path.join(codec_dir, 'encoded.{:02d}.dat'.format(i))
        
                    # one time encode and save array
                    if not os.path.exists(enc_fn):  # pragma: no cover
                        enc = codec.encode(arr)
                        enc = ensure_bytes(enc)
                        with open(enc_fn, mode='wb') as ef:
                            ef.write(enc)
        
                    # load and decode data
                    with open(enc_fn, mode='rb') as ef:
                        enc = ef.read()
                        dec = codec.decode(enc)
                        dec_arr = ensure_ndarray(dec).reshape(-1, order='A')
                        dec_arr = dec_arr.view(dtype=arr.dtype).reshape(arr.shape, order=order)
                        if precision and precision[j] is not None:
                            assert_array_almost_equal(arr, dec_arr, decimal=precision[j])
                        elif arr.dtype == 'object':
                            assert_array_items_equal(arr, dec_arr)
                        else:
    >                       assert_array_equal(arr, dec_arr)
    E                       AssertionError: 
    E                       Arrays are not equal
    E                       
    E                       (mismatch 100.0%)
    E                        x: array(['¡Hola mundo!', 'Hej Världen!', 'Servus Woid!', ...,
    E                              'Helló, világ!', 'Zdravo svete!', 'เฮลโลเวิลด์'], dtype='<U17')
    E                        y: [repr failed for <ndarray>: 'utf-32-le' codec can't decode bytes in position 0-3: code point not in range(0x110000)]
    
    ../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/common.py:237: AssertionError
    ____________________________________________________________ test_backwards_compatibility ____________________________________________________________
    
        def test_backwards_compatibility():
            precision = [codec.digits for codec in codecs]
    >       check_backwards_compatibility(Quantize.codec_id, arrays, codecs, precision=precision)
    
    ../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/test_quantize.py:77: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    codec_id = 'quantize'
    arrays = [array([100.        , 100.1001001 , 100.2002002 , 100.3003003 ,
           100.4004004 , 100.5005005 , 100.6006006 , 100.7...199.3993994 ,
             199.4994995 , 199.5995996 , 199.6996997 , 199.7997998 ,
             199.8998999 , 200.        ]]])]
    codecs = [Quantize(digits=-1, dtype='>f8', astype='>f2'), Quantize(digits=0, dtype='>f8', astype='>f2'), Quantize(digits=1, dtype='>f8', astype='>f2'), Quantize(digits=5, dtype='>f8', astype='>f4'), Quantize(digits=12, dtype='>f8')]
    precision = [-1, 0, 1, 5, 12], prefix = None
    
        def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, prefix=None):
        
            # setup directory to hold data fixture
            if prefix:
                fixture_dir = os.path.join('fixture', codec_id, prefix)
            else:
                fixture_dir = os.path.join('fixture', codec_id)
            if not os.path.exists(fixture_dir):  # pragma: no cover
                os.makedirs(fixture_dir)
        
            # save fixture data
            for i, arr in enumerate(arrays):
                arr_fn = os.path.join(fixture_dir, 'array.{:02d}.npy'.format(i))
                if not os.path.exists(arr_fn):  # pragma: no cover
                    np.save(arr_fn, arr)
        
            # load fixture data
            for arr_fn in glob(os.path.join(fixture_dir, 'array.*.npy')):
        
                # setup
                i = int(arr_fn.split('.')[-2])
                arr = np.load(arr_fn)
                arr_bytes = arr.tobytes(order='A')
                if arr.flags.f_contiguous:
                    order = 'F'
                else:
                    order = 'C'
        
                for j, codec in enumerate(codecs):
        
                    # setup a directory to hold encoded data
                    codec_dir = os.path.join(fixture_dir, 'codec.{:02d}'.format(j))
                    if not os.path.exists(codec_dir):  # pragma: no cover
                        os.makedirs(codec_dir)
        
                    # file with codec configuration information
                    codec_fn = os.path.join(codec_dir, 'config.json')
        
                    # one time save config
                    if not os.path.exists(codec_fn):  # pragma: no cover
                        with open(codec_fn, mode='w') as cf:
                            _json.dump(codec.get_config(), cf, sort_keys=True, indent=4)
        
                    # load config and compare with expectation
                    with open(codec_fn, mode='r') as cf:
                        config = _json.load(cf)
    >                   assert codec == get_codec(config)
    E                   AssertionError
    
    ../../../BUILDROOT/python-numcodecs-0.6.3-2.fc29.s390x/usr/lib64/python3.7/site-packages/numcodecs/tests/common.py:215: AssertionError
  2. alimanfoo commented on Mar 20, 2019

    @alimanfoo
    Member
  3. QuLogic commented on Mar 28, 2019

    @QuLogic
    ContributorAuthor

    The problem seems to be that the test setup uses native endianness, but the fixture data files are little-endian.

  4. QuLogic commented on Mar 28, 2019

    @QuLogic
    ContributorAuthor

    By forcing test data to be little-endian (to match the fixture files) #186, all the tests pass except the pickling of Unicode text one. It's probably the same problem, but there's no dtype on the Pickle codec, so I'm not sure where to apply the change.

  5. alimanfoo commented on Mar 28, 2019

    @alimanfoo
    Member

    The problem seems to be that the test setup uses native endianness, but the fixture data files are little-endian.

    You're right, I'm sorry about this, massive oversight. Each codec test module defines a list of arrays (e.g., here for the blosc tests, and then uses these for backwards compatibility tests (e.g., here for blosc). These arrays should all be instantiated with a dtype that explicitly sets the byte order, otherwise there may be differences between the platform on which the fixture data was created and the platform on which the fixture is being compared.

  6. QuLogic commented on Mar 28, 2019

    @QuLogic
    ContributorAuthor

    For the pickling test, the problem seems to arise somewhere in check_backwards_compatibility. Initially, arr is loaded from a NumPy file here:

    arr = np.load(arr_fn)

    and it is little-endian because that's how it was saved. Then the test array is encoded, and decoded again here:
    dec = codec.decode(enc)
    dec_arr = ensure_ndarray(dec).reshape(-1, order='A')
    dec_arr = dec_arr.view(dtype=arr.dtype).reshape(arr.shape, order=order)

    After the first line, dec_arr is '>U17' (big-endian, native), but then the view using arr's dtype treats it as little endian. This produces non-sensical Unicode values.

    Somehow this test helper works everywhere else though, so I'm not sure why it's producing incorrect views.

  7. alimanfoo commented on Mar 28, 2019

    @alimanfoo
    Member

    After the first line, dec_arr is '>U17' (big-endian, native), but then the view using arr's dtype treats it as little endian. This produces non-sensical Unicode values.

    I think problem occurs at this line in the pickle tests, the array needs to be created with an explicit dtype, e.g.:

        np.array(greetings * 100, dtype='<U17'),
    
  8. alimanfoo commented on Mar 28, 2019

    @alimanfoo
    Member

    Basically, in all test modules, all arrays need to be created with an explicit dtype that includes specification of byte order.

  9. alimanfoo commented on Mar 28, 2019

    @alimanfoo
    Member

    Basically, in all test modules, all arrays need to be created with an explicit dtype that includes specification of byte order.

    ...except for single byte dtypes and object dtype.

  10. QuLogic commented on Mar 28, 2019

    @QuLogic
    ContributorAuthor

    Unfortunately, I don't think the pickle codec is correctly able to restore byte order. Changing the input be explicitly little-endian still fails in test_backwards_compatibility and also causes test_encode_decode to fail.

  11. alimanfoo commented on Mar 29, 2019

    @alimanfoo
    Member
  12. avalentino commented on Aug 23, 2021

    @avalentino
    Contributor

    Is this one fixed?

  13. QuLogic commented on Aug 26, 2021

    @QuLogic
    ContributorAuthor

    Well, #282 got added later, but I think everything listed here is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions