Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-json_tricks for 
openSUSE:Factory checked in at 2023-06-18 23:08:30
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-json_tricks (Old)
 and      /work/SRC/openSUSE:Factory/.python-json_tricks.new.15902 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-json_tricks"

Sun Jun 18 23:08:30 2023 rev:12 rq:1093679 version:3.17.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-json_tricks/python-json_tricks.changes    
2023-05-18 15:19:27.169901052 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-json_tricks.new.15902/python-json_tricks.changes
 2023-06-18 23:08:31.801671684 +0200
@@ -1,0 +2,6 @@
+Sat Jun 17 18:40:58 UTC 2023 - Christian Boltz <[email protected]>
+
+- Update to 3.17.1
+  * no upstream changelog
+
+-------------------------------------------------------------------

Old:
----
  pyjson_tricks-3.16.1.tar.gz

New:
----
  pyjson_tricks-3.17.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-json_tricks.spec ++++++
--- /var/tmp/diff_new_pack.WMNAkD/_old  2023-06-18 23:08:32.589676399 +0200
+++ /var/tmp/diff_new_pack.WMNAkD/_new  2023-06-18 23:08:32.597676447 +0200
@@ -18,7 +18,7 @@
 
 %bcond_without python2
 Name:           python-json_tricks
-Version:        3.16.1
+Version:        3.17.1
 Release:        0
 Summary:        Extra features for Python's JSON
 License:        BSD-3-Clause

++++++ pyjson_tricks-3.16.1.tar.gz -> pyjson_tricks-3.17.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyjson_tricks-3.16.1/.github/workflows/tests.yml 
new/pyjson_tricks-3.17.1/.github/workflows/tests.yml
--- old/pyjson_tricks-3.16.1/.github/workflows/tests.yml        2022-11-04 
17:32:05.000000000 +0100
+++ new/pyjson_tricks-3.17.1/.github/workflows/tests.yml        2023-06-17 
13:53:18.000000000 +0200
@@ -22,8 +22,6 @@
         ]
         python-version: [
             '2.7',
-            '3.5',
-            '3.6',
             '3.7',
             '3.8',
             '3.9',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyjson_tricks-3.16.1/LICENSE.txt 
new/pyjson_tricks-3.17.1/LICENSE.txt
--- old/pyjson_tricks-3.16.1/LICENSE.txt        2022-11-04 17:32:05.000000000 
+0100
+++ new/pyjson_tricks-3.17.1/LICENSE.txt        2023-06-17 13:53:18.000000000 
+0200
@@ -1,7 +1,7 @@
 LICENSE: BSD-3-Clause
 
 
-Copyright (c) 2022 Mark V. All rights reserved.
+Copyright (c) 2023 Mark V. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without 
modification,
 are permitted provided that the following conditions are met:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyjson_tricks-3.16.1/README.md 
new/pyjson_tricks-3.17.1/README.md
--- old/pyjson_tricks-3.16.1/README.md  2022-11-04 17:32:05.000000000 +0100
+++ new/pyjson_tricks-3.17.1/README.md  2023-06-17 13:53:18.000000000 +0200
@@ -343,6 +343,7 @@
   that is valid, or as base64 otherwise. Base64 is always used if 
   primitives are requested. Serialized as
   `[{"__bytes_b64__": "aGVsbG8="}]` vs `[{"__bytes_utf8__": "hello"}]`.
+* Save and load slices (thanks to `claydugo`).
 
 # Preserve type vs use primitive
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyjson_tricks-3.16.1/json_tricks/__init__.py 
new/pyjson_tricks-3.17.1/json_tricks/__init__.py
--- old/pyjson_tricks-3.16.1/json_tricks/__init__.py    2022-11-04 
17:32:05.000000000 +0100
+++ new/pyjson_tricks-3.17.1/json_tricks/__init__.py    2023-06-17 
13:53:18.000000000 +0200
@@ -8,7 +8,7 @@
 from .encoders import TricksEncoder, json_date_time_encode, 
class_instance_encode, json_complex_encode, \
        numeric_types_encode, ClassInstanceEncoder, json_set_encode, 
pandas_encode, nopandas_encode, \
        numpy_encode, NumpyEncoder, nonumpy_encode, NoNumpyEncoder, 
fallback_ignore_unknown, pathlib_encode, \
-       bytes_encode
+       bytes_encode, slice_encode
 from .decoders import DuplicateJsonKeyException, TricksPairHook, 
json_date_time_hook, json_complex_hook, \
        numeric_types_hook, ClassInstanceHook, json_set_hook, pandas_hook, 
nopandas_hook, json_numpy_obj_hook, \
        json_nonumpy_obj_hook, pathlib_hook, json_bytes_hook
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyjson_tricks-3.16.1/json_tricks/_version.py 
new/pyjson_tricks-3.17.1/json_tricks/_version.py
--- old/pyjson_tricks-3.16.1/json_tricks/_version.py    2022-11-04 
17:32:05.000000000 +0100
+++ new/pyjson_tricks-3.17.1/json_tricks/_version.py    2023-06-17 
13:53:18.000000000 +0200
@@ -1,3 +1,3 @@
 
-VERSION = '3.16.1'
+VERSION = '3.17.1'
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyjson_tricks-3.16.1/json_tricks/decoders.py 
new/pyjson_tricks-3.17.1/json_tricks/decoders.py
--- old/pyjson_tricks-3.16.1/json_tricks/decoders.py    2022-11-04 
17:32:05.000000000 +0100
+++ new/pyjson_tricks-3.17.1/json_tricks/decoders.py    2023-06-17 
13:53:18.000000000 +0200
@@ -1,3 +1,4 @@
+import sys
 import warnings
 from base64 import standard_b64decode
 from collections import OrderedDict
@@ -151,6 +152,13 @@
                                                'is not enabled.'))
        return dct
 
