{"id":24350919,"url":"https://github.com/zzzzzzzzac/numfi","last_synced_at":"2025-04-09T23:07:38.918Z","repository":{"id":49152888,"uuid":"361585504","full_name":"ZZZZzzzzac/numfi","owner":"ZZZZzzzzac","description":"a subclass of numpy.ndarray that does fixed-point arithmetic","archived":false,"fork":false,"pushed_at":"2025-03-25T08:30:26.000Z","size":1069,"stargazers_count":13,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T23:07:33.456Z","etag":null,"topics":["dsp","fixed-point","fpga","numpy","numpy-arrays","simulation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZZZZzzzzac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-26T01:48:17.000Z","updated_at":"2025-03-25T08:30:29.000Z","dependencies_parsed_at":"2024-07-16T05:12:55.064Z","dependency_job_id":"b3ed8ed6-6335-4431-bea4-bb2556a63290","html_url":"https://github.com/ZZZZzzzzac/numfi","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZZZZzzzzac%2Fnumfi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZZZZzzzzac%2Fnumfi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZZZZzzzzac%2Fnumfi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZZZZzzzzac%2Fnumfi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZZZZzzzzac","download_url":"https://codeload.github.com/ZZZZzzzzac/numfi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125624,"owners_count":21051770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dsp","fixed-point","fpga","numpy","numpy-arrays","simulation"],"created_at":"2025-01-18T14:38:09.954Z","updated_at":"2025-04-09T23:07:38.913Z","avatar_url":"https://github.com/ZZZZzzzzac.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [numfi](https://github.com/ZZZZzzzzac/numfi)\n\nnumfi is a numpy.ndarray subclass that does fixed-point arithmetic.\n\nFeature:  \n\n- Automatically perform fixed-point arithmetic through overloaded operators\n\n- Maximum compatibility with numpy and other library, just like a normal numpy.ndarray  \n\n- Optimized calculation speed, and keep bit precision as much as possible\n\n- mimic the behavior of matlab's fixed-point toolbox\n\n## Install\n\n**Prerequisite**: python3 and numpy\n\n```bash\npip install numfi\n```\n\nor you can just copy [numfi.py](https://github.com/ZZZZzzzzac/numfi/blob/master/numfi/numfi.py) and do whatever you want, after all it's only 300 lines of code\n\n## Quick start\n\n```python\nfrom numfi import numfi as fi\nimport numpy as np\n\n# numfi(array=[], s=1, w=16, f=None, RoundingMethod='Nearest', OverflowAction='Saturate')\nx = fi([1,0,0.1234],1,16,8) \n# print(numfi) return brief description of numfi object: x =\u003e s16/8-N/S\n# s for 'signed', u for 'unsigned', followed by word bits(16) and fraction bits(8), N/S for 'Nearest' and 'Saturate` for rounding/overflow method\n\n# any arithmetic operation with numfi will return a numfi object with proper precision and value\n# By overloading operators, numfi object can do fixed-point arithmetic easily:\n\n# normal arithmetic operation work with float form of x\ny = x + 1\ny = [1] - x\ny = x * [3,0,-3]\ny = fi([1,0,0.1234],1,21,15) / x\ny = -x\ny = x ** 0.5\ny = x % 3\n# comparison return np.array of bool, just like normal np.array\ny = x \u003e 0.5\ny = x \u003e= fi([1,0,0.1234],1,21,15)\ny = x == x\ny = x \u003c= np.ones(3)\ny = x \u003c [1,1,1]\n# bitwise operation work with integer form of x\ny = x \u0026 0b101 \ny = 0b100 | x   # order of operands doesn't matter\ny = x ^ x       # two numfi object can also be used in bitwise operations\ny = x \u003c\u003c 4\ny = x \u003e\u003e 2\n...\n\n# numfi object can be used just like normal numpy array, and return same numfi object back\ny = np.sin(x)\ny = x[x\u003e1]\ny = x.sum()\ny = x.reshape(3,1)\nnp.convolve(x[0],np.ones(3))\nnp.fft.fft(x,n=512)\nplt.plot(x)\npandas.DataFrame(x)\nf, t, Sxx = scipy.signal.spectrogram(x,nperseg=256,noverlap=128)\nplt.pcolormesh(t, f, Sxx, shading='gouraud')\nfor i in x:\n    print(i)\n...\n```\n\n## Document\n\nDetails can be found here: [https://numfi.readthedocs.io/en/latest/?](https://numfi.readthedocs.io/en/latest/?)\n\n## License\n\nThe project is licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzzzzzzzac%2Fnumfi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzzzzzzzzac%2Fnumfi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzzzzzzzac%2Fnumfi/lists"}