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 hashes)

Uploaded Source

Built Distribution

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

Uploaded CPython 3.9 macOS 10.9+ x86-64

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