Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

numpy-flint

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

numpy-flint

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

  • 0.3.4
  • PyPI
  • Socket score

Maintainers
1

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/.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc