Registry / data / fastremap

fastremap

JSON →
library1.20.0pypypiunverified

fastremap is a highly optimized C++ library with a Python wrapper for high-performance image and point cloud processing. It provides extremely fast functions for remapping, masking, renumbering, finding unique elements, and in-place transposition of 3D labeled images. The current version is 1.18.0, and it maintains an active release cadence with frequent updates.

pip install fastremap
INSTALL
IMPORT
SIG · FASTREMAP
F
fastremap
datapythonv1.20.0
Install
4.0s avg
Import
Disk
118MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.20.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.0s · import 0.000s · 116MB
118MB installed
● package 118MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fastremap
import fastremap
import fastremap

This quickstart demonstrates basic usage of `fastremap` for remapping labels in a NumPy array. It shows both non-in-place (`remap`) and in-place (`remap_inplace`) operations, as well as the `renumber` function for making labels contiguous and obtaining the mapping.

import numpy as np import fastremap # Example 1: Remap an array using a dictionary arr1 = np.array([1, 2, 1, 3, 0], dtype=np.uint32) mapping = {1: 10, 2: 20, 3: 30} remapped_arr = fastremap.remap(arr1, mapping) print(f"Original array: {arr1}") print(f"Remapped array: {remapped_arr}") # Expected: Remapped array: [10 20 10 30 0] # Example 2: In-place remapping arr2 = np.array([10, 20, 10, 30, 0], dtype=np.uint32) reverse_mapping = {10: 1, 20: 2, 30: 3} fastremap.remap_inplace(arr2, reverse_mapping) print(f"Array after in-place remapping: {arr2}") # Expected: Array after in-place remapping: [1 2 1 3 0] # Example 3: Renumber contiguous labels arr3 = np.array([0, 5, 2, 0, 5, 10], dtype=np.uint32) new_array, old_to_new_map = fastremap.renumber(arr3) print(f"Original array for renumber: {arr3}") print(f"Renumbered array: {new_array}") print(f"Old to new map: {old_to_new_map}") # Expected: Renumbered array: [0 2 1 0 2 3], Old to new map: {0: 0, 5: 2, 2: 1, 10: 3}
Debug
Known issues
gotchaMany core functions like `remap_inplace` and `transpose_inplace` modify the input NumPy array directly (in-place). If you intend to preserve the original array, use their non-`_inplace` counterparts or create a copy before calling the in-place function.
fix
Use `arr.copy()` before passing to an `_inplace` function, or use functions like `fastremap.remap` which return a new array.
affects: All versions
gotchaThe `fastremap.renumber` function returns a tuple containing two items: the new renumbered array and a dictionary mapping old labels to new labels. Forgetting to unpack both can lead to errors or misunderstanding the output.
fix
Always unpack the return value like `new_array, old_to_new_map = fastremap.renumber(arr)` to access both components.
affects: All versions
gotchaFunctions expecting labels (e.g., `remap`, `renumber`, `mask`) often perform best or explicitly expect unsigned integer data types (like `np.uint32`). Using other types, especially floating-point, may lead to performance degradation, unexpected behavior, or errors due to casting or unsupported operations in the underlying C++.
fix
Ensure input arrays for label processing are explicitly cast to appropriate unsigned integer types (e.g., `arr.astype(np.uint32)`).
affects: All versions
Upgrade
Version history
1.20.0latest on PyPI · released Jun 11, 2026
Audit
Dependencies
numpyrequiredRequired for array manipulation and data structures.
scipyrequiredUsed for some advanced numerical operations.
Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
fastremap — pip install fastremap · libregistry