Skip to main content

Add a rounded floating point interval (flint) dtype to NumPy

Project description

Rounded Floating Point Arithmetic

This package implements a rounded floating point intervals or flint data-type in python and NumPy. The floating point interval type contains a pair of numbers that define the endpoint of an interval, and the exact value of a computation always lies somewhere in that interval. This type addresses one shortcoming of floating point numbers: equality comparisons. For this package, the equality operator for flints is implemented such that any overlap of the interval will be treated as equal, and should be though of as 'could be equal'.

To use in python, import the flint package and declare the number as a flint type.

from flint import flint

# Floating point numbers sometimes don't make sense
a = 0.2
b = 0.6
# This evaluate to False
print( (a+a+a) == b )

# Rounded floating point intervals will fix these issues
x = flint(0.2)
y = flint(0.6)
# This evalautes to True
print( (x+x+x) == y )

To use with NumPy, import NumPy as well and mark the array's dtype as flint.

import numpy as np
from flint import flint

a = np.fill((3,), 0.2, dtype=flint)
b = flint(0.6)
# This evaluates to True
print( np.sum(a) == b )

Further useage examples as well as a full API can be found on the project homepage

Installation

Binary packages are avialable from PyPI. Use pip to install the binary package.

> python -m pip install numpy-flint

If there not a version for your system, you can visit the project homepage which has instructions on building from source or contributing to the project.

License

Copyright (c) 2023, Jef Wagner

Numpy-flint is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Numpy-flint is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Numpy-flint. If not, see https://www.gnu.org/licenses/.

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-0.3.4.tar.gz (146.9 kB view hashes)

Uploaded Source

Built Distributions

numpy_flint-0.3.4-cp311-cp311-win_amd64.whl (70.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

numpy_flint-0.3.4-cp311-cp311-win32.whl (64.3 kB view hashes)

Uploaded CPython 3.11 Windows x86

numpy_flint-0.3.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (167.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

numpy_flint-0.3.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (175.6 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_flint-0.3.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (154.6 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

numpy_flint-0.3.4-cp311-cp311-macosx_11_0_arm64.whl (61.8 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

numpy_flint-0.3.4-cp311-cp311-macosx_10_9_x86_64.whl (66.2 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

numpy_flint-0.3.4-cp310-cp310-win_amd64.whl (70.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

numpy_flint-0.3.4-cp310-cp310-win32.whl (64.3 kB view hashes)

Uploaded CPython 3.10 Windows x86

numpy_flint-0.3.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (167.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

numpy_flint-0.3.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (175.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_flint-0.3.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (154.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

numpy_flint-0.3.4-cp310-cp310-macosx_11_0_arm64.whl (61.8 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

numpy_flint-0.3.4-cp310-cp310-macosx_10_9_x86_64.whl (66.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

numpy_flint-0.3.4-cp39-cp39-win_amd64.whl (70.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

numpy_flint-0.3.4-cp39-cp39-win32.whl (64.2 kB view hashes)

Uploaded CPython 3.9 Windows x86

numpy_flint-0.3.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (166.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

numpy_flint-0.3.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (175.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_flint-0.3.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (154.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

numpy_flint-0.3.4-cp39-cp39-macosx_11_0_arm64.whl (61.8 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

numpy_flint-0.3.4-cp39-cp39-macosx_10_9_x86_64.whl (66.2 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

numpy_flint-0.3.4-cp38-cp38-win_amd64.whl (70.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

numpy_flint-0.3.4-cp38-cp38-win32.whl (64.2 kB view hashes)

Uploaded CPython 3.8 Windows x86

numpy_flint-0.3.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (168.0 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

numpy_flint-0.3.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (176.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_flint-0.3.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (155.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

numpy_flint-0.3.4-cp38-cp38-macosx_11_0_arm64.whl (61.8 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

numpy_flint-0.3.4-cp38-cp38-macosx_10_9_x86_64.whl (66.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

numpy_flint-0.3.4-cp37-cp37m-win_amd64.whl (70.2 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

numpy_flint-0.3.4-cp37-cp37m-win32.whl (64.2 kB view hashes)

Uploaded CPython 3.7m Windows x86

numpy_flint-0.3.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (164.5 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

numpy_flint-0.3.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (172.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_flint-0.3.4-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (152.1 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

numpy_flint-0.3.4-cp37-cp37m-macosx_10_9_x86_64.whl (65.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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