+def slice_hook(dct):
+       if not isinstance(dct, dict):
+               return dct
+       if not '__slice__' in dct:
+               return dct
+       return slice(dct['start'], dct['stop'], dct['step'])
+
 
 class EnumInstanceHook(ClassInstanceHookBase):
        """
@@ -259,7 +267,7 @@
 
 def json_numpy_obj_hook(dct):
        """
-       Replace any numpy arrays previously encoded by NumpyEncoder to their 
proper
+       Replace any numpy arrays previously encoded by `numpy_encode` to their 
proper
        shape, data type and data.
 
        :param dct: (dict) json encoded ndarray
@@ -284,22 +292,23 @@
                if nptype == 'object':
                        return _lists_of_obj_to_ndarray(data_json, order, 
shape, nptype)
                if isinstance(data_json, str_type):
-                       return _bin_str_to_ndarray(data_json, order, shape, 
nptype)
+                       endianness = dct.get('endian', 'native')
+                       return _bin_str_to_ndarray(data_json, order, shape, 
nptype, endianness)
                else:
                        return _lists_of_numbers_to_ndarray(data_json, order, 
shape, nptype)
        else:
                return _scalar_to_numpy(data_json, nptype)
 
 
-def _bin_str_to_ndarray(data, order, shape, dtype):
+def _bin_str_to_ndarray(data, order, shape, np_type_name, data_endianness):
        """
        From base64 encoded, gzipped binary data to ndarray.
        """
        from base64 import standard_b64decode
-       from numpy import frombuffer
+       from numpy import frombuffer, dtype
 
        assert order in [None, 'C'], 'specifying different memory order is not 
(yet) supported ' \
-               'for binary numpy format (got order = {})'.format(order)
+                                                                'for binary 
numpy format (got order = {})'.format(order)
        if data.startswith('b64.gz:'):
                data = standard_b64decode(data[7:])
                data = gzip_decompress(data)
@@ -307,7 +316,16 @@
                data = standard_b64decode(data[4:])
        else:
                raise ValueError('found numpy array buffer, but did not 
understand header; supported: b64 or b64.gz')
-       data = frombuffer(data, dtype=dtype)
+       np_type = dtype(np_type_name)
+       if data_endianness == sys.byteorder:
+               pass
+       if data_endianness == 'little':
+               np_type = np_type.newbyteorder('<')
+       elif data_endianness == 'big':
+               np_type = np_type.newbyteorder('>')
+       elif data_endianness != 'native':
+               warnings.warn('array of shape {} has unknown endianness 
\'{}\''.format(shape, data_endianness))
+       data = frombuffer(data, dtype=np_type)
        return data.reshape(shape)
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyjson_tricks-3.16.1/json_tricks/encoders.py 
new/pyjson_tricks-3.17.1/json_tricks/encoders.py
--- old/pyjson_tricks-3.16.1/json_tricks/encoders.py    2022-11-04 
17:32:05.000000000 +0100
+++ new/pyjson_tricks-3.17.1/json_tricks/encoders.py    2023-06-17 
13:53:18.000000000 +0200
@@ -5,12 +5,11 @@
 from fractions import Fraction
 from functools import wraps
 from json import JSONEncoder
-from sys import version, stderr
+import sys
 
 from .utils import hashodict, get_module_name_from_object, NoEnumException, 
NoPandasException, \
        NoNumpyException, str_type, JsonTricksDeprecation, gzip_compress, 
filtered_wrapper, is_py3
 
-
 def _fallback_wrapper(encoder):
        """
        This decorator makes an encoder run only if the current object hasn't 
been changed yet.
@@ -50,7 +49,7 @@
                """
                if silence_typeerror and not getattr(TricksEncoder, 
'_deprecated_silence_typeerror'):
                        TricksEncoder._deprecated_silence_typeerror = True
-                       stderr.write('TricksEncoder.silence_typeerror is 
deprecated and may be removed in a future version\n')
+                       sys.stderr.write('TricksEncoder.silence_typeerror is 
deprecated and may be removed in a future version\n')
                self.obj_encoders = []
                if obj_encoders:
                        self.obj_encoders = list(obj_encoders)
@@ -162,7 +161,7 @@
                if not hasattr(obj, '__new__'):
                        raise TypeError('class "{0:s}" does not have a __new__ 
method; '.format(obj.__class__) +
                                ('perhaps it is an old-style class not derived 
from `object`; add `object` as a base class to encode it.'
-                                       if (version[:2] == '2.') else 'this 
should not happen in Python3'))
+                                       if (sys.version[:2] == '2.') else 'this 
should not happen in Python3'))
                if type(obj) == type(lambda: 0):
                        raise TypeError('instance "{0:}" of class "{1:}" cannot 
be encoded because it appears to be a lambda or function.'
                                .format(obj, obj.__class__))
@@ -278,6 +277,19 @@
 
        return {'__pathlib__': str(obj)}
 
+def slice_encode(obj, primitives=False):
+       if not isinstance(obj, slice):
+               return obj
+
+       if primitives:
+               return [obj.start, obj.stop, obj.step]
+       else:
+               return hashodict((
+                       ('__slice__', True),
+                       ('start', obj.start),
+                       ('stop', obj.stop),
+                       ('step', obj.step),
+               ))
 
 class ClassInstanceEncoder(JSONEncoder):
        """
@@ -357,12 +369,16 @@
        :param primitives: If True, arrays are serialized as (nested) lists 
without meta info.
        """
        from numpy import ndarray, generic
+
        if isinstance(obj, ndarray):
                if primitives:
                        return obj.tolist()
                else:
                        properties = properties or {}
                        use_compact = properties.get('ndarray_compact', None)
+                       store_endianness = 
properties.get('ndarray_store_byteorder', None)
+                       assert store_endianness in [None, 'little', 'big', 
'suppress'] ,\
+                               'property ndarray_store_byteorder should be 
\'little\', \'big\' or \'suppress\' if provided'
                        json_compression = bool(properties.get('compression', 
False))
                        if use_compact is None and json_compression and not 
getattr(numpy_encode, '_warned_compact', False):
                                numpy_encode._warned_compact = True
@@ -377,7 +393,7 @@
                                use_compact = obj.size >= use_compact
                        if use_compact:
                                # If the overall json file is compressed, then 
don't compress the array.
-                               data_json = _ndarray_to_bin_str(obj, 
do_compress=not json_compression)
+                               data_json = _ndarray_to_bin_str(obj, 
do_compress=not json_compression, store_endianness=store_endianness)
                        else:
                                data_json = obj.tolist()
                        dct = hashodict((
@@ -387,6 +403,8 @@
                        ))
                        if len(obj.shape) > 1:
                                dct['Corder'] = obj.flags['C_CONTIGUOUS']
+                       if use_compact and store_endianness != 'suppress':
+                               dct['endian'] = store_endianness or 
sys.byteorder
                        return dct
        elif isinstance(obj, generic):
                if NumpyEncoder.SHOW_SCALAR_WARNING:
@@ -396,7 +414,7 @@
        return obj
 
 
-def _ndarray_to_bin_str(array, do_compress):
+def _ndarray_to_bin_str(array, do_compress, store_endianness):
        """
        From ndarray to base64 encoded, gzipped binary data.
        """
@@ -405,6 +423,8 @@
 
        original_size = array.size * array.itemsize
        header = 'b64:'
+       if store_endianness in ['little', 'big'] and store_endianness != 
sys.byteorder:
+               array = array.byteswap(inplace=False)
        data = array.data
        if do_compress:
                small = gzip_compress(data, compresslevel=9)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyjson_tricks-3.16.1/json_tricks/nonp.py 
new/pyjson_tricks-3.17.1/json_tricks/nonp.py
--- old/pyjson_tricks-3.16.1/json_tricks/nonp.py        2022-11-04 
17:32:05.000000000 +0100
+++ new/pyjson_tricks-3.17.1/json_tricks/nonp.py        2023-06-17 
13:53:18.000000000 +0200
@@ -10,13 +10,13 @@
 from .encoders import TricksEncoder, json_date_time_encode, \
        class_instance_encode, json_complex_encode, json_set_encode, 
numeric_types_encode, numpy_encode, \
        nonumpy_encode, nopandas_encode, pandas_encode, noenum_instance_encode, 
\
-       enum_instance_encode, pathlib_encode, bytes_encode  # keep 'unused' 
imports
+       enum_instance_encode, pathlib_encode, bytes_encode, slice_encode  # 
keep 'unused' imports
 from .decoders import TricksPairHook, \
        json_date_time_hook, ClassInstanceHook, \
        json_complex_hook, json_set_hook, numeric_types_hook, 
json_numpy_obj_hook, \
        json_nonumpy_obj_hook, \
        nopandas_hook, pandas_hook, EnumInstanceHook, \
-       noenum_hook, pathlib_hook, nopathlib_hook, json_bytes_hook  # keep 
'unused' imports
+       noenum_hook, pathlib_hook, nopathlib_hook, json_bytes_hook, slice_hook  
# keep 'unused' imports
 
 
 ENCODING = 'UTF-8'
@@ -24,10 +24,26 @@
 
 _cih_instance = ClassInstanceHook()
 _eih_instance = EnumInstanceHook()
-DEFAULT_ENCODERS = [json_date_time_encode, json_complex_encode, 
json_set_encode,
-                                       numeric_types_encode, 
class_instance_encode, bytes_encode,]
-DEFAULT_HOOKS = [json_date_time_hook, json_complex_hook, json_set_hook,
-                               numeric_types_hook, _cih_instance, 
json_bytes_hook,]
+
+DEFAULT_ENCODERS = [
+    json_date_time_encode,
+    json_complex_encode,
+    json_set_encode,
+    numeric_types_encode,
+    class_instance_encode,
+    bytes_encode,
+    slice_encode,
+]
+
+DEFAULT_HOOKS = [
+    json_date_time_hook,
+    json_complex_hook,
+    json_set_hook,
+    numeric_types_hook,
+    _cih_instance,
+    json_bytes_hook,
+    slice_hook,
+]
 
 
 #TODO @mark: add properties to all built-in encoders (for speed - but it 
should keep working without)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyjson_tricks-3.16.1/tests/test_np.py 
new/pyjson_tricks-3.17.1/tests/test_np.py
--- old/pyjson_tricks-3.16.1/tests/test_np.py   2022-11-04 17:32:05.000000000 
+0100
+++ new/pyjson_tricks-3.17.1/tests/test_np.py   2023-06-17 13:53:18.000000000 
+0200
@@ -4,6 +4,7 @@
 from copy import deepcopy
 from os.path import join
 from tempfile import mkdtemp
+import sys
 
 from _pytest.recwarn import warns
 from numpy import arange, ones, array, array_equal, finfo, iinfo, pi
@@ -76,7 +77,7 @@
        arr = [array([[1.0, 2.0], [3.0, 4.0]])]
        path = join(mkdtemp(), 'pytest-np.json.gz')
        with open(path, 'wb+') as fh:
-               dump(arr, fh, compression=True, properties={'ndarray_compact': 
True})
+               dump(arr, fh, compression=True, 
properties=dict(ndarray_compact=True, ndarray_store_byteorder='little'))
 
 
 mixed_data = {
@@ -226,50 +227,85 @@
 
 def test_compact():
        data = [array(list(2**(x + 0.5) for x in range(-30, +31)))]
-       json = dumps(data, compression=True, properties={'ndarray_compact': 
True})
+       json = dumps(data, compression=True, 
properties=dict(ndarray_compact=True, ndarray_store_byteorder='little'))
        back = loads(json)
        assert_equal(data, back)
 
 
 def test_encode_disable_compact():
        data = [array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]), array([pi, 
exp(1)])]
-       gz_json = dumps(data, compression=True, properties={'ndarray_compact': 
False})
+       gz_json = dumps(data, compression=True, 
properties=dict(ndarray_compact=False))
        json = gzip_decompress(gz_json).decode('ascii')
        assert json == '[{"__ndarray__": [[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 
8.0]], "dtype": "float64", "shape": [2, 4], "Corder": true}, ' \
                '{"__ndarray__": [3.141592653589793, 2.718281828459045], 
"dtype": "float64", "shape": [2]}]'
 
 
-def test_encode_enable_compact():
+def test_encode_enable_compact_little_endian():
        data = [array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]), array([pi, 
exp(1)])]
-       gz_json = dumps(data, compression=True, properties={'ndarray_compact': 
True})
+       gz_json = dumps(data, compression=True, 
properties=dict(ndarray_compact=True, ndarray_store_byteorder='little'))
        json = gzip_decompress(gz_json).decode('ascii')
        assert json == '[{"__ndarray__": 
"b64:AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAA' \
                'UQAAAAAAAABhAAAAAAAAAHEAAAAAAAAAgQA==", "dtype": "float64", 
"shape": [2, 4], "Corder": ' \
-               'true}, {"__ndarray__": "b64:GC1EVPshCUBpVxSLCr8FQA==", 
"dtype": "float64", "shape": [2]}]'
+               'true, "endian": "little"}, {"__ndarray__": 
"b64:GC1EVPshCUBpVxSLCr8FQA==", "dtype": "float64", ' \
+               '"shape": [2], "endian": "little"}]'
+
+
+def test_encode_enable_compact_big_endian():
+       data = array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]])
+       gz_json = dumps(data, compression=True, 
properties=dict(ndarray_compact=True, ndarray_store_byteorder='big'))
+       json = gzip_decompress(gz_json).decode('ascii')
+       assert json == '{"__ndarray__": 
"b64:P/AAAAAAAABAAAAAAAAAAEAIAAAAAAAAQBAAAAAAAABAFAAAAAAAAEAYAA' \
+               'AAAAAAQBwAAAAAAABAIAAAAAAAAA==", "dtype": "float64", "shape": 
[2, 4], "Corder": ' \
+               'true, "endian": "big"}'
+
+
+def test_encode_enable_compact_native_endian():
+       data = array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]])
+       gz_json = dumps(data, compression=True, 
properties=dict(ndarray_compact=True))
+       json = gzip_decompress(gz_json).decode('ascii')
+       if sys.byteorder == 'little':
+               assert json == '{"__ndarray__": 
"b64:AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAA' \
+                       'UQAAAAAAAABhAAAAAAAAAHEAAAAAAAAAgQA==", "dtype": 
"float64", "shape": [2, 4], "Corder": ' \
+                       'true, "endian": "little"}'
+       elif sys.byteorder == 'big':
+               assert json == '{"__ndarray__": 
"b64:P/AAAAAAAABAAAAAAAAAAEAIAAAAAAAAQBAAAAAAAABAFAAAAAAAAEAYAA' \
+                       'AAAAAAQBwAAAAAAABAIAAAAAAAAA==", "dtype": "float64", 
"shape": [2, 4], "Corder": ' \
+                       'true, "endian": "big"}'
+       else:
+               raise Exception("unknown system endianness 
'{}'".format(sys.byteorder))
+
+
+def test_encode_enable_compact_suppress_endianness():
+       data = array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]])
+       gz_json = dumps(data, compression=True, 
properties=dict(ndarray_compact=True, ndarray_store_byteorder='suppress'))
+       json = gzip_decompress(gz_json).decode('ascii')
+       assert "endian" not in json
 
 
 def test_encode_compact_cutoff():
        data = [array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]), array([pi, 
exp(1)])]
-       gz_json = dumps(data, compression=True, properties={'ndarray_compact': 
5})
+       gz_json = dumps(data, compression=True, 
properties=dict(ndarray_compact=5, ndarray_store_byteorder='little'))
        json = gzip_decompress(gz_json).decode('ascii')
        assert json == '[{"__ndarray__": 
