blosc2 3.3.2__tar.gz → 3.3.3__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 (256) hide show
  1. {blosc2-3.3.2 → blosc2-3.3.3}/.pre-commit-config.yaml +1 -1
  2. {blosc2-3.3.2 → blosc2-3.3.3}/ANNOUNCE.rst +5 -6
  3. {blosc2-3.3.2 → blosc2-3.3.3}/CMakeLists.txt +1 -1
  4. {blosc2-3.3.2 → blosc2-3.3.3}/PKG-INFO +1 -1
  5. {blosc2-3.3.2 → blosc2-3.3.3}/RELEASE_NOTES.md +28 -0
  6. {blosc2-3.3.2 → blosc2-3.3.3}/doc/python-blosc2.rst +1 -1
  7. {blosc2-3.3.2 → blosc2-3.3.3}/pyproject.toml +2 -2
  8. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/__init__.py +1 -0
  9. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/blosc2_ext.pyx +2 -1
  10. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/core.py +34 -26
  11. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/lazyexpr.py +116 -9
  12. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/ndarray.py +16 -3
  13. blosc2-3.3.3/src/blosc2/version.py +1 -0
  14. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_evaluate.py +1 -1
  15. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_jit.py +1 -1
  16. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_lazyexpr.py +49 -42
  17. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_ndarray.py +8 -0
  18. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_reductions.py +10 -0
  19. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_zeros.py +37 -0
  20. blosc2-3.3.2/src/blosc2/version.py +0 -1
  21. {blosc2-3.3.2 → blosc2-3.3.3}/.gitignore +0 -0
  22. {blosc2-3.3.2 → blosc2-3.3.3}/.guix/modules/python-blosc2-package.scm +0 -0
  23. {blosc2-3.3.2 → blosc2-3.3.3}/.guix-channel +0 -0
  24. {blosc2-3.3.2 → blosc2-3.3.3}/CONTRIBUTING.rst +0 -0
  25. {blosc2-3.3.2 → blosc2-3.3.3}/LICENSE.txt +0 -0
  26. {blosc2-3.3.2 → blosc2-3.3.3}/README.rst +0 -0
  27. {blosc2-3.3.2 → blosc2-3.3.3}/README_DEVELOPERS.md +0 -0
  28. {blosc2-3.3.2 → blosc2-3.3.3}/RELEASING.rst +0 -0
  29. {blosc2-3.3.2 → blosc2-3.3.3}/code_of_conduct.md +0 -0
  30. {blosc2-3.3.2 → blosc2-3.3.3}/doc/_static/blosc-favicon_32x32.png +0 -0
  31. {blosc2-3.3.2 → blosc2-3.3.3}/doc/_static/blosc-favicon_64x64.png +0 -0
  32. {blosc2-3.3.2 → blosc2-3.3.3}/doc/_static/blosc-logo_128.png +0 -0
  33. {blosc2-3.3.2 → blosc2-3.3.3}/doc/_static/blosc-logo_256.png +0 -0
  34. {blosc2-3.3.2 → blosc2-3.3.3}/doc/_static/css/custom.css +0 -0
  35. {blosc2-3.3.2 → blosc2-3.3.3}/doc/conf.py +0 -0
  36. {blosc2-3.3.2 → blosc2-3.3.3}/doc/development/code-of-conduct.rst +0 -0
  37. {blosc2-3.3.2 → blosc2-3.3.3}/doc/development/contributing.rst +0 -0
  38. {blosc2-3.3.2 → blosc2-3.3.3}/doc/development/index.rst +0 -0
  39. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/index.rst +0 -0
  40. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/installation.rst +0 -0
  41. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/overview.rst +0 -0
  42. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/01.ndarray-basics.ipynb +0 -0
  43. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/02.lazyarray-expressions.ipynb +0 -0
  44. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/03.lazyarray-udf.ipynb +0 -0
  45. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/04.reductions.ipynb +0 -0
  46. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/05.persistent-reductions.ipynb +0 -0
  47. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/06.remote_proxy.ipynb +0 -0
  48. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/07.schunk-basics.ipynb +0 -0
  49. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/08.schunk-slicing_and_beyond.ipynb +0 -0
  50. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/10.ucodecs-ufilters.ipynb +0 -0
  51. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/11.prefilters.ipynb +0 -0
  52. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/12.postfilters.ipynb +0 -0
  53. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/blosc2-pipeline.png +0 -0
  54. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/blosc2-pipeline.svg +0 -0
  55. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/lazyexpr-broadcast.png +0 -0
  56. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/reductions/3D-cube-plane.png +0 -0
  57. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/reductions/3D-cube.png +0 -0
  58. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/reductions/memory-access-2D-x.png +0 -0
  59. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/reductions/memory-access-2D-y.png +0 -0
  60. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/remote_proxy.png +0 -0
  61. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/backward.png +0 -0
  62. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/backward.svg +0 -0
  63. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/decoder.png +0 -0
  64. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/decoder.svg +0 -0
  65. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/decoder2.png +0 -0
  66. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/decoder2.svg +0 -0
  67. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/encoder.png +0 -0
  68. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/encoder.svg +0 -0
  69. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/encoder2.png +0 -0
  70. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/encoder2.svg +0 -0
  71. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/forward.png +0 -0
  72. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials/images/ucodecs-filters/forward.svg +0 -0
  73. {blosc2-3.3.2 → blosc2-3.3.3}/doc/getting_started/tutorials.rst +0 -0
  74. {blosc2-3.3.2 → blosc2-3.3.3}/doc/index.rst +0 -0
  75. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/array_operations.rst +0 -0
  76. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.__getitem__.rst +0 -0
  77. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.__init__.rst +0 -0
  78. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.__len__.rst +0 -0
  79. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.__setitem__.rst +0 -0
  80. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.append_data.rst +0 -0
  81. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.decompress_chunk.rst +0 -0
  82. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.delete_chunk.rst +0 -0
  83. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.fill_special.rst +0 -0
  84. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.filler.rst +0 -0
  85. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.get_chunk.rst +0 -0
  86. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.get_slice.rst +0 -0
  87. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.insert_chunk.rst +0 -0
  88. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.insert_data.rst +0 -0
  89. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.iterchunks.rst +0 -0
  90. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.iterchunks_info.rst +0 -0
  91. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.postfilter.rst +0 -0
  92. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.prefilter.rst +0 -0
  93. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.remove_postfilter.rst +0 -0
  94. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.remove_prefilter.rst +0 -0
  95. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.to_cframe.rst +0 -0
  96. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.update_chunk.rst +0 -0
  97. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/autofiles/schunk/blosc2.schunk.SChunk.update_data.rst +0 -0
  98. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/c2array.rst +0 -0
  99. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/classes.rst +0 -0
  100. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/decorators.rst +0 -0
  101. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/index.rst +0 -0
  102. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/lazy_functions.rst +0 -0
  103. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/lazyarray.rst +0 -0
  104. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/linear_algebra.rst +0 -0
  105. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/low_level.rst +0 -0
  106. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/ndarray.rst +0 -0
  107. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/ndfield.rst +0 -0
  108. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/proxy.rst +0 -0
  109. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/proxyndsource.rst +0 -0
  110. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/proxysource.rst +0 -0
  111. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/reduction_functions.rst +0 -0
  112. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/save_load.rst +0 -0
  113. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/schunk.rst +0 -0
  114. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/storage.rst +0 -0
  115. {blosc2-3.3.2 → blosc2-3.3.3}/doc/reference/utilities.rst +0 -0
  116. {blosc2-3.3.2 → blosc2-3.3.3}/doc/release_notes/index.md +0 -0
  117. {blosc2-3.3.2 → blosc2-3.3.3}/examples/btune.py +0 -0
  118. {blosc2-3.3.2 → blosc2-3.3.3}/examples/c2array-get-slice.py +0 -0
  119. {blosc2-3.3.2 → blosc2-3.3.3}/examples/compress2_decompress2.py +0 -0
  120. {blosc2-3.3.2 → blosc2-3.3.3}/examples/compress_decompress.py +0 -0
  121. {blosc2-3.3.2 → blosc2-3.3.3}/examples/filler.py +0 -0
  122. {blosc2-3.3.2 → blosc2-3.3.3}/examples/gil.py +0 -0
  123. {blosc2-3.3.2 → blosc2-3.3.3}/examples/mmap-rw.py +0 -0
  124. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/arange-constructor.py +0 -0
  125. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/asarray_.py +0 -0
  126. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/broadcast_expr.py +0 -0
  127. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/buffer.py +0 -0
  128. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/bytedelta_filter.py +0 -0
  129. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/c2array_expr.py +0 -0
  130. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/compute_expr.py +0 -0
  131. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/compute_fields.py +0 -0
  132. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/compute_udf_numba.py +0 -0
  133. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/compute_where.py +0 -0
  134. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/copy_.py +0 -0
  135. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/empty_.py +0 -0
  136. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/eye-constructor.py +0 -0
  137. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/filter_sort_fields.py +0 -0
  138. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/formats.py +0 -0
  139. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/fromiter-constructor.py +0 -0
  140. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/general_expressions.py +0 -0
  141. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/getitem.py +0 -0
  142. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/iterchunks_info.py +0 -0
  143. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/jit-expr.py +0 -0
  144. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/jit-numpy-funcs.py +0 -0
  145. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/jit-reduc.py +0 -0
  146. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/linspace-constructor.py +0 -0
  147. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/lists-vs-bools-idx.py +0 -0
  148. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/meta.py +0 -0
  149. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/ndarray_copy.py +0 -0
  150. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/ndmean.py +0 -0
  151. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/persistency.py +0 -0
  152. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/proxy-carray.py +0 -0
  153. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/proxy-ndarray.py +0 -0
  154. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/reduce_and_enlarge.py +0 -0
  155. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/reduce_expr.py +0 -0
  156. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/reduce_expr_save.py +0 -0
  157. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/reduce_string_expr.py +0 -0
  158. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/resize_.py +0 -0
  159. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/work_with_numpy.py +0 -0
  160. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ndarray/zfp_codec.py +0 -0
  161. {blosc2-3.3.2 → blosc2-3.3.3}/examples/pack_array.py +0 -0
  162. {blosc2-3.3.2 → blosc2-3.3.3}/examples/pack_tensor.py +0 -0
  163. {blosc2-3.3.2 → blosc2-3.3.3}/examples/postfilter1.py +0 -0
  164. {blosc2-3.3.2 → blosc2-3.3.3}/examples/postfilter2.py +0 -0
  165. {blosc2-3.3.2 → blosc2-3.3.3}/examples/postfilter3.py +0 -0
  166. {blosc2-3.3.2 → blosc2-3.3.3}/examples/prefilter.py +0 -0
  167. {blosc2-3.3.2 → blosc2-3.3.3}/examples/save_tensor.py +0 -0
  168. {blosc2-3.3.2 → blosc2-3.3.3}/examples/schunk.py +0 -0
  169. {blosc2-3.3.2 → blosc2-3.3.3}/examples/schunk_roundtrip.py +0 -0
  170. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ucodecs.py +0 -0
  171. {blosc2-3.3.2 → blosc2-3.3.3}/examples/ufilters.py +0 -0
  172. {blosc2-3.3.2 → blosc2-3.3.3}/examples/vlmeta.py +0 -0
  173. {blosc2-3.3.2 → blosc2-3.3.3}/generate_version.py +0 -0
  174. {blosc2-3.3.2 → blosc2-3.3.3}/guix.scm +0 -0
  175. {blosc2-3.3.2 → blosc2-3.3.3}/images/Complete-Write-Read-B2ND.png +0 -0
  176. {blosc2-3.3.2 → blosc2-3.3.3}/images/M1-i386-vs-arm64-pack.png +0 -0
  177. {blosc2-3.3.2 → blosc2-3.3.3}/images/M1-i386-vs-arm64-unpack.png +0 -0
  178. {blosc2-3.3.2 → blosc2-3.3.3}/images/Read-Partial-Slices-B2ND.png +0 -0
  179. {blosc2-3.3.2 → blosc2-3.3.3}/images/b2nd-2level-parts.png +0 -0
  180. {blosc2-3.3.2 → blosc2-3.3.3}/images/eval-expr-full-mem-M2.png +0 -0
  181. {blosc2-3.3.2 → blosc2-3.3.3}/images/eval-expr-scarce-mem-M2.png +0 -0
  182. {blosc2-3.3.2 → blosc2-3.3.3}/images/lazyarray-dask-large.png +0 -0
  183. {blosc2-3.3.2 → blosc2-3.3.3}/images/lazyarray-dask-small.png +0 -0
  184. {blosc2-3.3.2 → blosc2-3.3.3}/images/lazyarray-expr-large.png +0 -0
  185. {blosc2-3.3.2 → blosc2-3.3.3}/images/lazyarray-expr.png +0 -0
  186. {blosc2-3.3.2 → blosc2-3.3.3}/images/linspace-compress.png +0 -0
  187. {blosc2-3.3.2 → blosc2-3.3.3}/images/linspace-decompress.png +0 -0
  188. {blosc2-3.3.2 → blosc2-3.3.3}/images/pack-array-cratios.png +0 -0
  189. {blosc2-3.3.2 → blosc2-3.3.3}/images/reduc-float64-amd.png +0 -0
  190. {blosc2-3.3.2 → blosc2-3.3.3}/images/reduc-float64-log-amd.png +0 -0
  191. {blosc2-3.3.2 → blosc2-3.3.3}/pytest.ini +0 -0
  192. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/c2array.py +0 -0
  193. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/helpers.py +0 -0
  194. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/info.py +0 -0
  195. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/proxy.py +0 -0
  196. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/schunk.py +0 -0
  197. {blosc2-3.3.2 → blosc2-3.3.3}/src/blosc2/storage.py +0 -0
  198. {blosc2-3.3.2 → blosc2-3.3.3}/tests/conftest.py +0 -0
  199. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_auto_parts.py +0 -0
  200. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_buffer.py +0 -0
  201. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_c2array_expr.py +0 -0
  202. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_c2array_reductions.py +0 -0
  203. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_c2array_udf.py +0 -0
  204. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_copy.py +0 -0
  205. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_empty.py +0 -0
  206. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_full.py +0 -0
  207. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_get_slice_nchunks.py +0 -0
  208. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_getitem.py +0 -0
  209. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_iterchunks_info.py +0 -0
  210. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_lazyexpr_fields.py +0 -0
  211. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_lazyudf.py +0 -0
  212. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_lossy.py +0 -0
  213. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_matmul.py +0 -0
  214. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_metalayers.py +0 -0
  215. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_mode.py +0 -0
  216. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_nans.py +0 -0
  217. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_numpy.py +0 -0
  218. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_persistency.py +0 -0
  219. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_proxy.py +0 -0
  220. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_proxy_c2array.py +0 -0
  221. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_proxy_expr.py +0 -0
  222. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_resize.py +0 -0
  223. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_setitem.py +0 -0
  224. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_slice.py +0 -0
  225. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_squeeze.py +0 -0
  226. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_struct_dtype.py +0 -0
  227. {blosc2-3.3.2 → blosc2-3.3.3}/tests/ndarray/test_transpose.py +0 -0
  228. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_bytes_array.py +0 -0
  229. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_comp_info.py +0 -0
  230. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_compress2.py +0 -0
  231. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_compression_parameters.py +0 -0
  232. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_compressors.py +0 -0
  233. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_decompress.py +0 -0
  234. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_iterchunks.py +0 -0
  235. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_mmap.py +0 -0
  236. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_open.py +0 -0
  237. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_open_c2array.py +0 -0
  238. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_pathlib.py +0 -0
  239. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_postfilters.py +0 -0
  240. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_prefilters.py +0 -0
  241. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_proxy_schunk.py +0 -0
  242. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_python_blosc.py +0 -0
  243. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_schunk.py +0 -0
  244. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_schunk_constructor.py +0 -0
  245. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_schunk_delete.py +0 -0
  246. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_schunk_get_slice.py +0 -0
  247. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_schunk_get_slice_nchunks.py +0 -0
  248. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_schunk_insert.py +0 -0
  249. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_schunk_set_slice.py +0 -0
  250. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_schunk_update.py +0 -0
  251. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_storage.py +0 -0
  252. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_tensor.py +0 -0
  253. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_ucodecs.py +0 -0
  254. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_ufilters.py +0 -0
  255. {blosc2-3.3.2 → blosc2-3.3.3}/tests/test_vlmeta.py +0 -0
  256. {blosc2-3.3.2 → blosc2-3.3.3}/update_version.py +0 -0
@@ -16,7 +16,7 @@ repos:
16
16
  - id: trailing-whitespace
17
17
 
18
18
  - repo: https://github.com/astral-sh/ruff-pre-commit
19
- rev: v0.11.4
19
+ rev: v0.11.8
20
20
  hooks:
21
21
  - id: ruff
22
22
  args: ["--fix", "--show-fixes"]
@@ -1,11 +1,10 @@
1
- Announcing Python-Blosc2 3.3.2
1
+ Announcing Python-Blosc2 3.3.3
2
2
  ==============================
3
3
 
4
- This is a bugfix release, with some minor optimizations. We fixed
5
- specially a bug in the determination of chunk shape in constructors
6
- on CPUs with large L3 cache sizes (like AMD EPYC). We also fixed a
7
- bug preventing the correct chaining of *string* lazy expressions for
8
- logical operators (``&``, ``|``, ``^``...).
4
+ This is a bugfix release, with some minor optimizations. We improved the
5
+ correct chaining of *string* lazy expressions (there is still room for
6
+ improvement). Also, a new version of C-Blosc2 (v2.7.2.dev) that fixes
7
+ mmap issues on Windows is used; thanks to @JanSellner for the fix.
9
8
 
10
9
  You can think of Python-Blosc2 3.x as an extension of NumPy/numexpr that:
