Utility library that provides a floating point type with tolerance for equality comparisons
Project description
fuzzyfloat
A utility library that provides transparent floating point types with tolerances for equality comparison.
Getting Started
>>>from fuzzyfloat import rel_fp
>>>value = rel_fp(100)
>>>value == 100
True
>>>value == 99.99999999
True
>>>value == 100.00000001
True
>>>value = 1000
>>>value == 1000.0000001
True
>>>value = 10000
>>>value == 10000.000001
True
>>>value = 100000
>>>value == 100000.00001
True
>>>from fuzzyfloat import abs_fp
>>>value = abs_fp(100)
>>>value = 100000
>>>value == 100000.00001
False
>>>value == 100000.00000001
True
Setting different tolerances
from fuzzyfloat import FuzzyFloatMeta
class my_fp(metaclass=FuzzyFloatMeta, rel_tol=1e-05, atol=0.01):
pass
Using a different underlying type
import numpy as np
from fuzzyfloat import FuzzyFloatMeta
class np_fp(metaclass=FuzzyFloatMeta, ftype=np.float128):
pass
class c_fp(metaclass=FuzzyFloatMeta, ftype=complex):
pass
Limitations
Any operations provided by the operators module will propogate the class type (and therefore the tolerances).
However, there are many other functions, especially those that touch c extensions, where the type information will
be lost, such as math.sqrt()
.
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
fuzzyfloat-1.0.3.tar.gz
(2.7 kB
view details)
Built Distribution
File details
Details for the file fuzzyfloat-1.0.3.tar.gz
.
File metadata
- Download URL: fuzzyfloat-1.0.3.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5aeaaf6095b24179d2bc6132175d877d8ec3972a10cf09e6b5eb73fcc4bb8a7 |
|
MD5 | 6f758b8b4d5892dd86cdde1f5e561591 |
|
BLAKE2b-256 | 464748222255763bbd19b3604ece45bdb1eb7fba0238a01a29191e7e8cc354b4 |
File details
Details for the file fuzzyfloat-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: fuzzyfloat-1.0.3-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 161295469f25a69436bebb7b5ae65e3570a12f273ab443c450c8ba187c0f1a13 |
|
MD5 | 7b1633b9a79071ca97c49cb17d00687c |
|
BLAKE2b-256 | e761173ce7ecd9b41ad3bd59c654b04b443c8ecc2d29e882fa7698c405e56713 |