"b64:AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAA' \
                'UQAAAAAAAABhAAAAAAAAAHEAAAAAAAAAgQA==", "dtype": "float64", 
"shape": [2, 4], "Corder": ' \
-               'true}, {"__ndarray__": [3.141592653589793, 2.718281828459045], 
"dtype": "float64", "shape": [2]}]'
+               'true, "endian": "little"}, {"__ndarray__": [3.141592653589793, 
2.718281828459045], "dtype": "float64", ' \
+               '"shape": [2]}]'
 
 
 def test_encode_compact_inline_compression():
        data = [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]])]
-       json = dumps(data, compression=False, properties={'ndarray_compact': 
True})
+       json = dumps(data, compression=False, 
properties=dict(ndarray_compact=True, ndarray_store_byteorder='little'))
        assert 'b64.gz:' in json, 'If the overall file is not compressed and 
there are significant savings, then do inline gzip compression.'
-       assert json == '[{"__ndarray__": 
"b64.gz:H4sIAAAAAAAC/2NgAIEP9gwQ4AChOKC0AJQWgdISUFoGSitAaSUorQKl1aC0BpTWgtI6UFoPShs4AABmfqWAgAAAAA==",
 "dtype": "float64", "shape": [4, 4], "Corder": true}]'
+       assert json == '[{"__ndarray__": 
"b64.gz:H4sIAAAAAAAC/2NgAIEP9gwQ4AChOKC0AJQWgdISUFoGSitAaSUorQKl1aC0BpTWgtI6UFoPShs4AABmfqWAgAAAAA==",
 ' \
+               '"dtype": "float64", "shape": [4, 4], "Corder": true, "endian": 
"little"}]'
 
 
 def test_encode_compact_no_inline_compression():
        data = [array([[1.0, 2.0], [3.0, 4.0]])]
