Skip to main content

Arbitrary precision ball arithmetic (interval arithmetic) dtype in NumPy

Project description

numpy-flint-arb

CI Status Documentation Status Test coverage percentage

uv Ruff pre-commit

PyPI Version Supported Python versions License


Documentation: https://numpy-flint-arb.readthedocs.io

Source Code: https://github.com/34j/numpy-flint-arb


Arbitrary precision ball arithmetic (interval arithmetic) dtype in NumPy

Installation

Install this via pip (or your favourite package manager):

pip install numpy-flint-arb

Usage

Import numpy_flint_arb.np instead of numpy:

A = np.random.normal(size=(2, 2))
b = np.random.normal(size=(2,))
x = np.linalg.solve(A, b)
b_approx = A @ x
assert np.all(np.contains(b_approx, b))

What it does

  • This package adds a flarray which subclasses ndarray in order to
    • Override __array_namespace__ to numpy_flint_arb.np
    • Override dtype to return newly added _fl_dtype private attribute, since the actual internal dtype object cannot be overridden.
    • Override __array_finalize__ as recommended by the NumPy docs to return flarray with proper _fl_dtype instead of ndarray after Numpy operations.
  • Partially supports linalg and (scipy.)special functions.
  • Adds tomat() and frommat() to treat flarray as array of arb_mat / acb_mat, so that we can perform matrix operations like np.linalg.solve on flarray.
  • Does not perform any parallelization to avoid complexity and to fully utilize the great python-flint library
    • Using arb_series and acb_series may be faster for additions but this is too hacky.
    • Defining custom dtype is way too complicated
    • Writing C extension would be theoretically also possible but is still too complicated.
  • Does not support in operator since it tries to convert the return value to bool. Use newly added np.contains(x, y) and np.overlaps(x, y) instead.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

34j
34j

💻 🤔 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

Copier

This package was created with Copier and the browniebroke/pypackage-template project template.

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

numpy_flint_arb-1.2.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numpy_flint_arb-1.2.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file numpy_flint_arb-1.2.1.tar.gz.

File metadata

  • Download URL: numpy_flint_arb-1.2.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for numpy_flint_arb-1.2.1.tar.gz
Algorithm Hash digest
SHA256 0643a74aec351d7cf1df98ea65371e0841a4260302f2e0a91324906bf6d7fd73
MD5 62e8f7159b568eb79941d9b259079906
BLAKE2b-256 04803cd743212681dc81d72d123962ea30682c7efb459eb99e0161bc6a6891f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for numpy_flint_arb-1.2.1.tar.gz:

Publisher: ci.yml on 34j/numpy-flint-arb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file numpy_flint_arb-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for numpy_flint_arb-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a47c8d436f4da4b9d2140127b7a4db2b9938b33c11f2d7e9263088b0348106ac
MD5 5706d76b0a9d479cb35c8b0396dc962d
BLAKE2b-256 84a221af6d55eb59ab2d8a97ec4378955c68b22d5607b50faf002e3dea4198a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for numpy_flint_arb-1.2.1-py3-none-any.whl:

Publisher: ci.yml on 34j/numpy-flint-arb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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