11
10
 
@@ -50,7 +50,7 @@ else()
50
50
  include(FetchContent)
51
51
  FetchContent_Declare(blosc2
52
52
  GIT_REPOSITORY https://github.com/Blosc/c-blosc2
53
- GIT_TAG 5fcd6fbf9ffcf613fabdb1eb3a90eeb12f7c04fe # v2.17.1
53
+ GIT_TAG 3f9c085c0c0f357b140fb5a50d1f8df06de3383a # v2.17.1 + mmap fix
54
54
  )
55
55
  FetchContent_MakeAvailable(blosc2)
56
56
  include_directories("${blosc2_SOURCE_DIR}/include")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blosc2
3
- Version: 3.3.2
3
+ Version: 3.3.3
4
4
  Summary: A fast & compressed ndarray library with a flexible compute engine.
5
5
  Author-Email: Blosc Development Team <blosc@blosc.org>
6
6
  Maintainer-Email: Blosc Development Team <blosc@blosc.org>
@@ -1,5 +1,31 @@
1
1
  # Release notes
2
2
 
3
+ ## Changes from 3.3.2 to 3.3.3
4
+
5
+ * Expand possibilities for chaining string-based lazy expressions to include
6
+ main operand types (LazyExpr and NDArray). Still have to incorporate other
7
+ data types (which do not have shape attribute, e.g. int, float etc.).
8
+ See #406.
9
+
10
+ * Fix indexing for lazy expressions, and allow use of None in getitem.
11
+ See PR #402.
12
+
13
+ * Fix incorrect appending of dim to computed reductions. See PR #404.
14
+
15
+ * Fix `blosc2.linspace()` for incompatible num/shape. See PR #408.
16
+
17
+ * Add support for NumPy dtypes that are n-dimensional (e.g.
18
+ `np.dtype(("<i4,>f4", (10,))),`).
19
+
20
+ * New MAX_DIM constant for the maximum number of dimensions supported.
21
+ This is useful for checking if a given array is too large to be handled.
22
+
23
+ * More refinements on guessing cache sizes for Linux.
24
+
25
+ * Update to C-Blosc2 2.17.2.dev. Now, we are forcing the flush of modified
26
+ pages only in write mode for mmap files. This fixes mmap issues on Windows.
27
+ Thanks to @JanSellner for the implementation.
28
+
3
29
  ## Changes from 3.3.1 to 3.3.2
