fastremap 1.17.0__cp313-cp313-macosx_10_13_x86_64.whl → 1.17.2__cp313-cp313-macosx_10_13_x86_64.whl

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.
fastremap/__init__.py CHANGED
@@ -2,6 +2,7 @@ from .fastremap import (
2
2
  ascontiguousarray,
3
3
  asfortranarray,
4
4
  component_map,
5
+ fit_dtype,
5
6
  foreground,
6
7
  indices,
7
8
  inverse_component_map,
@@ -26,6 +27,7 @@ __all__ = [
26
27
  "ascontiguousarray",
27
28
  "asfortranarray",
28
29
  "component_map",
30
+ "fit_dtype",
29
31
  "foreground",
30
32
  "indices",
31
33
  "inverse_component_map",
Binary file
fastremap/fastremap.pyi CHANGED
@@ -441,6 +441,13 @@ def ascontiguousarray(arr: NDArray[Any]) -> NDArray[Any]:
441
441
  """
442
442
  ...
443
443
 
444
+ def fit_dtype(
445
+ dtype:DTypeLike,
446
+ value:Union[int, float, np.integer, np.unsignedinteger, np.complexfloating, np.floating],
447
+ exotics:bool = False,
448
+ ) -> DTypeLike:
449
+ ...
450
+
444
451
  def minmax(
445
452
  arr: NDArray[Any],
446
453
  ) -> tuple[Union[int, float, None], Union[int, float, None]]:
@@ -458,7 +465,7 @@ def pixel_pairs(labels: NDArray[Any]) -> int:
458
465
  """
459
466
  ...
460
467
 
461
- def foreground(arr: NDArray[Any]) -> int:
468
+ def foreground(arr: NDArray[np.integer]) -> int:
462
469
  """Returns the number of non-zero voxels in an array."""
463
470
  ...
464
471
 
fastremap/fastremap.pyx CHANGED
@@ -292,7 +292,7 @@ def refit(arr, value=None, increase_only=False, exotics=False):
292
292
  else:
293
293
  value = min_value
294
294
 
295
- dtype = _fit_dtype(arr.dtype, value, exotics=exotics)
295
+ dtype = fit_dtype(arr.dtype, value, exotics=exotics)
296
296
 
297
297
  if increase_only and np.dtype(dtype).itemsize <= np.dtype(arr.dtype).itemsize:
298
298
  return arr
@@ -300,7 +300,7 @@ def refit(arr, value=None, increase_only=False, exotics=False):
300
300
  return arr
301
301
  return arr.astype(dtype)
302
302
 
303
- def _fit_dtype(dtype, value, exotics=False):
303
+ def fit_dtype(dtype, value, exotics=False):
304
304
  """
305
305
  Find the smallest dtype of the
306
306
  same kind that will fit a given value.
@@ -973,9 +973,18 @@ def _unique_via_shifted_array(labels, min_label=None, max_label=None, return_ind
973
973
  if min_label is None or max_label is None:
974
974
  min_label, max_label = minmax(labels)
975
975
 
976
- labels -= min_label
977
- uniq, idx, counts, inverse = _unique_via_array(labels, max_label - min_label + 1, return_index, return_inverse)
978
- labels += min_label
976
+ if labels.flags.writeable:
977
+ labels -= min_label
978
+ arr = labels
979
+ else:
980
+ arr = labels - min_label
981
+
982
+ uniq, idx, counts, inverse = _unique_via_array(arr, max_label - min_label + 1, return_index, return_inverse)
983
+ del arr
984
+
985
+ if labels.flags.writeable:
986
+ labels += min_label
987
+
979
988
  uniq += min_label
980
989
  return uniq, idx, counts, inverse
981
990
 
@@ -990,7 +999,7 @@ def _unique_via_renumber(labels, return_index=False, return_inverse=False):
990
999
  uniq.sort()
991
1000
  return uniq, idx, counts, inverse
992
1001
 
993
- uniq, idx2 = np.unique(uniq, return_index=return_index)
1002
+ uniq, idx2 = np.unique(uniq, return_index=True)
994
1003
  if idx is not None:
995
1004
  idx = idx[idx2]
996
1005
  if counts is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastremap
3
- Version: 1.17.0
3
+ Version: 1.17.2
4
4
  Summary: Remap, mask, renumber, unique, and in-place transposition of 3D labeled images. Point cloud too.
5
5
  Home-page: https://github.com/seung-lab/fastremap/
6
6
  Author: William Silversmith
@@ -0,0 +1,15 @@
1
+ fastremap-1.17.2.dist-info/RECORD,,
2
+ fastremap-1.17.2.dist-info/WHEEL,sha256=Fjkpi1DxIt31VKqtJdsn0C_s0PSBt8Ck_bF8Ba4h_uI,111
3
+ fastremap-1.17.2.dist-info/pbr.json,sha256=z-ahicM-bsw4Dwxh-QOB5RSgxodG7zN9H-J0_kKaSjc,47
4
+ fastremap-1.17.2.dist-info/top_level.txt,sha256=D-q4-YJbbk7QpuU8fxH9rFQEjV_W6wpdruzTTDV4N5s,10
5
+ fastremap-1.17.2.dist-info/METADATA,sha256=6Y0U4bh3nuaTAIpQMkolhrg_fA0vI4djjF7-Q54gDFs,10294
6
+ fastremap-1.17.2.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
7
+ fastremap-1.17.2.dist-info/licenses/AUTHORS,sha256=Aa4H7O3dtmfq0lF_eATudy11i8K6QAI8LykzASr9bL0,52
8
+ fastremap/fastremap.cpython-313-darwin.so,sha256=12RLOZV4z2LvKDUcl-Lcx5PZB1Y75_C6j_ycVuU1SoI,2553984
9
+ fastremap/__init__.py,sha256=OgcsmS2SUE7W1fDcPQEQEba-zmOyZQ6ezZBnYglHTNc,814
10
+ fastremap/fastremap.pyx,sha256=q2jCUyzB3Un9glI1BBowkLnKTV-d98COsqBTJWGl9jU,45163
11
+ fastremap/fastremap.pxd,sha256=lHTRtJC_SuDBuOGFtEx3zf7WTCAWuQ0oumwC9IdiuLk,3966
12
+ fastremap/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ fastremap/ipt.hpp,sha256=aTS5-ftA8r0vGhJ1T5lE2xZwKCE1oCzgTbbNgIfehhM,7907
14
+ fastremap/ska_flat_hash_map.hpp,sha256=eny2nkM5ME8SxYobjFgoypKjchpP1gLq8zI-S3EFYDw,61579
15
+ fastremap/fastremap.pyi,sha256=vsAuGtadHq0l9yxpZpjAnv0EPhIWytYLVWpISUwISrw,15087
@@ -0,0 +1 @@
1
+ William Silversmith <william.silversmith@gmail.com>
@@ -0,0 +1 @@
1
+ {"git_version": "1fec0d5", "is_release": false}
@@ -1,15 +0,0 @@
1
- fastremap/fastremap.cpython-313-darwin.so,sha256=LbcbpfYoTfGebhHynVZgNNwUuuaQXoirpu4ert7G8kA,2553936
2
- fastremap/__init__.py,sha256=hB8qCFtoI0dJgCziFURiIjHLjuTjA2lU-HNNzcM0W-g,782
3
- fastremap/fastremap.pyx,sha256=12Ys8lgn_RHRwipHyrvbvR__qLJgse5X1IhFlkd_zjs,45047
4
- fastremap/fastremap.pxd,sha256=lHTRtJC_SuDBuOGFtEx3zf7WTCAWuQ0oumwC9IdiuLk,3966
5
- fastremap/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- fastremap/ipt.hpp,sha256=aTS5-ftA8r0vGhJ1T5lE2xZwKCE1oCzgTbbNgIfehhM,7907
7
- fastremap/ska_flat_hash_map.hpp,sha256=eny2nkM5ME8SxYobjFgoypKjchpP1gLq8zI-S3EFYDw,61579
8
- fastremap/fastremap.pyi,sha256=BtOaLT8CMKu9dljUB_WnhZs97_e-NVZlExdOLrLcEaI,14897
9
- fastremap-1.17.0.dist-info/RECORD,,
10
- fastremap-1.17.0.dist-info/WHEEL,sha256=Fjkpi1DxIt31VKqtJdsn0C_s0PSBt8Ck_bF8Ba4h_uI,111
11
- fastremap-1.17.0.dist-info/pbr.json,sha256=dR1UpQuiiTyrZ7Y1PMguAEXlAjPBXmHM_DXmzrK1gbY,47
12
- fastremap-1.17.0.dist-info/top_level.txt,sha256=D-q4-YJbbk7QpuU8fxH9rFQEjV_W6wpdruzTTDV4N5s,10
13
- fastremap-1.17.0.dist-info/METADATA,sha256=P86CEeEBDSz3Dj-at8iRQ4wies_I0m6FNlQKTyXJxpU,10294
14
- fastremap-1.17.0.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
15
- fastremap-1.17.0.dist-info/licenses/AUTHORS,sha256=fp7K3Hh22cRdHzMj837IAKImGxut2SRouzHe8pNphus,62
@@ -1 +0,0 @@
1
- Matthew Vine <32849887+MattTheCuber@users.noreply.github.com>
@@ -1 +0,0 @@
1
- {"git_version": "1b389a3", "is_release": false}