Overload NumPy Functions
Project description
Tools for implementing __numpy_function__ on custom functions.
Quick Worked Example
This is a simple example.
First, some imports:
>>> from dataclasses import dataclass >>> from typing import ClassVar >>> import numpy as np >>> from overload_numpy import NumPyOverloader, NDFunctionMixin
Now we can define a overload_numpy.NumPyOverloader instance:
>>> VEC_FUNCS = NumPyOverloader()
The overloads apply to an array wrapping class. Let’s define one:
>>> @dataclass ... class Vector1D(NDFunctionMixin): ... '''A simple array wrapper.''' ... x: np.ndarray ... NP_FUNC_OVERLOADS: ClassVar[NumPyOverloader] = VEC_FUNCS
Now numpy functions can be overloaded and registered for Vector1D.
>>> @VEC_FUNCS.implements(np.concatenate, Vector1D) ... def concatenate(vec1ds: tuple[Vector1D, ...]) -> Vector1D: ... return Vector1D(np.concatenate(tuple(v.x for v in vec1ds)))
Time to check this works:
>>> vec1d = Vector1D(np.arange(3)) >>> newvec = np.concatenate((vec1d, vec1d)) >>> newvec Vector1D(x=array([0, 1, 2, 0, 1, 2]))
Great. Your turn!
Details
See the Docs.
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
Built Distributions
File details
Details for the file overload_numpy-0.0.1.tar.gz
.
File metadata
- Download URL: overload_numpy-0.0.1.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e60ced859883509b45b0d9c0676cb8e34ff75c414ade5173aceea04f06e1ee6e |
|
MD5 | 4fec3673eb99f23e628bfcbf0d486d96 |
|
BLAKE2b-256 | 9d7fbe3210590b4488875486109159e8a2a196366bd8eb4f264a3b83bbb09fc1 |
File details
Details for the file overload_numpy-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 011aa5b5ff8c5a9b1248f10513f978b560eb5ff82c595fd9d35025bab8a051c5 |
|
MD5 | a0b70fa90a939d3833b2e86bb1212a8f |
|
BLAKE2b-256 | c3b9c928ca07a6701f320a307fcdf200f260487c34eaf978c3b1184b04b933c3 |
File details
Details for the file overload_numpy-0.0.1-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 72.8 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c0d3ec7f9c880dc3e23fbff25b5b049e6cf55293347f9e5b6c8eb5df4d39865 |
|
MD5 | e8516243c4322b028912931da4e9c45f |
|
BLAKE2b-256 | 45c0b62efc4ee224b717a3368dfc6746fc7d8e04ff1bf2e5bec230b77f289227 |
File details
Details for the file overload_numpy-0.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 162.0 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6f05f385e9ac62c37b5ec4b36e67932458f1cf4a638be6970310f7c2fe78032 |
|
MD5 | 96b589c08032566dee911bba5349a46f |
|
BLAKE2b-256 | 19eb952d3c6986635e01c9b949fc09961da02feb8c9053dea56be578cc80bb52 |
File details
Details for the file overload_numpy-0.0.1-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 88.6 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff951574ceb2f5c8a54b6f0015497b9482ffdae9b2569c6bd167fe5282f0a5c2 |
|
MD5 | 7eb2bc397e7fddd6960d8212a1f30e45 |
|
BLAKE2b-256 | 5a78d0c8f777296100ddbdebb5d083acb7b2aacdd8b917675e42ac811ee17b7a |
File details
Details for the file overload_numpy-0.0.1-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 90.6 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0890d5114f196f663a7ead85506d9a236579bb878e02413b61d453c0400303d0 |
|
MD5 | 5fb122409467ed39b8830956655d5ea5 |
|
BLAKE2b-256 | 16d50f5c1cd03fe913f44a06a88597226aab28add6103ae43070bbcf1dfc039a |
File details
Details for the file overload_numpy-0.0.1-cp310-cp310-macosx_10_9_universal2.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 166.5 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d38a8372d40cf389c2b3722e1029e8544c27b5fac74c60e82257d53e52853e83 |
|
MD5 | 8c58737d0726eefd70e4875f1f724390 |
|
BLAKE2b-256 | 5fd7c7d71cb1a07087d203577e8f79c7315017aff0e6918060e703d4d1508cb8 |
File details
Details for the file overload_numpy-0.0.1-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 72.7 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2ed7f13f5f326cf515a73089e351bb3660bc76bc848dff64d27f7d6555acea5 |
|
MD5 | ef0f1a127aca449387945da79d4fadbc |
|
BLAKE2b-256 | 3daec242358345e8f1ebecdae5063cefb87ad661d54a01627f745d2adff50eea |
File details
Details for the file overload_numpy-0.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 161.2 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e0b0aca5c31ff76c3d7061abc87ab5b330e8f1737408cce1296691e4d2683c2 |
|
MD5 | f8c1bd787461137a2b65d17e8a351abd |
|
BLAKE2b-256 | 1f6acc25af3ac5477a57adb8e7171df3067f6aa595d99fa3c2e958308351105f |
File details
Details for the file overload_numpy-0.0.1-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 88.6 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9c34f4dd87cb3c73a4d53c7a1d7a5c8873d10226145d179de9cfed801b35805 |
|
MD5 | 0f1a43bcb35b4286750ee9dcbf137b2a |
|
BLAKE2b-256 | 624314b5209da0e70bf5fd52469810b0280e338ce748647f889f051114b213a4 |
File details
Details for the file overload_numpy-0.0.1-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 90.6 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed91554eb9deb4bd36c7637ca13cd1aeb0d958840fd1aa5a3aa0d156cc87ed89 |
|
MD5 | 9b0b9e61fceb1b8cca593d002325c714 |
|
BLAKE2b-256 | ca5c0edb90478070106238484b0c2b2b0ab7b12fd31fe513ecfd3a387b0a5f6d |
File details
Details for the file overload_numpy-0.0.1-cp39-cp39-macosx_10_9_universal2.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 166.6 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d465645b967cbd8cc01c292cdf2257a5f3f0935f9e72dd26beb84513d1422437 |
|
MD5 | c2e03f2e2d21537c05a9d2d8f9a67962 |
|
BLAKE2b-256 | a25f359980af490a78e07f56eee3b950f6c5be98e452e9912e974f4cfd3d302e |
File details
Details for the file overload_numpy-0.0.1-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 72.3 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fa4050bf5a434c3069e42069f8c50d94d29a916ef06d98073cc3efc45a060d3 |
|
MD5 | 153682769c3a471e6976fd1692a3fd04 |
|
BLAKE2b-256 | d684318141617b34bbf67a181bc67365277b66b76a67f2feed53147c328e0278 |
File details
Details for the file overload_numpy-0.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 159.2 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 117892522642f243135f3d7eacd172a51de641d41016ea688fc85d1d246f1894 |
|
MD5 | 57fcf12cd7a1db2a5f315d317e3c2b4f |
|
BLAKE2b-256 | ff7d031626da853a580292cd84e0ef63f3e167e1d2e437bff03e819874ecfc34 |
File details
Details for the file overload_numpy-0.0.1-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 87.5 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25787a2f51c100d6dbd178775bd09dee7de282a450d4fd81bacac7387f47da26 |
|
MD5 | f6d26df67a51d68a5512c8f18b4f70e5 |
|
BLAKE2b-256 | 79e25512397aa3f2b15233772b0ca91a7d7c72cb52b339943008def4f28fb263 |
File details
Details for the file overload_numpy-0.0.1-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 89.1 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d357290586b6463110d5d17a5ad3c7052329cc738937d1af6cc8b768643f7a2 |
|
MD5 | 485110efe54362b96ea470a6cffee596 |
|
BLAKE2b-256 | 7a7bc58f28efc51c80475f028bc3b881a60782d39abba98f94a5b562836bbabb |
File details
Details for the file overload_numpy-0.0.1-cp38-cp38-macosx_10_9_universal2.whl
.
File metadata
- Download URL: overload_numpy-0.0.1-cp38-cp38-macosx_10_9_universal2.whl
- Upload date:
- Size: 163.8 kB
- Tags: CPython 3.8, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff87e4b3f7239d9ebdced6a87c0d2a2e0cb816ecca3ec7b31f382e1c22f063ba |
|
MD5 | b40fcad619f559c82c2a867a21bed4df |
|
BLAKE2b-256 | bd1e0292d1897329c283c184428ad6491cbf2066739dc6be24a88e2f3327aee4 |