Skip to main content

Python library for to build and handle stacks of sparse COO arrays efficiently

Project description

GitHub PyPI GitHub Workflow Status

sparsestack

Memory efficient stack of multiple 2D sparse arrays.

First code example (until better readme is done...)

import numpy as np
from sparsestack import StackedSparseArray

# Create some fake data
scores1 = np.random.random((12, 10))
scores2 = np.random.random((12, 10))
scores_array = StackedSparseArray(12, 10)
scores_array.add_dense_matrix(scores1, "scores_1")
scores_array = scores_array.filter_by_range("scores_1", low=0.5)

# Add second scores and filter
scores_array.add_dense_matrix(scores2, "scores_2")
scores_array = scores_array.filter_by_range("scores_2", low=0.1, high=0.4)

# Scores can be accessed using (limited) slicing capabilities
scores_array[3, 4]  # => scores_1 and scores_2 at position row=3, col=4
scores_array[3, :]  # => tuple with row, col, scores for all entries in row=3
scores_array[:, 2]  # => tuple with row, col, scores for all entries in col=2
scores_array[3, :, 0]  # => tuple with row, col, scores_1 for all entries in row=3
scores_array[3, :, "scores_1"]  # => same as the one before

# Scores can also be converted to a dense numpy array:
scores2_after_filtering = scores_array.to_array("scores_2")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sparsestack-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sparsestack-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file sparsestack-0.1.0.tar.gz.

File metadata

  • Download URL: sparsestack-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for sparsestack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f93a5183f926f0ed0109bfa82ceea3ecbd48ab1384eb36caa0bafc2063742323
MD5 49586a94add2b1b0540299c42a2b5a20
BLAKE2b-256 71d1f992541a6ef3d47bf5794e2412f02fdcb3bde43644a121a6241193a9fb9f

See more details on using hashes here.

File details

Details for the file sparsestack-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sparsestack-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for sparsestack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e6f28025857c5acf521009b8427294ef0b4eed88714255ceaffd0247e6f15c0
MD5 e746a5927067b09fd95039afbce73545
BLAKE2b-256 f647d56027691d95729a89cb69fb889940ebcbb9a5cac9c22506d7cfb92d703e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page