Python library to handle stacks of sparse COO arrays efficiently.
Project description
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
Release history Release notifications | RSS feed
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.1.tar.gz
(8.7 kB
view hashes)
Built Distribution
Close
Hashes for sparsestack-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8893861d90b858fc44b3d84eb93182d1767c47ee238826819da5856d7c85e3be |
|
MD5 | 9d962077fbc037a3ac6bebb2bc52a55d |
|
BLAKE2b-256 | b8b9992805c509f4c278a5ff37edad0127d5fbb023d61e67ca8413e7dbf2c224 |