4
30
 
5
31
  * Fixed a bug in the determination of chunk shape for the `NDArray` constructor.
@@ -15,6 +41,8 @@
15
41
  * Now, storage defaults (`blosc2.storage_dflts`) are honored, even if no
16
42
  `storage=` param is used in constructors.
17
43
 
44
+ * We are distributing Python 3.10 wheels now.
45
+
18
46
  ## Changes from 3.3.0 to 3.3.1
19
47
 
20
48
  * In our effort to better adapt to better adapt to the array API
@@ -6,7 +6,7 @@
6
6
 
7
7
  <p style="text-align: center; color: black; background-color: rgba(230, 169, 9, 0.65);">
8
8
  <a href="https://github.com/Blosc/python-blosc2/blob/main/RELEASE_NOTES.md"
9
- style="font-size: 1.5em;">Version 3.3.1 released on 2025-04-20!</a>
9
+ style="font-size: 1.5em;">Version 3.3.2 released on 2025-05-01!</a>
10
10
  <span style="display: inline-block; width: 20px;"></span>
11
11
  <span style="font-family: monospace;">pip install blosc2 -U</span>
12
12
  </p>
@@ -41,7 +41,7 @@ dependencies = [
41
41
  "py-cpuinfo; platform_machine != 'wasm32'",
42
42
  "requests",
43
43
  ]
44
- version = "3.3.2"
44
+ version = "3.3.3"
45
45
 
46
46
 
47
47
  [project.optional-dependencies]
@@ -111,7 +111,7 @@ extend-select = [
111
111
  "RET",
112
112
  "RUF",
113
113
  "SIM",
114
- "TCH",
114
+ "TC",
115
115
  "UP",
116
116
  ]
