{"id":22177885,"url":"https://github.com/gasinan/bitwiseround","last_synced_at":"2025-03-24T18:26:13.218Z","repository":{"id":204150916,"uuid":"711167230","full_name":"GasinAn/bitwiseround","owner":"GasinAn","description":"Fast bitwise rounding for low-rate lossy compression","archived":false,"fork":false,"pushed_at":"2024-11-28T14:39:10.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T23:16:14.135Z","etag":null,"topics":["bitwise","round"],"latest_commit_sha":null,"homepage":"","language":"C","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/GasinAn.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":"2023-10-28T12:15:30.000Z","updated_at":"2024-11-28T14:36:25.000Z","dependencies_parsed_at":"2023-11-12T13:27:24.848Z","dependency_job_id":"12d457b7-1b6f-4ef4-8e48-3a22cf188255","html_url":"https://github.com/GasinAn/bitwiseround","commit_stats":null,"previous_names":["gasinan/bitround","gasinan/bitwiseround"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GasinAn%2Fbitwiseround","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GasinAn%2Fbitwiseround/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GasinAn%2Fbitwiseround/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GasinAn%2Fbitwiseround/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GasinAn","download_url":"https://codeload.github.com/GasinAn/bitwiseround/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245326837,"owners_count":20597097,"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":["bitwise","round"],"created_at":"2024-12-02T08:33:10.110Z","updated_at":"2025-03-24T18:26:13.198Z","avatar_url":"https://github.com/GasinAn.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bitwiseround\n\nFast bitwise rounding for low-rate lossy compression\n\n## Overview\n\nThe Numpy ufunc `bitwiseround.bitwise_round` makes bitwise rounding for floats. It takes two inputs: $a$ and $d$. It modifies $a$ to $\\text{sgn}(a) \\cdot \\text{round}(\\text{abs}(a)/2^{n}) \\cdot 2^{n}$, where $n = \\text{floor}(\\log_{2}(d)) + 1$. After bitwise rounding, elements in $a$ will have more bits with the value of $0$ at the ends. This makes `bitwiseround.bitwise_round` cooperate with [Bitshuffle](https://github.com/kiyo-masui/bitshuffle) compression well. It will make the compression rate lower, while leading to a loss of precision controlled by $d$.\n\n## Warning\n\nAt this moment, `bitwiseround.bitwise_round` works only for float64s.\n\nThe behavior of `bitwiseround.bitwise_round` is UNDEFINED when one of the following situations holds:\n\n * $d$ is not a positive normal number;\n * $a$ is a subnormal number;\n * $\\text{floor}(\\log_{2}(a)) - \\text{floor}(\\log_{2}(d)) \\leq 1022$.\n\n## Installation\n\n### Building from Source\n\n[build](https://pypa-build.readthedocs.io/en/stable/), [Setuptools](https://setuptools.pypa.io/en/latest/), [Numpy](https://numpy.org/) and a C compiler (such as [GCC](https://gcc.gnu.org/)) should be installed first.\n\n```\ngit clone https://github.com/GasinAn/bitwiseround.git\ncd bitwiseround\npython -m build -n\n```\n\nThen the package can be installed by using [pip](https://pip.pypa.io/en/stable/):\n\n```\npip install dist/*.whl\n```\n\nNow LEAVE the `bitwiseround` directory to use the package.\n\n## Example\n\n```python\nimport numpy\nimport h5py\nimport bitshuffle.h5\n\nfrom bitwiseround import bitwise_round\n\nfile = h5py.File('example.hdf5', 'w')\n\ndataset = file.create_dataset(\n    'data',\n    (100, 100, 100),\n    compression=bitshuffle.h5.H5FILTER,\n    compression_opts=(0, bitshuffle.h5.H5_COMPRESS_LZ4),\n    dtype='float64',\n    )\n\ndata = numpy.random.rand(100, 100, 100)\ndata = data.astype('float64')\n\n# Use bitwise_round here!\nbitwise_round(data, 0.333)\n\ndataset[...] = data\n\nfile.close()\n```\n\n## See also\n\n * [Bitshuffle](https://github.com/kiyo-masui/bitshuffle)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgasinan%2Fbitwiseround","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgasinan%2Fbitwiseround","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgasinan%2Fbitwiseround/lists"}