bjdata 0.3.4__tar.gz → 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {bjdata-0.3.4 → bjdata-0.4.1}/PKG-INFO +12 -10
  2. {bjdata-0.3.4 → bjdata-0.4.1}/README.md +6 -5
  3. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata/__init__.py +2 -2
  4. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata/__main__.py +1 -1
  5. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata/compat.py +1 -1
  6. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata/decoder.py +9 -2
  7. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata/encoder.py +60 -3
  8. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata/markers.py +1 -1
  9. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata.egg-info/PKG-INFO +12 -10
  10. {bjdata-0.3.4 → bjdata-0.4.1}/setup.py +4 -2
  11. {bjdata-0.3.4 → bjdata-0.4.1}/src/_bjdata.c +6 -1
  12. {bjdata-0.3.4 → bjdata-0.4.1}/src/common.h +1 -1
  13. {bjdata-0.3.4 → bjdata-0.4.1}/src/decoder.c +8 -10
  14. {bjdata-0.3.4 → bjdata-0.4.1}/src/decoder.h +1 -3
  15. {bjdata-0.3.4 → bjdata-0.4.1}/src/encoder.c +112 -6
  16. {bjdata-0.3.4 → bjdata-0.4.1}/src/encoder.h +1 -1
  17. {bjdata-0.3.4 → bjdata-0.4.1}/src/markers.h +1 -1
  18. {bjdata-0.3.4 → bjdata-0.4.1}/src/python_funcs.c +1 -1
  19. {bjdata-0.3.4 → bjdata-0.4.1}/test/test.py +31 -7
  20. {bjdata-0.3.4 → bjdata-0.4.1}/Binary_JData_Specification.md +0 -0
  21. {bjdata-0.3.4 → bjdata-0.4.1}/CHANGELOG +0 -0
  22. {bjdata-0.3.4 → bjdata-0.4.1}/LICENSE +0 -0
  23. {bjdata-0.3.4 → bjdata-0.4.1}/MANIFEST.in +0 -0
  24. {bjdata-0.3.4 → bjdata-0.4.1}/NOTICE +0 -0
  25. {bjdata-0.3.4 → bjdata-0.4.1}/UBJSON-Specification.md +0 -0
  26. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata.egg-info/SOURCES.txt +0 -0
  27. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata.egg-info/dependency_links.txt +0 -0
  28. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata.egg-info/not-zip-safe +0 -0
  29. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata.egg-info/requires.txt +0 -0
  30. {bjdata-0.3.4 → bjdata-0.4.1}/bjdata.egg-info/top_level.txt +0 -0
  31. {bjdata-0.3.4 → bjdata-0.4.1}/ez_setup.py +0 -0
  32. {bjdata-0.3.4 → bjdata-0.4.1}/pyproject.toml +0 -0
  33. {bjdata-0.3.4 → bjdata-0.4.1}/setup.cfg +0 -0
  34. {bjdata-0.3.4 → bjdata-0.4.1}/src/python_funcs.h +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bjdata
3
- Version: 0.3.4
3
+ Version: 0.4.1
4
4
  Summary: Binary JData and UBJSON encoder/decoder
5
5
  Home-page: https://github.com/NeuroJSON/pybj
6
6
  Author: Qianqian Fang
@@ -9,7 +9,6 @@ Maintainer: Qianqian Fang
9
9
  Maintainer-email: fangqq@gmail.com
10
10
  License: Apache License 2.0
11
11
  Keywords: JSON,JData,UBJSON,BJData,OpenJData,NeuroJSON,JNIfTI,Encoder,Decoder
12
- Platform: UNKNOWN
13
12
  Classifier: Development Status :: 4 - Beta
14
13
  Classifier: License :: OSI Approved :: Apache Software License
15
14
  Classifier: Intended Audience :: Developers
@@ -23,21 +22,25 @@ Classifier: Programming Language :: Python :: 3.5
23
22
  Classifier: Programming Language :: Python :: 3.6
24
23
  Classifier: Programming Language :: Python :: 3.7
25
24
  Classifier: Programming Language :: Python :: 3.8
25
+ Classifier: Programming Language :: Python :: 3.9
26
26
  Classifier: Topic :: Software Development :: Libraries
27
27
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
28
  Description-Content-Type: text/markdown
29
- Provides-Extra: dev
30
29
  License-File: LICENSE
31
30
  License-File: NOTICE
31
+ Requires-Dist: numpy>=1.8.0
32
+ Provides-Extra: dev
33
+ Requires-Dist: Pympler<0.8,>=0.7; extra == "dev"
34
+ Requires-Dist: coverage<4.6,>=4.5.3; extra == "dev"
32
35
 
33
36
  ![](https://neurojson.org/wiki/upload/neurojson_banner_long.png)
34
37
 
35
38
  # Binary JData for Python - a lightweight binary JSON format
36
39
 
37
- - Copyright: (C) Qianqian Fang (2020-2022) <q.fang at neu.edu>
40
+ - Copyright: (C) Qianqian Fang (2020-2023) <q.fang at neu.edu>
38
41
  - Copyright: (C) Iotic Labs Ltd. (2016-2019) <vilnis.termanis at iotic-labs.com>
39
42
  - License: Apache License, Version 2.0
40
- - Version: 0.3.4
43
+ - Version: 0.4.1
41
44
  - URL: https://pypi.org/project/bjdata/
42
45
  - Github: https://github.com/NeuroJSON/pybj
43
46
  - BJData Spec Version: [V1 Draft 2](https://neurojson.org/bjdata/draft2)
@@ -45,8 +48,8 @@ License-File: NOTICE
45
48
 
46
49
  [![Build Status](https://travis-ci.com/NeuroJSON/pybj.svg?branch=master)](https://travis-ci.com/NeuroJSON/pybj)
47
50
 
48
- This is a Python v3.2+ (and 2.7+) [Binary JData](http://neurojson.org) based on
49
- the [Draft-2](Binary_JData_Specification.md) specification.
51
+ This is a Python v3.2+ (and 2.7+) [Binary JData](https://neurojson.org) encoder
52
+ and decoder based on the [Draft-2](Binary_JData_Specification.md) specification.
50
53
 
51
54
  ## Installing / packaging
52
55
  ```shell
@@ -64,7 +67,7 @@ pip3 install bjdata --user
64
67
  ## To get from PyPI via python
65
68
  python3 -mpip install bjdata
66
69
 
67
- ## To only build extension modules inline (e.g. in repository)
70
+ ## To only build extension modules in-place (e.g. in repository)
68
71
  python3 setup.py build_ext -i
69
72
 
70
73
  ## To build & install globally
@@ -159,6 +162,7 @@ pip install -e .[dev]
159
162
  - Strongly-typed containers are only supported by the decoder (apart from for
160
163
  **bytes**/**bytearray**) and not for No-Op.
161
164
  - Encoder/decoder extensions are not supported at this time.
165
+ - Encoder/decoder only support numpy NDarrays and scalars, other numpy types are not supported.
162
166
 
163
167
 
164
168
  ## Acknowledgement
@@ -177,5 +181,3 @@ the below new features:
177
181
  * BJData does not convert NaN/Inf/-Inf to `null`
178
182
  * BJData uses little-Endian as the default integer/floating-point numbers while UBJSON uses big-Endian
179
183
  * BJData only permits non-zero-fixed-length data types (`UiuImlMLhdDC`) in strongly-typed array/object containers
180
-
181
-
@@ -2,10 +2,10 @@
2
2
 
3
3
  # Binary JData for Python - a lightweight binary JSON format
4
4
 
5
- - Copyright: (C) Qianqian Fang (2020-2022) <q.fang at neu.edu>
5
+ - Copyright: (C) Qianqian Fang (2020-2023) <q.fang at neu.edu>
6
6
  - Copyright: (C) Iotic Labs Ltd. (2016-2019) <vilnis.termanis at iotic-labs.com>
7
7
  - License: Apache License, Version 2.0
8
- - Version: 0.3.4
8
+ - Version: 0.4.1
9
9
  - URL: https://pypi.org/project/bjdata/
10
10
  - Github: https://github.com/NeuroJSON/pybj
11
11
  - BJData Spec Version: [V1 Draft 2](https://neurojson.org/bjdata/draft2)
@@ -13,8 +13,8 @@
13
13
 
14
14
  [![Build Status](https://travis-ci.com/NeuroJSON/pybj.svg?branch=master)](https://travis-ci.com/NeuroJSON/pybj)
15
15
 
16
- This is a Python v3.2+ (and 2.7+) [Binary JData](http://neurojson.org) based on
17
- the [Draft-2](Binary_JData_Specification.md) specification.
16
+ This is a Python v3.2+ (and 2.7+) [Binary JData](https://neurojson.org) encoder
17
+ and decoder based on the [Draft-2](Binary_JData_Specification.md) specification.
18
18
 
19
19
  ## Installing / packaging
20
20
  ```shell
@@ -32,7 +32,7 @@ pip3 install bjdata --user
32
32
  ## To get from PyPI via python
33
33
  python3 -mpip install bjdata
34
34
 
35
- ## To only build extension modules inline (e.g. in repository)
35
+ ## To only build extension modules in-place (e.g. in repository)
36
36
  python3 setup.py build_ext -i
37
37
 
38
38
  ## To build & install globally
@@ -127,6 +127,7 @@ pip install -e .[dev]
127
127
  - Strongly-typed containers are only supported by the decoder (apart from for
128
128
  **bytes**/**bytearray**) and not for No-Op.
129
129
  - Encoder/decoder extensions are not supported at this time.
130
+ - Encoder/decoder only support numpy NDarrays and scalars, other numpy types are not supported.
130
131
 
131
132
 
132
133
  ## Acknowledgement
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
1
+ # Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
2
  # Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,6 +38,6 @@ except ImportError: # pragma: no cover
38
38
  from .encoder import EncoderException
39
39
  from .decoder import DecoderException
40
40
 
41
- __version__ = '0.3.4'
41
+ __version__ = '0.4.1'
42
42
 
43
43
  __all__ = ('EXTENSION_ENABLED', 'dump', 'dumpb', 'EncoderException', 'load', 'loadb', 'DecoderException')
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
1
+ # Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
2
  # Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
1
+ # Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
2
  # Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
1
+ # Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
2
  # Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,7 +26,7 @@ from .markers import (TYPE_NONE, TYPE_NULL, TYPE_NOOP, TYPE_BOOL_TRUE, TYPE_BOOL
26
26
  TYPE_INT16, TYPE_INT32, TYPE_INT64, TYPE_FLOAT32, TYPE_FLOAT64, TYPE_HIGH_PREC, TYPE_CHAR,
27
27
  TYPE_UINT16, TYPE_UINT32, TYPE_UINT64, TYPE_FLOAT16,
28
28
  TYPE_STRING, OBJECT_START, OBJECT_END, ARRAY_START, ARRAY_END, CONTAINER_TYPE, CONTAINER_COUNT)
29
- from numpy import array as ndarray, dtype as npdtype, frombuffer as buffer2numpy
29
+ from numpy import array as ndarray, dtype as npdtype, frombuffer as buffer2numpy, half as halfprec
30
30
  from array import array as typedarray
31
31
 
32
32
  __TYPES = frozenset((TYPE_NULL, TYPE_BOOL_TRUE, TYPE_BOOL_FALSE, TYPE_INT8, TYPE_UINT8, TYPE_INT16, TYPE_INT32,
@@ -170,6 +170,12 @@ def __decode_uint64(fp_read, marker, le=1):
170
170
  raise_from(DecoderException('Failed to unpack uint64'), ex)
171
171
 
172
172
 
173
+ def __decode_float16(fp_read, marker, le=1):
174
+ try:
175
+ return __UNPACK_FLOAT16[le](fp_read(2))[0]
176
+ except StructError as ex:
177
+ raise_from(DecoderException('Failed to unpack float16'), ex)
178
+
173
179
  def __decode_float32(fp_read, marker, le=1):
174
180
  try:
175
181
  return __UNPACK_FLOAT32[le](fp_read(4))[0]
@@ -229,6 +235,7 @@ __METHOD_MAP = {TYPE_NULL: (lambda _, __, ___: None),
229
235
  TYPE_UINT32: __decode_uint32,
230
236
  TYPE_INT64: __decode_int64,
231
237
  TYPE_UINT64: __decode_uint64,
238
+ TYPE_FLOAT16: __decode_float16,
232
239
  TYPE_FLOAT32: __decode_float32,
233
240
  TYPE_FLOAT64: __decode_float64,
234
241
  TYPE_HIGH_PREC: __decode_high_prec,
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
1
+ # Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
2
  # Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,6 +40,21 @@ __PACK_FLOAT16 = [Struct('>h').pack, Struct('<h').pack]
40
40
  __PACK_FLOAT32 = [Struct('>f').pack, Struct('<f').pack]
41
41
  __PACK_FLOAT64 = [Struct('>d').pack, Struct('<d').pack]
42
42
 
43
+ __DTYPE_TO_MARKER = {
44
+ 'i1' : TYPE_INT8,
45
+ 'i2' : TYPE_INT16,
46
+ 'i4' : TYPE_INT32,
47
+ 'i8' : TYPE_INT64,
48
+ 'u1' : TYPE_UINT8,
49
+ 'u2' : TYPE_UINT16,
50
+ 'u4' : TYPE_UINT32,
51
+ 'u8' : TYPE_UINT64,
52
+ 'f2' : TYPE_FLOAT16,
53
+ 'f4' : TYPE_FLOAT32,
54
+ 'f8' : TYPE_FLOAT64,
55
+ 'b1' : TYPE_INT8,
56
+ 'S1' : TYPE_CHAR
57
+ }
43
58
 
44
59
  # Prefix applicable to specialised byte array container
45
60
  __BYTES_ARRAY_PREFIX = ARRAY_START + CONTAINER_TYPE + TYPE_UINT8 + CONTAINER_COUNT
@@ -143,7 +158,8 @@ def __encode_bytes(fp_write, item, le=1):
143
158
 
144
159
 
145
160
  def __encode_value(fp_write, item, seen_containers, container_count, sort_keys, no_float32, islittle, default):
146
- le=islittle;
161
+ le=islittle
162
+
147
163
  if isinstance(item, UNICODE_TYPE):
148
164
  __encode_string(fp_write, item, le)
149
165
 
@@ -156,7 +172,7 @@ def __encode_value(fp_write, item, seen_containers, container_count, sort_keys,
156
172
  elif item is False:
157
173
  fp_write(TYPE_BOOL_FALSE)
158
174
 
159
- elif isinstance(item, INTEGER_TYPES):
175
+ elif isinstance(item, INTEGER_TYPES) and not (type(item).__module__ == "numpy"):
160
176
  __encode_int(fp_write, item, le)
161
177
 
162
178
  elif isinstance(item, float):
@@ -181,6 +197,9 @@ def __encode_value(fp_write, item, seen_containers, container_count, sort_keys,
181
197
  elif default is not None:
182
198
  __encode_value(fp_write, default(item), seen_containers, container_count, sort_keys, no_float32, islittle, default)
183
199
 
200
+ elif type(item).__module__ == "numpy":
201
+ __encode_numpy(fp_write, item, islittle, default)
202
+
184
203
  else:
185
204
  raise EncoderException('Cannot encode item of type %s' % type(item))
186
205
 
@@ -238,6 +257,44 @@ def __encode_object(fp_write, item, seen_containers, container_count, sort_keys,
238
257
 
239
258
  del seen_containers[container_id]
240
259
 
260
+ def __map_dtype(dtypestr):
261
+ if len(dtypestr) == 3 and (dtypestr.startswith('<') or dtypestr.startswith('|') or dtypestr.startswith('>')):
262
+ return __DTYPE_TO_MARKER[dtypestr[1:3]]
263
+ else:
264
+ raise Exception("bjdata", "numpy dtype {} is not supported".format(dtypestr))
265
+
266
+ def __encode_numpy(fp_write, item, islittle, default):
267
+ try:
268
+ import numpy as np
269
+ except ImportError:
270
+ raise Exception("bjdata", "you must install 'numpy' to encode this data")
271
+
272
+ # TODO: need to detect big-endian data and swap bytes
273
+ if(np.isscalar(item)):
274
+ fp_write(__map_dtype(item.dtype.str))
275
+ fp_write(item.data)
276
+ return
277
+
278
+ if not (type(item).__name__ == 'ndarray' or type(item).__name__ == 'chararray'):
279
+ raise Exception("bjdata", "only numerical scalars and ndarrays are supported for numpy data")
280
+
281
+ if(item.dtype.str[1] == 'U' or item.dtype.str[1] == 'S') and item.ndim == 0:
282
+ fp_write(TYPE_STRING)
283
+ __encode_int(fp_write, int(item.dtype.str[2:]) * (4 if item.dtype.str[1] == 'U' else 1), islittle)
284
+ fp_write(item.data)
285
+ return
286
+
287
+ if(np.isfortran(item)):
288
+ item = np.array( item, order = 'C') # currently, BJData ND-array syntax only support row-major
289
+
290
+ fp_write(ARRAY_START + CONTAINER_TYPE + __map_dtype(item.dtype.str) + CONTAINER_COUNT)
291
+ fp_write(ARRAY_START)
292
+ for value in item.shape:
293
+ __encode_int(fp_write, value, islittle)
294
+ fp_write(ARRAY_END)
295
+
296
+ fp_write(item.data)
297
+
241
298
 
242
299
  def dump(obj, fp, container_count=False, sort_keys=False, no_float32=True, islittle=True, default=None):
243
300
  """Writes the given object as BJData/UBJSON to the provided file-like object
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
1
+ # Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
2
  # Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bjdata
3
- Version: 0.3.4
3
+ Version: 0.4.1
4
4
  Summary: Binary JData and UBJSON encoder/decoder
5
5
  Home-page: https://github.com/NeuroJSON/pybj
6
6
  Author: Qianqian Fang
@@ -9,7 +9,6 @@ Maintainer: Qianqian Fang
9
9
  Maintainer-email: fangqq@gmail.com
10
10
  License: Apache License 2.0
11
11
  Keywords: JSON,JData,UBJSON,BJData,OpenJData,NeuroJSON,JNIfTI,Encoder,Decoder
12
- Platform: UNKNOWN
13
12
  Classifier: Development Status :: 4 - Beta
14
13
  Classifier: License :: OSI Approved :: Apache Software License
15
14
  Classifier: Intended Audience :: Developers
@@ -23,21 +22,25 @@ Classifier: Programming Language :: Python :: 3.5
23
22
  Classifier: Programming Language :: Python :: 3.6
24
23
  Classifier: Programming Language :: Python :: 3.7
25
24
  Classifier: Programming Language :: Python :: 3.8
25
+ Classifier: Programming Language :: Python :: 3.9
26
26
  Classifier: Topic :: Software Development :: Libraries
27
27
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
28
  Description-Content-Type: text/markdown
29
- Provides-Extra: dev
30
29
  License-File: LICENSE
31
30
  License-File: NOTICE
31
+ Requires-Dist: numpy>=1.8.0
32
+ Provides-Extra: dev
33
+ Requires-Dist: Pympler<0.8,>=0.7; extra == "dev"
34
+ Requires-Dist: coverage<4.6,>=4.5.3; extra == "dev"
32
35
 
33
36
  ![](https://neurojson.org/wiki/upload/neurojson_banner_long.png)
34
37
 
35
38
  # Binary JData for Python - a lightweight binary JSON format
36
39
 
37
- - Copyright: (C) Qianqian Fang (2020-2022) <q.fang at neu.edu>
40
+ - Copyright: (C) Qianqian Fang (2020-2023) <q.fang at neu.edu>
38
41
  - Copyright: (C) Iotic Labs Ltd. (2016-2019) <vilnis.termanis at iotic-labs.com>
39
42
  - License: Apache License, Version 2.0
40
- - Version: 0.3.4
43
+ - Version: 0.4.1
41
44
  - URL: https://pypi.org/project/bjdata/
42
45
  - Github: https://github.com/NeuroJSON/pybj
43
46
  - BJData Spec Version: [V1 Draft 2](https://neurojson.org/bjdata/draft2)
@@ -45,8 +48,8 @@ License-File: NOTICE
45
48
 
46
49
  [![Build Status](https://travis-ci.com/NeuroJSON/pybj.svg?branch=master)](https://travis-ci.com/NeuroJSON/pybj)
47
50
 
48
- This is a Python v3.2+ (and 2.7+) [Binary JData](http://neurojson.org) based on
49
- the [Draft-2](Binary_JData_Specification.md) specification.
51
+ This is a Python v3.2+ (and 2.7+) [Binary JData](https://neurojson.org) encoder
52
+ and decoder based on the [Draft-2](Binary_JData_Specification.md) specification.
50
53
 
51
54
  ## Installing / packaging
52
55
  ```shell
@@ -64,7 +67,7 @@ pip3 install bjdata --user
64
67
  ## To get from PyPI via python
65
68
  python3 -mpip install bjdata
66
69
 
67
- ## To only build extension modules inline (e.g. in repository)
70
+ ## To only build extension modules in-place (e.g. in repository)
68
71
  python3 setup.py build_ext -i
69
72
 
70
73
  ## To build & install globally
@@ -159,6 +162,7 @@ pip install -e .[dev]
159
162
  - Strongly-typed containers are only supported by the decoder (apart from for
160
163
  **bytes**/**bytearray**) and not for No-Op.
161
164
  - Encoder/decoder extensions are not supported at this time.
165
+ - Encoder/decoder only support numpy NDarrays and scalars, other numpy types are not supported.
162
166
 
163
167
 
164
168
  ## Acknowledgement
@@ -177,5 +181,3 @@ the below new features:
177
181
  * BJData does not convert NaN/Inf/-Inf to `null`
178
182
  * BJData uses little-Endian as the default integer/floating-point numbers while UBJSON uses big-Endian
179
183
  * BJData only permits non-zero-fixed-length data types (`UiuImlMLhdDC`) in strongly-typed array/object containers
180
-
181
-
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
1
+ # Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
2
  # Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,6 +35,7 @@ from distutils.command.build_ext import build_ext
35
35
  from distutils.errors import CCompilerError
36
36
  from distutils.errors import DistutilsPlatformError, DistutilsExecError
37
37
 
38
+
38
39
  def load_description(filename):
39
40
  script_dir = os.path.abspath(os.path.dirname(__file__))
40
41
  with open(os.path.join(script_dir, filename), 'r') as infile:
@@ -72,7 +73,7 @@ COMPILE_ARGS = ['-std=c99', '-DUSE__BJDATA']
72
73
 
73
74
  setup(
74
75
  name='bjdata',
75
- version='0.3.4',
76
+ version='0.4.1',
76
77
  description='Binary JData and UBJSON encoder/decoder',
77
78
  long_description=load_description('README.md'),
78
79
  long_description_content_type='text/markdown',
@@ -116,6 +117,7 @@ setup(
116
117
  'Programming Language :: Python :: 3.6',
117
118
  'Programming Language :: Python :: 3.7',
118
119
  'Programming Language :: Python :: 3.8',
120
+ 'Programming Language :: Python :: 3.9',
119
121
  'Topic :: Software Development :: Libraries',
120
122
  'Topic :: Software Development :: Libraries :: Python Modules'
121
123
  ]
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
+ * Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
3
3
  * Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,10 @@
21
21
  #include "encoder.h"
22
22
  #include "decoder.h"
23
23
 
24
+ #define PY_ARRAY_UNIQUE_SYMBOL bjdata_numpy_array
25
+ #define NPY_NO_DEPRECATED_API 0
26
+ #include <numpy/arrayobject.h>
27
+
24
28
  /******************************************************************************/
25
29
 
26
30
  // container_count, sort_keys, no_float32, islittle
@@ -233,6 +237,7 @@ init_bjdata(void)
233
237
  PyObject *module = Py_InitModule("_bjdata", UbjsonMethods);
234
238
  #endif
235
239
 
240
+ import_array();
236
241
  BAIL_ON_NONZERO(_bjdata_encoder_init());
237
242
  BAIL_ON_NONZERO(_bjdata_decoder_init());
238
243
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
+ * Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
3
3
  * Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
+ * Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
3
3
  * Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,10 +15,12 @@
15
15
  * limitations under the License.
16
16
  */
17
17
 
18
- //#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
19
-
20
18
  #include <Python.h>
21
19
  #include <bytesobject.h>
20
+
21
+ #define NO_IMPORT_ARRAY
22
+ #define PY_ARRAY_UNIQUE_SYMBOL bjdata_numpy_array
23
+ #define NPY_NO_DEPRECATED_API 0
22
24
  #include <numpy/arrayobject.h>
23
25
 
24
26
  #include "common.h"
@@ -449,7 +451,7 @@ static PyObject* _decode_uint16_32(_bjdata_decoder_buffer_t *buffer, Py_ssize_t
449
451
  }
450
452
  }
451
453
  #if PY_MAJOR_VERSION < 3
452
- return PyLong_FromUnsignedLong(value);
454
+ return PyInt_FromLong(value);
453
455
  #else
454
456
  return PyLong_FromUnsignedLong(value);
455
457
  #endif
@@ -842,7 +844,7 @@ static int _get_type_info(char type, int *bytelen) {
842
844
  return PyArray_ULONGLONG;
843
845
  case TYPE_CHAR:
844
846
  *bytelen=1;
845
- return PyArray_CHAR;
847
+ return PyArray_STRING;
846
848
  default:
847
849
  *bytelen=0;
848
850
  PyErr_SetString(PyExc_RuntimeError, "Internal error - _get_type_info");
@@ -1211,6 +1213,7 @@ PyObject* _bjdata_decode_value(_bjdata_decoder_buffer_t *buffer, char *given_mar
1211
1213
  #ifdef USE__BJDATA
1212
1214
  case TYPE_UINT8:
1213
1215
  RETURN_OR_RAISE_DECODER_EXCEPTION(_decode_uint8(buffer), "uint8");
1216
+ case TYPE_FLOAT16:
1214
1217
  case TYPE_UINT16:
1215
1218
  RETURN_OR_RAISE_DECODER_EXCEPTION(_decode_uint16_32(buffer, 2), "uint16");
1216
1219
  case TYPE_UINT32:
@@ -1240,10 +1243,6 @@ bail:
1240
1243
  return NULL;
1241
1244
  }
1242
1245
 
1243
- PyMODINIT_FUNC _bjdata_init_numpy(void) {
1244
- import_array();
1245
- }
1246
-
1247
1246
  /******************************************************************************/
1248
1247
 
1249
1248
  int _bjdata_decoder_init(void) {
@@ -1266,7 +1265,6 @@ int _bjdata_decoder_init(void) {
1266
1265
  }
1267
1266
  PyDec_Type = (PyTypeObject*) tmp_obj;
1268
1267
  Py_CLEAR(tmp_module);
1269
- _bjdata_init_numpy();
1270
1268
 
1271
1269
  return 0;
1272
1270
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
+ * Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
3
3
  * Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,8 +21,6 @@
21
21
  extern "C" {
22
22
  #endif
23
23
 
24
- #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
25
-
26
24
  #include <Python.h>
27
25
 
28
26
  /******************************************************************************/
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
+ * Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
3
3
  * Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +17,12 @@
17
17
 
18
18
  #include <Python.h>
19
19
  #include <bytesobject.h>
20
+ #include <string.h>
21
+
22
+ #define NO_IMPORT_ARRAY
23
+ #define PY_ARRAY_UNIQUE_SYMBOL bjdata_numpy_array
24
+ #define NPY_NO_DEPRECATED_API 0
25
+ #include <numpy/arrayobject.h>
20
26
 
21
27
  #include "common.h"
22
28
  #include "markers.h"
@@ -77,6 +83,38 @@ static int _encode_PySequence(PyObject *obj, _bjdata_encoder_buffer_t *buffer);
77
83
  static int _encode_mapping_key(PyObject *obj, _bjdata_encoder_buffer_t *buffer);
78
84
  static int _encode_PyMapping(PyObject *obj, _bjdata_encoder_buffer_t *buffer);
79
85
 
86
+ const int numpytypes[][2] = {
87
+ {NPY_BOOL, TYPE_UINT8},
88
+ {NPY_BYTE, TYPE_INT8},
89
+ {NPY_INT8, TYPE_INT8},
90
+ {NPY_SHORT, TYPE_INT16},
91
+ {NPY_INT16, TYPE_INT16},
92
+ {NPY_INT, TYPE_INT32},
93
+ {NPY_INT32, TYPE_INT32},
94
+ {NPY_LONGLONG, TYPE_INT64},
95
+ {NPY_INT64, TYPE_INT64},
96
+ {NPY_UINT8, TYPE_UINT8},
97
+ {NPY_UBYTE, TYPE_UINT8},
98
+ {NPY_USHORT, TYPE_UINT16},
99
+ {NPY_UINT16, TYPE_UINT16},
100
+ {NPY_UINT, TYPE_UINT32},
101
+ {NPY_UINT32, TYPE_UINT32},
102
+ {NPY_ULONGLONG, TYPE_UINT64},
103
+ {NPY_UINT64, TYPE_UINT64},
104
+ {NPY_HALF, TYPE_FLOAT16},
105
+ {NPY_FLOAT16, TYPE_FLOAT16},
106
+ {NPY_FLOAT, TYPE_FLOAT32},
107
+ {NPY_FLOAT32, TYPE_FLOAT32},
108
+ {NPY_DOUBLE, TYPE_FLOAT64},
109
+ {NPY_FLOAT64, TYPE_FLOAT64},
110
+ {NPY_CFLOAT, TYPE_FLOAT32},
111
+ {NPY_COMPLEX64, TYPE_FLOAT32},
112
+ {NPY_CDOUBLE, TYPE_FLOAT64},
113
+ {NPY_COMPLEX128, TYPE_FLOAT64},
114
+ {NPY_STRING, TYPE_STRING},
115
+ {NPY_UNICODE, TYPE_STRING}
116
+ };
117
+
80
118
  /******************************************************************************/
81
119
 
82
120
  /* fp_write, if not NULL, must be a callable which accepts a single bytes argument. On failure will set exception.
@@ -236,6 +274,69 @@ bail:
236
274
 
237
275
  /******************************************************************************/
238
276
 
277
+ static int _lookup_marker(npy_intp numpytypeid) {
278
+ int i, len = (sizeof(numpytypes) >> 3);
279
+ for(i = 0; i < len; i++){
280
+ if(numpytypeid == (npy_intp)numpytypes[i][0])
281
+ return numpytypes[i][1];
282
+ }
283
+ return -1;
284
+ }
285
+
286
+ static int _encode_NDarray(PyObject *obj, _bjdata_encoder_buffer_t *buffer) {
287
+ PyArrayObject *arr;
288
+ Py_INCREF(obj);
289
+ arr = (PyArrayObject *)PyArray_EnsureArray(obj);
290
+ BAIL_ON_NONZERO(arr == NULL);
291
+
292
+ int ndim = PyArray_NDIM(arr);
293
+ int type = PyArray_TYPE(arr);
294
+ npy_intp bytes = PyArray_ITEMSIZE(arr);
295
+
296
+ int marker = _lookup_marker(type);
297
+
298
+ BAIL_ON_NONZERO(marker < 0)
299
+ if(ndim == 0){ /*scalar*/
300
+ WRITE_CHAR_OR_BAIL((char)marker);
301
+ if(marker == TYPE_STRING) {
302
+ _encode_longlong(bytes, buffer);
303
+ }
304
+ WRITE_OR_BAIL(PyArray_BYTES(arr), bytes);
305
+ Py_DECREF(arr);
306
+ return 0;
307
+ }
308
+
309
+ npy_intp * dims = PyArray_DIMS(arr);
310
+ npy_intp total = PyArray_SIZE(arr);
311
+
312
+ WRITE_CHAR_OR_BAIL(ARRAY_START);
313
+ WRITE_CHAR_OR_BAIL(CONTAINER_TYPE);
314
+ if(marker == TYPE_STRING) {
315
+ WRITE_CHAR_OR_BAIL(TYPE_CHAR);
316
+ } else {
317
+ WRITE_CHAR_OR_BAIL((char)marker);
318
+ }
319
+ WRITE_CHAR_OR_BAIL(CONTAINER_COUNT);
320
+
321
+ WRITE_CHAR_OR_BAIL(ARRAY_START);
322
+ for(int i=0 ; i<ndim; i++)
323
+ _encode_longlong(dims[i], buffer);
324
+ if(type == NPY_UNICODE)
325
+ _encode_longlong(4, buffer);
326
+ WRITE_CHAR_OR_BAIL(ARRAY_END);
327
+
328
+ WRITE_OR_BAIL(PyArray_BYTES(arr), bytes*total);
329
+ Py_DECREF(arr);
330
+ // no ARRAY_END since length was specified
331
+
332
+ return 0;
333
+
334
+ bail:
335
+ return 1;
336
+ }
337
+
338
+ /******************************************************************************/
339
+
239
340
  static int _encode_PyObject_as_PyDecimal(PyObject *obj, _bjdata_encoder_buffer_t *buffer) {
240
341
  PyObject *decimal = NULL;
241
342
 
@@ -708,7 +809,7 @@ int _bjdata_encode_value(PyObject *obj, _bjdata_encoder_buffer_t *buffer) {
708
809
  } else if (PyUnicode_Check(obj)) {
709
810
  BAIL_ON_NONZERO(_encode_PyUnicode(obj, buffer));
710
811
  #if PY_MAJOR_VERSION < 3
711
- } else if (PyInt_Check(obj)) {
812
+ } else if (PyInt_Check(obj) && Py_TYPE(obj)!=NULL && strstr(Py_TYPE(obj)->tp_name, "numpy")==NULL) {
712
813
  BAIL_ON_NONZERO(_encode_PyInt(obj, buffer));
713
814
  #endif
714
815
  } else if (PyLong_Check(obj)) {
@@ -721,6 +822,14 @@ int _bjdata_encode_value(PyObject *obj, _bjdata_encoder_buffer_t *buffer) {
721
822
  BAIL_ON_NONZERO(_encode_PyBytes(obj, buffer));
722
823
  } else if (PyByteArray_Check(obj)) {
723
824
  BAIL_ON_NONZERO(_encode_PyByteArray(obj, buffer));
825
+ } else if (PyArray_CheckAnyScalar(obj)) {
826
+ RECURSE_AND_BAIL_ON_NONZERO(_encode_NDarray(obj, buffer), " while encoding a Numpy scalar");
827
+ } else if (PySequence_Check(obj)) {
828
+ if (PyArray_CheckExact(obj)) {
829
+ RECURSE_AND_BAIL_ON_NONZERO(_encode_NDarray(obj, buffer), " while encoding a Numpy ndarray");
830
+ } else {
831
+ RECURSE_AND_BAIL_ON_NONZERO(_encode_PySequence(obj, buffer), " while encoding an array");
832
+ }
724
833
  // order important since Mapping could also be Sequence
725
834
  } else if (PyMapping_Check(obj)
726
835
  // Unfortunately PyMapping_Check is no longer enough, see https://bugs.python.org/issue5945
@@ -728,9 +837,7 @@ int _bjdata_encode_value(PyObject *obj, _bjdata_encoder_buffer_t *buffer) {
728
837
  && PyObject_HasAttrString(obj, "items")
729
838
  #endif
730
839
  ) {
731
- RECURSE_AND_BAIL_ON_NONZERO(_encode_PyMapping(obj, buffer), " while encoding a BJData object");
732
- } else if (PySequence_Check(obj)) {
733
- RECURSE_AND_BAIL_ON_NONZERO(_encode_PySequence(obj, buffer), " while encoding a BJData array");
840
+ RECURSE_AND_BAIL_ON_NONZERO(_encode_PyMapping(obj, buffer), " while encoding an object");
734
841
  } else if (NULL == obj) {
735
842
  PyErr_SetString(PyExc_RuntimeError, "Internal error - _bjdata_encode_value got NULL obj");
736
843
  goto bail;
@@ -749,7 +856,6 @@ bail:
749
856
  return 1;
750
857
  }
751
858
 
752
-
753
859
  int _bjdata_encoder_init(void) {
754
860
  PyObject *tmp_module = NULL;
755
861
  PyObject *tmp_obj = NULL;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
+ * Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
3
3
  * Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
+ * Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
3
3
  * Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
+ * Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
3
3
  * Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
4
4
  *
5
5
  * Licensed under PSF license, see: https://docs.python.org/3/license.html
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
1
+ # Copyright (c) 2020-2023 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
2
2
  # Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -220,9 +220,9 @@ class TestEncodeDecodePlain(TestCase): # pylint: disable=too-many-public-method
220
220
  '-1.2345e67890'):
221
221
  # minimum length because: marker + length marker + length + value
222
222
  self.check_enc_dec(Decimal(value), 4, length_greater_or_equal=True)
223
- # cannot compare equality, so test separately (since these evaluate to "NULL"
224
- #for value in ('nan', '-inf', 'inf'):
225
- # self.assertEqual(self.bjdloadb(self.bjddumpb(Decimal(value))), None)
223
+ # cannot compare equality, so test separately
224
+ for value in ('nan', '-inf', 'inf'):
225
+ self.assertEqual(str(self.bjdloadb(self.bjddumpb(float(value)))), value)
226
226
 
227
227
  def test_float(self):
228
228
  # insufficient length
@@ -248,9 +248,10 @@ class TestEncodeDecodePlain(TestCase): # pylint: disable=too-many-public-method
248
248
  9 if type_ == TYPE_FLOAT32 else total_size,
249
249
  approximate=True,
250
250
  expected_type=(TYPE_FLOAT64 if type_ == TYPE_FLOAT32 else type_))
251
- #for value in ('nan', '-inf', 'inf'):
252
- # for no_float32 in (True, False):
253
- # self.assertEqual(self.bjdloadb(self.bjddumpb(float(value), no_float32=no_float32)), None)
251
+ for value in ('nan', '-inf', 'inf'):
252
+ for no_float32 in (True, False):
253
+ self.assertEqual(str(self.bjdloadb(self.bjddumpb(float(value), no_float32=no_float32))), value)
254
+
254
255
  # value which results in high_prec usage
255
256
  for no_float32 in (True, False):
256
257
  self.check_enc_dec(2.22e-308, 4, expected_type=TYPE_HIGH_PREC, length_greater_or_equal=True,
@@ -298,10 +299,33 @@ class TestEncodeDecodePlain(TestCase): # pylint: disable=too-many-public-method
298
299
  b'\x03' + b'\x02' + b'\x01'+ b'\x02'+ b'\x03'+ b'\x04'+ b'\x05'+ b'\x06')
299
300
  self.assertEqual((self.bjdloadb(raw_start)==ndarray([[1,2],[3,4],[5,6]], npint8)).all(), True)
300
301
 
302
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.uint8(9))) == np.uint8(9)), True)
303
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.int8(9))) == np.int8(9)), True)
304
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.uint16(6))) == np.uint16(6)), True)
305
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.int16(6))) == np.int16(6)), True)
306
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.uint32(6))) == np.uint32(6)), True)
307
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.int32(6))) == np.int32(6)), True)
308
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.uint64(6))) == np.uint64(6)), True)
309
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.int64(5))) == np.int64(5)), True)
310
+
311
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.eye(2, dtype=np.uint8))) == np.eye(2, dtype=np.uint8)).all(), True)
312
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.eye(2, dtype=np.int16))) == np.eye(2, dtype=np.int16)).all(), True)
313
+
314
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.float16(2.2))) == 16486), True)
315
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.float32(2.2))) == np.float32(2.2)), True)
316
+
317
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.array([1.3,-0.5,0.7,1000,11], dtype=np.float32))) == np.array([1.3,-0.5,0.7,1000,11], dtype=np.float32)).all(), True)
318
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.array([1,2,3,4], dtype=np.uint16))) == np.array([1,2,3,4], dtype=np.uint16)).all(), True)
319
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.array([1,2,3,4], dtype=np.uint8))) == np.array([1,2,3,4], dtype=np.uint8)).all(), True)
320
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.array([], dtype=np.int8))) == np.array([], dtype=np.int8)).all(), True)
321
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.array([-1,-2,-3,-4], dtype=np.float32))) == np.array([-1,-2,-3,-4], dtype=np.float32)).all(), True)
322
+ self.assertEqual((self.bjdloadb(self.bjddumpb(np.array([[-1,-2,5],[-3,-4,-6]], dtype=np.float64))) == np.array([[-1,-2,5],[-3,-4,-6]], dtype=np.float64)).all(), True)
323
+
301
324
  raw_start = (ARRAY_START + CONTAINER_TYPE + TYPE_INT8 + CONTAINER_COUNT + ARRAY_START + \
302
325
  TYPE_UINT8 + b'\x03' + TYPE_UINT16 + b'\x02' + b'\x00' + ARRAY_END + \
303
326
  b'\x01'+ b'\x02'+ b'\x03'+ b'\x04'+ b'\x05'+ b'\x06')
304
327
  self.assertEqual((self.bjdloadb(raw_start)==ndarray([[1,2],[3,4],[5,6]], npint8)).all(), True)
328
+
305
329
  def test_array_fixed(self):
306
330
  raw_start = ARRAY_START + CONTAINER_TYPE + TYPE_INT8 + CONTAINER_COUNT + TYPE_UINT8
307
331
  self.assertEqual(self.bjdloadb(raw_start + b'\x00'), [])
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes