Skip to main content

Travis PyPI Anaconda

Numpy indexed operations

This package contains functionality for indexed operations on numpy ndarrays, providing efficient vectorized functionality such as grouping and set operations.

  • Rich and efficient grouping functionality:

    • splitting of values by key-group

    • reductions of values by key-group

  • Generalization of existing array set operation to nd-arrays, such as:

    • unique

    • union

    • difference

    • exclusive (xor)

    • contains / in (in1d)

  • Some new functions:

    • indices: numpy equivalent of list.index

    • count: numpy equivalent of collections.Counter

    • mode: find the most frequently occuring items in a set

    • multiplicity: number of occurrences of each key in a sequence

    • count_table: like R’s table or pandas crosstab, or an ndim version of np.bincount

Some brief examples to give an impression hereof:

# three sets of graph edges (doublet of ints)
edges = np.random.randint(0, 9, (3, 100, 2))
# find graph edges exclusive to one of three sets
ex = exclusive(*edges)
print(ex)
# which edges are exclusive to the first set?
print(contains(edges[0], ex))
# where are the exclusive edges relative to the totality of them?
print(indices(union(*edges), ex))
# group and reduce values by identical keys
values = np.random.rand(100, 20)
# and so on...
print(group_by(edges[0]).median(values))

Installation

> conda install numpy-indexed -c conda-forge

or

> pip install numpy-indexed

See: https://pypi.python.org/pypi/numpy-indexed

Design decisions:

This package builds upon a generalization of the design pattern as can be found in numpy.unique. That is, by argsorting an ndarray, many subsequent operations can be implemented efficiently and in a vectorized manner.

The sorting and related low level operations are encapsulated into a hierarchy of Index classes, which allows for efficient lookup of many properties for a variety of different key-types. The public API of this package is a quite thin wrapper around these Index objects.

The two complex key types currently supported, beyond standard sequences of sortable primitive types, are ndarray keys (i.e, finding unique rows/columns of an array) and composite keys (zipped sequences). For the exact casting rules describing valid sequences of key objects to index objects, see as_index().

Todo and open questions:

  • There may be further generalizations that could be built on top of these abstractions. merge/join functionality perhaps?

Metadata

Release files for numpy-indexed 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for numpy-indexed 0.3.7
File Interpreter ABI Platform Actions
numpy_indexed-0.3.7-py2.py3-none-any.whl Python 3, Python 2 none any Details for numpy_indexed-0.3.7-py2.py3-none-any.whl

Release files / numpy_indexed-0.3.7-py2.py3-none-any.whl

Download URL numpy_indexed-0.3.7-py2.py3-none-any.whl
Size 19.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3e9f8f5ca453e49809618b3717b8ce07551b616a4ae43069c46aaad286386a9e
BLAKE2b-256 checksum
How to use checksums
51a228e87c9255c4a2ead7a1253f48296faa1e5a86273f99da74a0ff9619f583
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.16

Security for numpy-indexed 0.3.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page