Skip to main content

Pack and unpack 1, 2 and 4 bit data to/from 8-bit numpy arrays.

Project description

numbits

Tests

Pack and unpack 1, 2 and 4 bit data to/from 8-bit numpy arrays

Motivated by radio astronomy, where low bitwidths are common.

Project built with pybind11. Pack/unpack code based on sigpyproc.

Installation

On Unix (Linux, OS X)

You can either:

  • Install numbits from PyPI with:

    pip install numbits
    

or you can:

  • Clone this repository. and then:

    • Build shared object .so locally, using:

      python setup.py build_ext -i
      
    • Or install the package globally, using:

      python -m pip install .
      

      or:

      python setup.py install
      

Test call

import numpy as np
import numbits
a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8], dtype='uint8')
b = numbits.unpack(a, nbits=2)

>>> array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 1, 0, 0, 0,
           1, 1, 0, 0, 1, 2, 0, 0, 1, 3, 0, 0, 2, 0], dtype=uint8)

Project details


Download files

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

Source Distribution

numbits-0.0.1.tar.gz (62.9 kB view details)

Uploaded Source

Built Distribution

numbits-0.0.1-cp39-cp39-macosx_10_9_x86_64.whl (55.6 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file numbits-0.0.1.tar.gz.

File metadata

  • Download URL: numbits-0.0.1.tar.gz
  • Upload date:
  • Size: 62.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for numbits-0.0.1.tar.gz
Algorithm Hash digest
SHA256 be07e05245ced1d8081b60a0bd10dbde2cab50c3b155ed4047c03536b1ee8d00
MD5 4a49c08d2b4e274826dce0bd75dd57ab
BLAKE2b-256 963ca80333ba4bbfaeb94cd0fb493879dff9887fcfd93742b86096d6fb389d81

See more details on using hashes here.

File details

Details for the file numbits-0.0.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: numbits-0.0.1-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 55.6 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for numbits-0.0.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9cb83a61a7e96c54adc7a0dc8ba46085d87ef3718155e9903f9ce571ee52e895
MD5 8db01a14f6984e35ba187877e3bd3060
BLAKE2b-256 6283f8a8256ba525b0f88ae312a9c7b3a3763a44c47d593c6deb14aceb3f57c2

See more details on using hashes here.

Supported by

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