Skip to main content

Some useful extensions for NumPy

Project description

npx

PyPi Version PyPI pyversions GitHub stars PyPi downloads

gh-actions codecov LGTM Code style: black

NumPy is a large library used everywhere in scientific computing. That's why breaking backwards-compatibility comes as a significant cost and is almost always avoided, even if the API of some methods is arguably lacking. This package provides drop-in wrappers "fixing" those.

scipyx does the same for SciPy.

If you have a fix for a NumPy method that can't go upstream for some reason, feel free to PR here.

dot

npx.dot(a, b)

Forms the dot product between the last axis of a and the first axis of b.

(Not the second-last axis of b as numpy.dot(a, b).)

np.solve

npx.solve(A, b)

Solves a linear equation system with a matrix of shape (n, n) and an array of shape (n, ...). The output has the same shape as the second argument.

sum_at/add_at

npx.sum_at(a, idx, minlength=0)
npx.add_at(out, idx, a)

Returns an array with entries of a summed up at indices idx with a minumum length of minlength. idx can have any shape as long as it's matching a. The output shape is (minlength,...).

The numpy equivalent numpy.add.at is much slower:

memory usage

Relevant issue reports:

unique_rows

npx.unique_rows(a, return_inverse=False, return_counts=False)

Returns the unique rows of the integer array a. The numpy alternative np.unique(a, axis=0) is slow.

Relevant issue reports:

isin_rows

npx.isin_rows(a, b)

Returns a boolean array of length len(a) specifying if the rows a[k] appear in b. Similar to NumPy's own np.isin which only works for scalars.

License

This software is published under the BSD-3-Clause license.

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

npx-0.0.14.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

npx-0.0.14-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file npx-0.0.14.tar.gz.

File metadata

  • Download URL: npx-0.0.14.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for npx-0.0.14.tar.gz
Algorithm Hash digest
SHA256 9a69824825482bb059e5283ad4df04180c4938f6301757cb66a48ff0910b9ca9
MD5 95fa204407def1a9a7106b3a4f6bd3a8
BLAKE2b-256 3ebfe639661f98554909bb470f5a4ae4154775b2131b311611d4d1ff47e7bae2

See more details on using hashes here.

File details

Details for the file npx-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: npx-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for npx-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 4615d6b172893f551b3c2b4b5381f65766b5553583d61ec3d4bb4279ddfd8dab
MD5 b0f1f35654007fa8e7ff0243b4ffe76c
BLAKE2b-256 fa347da4529b99c28478e8e1aba9eb504dad3e547ecfca937cc8c362caf1d02a

See more details on using hashes here.

Supported by

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