Skip to main content

a numpy.ndarray subclass that does fixed-point arithmetic

Project description

numfi

numfi is a numpy.ndarray subclass that does fixed-point arithmetic.

Feature:

  • Automatically perform fixed-point arithmetic through overloaded operators

  • Maximum compatibility with numpy and other library, just like a normal numpy.ndarray

  • Optimized calculation speed by minimizing quantization as much as possible

Install

Prerequisite: python3 and numpy

pip install numfi

or you can just copy numfi.py and do whatever you want, after all it's only 200 lines of code

Quick start

from numfi import numfi

# numfi(array=[], signed=1, bits_word=32, bits_frac=16, rounding='round', overflow='wrap')
x = numfi(np.random.rand(3,3),1,16,8) 

# any arithmetic operation with numfi will return a numfi object with proper precision and value
y = x + 1 
z = x * 2
w = np.sin(x)
...

Document

Details can be found here: https://numfi.readthedocs.io/en/latest/?

License

The project is licensed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

numfi-0.2.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file numfi-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: numfi-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for numfi-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0cb8cbfe0f6d15ee68ea6fa93893739474f7438858a6613f1222dddc7f7f927d
MD5 d4a328479269de428649830fcf372c66
BLAKE2b-256 b4643a880a8f25f3e6fd4e01ebee196f8f273ebe9a1ff66e76b61677efbf0fb6

See more details on using hashes here.

Supported by

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