-       json = dumps(data, compression=False, properties={'ndarray_compact': 
True})
+       json = dumps(data, compression=False, 
properties=dict(ndarray_compact=True, ndarray_store_byteorder='little'))
        assert 'b64.gz:' not in json, 'If the overall file is not compressed, 
but there are no significant savings, then do not do inline compression.'
        assert json == '[{"__ndarray__": 
"b64:AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEA=", ' \
-               '"dtype": "float64", "shape": [2, 2], "Corder": true}]'
+               '"dtype": "float64", "shape": [2, 2], "Corder": true, "endian": 
"little"}]'
 
 
 def test_decode_compact_mixed_compactness():
@@ -280,6 +316,32 @@
        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)]))
 
 
+def test_decode_big_endian():
+       json = '{"__ndarray__": 
"b64:P/AAAAAAAABAAAAAAAAAAEAIAAAAAAAAQBAAAAAAAABAFAAAAAAAAEAYAA' \
+                  'AAAAAAQBwAAAAAAABAIAAAAAAAAA==", "dtype": "float64", 
"shape": [2, 4], "Corder": ' \
+                  'true, "endian": "big"}'
+       data = loads(json)
+       assert_equal(data, array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]))
+
+
+def test_decode_little_endian():
+       json = '{"__ndarray__": 
"b64:AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAA' \
+               'UQAAAAAAAABhAAAAAAAAAHEAAAAAAAAAgQA==", "dtype": "float64", 
"shape": [2, 4], "Corder": ' \
+               'true, "endian": "little"}'
+       data = loads(json)
+       assert_equal(data, array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]))
+
+
+def test_decode_without_endianness():
+       json = '[{"__ndarray__": 
"b64:AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAA' \
+               'UQAAAAAAAABhAAAAAAAAAHEAAAAAAAAAgQA==", "dtype": "float64", 
"shape": [2, 4], "Corder": true}]'
+       data = loads(json)
+       if sys.byteorder == 'big':
+               import pytest
+               pytest.skip('skip for big endian systems')
+       assert_equal(data[0], array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 
8.0]]))
+
+
 def test_decode_compact_inline_compression():
        json = '[{"__ndarray__": 
"b64.gz:H4sIAAAAAAAC/2NgAIEP9gwQ4AChOKC0AJQWgdISUFoGSitAaSUorQKl1aC0BpTWgtI6UFoPShs4AABmfqWAgAAAAA==",
 "dtype": "float64", "shape": [4, 4], "Corder": true}]'
        data = loads(json)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyjson_tricks-3.16.1/tests/test_slice.py 
new/pyjson_tricks-3.17.1/tests/test_slice.py
--- old/pyjson_tricks-3.16.1/tests/test_slice.py        1970-01-01 
01:00:00.000000000 +0100
+++ new/pyjson_tricks-3.17.1/tests/test_slice.py        2023-06-17 
13:53:18.000000000 +0200
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from pathlib import Path
+from json_tricks import dumps, loads
+
+def test_slice():
+    original_slice = slice(0, 10, 2)
+    json_slice = dumps(original_slice)
+    loaded_slice = loads(json_slice)
+    assert original_slice == loaded_slice
+
+def test_slice_no_step():
+    original_slice = slice(0, 5)
+    json_slice = dumps(original_slice)
+    loaded_slice = loads(json_slice)
+    assert original_slice == loaded_slice

Reply via email to