pyPhix, the Python Fixed Point module
pyPhix is a python package for fixed point number representation. It is intended to support the implementation of digital signal processing systems. As such only fix-point addition, subtraction and multiplication operations are implemented.
You can find more information about the module objects and functionalities at readthedocs project page.
Features
- virtually unlimited number length (depending on your RAM size)
- based on NumPy
- customizable rounding method (
SymInf,SymZero,NonSymPos,NonSymNeg,ConvEven,ConvOdd,Floor,Ceil) - customizable wrapping method (
Sat,Wrap) - support various representation formats (
bin,hex,int,float) - perform single or array based operations with customizable output format (
+,-,*)
License
pyPhix
pyPhix is an open source python module released under the terms of Mozilla Public License Version 2.0.
NumPy
NumPy is the fundamental package needed for scientific computing with Python and it is released under these terms.
Install
The pyPhix package is available on pypi.org. You can install it by running:
$ pip install pyphix.
Alternatively you can clone the pyPhix repository and from the folder containing the setup.py file run:
$ python setup install
This package requires Python 3.6 to work.
You can also directly download the tar.gz archive from pypi.org. The archive can be easily verified by adding the gpg public key 1E948096166391C0 to your keyring.
Usage Examples
Fix Format
This object is used to indicate the number of bits the user wants to use for value reprensetation.
Create fix-point format objets:
>>> from pyphix import fix
>>> fmt_a=fix.FixFmt(True, 2, 10)
>>> fmt_b=fix.FixFmt(False, 0, 7)
Print the maximum representable ranges and test if a value is included in the range:
>>> fmt_a.fixrange
(-4.0, 3.9990234375)
>>> fmt_b.fixrange
(0.0, 0.9921875)
>>> -10 in fmt_a
False
>>> 0 in fmt_b
True
Different representations are available:
>>> fmt_a.tuplefmt
(True, 2, 10)
>>> fmt_b.listfmt
[False, 0, 7]
>>> print(fmt_b)
(False, 0, 7)
Fix Number
This object contain fix-point number represenation.
Round methods comparison, assuming format (True, 4, 5):
| Round method | Pos odd fraction | Pos even fraction | Neg odd fraction | Neg even fraction |
|---|---|---|---|---|
| Real value | 7.296875 | 2.325 | -1.078125 | -1.08125 |
| Mult by 2^5 | 233.5 | 74.4 | -34.5 | -34.6 |
SymInf |
7.3125 | 2.3125 | -1.09375 | -1.09375 |
SymZero |
7.28125 | 2.3125 | -1.0625 | -1.09375 |
NonSymPos |
7.3125 | 2.3125 | -1.0625 | -1.09375 |
NonSymNeg |
7.28125 | 2.3125 | -1.09375 | -1.09375 |
ConvEven |
7.3125 | 2.3125 | -1.0625 | -1.09375 |
ConvOdd |
7.28125 | 2.3125 | -1.09375 | -1.09375 |
Floor |
7.28125 | 2.3125 | -1.09375 | -1.09375 |
Ceil |
7.3125 | 2.34375 | -1.0625 | -1.0625 |
A small usage example:
>>> from pyphix import fix
>>> from pyphix.fix import ERoundMethod, EOverMethod
>>> fmt = fix.FixFmt(True, 4, 5)
>>> fix_vec = fix.FixNum(
[7.296875, 2.325 , -1.078125, -1.08125], fmt,
rnd=ERoundMethod.CONV_ODD, over=EOverMethod.WRAP)
>>> fix_val = fix.FixNum(
1.16, fmt,
rnd=ERoundMethod.CONV_ODD, over=EOverMethod.WRAP)
Perform a full resolution addition:
>>> fix_vec + fix_val
[8.4375 3.46875 0.0625 0.0625 ]
fmt: (True, 5, 5)
rnd: ERoundMethod.CONV_ODD
over: EOverMethod.WRAP
Perform a multiplication and cast result to a small format:
>>> fix_val.mult(
fix_vec, out_fmt=fix.FixFmt(False, 3, 2),
rnd=ERoundMethod.SYM_INF, over=EOverMethod.SAT)
[7.75 2.75 0. 0. ]
fmt: (False, 3, 2)
rnd: ERoundMethod.SYM_INF
over: EOverMethod.SAT
Metadata
Release files for pyPhix 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyPhix-0.1.tar.gz | 11.4 kB | Without provenance | Details for pyPhix-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyPhix-0.1-py3-none-any.whl | Python 3 | none | any | Details for pyPhix-0.1-py3-none-any.whl |
Total release size: 23.4 kB
Release files / pyPhix-0.1.tar.gz
| Download URL | pyPhix-0.1.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8cb87ee23c280fb8a506904b9d7f8d80cd97cf89eea6fe4efe90857e3eb841cf
|
|
BLAKE2b-256 checksum How to use checksums |
e93208bebf0e22dc65f5a7c72f4769ded3760a01eaeadd5b1a309592307ae65e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.4
|
Release files / pyPhix-0.1-py3-none-any.whl
| Download URL | pyPhix-0.1-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f421cae379f0603178c4ffb01b069dbe1c9c2a6891498b728d9a7842b0bc5680
|
|
BLAKE2b-256 checksum How to use checksums |
79cb5b89e63acddfeb8b33b75d70dcfe4c9f568ae4f11de6f8630093cbcd7655
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.4
|
Security for pyPhix 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.