Registry / data / slicer

slicer

JSON →
library0.0.8pypypi✓ verified 24d ago

Slicer is a lightweight Python package designed to provide a unified and extended slicing interface for diverse tensor-like objects. It wraps standard Python data structures (lists, dicts) and scientific computing libraries (NumPy arrays, Pandas DataFrames, SciPy sparse matrices, PyTorch tensors) to enable advanced slicing functionalities like non-integer indexing and nested slicing in a single operation. The current version is 0.0.8, with its last update in 2021, suggesting a maintenance-oriented release cadence.

pip install slicer
INSTALL
IMPORT
SIG · SLICER
S
slicer
datapythonv0.0.8
Install
1.6s avg
Import
13ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.8 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.014s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.012s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

Slicer
from slicer import Slicer as S
Alias
from slicer import Alias as A
Alias is used for named slicing and tracking object references.

Demonstrates basic anonymous slicing for lists and dictionaries, and named slicing for a Pandas DataFrame and a NumPy array.

from slicer import Slicer as S import pandas as pd import numpy as np # Basic anonymous slicing for lists li = [[1, 2, 3], [4, 5, 6]] result_list = S(li)[:, 0:2].o # result_list will be [[1, 2], [4, 5]] # Basic anonymous slicing for dictionaries di = {'x': [1, 2, 3], 'y': [4, 5, 6]} result_dict = S(di)[:, 0:2].o # result_dict will be {'x': [1, 2], 'y': [4, 5]} # Basic named slicing for multiple objects df = pd.DataFrame({'A': [1, 3], 'B': [2, 4]}) ar = np.array([[5, 6], [7, 8]]) sliced_objects = S(first=df, second=ar)[0, :] # sliced_objects.first will be a pandas Series # sliced_objects.second will be a numpy array
Debug
Known issues
breakingSlicer v0.0.8 fixed compatibility issues due to the renaming of `scipy.sparse` classes (e.g., `csr_matrix` to `csr_array`). Projects using older Slicer versions with newer SciPy releases may encounter `AttributeError` or unexpected behavior with sparse matrix slicing.
fix
Upgrade Slicer to version 0.0.8 or newer: `pip install --upgrade slicer`. If using `scipy.sparse`, consult the SciPy migration guide from `spmatrix` to `sparray` for further compatibility adjustments in your code.
affects: <0.0.8
gotchaThe library explicitly states it has '0 dependencies'. However, its core utility is to provide enhanced slicing for objects from other libraries (NumPy, Pandas, SciPy, PyTorch). To use Slicer effectively with these data types, you must install the respective underlying libraries separately.
fix
Ensure that `numpy`, `pandas`, `scipy`, `pytorch` (or any other library whose objects you intend to slice) are installed in your environment if you wish to use Slicer's functionality with them (e.g., `pip install numpy pandas scipy pytorch`).
affects: All versions
deprecatedBehavior around alias re-assignment was corrected in Slicer v0.0.7. Prior versions may have exhibited inconsistent or unexpected results when re-assigning values to aliases tracked by a Slicer object.
fix
Upgrade Slicer to version 0.0.7 or newer: `pip install --upgrade slicer`.
affects: <0.0.7
gotchaThe project's last release was in 2021, and its development activity appears to be infrequent. While bug fixes have occurred, users should be aware that new features or rapid responses to external library changes might not be a priority.
fix
Review the GitHub repository's commit history and issue tracker (https://github.com/interpretml/slicer/pulse) to gauge current activity if long-term active maintenance is a critical factor for your application.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'slicer'
The 'slicer' Python package is not installed in the current environment, or there is confusion with the 3D Slicer application which is a different project.
fix
Install the package using pip: `pip install slicer`
AttributeError: 'int' object has no attribute '__getitem__'
The `slicer.Slicer` object was initialized with a data type that does not support indexing (e.g., an integer or None), and then an attempt was made to slice it.
fix
Initialize `slicer.Slicer` with a supported data structure such as a list, NumPy array, Pandas DataFrame, or PyTorch tensor: `s = slicer.Slicer([1, 2, 3])`
TypeError: 'str' object cannot be interpreted as an integer
The `dim()` method (or similar axis-related functions) of a `slicer.Slicer` object was called with a non-integer argument, but it expects an integer representing the axis index.
fix
Provide an integer value for the axis when using `dim()` or other axis-related methods: `s.dim(0)`
Upgrade
Version history
0.0.8latest on PyPI · released Mar 9, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
1
Resources