slicer

Unified slicing for all Python data structures.

https://github.com/interpretml/slicer

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.7%) to scientific vocabulary

Keywords

python slicing
Last synced: 6 months ago · JSON representation

Repository

Unified slicing for all Python data structures.

Basic Info
  • Host: GitHub
  • Owner: interpretml
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 43 KB
Statistics
  • Stars: 35
  • Watchers: 4
  • Forks: 4
  • Open Issues: 2
  • Releases: 5
Topics
python slicing
Created over 5 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License

README.md

slicer [alpha]

License Python Version Package Version Maintenance

(Equal Contribution) Samuel Jenkins & Harsha Nori & Scott Lundberg

slicer wraps tensor-like objects and provides a uniform slicing interface via __getitem__.


It supports many data types including:

   numpy | pandas | scipy | pytorch | list | tuple | dict

And enables upgraded slicing functionality on its objects: ```python

Handles non-integer indexes for slicing.

S(df)[:, ["Age", "Income"]]

Handles nested slicing in one call.

S(nested_list)[..., :5] ```

It can also simultaneously slice many objects at once: ```python

Gets first elements of both objects.

S(first=df, second=ar)[0, :] ```

This package has 0 dependencies. Not even one.

Installation

Python 3.6+ | Linux, Mac, Windows sh pip install slicer

Getting Started

Basic anonymous slicing: ```python from slicer import Slicer as S li = [[1, 2, 3], [4, 5, 6]] S(li)[:, 0:2].o

[[1, 2], [4, 5]]

di = {'x': [1, 2, 3], 'y': [4, 5, 6]} S(di)[:, 0:2].o

{'x': [1, 2], 'y': [4, 5]}

```

Basic named slicing: ```python import pandas as pd import numpy as np df = pd.DataFrame({'A': [1, 3], 'B': [2, 4]}) ar = np.array([[5, 6], [7, 8]]) sliced = S(first=df, second=ar)[0, :] sliced.first

A 1

B 2

Name: 0, dtype: int64

sliced.second

array([5, 6])

```

Real example: ```python from slicer import Slicer as S from slicer import Alias as A

data = [[1, 2], [3, 4]] values = [[5, 6], [7, 8]] identifiers = ["id1", "id1"] instancenames = ["r1", "r2"] featurenames = ["f1", "f2"] full_name = "A"

slicer = S( data=data, values=values, # Aliases are objects that also function as slicing keys. # A(obj, dim) where dim informs what dimension it can be sliced on. identifiers=A(identifiers, 0), instancenames=A(instancenames, 0), featurenames=A(featurenames, 1), fullname=fullname, )

sliced = slicer[:, 1] # Tensor-like parallel slicing on all objects assert sliced.data == [2, 4] assert sliced.instancenames == ["r1", "r2"] assert sliced.featurenames == "f2" assert sliced.values == [6, 8]

sliced = slicer["r1", "f2"] # Example use of aliasing assert sliced.data == 2 assert sliced.featurenames == "f2" assert sliced.instancenames == "r1" assert sliced.values == 6 ```

Contact us

Raise an issue on GitHub, or contact us at interpret@microsoft.com

Owner

  • Name: InterpretML
  • Login: interpretml
  • Kind: organization
  • Email: interpret@microsoft.com

If a tree fell in your random forest, would anyone notice?

GitHub Events

Total
  • Issues event: 2
  • Push event: 4
  • Pull request review event: 1
  • Pull request event: 2
  • Create event: 1
Last Year
  • Issues event: 2
  • Push event: 4
  • Pull request review event: 1
  • Pull request event: 2
  • Create event: 1

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 31
  • Total Committers: 6
  • Avg Commits per committer: 5.167
  • Development Distribution Score (DDS): 0.323
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
InterpretML 5****l 21
Scott Lundberg s****g@m****m 4
connortann 7****n 3
natsukium t****i@g****m 1
S Jenkins 6****e 1
Paul Koch c****e@k****a 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 4
  • Total pull requests: 4
  • Average time to close issues: 3 days
  • Average time to close pull requests: 2 months
  • Total issue authors: 3
  • Total pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 4.0
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • slundberg (2)
  • connortann (1)
  • detrin (1)
Pull Request Authors
  • connortann (6)
  • natsukium (2)
  • Copilot (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 8,624,320 last-month
  • Total docker downloads: 407,562
  • Total dependent packages: 27
    (may contain duplicates)
  • Total dependent repositories: 852
    (may contain duplicates)
  • Total versions: 13
  • Total maintainers: 2
pypi.org: slicer

A small package for big slicing.

  • Versions: 8
  • Dependent Packages: 21
  • Dependent Repositories: 826
  • Downloads: 8,624,320 Last month
  • Docker Downloads: 407,562
Rankings
Downloads: 0.1%
Dependent repos count: 0.4%
Dependent packages count: 0.6%
Docker downloads count: 1.0%
Average: 5.1%
Stargazers count: 11.6%
Forks count: 16.9%
Maintainers (1)
Last synced: 6 months ago
spack.io: py-slicer

slicer wraps tensor-like objects and provides a uniform slicing interface via __getitem__

  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Stargazers count: 24.4%
Average: 28.2%
Forks count: 31.0%
Dependent packages count: 57.3%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: slicer
  • Versions: 2
  • Dependent Packages: 4
  • Dependent Repositories: 13
Rankings
Dependent repos count: 9.8%
Dependent packages count: 12.5%
Average: 32.9%
Stargazers count: 46.7%
Forks count: 62.4%
Last synced: 6 months ago
anaconda.org: slicer

slicer wraps tensor-like objects and provides a uniform slicing interface via __getitem__.

  • Versions: 2
  • Dependent Packages: 1
  • Dependent Repositories: 13
Rankings
Dependent packages count: 30.6%
Dependent repos count: 36.0%
Average: 43.9%
Stargazers count: 50.9%
Forks count: 58.1%
Last synced: 6 months ago

Dependencies

setup.py pypi
.github/workflows/run_tests.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite