Nani
Nani is a Python library that provides an alternative approach to defining and viewing NumPy’s arrays.
Upon getting started with NumPy, the rules to define numpy.dtype objects tend to quickly become confusing. Not only different syntaxes can create a same data type, but it also seems arbitrary and hence difficult to remember that sub-array data types can only be defined as tuples while structured data types exclusively require lists made of field tuples, and so on.
To address this point, Nani takes the stance of offering one—and only one—way of constructing numpy.dtype objects. Although this syntax makes the code more verbose, it also makes it easier to read and to reason about.
Nani’s approach allows type introspection which brings additional benefits in the form of dynamically generated default values and view types. Default values facilitate the definition of new array elements while view types are useful to encapsulate interactions with NumPy and to expose a different public interface to your library users instead of the one provided with numpy.ndarray.
Features
explicit syntax for defining numpy.dtype objects.
generates default values and view types.
allows for type introspection.
Usage
>>> import numpy
>>> import nani
>>> color_type = nani.Array(
... element_type=nani.Number(type=numpy.uint8, default=255),
... shape=3,
... view=None)
>>> dtype, default, view = nani.resolve(color_type, name='Color')
>>> a = numpy.array([default] * 2, dtype=dtype)
>>> v = view(a)
>>> for color in v:
... print(color)
[255, 255, 255]
[255, 255, 255]
The color_type above defines an array of 3 numpy.uint8 elements having each a default value of 255. The resulting dtype and default objects are used to initialize a new NumPy array of 10 color elements, while the view type is used to wrap that array into a standard collection interface.
See the Tutorial section from the documentation for more detailed examples and explanations on how to use Nani.
Documentation
Read the documentation online at nani.readthedocs.io or check its source in the doc directory.
Metadata
Release files for nani 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nani-0.2.0.tar.gz | 28.2 kB | Without provenance | Details for nani-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nani-0.2.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for nani-0.2.0-py2.py3-none-any.whl |
Total release size: 41.4 kB
Release files / nani-0.2.0.tar.gz
| Download URL | nani-0.2.0.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
301d5c52c48c95fc82999560925a6f5fd2e74e91dab4b8b4d28e1c71aef0b9b9
|
|
BLAKE2b-256 checksum How to use checksums |
552cf0dcf343c4c52b9ac6e7356d6c0e3af80bd323ae516ddd415ae27f342d9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / nani-0.2.0-py2.py3-none-any.whl
| Download URL | nani-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a21b9bed0d538ab33cbcd53bfdf1f483ce8394c1b18eda6b4101bc9418b4fc48
|
|
BLAKE2b-256 checksum How to use checksums |
e2b007986113daee52c877ce33a5a576df593ad0b056d1bdce70a1786825a613
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for nani 0.2.0
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.