117
117
  ignore = [
@@ -109,6 +109,7 @@ from .blosc2_ext import (
109
109
  GLOBAL_REGISTERED_CODECS_STOP,
110
110
  MAX_BLOCKSIZE,
111
111
  MAX_BUFFERSIZE,
112
+ MAX_DIM,
112
113
  MAX_OVERHEAD,
113
114
  MAX_TYPESIZE,
114
115
  MIN_HEADER_LENGTH,
@@ -542,6 +542,7 @@ MAX_TYPESIZE = BLOSC2_MAXTYPESIZE
542
542
  MAX_BUFFERSIZE = BLOSC2_MAX_BUFFERSIZE
543
543
  MAX_BLOCKSIZE = BLOSC2_MAXBLOCKSIZE
544
544
  MAX_OVERHEAD = BLOSC2_MAX_OVERHEAD
545
+ MAX_DIM = B2ND_MAX_DIM
545
546
  VERSION_STRING = (<char*>BLOSC2_VERSION_STRING).decode("utf-8")
546
547
  VERSION_DATE = (<char*>BLOSC2_VERSION_DATE).decode("utf-8")
547
548
  MIN_HEADER_LENGTH = BLOSC_MIN_HEADER_LENGTH
@@ -2391,7 +2392,7 @@ cdef class NDArray:
2391
2392
  str_dtype = bytes_dtype.decode("utf-8")
2392
2393
  try:
2393
2394
  dtype = np.dtype(str_dtype)
2394
- except TypeError:
2395
+ except (ValueError, TypeError):
2395
2396
  dtype = np.dtype(ast.literal_eval(str_dtype))
2396
2397
  self._dtype = dtype
2397
2398
  return dtype
@@ -1164,50 +1164,58 @@ def apple_silicon_cache_size(cache_level: int) -> int:
1164
1164
  return size.value
1165
1165
 
1166
1166
 
1167
- def get_l3_cache_info():
1167
+ def get_cache_info(cache_level: int) -> tuple:
1168
1168
  result = subprocess.run(["lscpu", "--json"], capture_output=True, text=True)
1169
1169
  lscpu_info = json.loads(result.stdout)
1170
+ if cache_level == 0:
1171
+ cache_level = "1d"
1170
1172
  for entry in lscpu_info["lscpu"]:
1171
- if entry["field"] == "L3 cache:":
1173
+ if entry["field"] == f"L{cache_level} cache:":
1172
1174
  size_str, instances_str = entry["data"].split(" (")
1173
- size = int(size_str.split()[0]) * 1024 * 1024 # Convert MiB to bytes
1175
+ size, units = size_str.split()
1176
+ size = int(size)
1177
+ if units == "KiB":
1178
+ size *= 2**10
1179
+ elif units == "MiB":
1180
+ size *= 2**20
1181
+ elif units == "GiB":
1182
+ size *= 2**30
1183
+ else:
1184
+ raise ValueError("Unrecognized unit when guessing cache units")
1174
1185
  instances = int(instances_str.split()[0])
1175
1186
  return size, instances
1176
1187
 
1177
- raise ValueError("L3 cache not found in lscpu output")
1188
+ raise ValueError(f"L{cache_level} cache not found in lscpu output")
1178
1189
 
1179
1190
 
1180
1191
  def linux_cache_size(cache_level: int, default_size: int) -> int:
1181
1192
  """Get the data cache_level size in bytes for Linux."""
1182
1193
  cache_size = default_size
1183
- if cache_level == 3:
1184
- # In modern multicore CPUs, the L3 cache is normally shared among all core complexes (CCX),
1185
- # but sysfs only reports the cache size for each complex, so better use lscpu, if available.
1186
- try:
1187
- l3_cache_size, l3_cache_instances = get_l3_cache_info()
1188
- # What comes next is a heuristic to guess the most appropriate L3 cache size.
1189
- # Essentially, this is the result of different experiments, mainly on AMD CPUs
1190
- # (in particular, Ryzen 9800X3D with 8 cores, and EPYC 9454P with 48 cores).
1191
- # For Intel, YMMV, but my guess is that they are not using the same CCX approach.
1192
- l3_cache_size *= l3_cache_instances
1193
- if l3_cache_instances > 1:
1194
- # This is yet another heuristic for large CPUs with core sets (CCX) having
1195
- # their own L3. No idea why, but it seems to work well.
1196
- l3_cache_size *= l3_cache_instances // 2
1197
- return l3_cache_size
1198
- except (FileNotFoundError, ValueError):
1199
- # If lscpu is not available or the cache size cannot be read, try with sysfs
1200
- pass
1201
1194
  try:
1195
+ # Try to read the cache size from sysfs
1202
1196
  with open(f"/sys/devices/system/cpu/cpu0/cache/index{cache_level}/size") as f:
1203
1197
  size = f.read()
1204
1198
  if size.endswith("K\n"):
1205
- cache_size = int(size[:-2]) * 1024
1199
+ cache_size = int(size[:-2]) * 2**10
1206
1200
  elif size.endswith("M\n"):
1207
- cache_size = int(size[:-2]) * 1024 * 1024
1201
+ cache_size = int(size[:-2]) * 2**20
1202
+ elif size.endswith("G\n"):
1203
+ cache_size = int(size[:-2]) * 2**30
1208
1204
  except FileNotFoundError:
1209
- # If the cache size cannot be read, return the default size
1210
- pass
1205
+ # Try with lscpu, if available.
1206
+ try:
1207
+ cache_size, cache_instances = get_cache_info(cache_level)
1208
+ # cache_instances typically refers to the number of sockets, CCXs or cores,
1209
+ # depending on the CPU and cache level.
1210
+ # In general, dividing the cache size by the number of instances would bring
1211
+ # best performance for private caches (L1 and L2). For shared caches (L3),
1212
+ # this should be the case as well, but more experimentation is needed.
1213
+ cache_size //= cache_instances
1214
+ return cache_size
1215
+ except (FileNotFoundError, ValueError):
1216
+ # If lscpu is not available or the cache size cannot be read from sysfs,
1217
+ # return the default size.
1218
+ pass
1211
1219
  return cache_size
1212
1220
 
1213
1221
 
@@ -37,7 +37,7 @@ import numpy as np
37
37
  import blosc2
38
38
  from blosc2 import compute_chunks_blocks
39
39
  from blosc2.info import InfoReporter
40
- from blosc2.ndarray import _check_allowed_dtypes, get_chunks_idx, is_inside_new_expr
40
+ from blosc2.ndarray import _check_allowed_dtypes, get_chunks_idx, is_inside_new_expr, process_key
41
41
 
42
42
  if not blosc2.IS_WASM:
43
43
  import numexpr
@@ -630,6 +630,107 @@ def get_expr_operands(expression: str) -> set:
630
630
  return set(visitor.operands)
631
631
 
632
632
 
633
+ def conserve_functions( # noqa: C901
634
+ expression: str,
635
+ operands_old: dict[str, blosc2.NDArray | blosc2.LazyExpr],
636
+ operands_new: dict[str, blosc2.NDArray | blosc2.LazyExpr],
637
+ ) -> tuple(str, dict[str, blosc2.NDArray]):
638
+ """
639
+ Given an expression in string form, return its operands.
640
+
641
+ Parameters
642
+ ----------
643
+ expression : str
644
+ The expression in string form.
645
+
646
+ operands_old: dict[str : blosc2.ndarray | blosc2.LazyExpr]
647
+ Dict of operands from expression prior to eval.
648
+
649
+ operands_new: dict[str : blosc2.ndarray | blosc2.LazyExpr]
650
+ Dict of operands from expression after eval.
651
+ Returns
652
+ -------
653
+ newexpression
654
+ A modified string expression with the functions/constructors conserved and
655
+ true operands rebased and written in o- notation.
656
+ newoperands
657
+ Dict of the set of rebased operands.
658
+ """
659
+
660
+ operand_to_key = {id(v): k for k, v in operands_new.items()}
661
+ for k, v in operands_old.items(): # extend operands_to_key with old operands
662
+ if isinstance(
663
+ v, blosc2.LazyExpr
664
+ ): # unroll operands in LazyExpr (only necessary when have reduced a lazyexpr)
665
+ d = v.operands
666
+ else:
667
+ d = {k: v}
668
+ for newk, newv in d.items():
669
+ try:
670
+ operand_to_key[id(newv)]
671
+ except KeyError:
672
+ newk = (
673
+ f"o{len(operands_new)}" if newk in operands_new else newk
674
+ ) # possible that names coincide
675
+ operand_to_key[id(newv)] = newk
676
+ operands_new[newk] = newv
677
+
678
+ class OperandVisitor(ast.NodeVisitor):
679
+ def __init__(self):
680
+ self.operandmap = {}
681
+ self.operands = {}
682
+ self.opcounter = 0
683
+ self.function_names = set()
684
+
685
+ def update_func(self, localop):
686
+ k = operand_to_key[id(localop)]
687
+ if k not in self.operandmap:
688
+ newkey = f"o{self.opcounter}"
689
+ self.operands[newkey] = operands_new[k]
690
+ self.operandmap[k] = newkey
691
+ self.opcounter += 1
692
+ return newkey
693
+ else:
694
+ return self.operandmap[k]
695
+
696
+ def visit_Name(self, node):
697
+ if node.id == "np": # Skip NumPy namespace (e.g. np.int8, which will be treated separately)
698
+ return
699
+ if node.id in self.function_names: # Skip function names
700
+ return
701
+ elif node.id not in dtype_symbols:
702
+ localop = operands_old[node.id]
703
+ if isinstance(localop, blosc2.LazyExpr):
704
+ newexpr = localop.expression
705
+ for (
706
+ opname,
707
+ v,
708
+ ) in localop.operands.items(): # expression operands already in terms of basic operands
709
+ newopname = self.update_func(v)
710
+ newexpr = re.sub(
711
+ rf"(?<=\s){opname}|(?<=\(){opname}", newopname, newexpr
712
+ ) # replace with newopname
713
+ node.id = newexpr
714
+ else:
715
+ node.id = self.update_func(localop)
716
+ else:
717
+ pass
718
+ self.generic_visit(node)
719
+
720
+ def visit_Call(self, node):
721
+ if isinstance(
722
+ node.func, ast.Name
723
+ ): # visits Call first, then Name, so don't increment operandcounter yet
724
+ self.function_names.add(node.func.id)
725
+ self.generic_visit(node)
726
+
727
+ tree = ast.parse(expression)
728
+ visitor = OperandVisitor()
729
+ visitor.visit(tree)
730
+ newexpression, newoperands = ast.unparse(tree), visitor.operands
731
+ return newexpression, newoperands
732
+
733
+
633
734
  class TransformNumpyCalls(ast.NodeTransformer):
634
735
  def __init__(self):
635
736
  self.replacements = {}
@@ -2434,22 +2535,24 @@ class LazyExpr(LazyArray):
2434
2535
  _globals = get_expr_globals(self.expression)
2435
2536
  lazy_expr = eval(self.expression, _globals, self.operands)
2436
2537
  if not isinstance(lazy_expr, blosc2.LazyExpr):
2538
+ key, _ = process_key(item, self.shape)
2437
2539
  # An immediate evaluation happened (e.g. all operands are numpy arrays)
2438
2540
  if hasattr(self, "_where_args"):
2439
2541
  # We need to apply the where() operation
2440
2542
  if len(self._where_args) == 1:
2441
2543
  # We have a single argument
2442
2544
  where_x = self._where_args["_where_x"]
2443
- return where_x[:][lazy_expr]
2545
+ return (where_x[:][lazy_expr])[key]
2444
2546
  if len(self._where_args) == 2:
2445
2547
  # We have two arguments
2446
2548
  where_x = self._where_args["_where_x"]
2447
2549
  where_y = self._where_args["_where_y"]
2448
- return np.where(lazy_expr, where_x, where_y)
2550
+ return np.where(lazy_expr, where_x, where_y)[key]
2449
2551
  if hasattr(self, "_output"):
2450
2552
  # This is not exactly optimized, but it works for now
2451
- self._output[:] = lazy_expr
2452
- return lazy_expr
2553
+ self._output[:] = lazy_expr[key]
2554
+ return self._output
2555
+ return lazy_expr[key]
2453
2556
 
2454
2557
  return chunked_eval(lazy_expr.expression, lazy_expr.operands, item, **kwargs)
2455
2558
 
@@ -2676,10 +2779,14 @@ class LazyExpr(LazyArray):
2676
2779
  _dtype = new_expr.dtype
2677
2780
  _shape = new_expr.shape
2678
2781
  if isinstance(new_expr, blosc2.LazyExpr):
2679
- # Restore the original expression and operands
2680
- new_expr.expression = f"({_expression})" # forcibly add parenthesis
2681
- new_expr.expression_tosave = _expression
2682
- new_expr.operands = _operands
2782
+ # DO NOT restore the original expression and operands
2783
+ # Instead rebase operands and restore only constructors
2784
+ expression_, operands_ = conserve_functions(
2785
+ _expression, _operands, new_expr.operands | local_vars
2786
+ )
2787
+ new_expr.expression = f"({expression_})" # force parenthesis
2788
+ new_expr.expression_tosave = expression
2789
+ new_expr.operands = operands_
2683
2790
  new_expr.operands_tosave = operands
2684
2791
  else:
2685
2792
  # An immediate evaluation happened (e.g. all operands are numpy arrays)
@@ -2914,6 +2914,8 @@ def _check_shape(shape):
2914
2914
  shape = (shape,)
2915
2915
  elif not isinstance(shape, tuple | list):
2916
2916
  raise TypeError("shape should be a tuple or a list!")
2917
+ if len(shape) > blosc2.MAX_DIM:
2918
+ raise ValueError(f"shape length {len(shape)} is too large (>{blosc2.MAX_DIM})!")
2917
2919
  return shape
2918
2920
 
2919
2921
 
@@ -3266,7 +3268,9 @@ def arange(
3266
3268
 
3267
3269
 
3268
3270
  # Define a numpy linspace-like function
3269
- def linspace(start, stop, num=50, endpoint=True, dtype=np.float64, shape=None, c_order=True, **kwargs: Any):
3271
+ def linspace(
3272
+ start, stop, num=None, endpoint=True, dtype=np.float64, shape=None, c_order=True, **kwargs: Any
3273
+ ):
3270
3274
  """Return evenly spaced numbers over a specified interval.
3271
3275
 
3272
3276
  This is similar to `numpy.linspace` but it returns a `NDArray`
@@ -3308,8 +3312,17 @@ def linspace(start, stop, num=50, endpoint=True, dtype=np.float64, shape=None, c
3308
3312
  stop_ = start_ + lout / num * (stop - start)
3309
3313
  output[:] = np.linspace(start_, stop_, lout, endpoint=False, dtype=output.dtype)
3310
3314
 
3311
- if not shape:
3312
- shape = (num,)
3315
+ if shape is None or num is None:
3316
+ if shape is None and num is None:
3317
+ raise ValueError("Either `shape` or `num` must be specified.")
3318
+ if shape is None: # num is not None
3319
+ shape = (num,)
3320
+ else: # num is none
3321
+ num = math.prod(shape)
3322
+
3323
+ # check compatibility of shape and num
3324
+ if math.prod(shape) != num:
3325
+ raise ValueError("The specified shape is not consistent with the specified num value")
3313
3326
  dtype = _check_dtype(dtype)
3314
3327
 
3315
3328
  if is_inside_new_expr():
@@ -0,0 +1 @@
1
+ __version__ = "3.3.3"
@@ -27,7 +27,7 @@ def sample_data(request):
27
27
  # The jit decorator can work with any numpy or NDArray params in functions
28
28
  a = blosc2.linspace(0, 1, shape[0] * shape[1], dtype=dtype, shape=shape)
29
29
  b = np.linspace(1, 2, shape[0] * shape[1], dtype=dtype).reshape(shape)
30
- c = blosc2.linspace(-10, 10, cshape[0], dtype=dtype, shape=cshape)
30
+ c = blosc2.linspace(-10, 10, np.prod(cshape), dtype=dtype, shape=cshape)
31
31
  return a, b, c, shape
32
32
 
33
33
 
@@ -26,7 +26,7 @@ def sample_data(request):
26
26
  # The jit decorator can work with any numpy or NDArray params in functions
27
27
  a = blosc2.linspace(0, 1, shape[0] * shape[1], dtype=dtype, shape=shape)
28
28
  b = np.linspace(1, 2, shape[0] * shape[1], dtype=dtype).reshape(shape)
29
- c = blosc2.linspace(-10, 10, cshape[0], dtype=dtype, shape=cshape)
29
+ c = blosc2.linspace(-10, 10, np.prod(cshape), dtype=dtype, shape=cshape)
30
30
  return a, b, c, shape
31
31
 
32
32
 
@@ -1354,45 +1354,52 @@ def test_chain_expressions():
1354
1354
  le3_ = blosc2.lazyexpr("(le2 & (b < 0))", {"le2": le2_, "b": b})
1355
1355
  assert (le3_[:] == le3[:]).all()
1356
1356
 
1357
- # TODO: This test should pass eventually
1358
- # le1 = a ** 3 + blosc2.sin(a ** 2)
1359
- # le2 = le1 < c
1360
- # le3 = (b < 0)
1361
- # le4 = le2 & le3
1362
- # le1_ = blosc2.lazyexpr("a ** 3 + sin(a ** 2)", {"a": a})
1363
- # le2_ = blosc2.lazyexpr("(le1 < c)", {"le1": le1_, "c": c})
1364
- # le3_ = blosc2.lazyexpr("(b < 0)", {"b": b})
1365
- # le4_ = blosc2.lazyexpr("(le2 & le3)", {"le2": le2_, "le3": le3_})
1366
- # assert (le4_[:] == le4[:]).all()
1367
-
1368
-
1369
- # TODO: Test the chaining of multiple persistent lazy expressions
1370
- # def test_chain_persistentexpressions():
1371
- # N = 1_000
1372
- # dtype = "float64"
1373
- # a = blosc2.linspace(0, 1, N * N, dtype=dtype, shape=(N, N), urlpath="a.b2nd", mode="w")
1374
- # b = blosc2.linspace(1, 2, N * N, dtype=dtype, shape=(N, N), urlpath="b.b2nd", mode="w")
1375
- # c = blosc2.linspace(0, 1, N, dtype=dtype, shape=(N,), urlpath="c.b2nd", mode="w")
1376
- #
1377
- # le1 = a ** 3 + blosc2.sin(a ** 2)
1378
- # le2 = le1 < c
1379
- # le3 = (b < 0)
1380
- # le4 = le2 & le3
1381
- #
1382
- # le1_ = blosc2.lazyexpr("a ** 3 + sin(a ** 2)", {"a": a})
1383
- # le1_.save("expr1.b2nd", mode="w")
1384
- # myle1 = blosc2.open("expr1.b2nd")
1385
- #
1386
- # le2_ = blosc2.lazyexpr("(le1 < c)", {"le1": myle1, "c": c})
1387
- # le2_.save("expr2.b2nd", mode="w")
1388
- # myle2 = blosc2.open("expr2.b2nd")
1389
- #
1390
- # le3_ = blosc2.lazyexpr("(b < 0)", {"b": b})
1391
- # le3_.save("expr3.b2nd", mode="w")
1392
- # myle3 = blosc2.open("expr3.b2nd")
1393
- #
1394
- # le4_ = blosc2.lazyexpr("(le2 & le3)", {"le2": myle2, "le3": myle3})
1395
- # le4_.save("expr4.b2nd", mode="w")
1396
- # myle4 = blosc2.open("expr4.b2nd")
1397
- # print((myle4[:] == le4[:]).all())
1398
- #
1357
+ le1 = a**3 + blosc2.sin(a**2)
1358
+ le2 = le1 < c
1359
+ le3 = b < 0
1360
+ le4 = le2 & le3
1361
+ le1_ = blosc2.lazyexpr("a ** 3 + sin(a ** 2)", {"a": a})
1362
+ le2_ = blosc2.lazyexpr("(le1 < c)", {"le1": le1_, "c": c})
1363
+ le3_ = blosc2.lazyexpr("(b < 0)", {"b": b})
1364
+ le4_ = blosc2.lazyexpr("(le2 & le3)", {"le2": le2_, "le3": le3_})
1365
+ assert (le4_[:] == le4[:]).all()
1366
+
1367
+ # TODO: Eventually this test should pass
1368
+ # expr1 = blosc2.lazyexpr("arange(N) + b")
1369
+ # expr2 = blosc2.lazyexpr("a * b + 1")
1370
+ # expr = blosc2.lazyexpr("expr1 - expr2")
1371
+ # expr_final = blosc2.lazyexpr("expr * expr")
1372
+ # nres = (expr * expr)[:]
1373
+ # res = expr_final.compute()
1374
+ # np.testing.assert_allclose(res[:], nres)
1375
+
1376
+
1377
+ # Test the chaining of multiple persistent lazy expressions
1378
+ def test_chain_persistentexpressions():
1379
+ N = 1_000
1380
+ dtype = "float64"
1381
+ a = blosc2.linspace(0, 1, N * N, dtype=dtype, shape=(N, N), urlpath="a.b2nd", mode="w")
1382
+ b = blosc2.linspace(1, 2, N * N, dtype=dtype, shape=(N, N), urlpath="b.b2nd", mode="w")
1383
+ c = blosc2.linspace(0, 1, N, dtype=dtype, shape=(N,), urlpath="c.b2nd", mode="w")
1384
+
1385
+ le1 = a**3 + blosc2.sin(a**2)
1386
+ le2 = le1 < c
1387
+ le3 = b < 0
1388
+ le4 = le2 & le3
1389
+
1390
+ le1_ = blosc2.lazyexpr("a ** 3 + sin(a ** 2)", {"a": a})
1391
+ le1_.save("expr1.b2nd", mode="w")
1392
+ myle1 = blosc2.open("expr1.b2nd")
1393
+
1394
+ le2_ = blosc2.lazyexpr("(le1 < c)", {"le1": myle1, "c": c})
1395
+ le2_.save("expr2.b2nd", mode="w")
1396
+ myle2 = blosc2.open("expr2.b2nd")
1397
+
1398
+ le3_ = blosc2.lazyexpr("(b < 0)", {"b": b})
1399
+ le3_.save("expr3.b2nd", mode="w")
1400
+ myle3 = blosc2.open("expr3.b2nd")
1401
+
1402
+ le4_ = blosc2.lazyexpr("(le2 & le3)", {"le2": myle2, "le3": myle3})
1403
+ le4_.save("expr4.b2nd", mode="w")
1404
+ myle4 = blosc2.open("expr4.b2nd")
1405
+ assert (myle4[:] == le4[:]).all()
@@ -187,6 +187,14 @@ def test_linspace(ss, shape, dtype, chunks, blocks, endpoint, c_order):
187
187
  else:
188
188
  # This is chunk order, so testing is more laborious, and not really necessary
189
189
  pass
190
+ with pytest.raises(ValueError):
191
+ a = blosc2.linspace(start, stop, 10, shape=(20,)) # num incompatible with shape
192
+ with pytest.raises(ValueError):
193
+ a = blosc2.linspace(start, stop) # num or shape should be specified
194
+ a = blosc2.linspace(start, stop, shape=(20,)) # should have length 20
195
+ assert a.shape == (20,)
196
+ a = blosc2.linspace(start, stop, num=20) # should have length 20
197
+ assert a.shape == (20,)
190
198
 
191
199
 
192
200
  @pytest.mark.parametrize(("N", "M"), [(10, None), (10, 20), (20, 10)])
@@ -418,3 +418,13 @@ def test_save_constructor_reduce2(shape, disk, compute):
418
418
  blosc2.remove_urlpath(urlpath_a)
419
419
  blosc2.remove_urlpath(urlpath_b)
420
420
  blosc2.remove_urlpath("out.b2nd")
421
+
422
+
423
+ def test_reduction_index():
424
+ shape = (20, 20)
425
+ a = blosc2.linspace(0, 20, num=np.prod(shape), shape=shape)
426
+ arr = blosc2.lazyexpr("sum(a,axis=0)", {"a": a})
427
+ newarr = arr.compute()
428
+ assert arr[:10].shape == (10,)
429
+ assert arr[0].shape == (1,)
430
+ assert arr.shape == newarr.shape
@@ -135,3 +135,40 @@ def test_large_typesize(shape, typesize, asarray):
135
135
  else:
136
136
  b = blosc2.zeros(shape, dtype=dtype)
137
137
  assert np.array_equal(b[0], a[0])
138
+
139
+
140
+ @pytest.mark.parametrize(
141
+ "dtype",
142
+ [
143
+ np.dtype(("<f8", (10,))),
144
+ np.dtype(("<i8", (10,))),
145
+ np.dtype(("<i4,>f4", (10,))),
146
+ ],
147
+ )
148
+ def test_nd_dtype(dtype):
149
+ # Test that the dtype is correctly set for a 1D array with a nested dtype
150
+ a = blosc2.zeros((1,), dtype=dtype)
151
+ assert a.dtype == dtype
152
+ b = np.zeros((1,), dtype=dtype)
153
+ if dtype.base.fields: # ("<i8,>f4", (10,))
154
+ # Check values by converting to a dtype without a structure
155
+ a2 = a[:].view(dtype=np.int8)
156
+ b2 = b[:].view(dtype=np.int8)
157
+ np.testing.assert_equal(a2, b2)
158
+ else:
159
+ np.testing.assert_equal(a[:], b)
160
+
161
+
162
+ def test_shape_empty():
163
+ # Test that the shape is correctly set to () for an empty array
164
+ a = blosc2.zeros((), dtype=np.int32)
165
+ assert a.shape == ()
166
+ assert a.dtype == np.int32
167
+ b = np.zeros((), dtype=np.int32)
168
+ np.testing.assert_equal(a[()], b)
169
+
170
+
171
+ def test_shape_max_dims():
172
+ # Test that the shape cannot exceed the maximum number of dimensions
173
+ with pytest.raises(ValueError):
174
+ a = blosc2.zeros((1,) * (blosc2.MAX_DIM + 1), dtype=np.int32)
@@ -1 +0,0 @@
1
- __version__ = "3.3.2"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes