Skip to main content

Library for generating and working with binary sequences.

Project description

bseqgen

Current Version: 0.1.4

Small Python library for working with Binary Sequences, with a focus on pseudorandom binary sequences and signal-processing style operations.

Status: Beta (API may evolve and change significantly before v1.0)

PyPI

CI


Features

  • Tuple binary sequence representation.
  • Input validation from strings, lists, tuples, etc.
  • Shift sequences left/right (circular, supports negative shifts).
  • Sequence repetition and truncation.
  • Byte/hex/string representations.
  • Basic sequence metrics (bit counts, balance, basic symbol entropy).
  • bitwise xor, bitwise_and, bitwise_or (or use operators ^, &, |).
  • inverted to get inverted sequence (or use ~).
  • to_numpy() and from_numpy() for NumPy interop.
  • Use random_sequence to generate a random binary sequence.

Installation

pip install bseqgen

Quick Examples

from bseqgen.base import BinarySequence
from bseqgen import random_sequence

# can define your own binary sequence.
seq = BinarySequence("110011")

# or use one that comes with bseqgen
random_seq = random_sequence(n=10)

# enjoy! 
print(seq.bits)
# (1, 1, 0, 0, 1, 1)

print(seq.shift(2).bits)
# (0, 0, 1, 1, 1, 1)

print(seq.ones, seq.zeros)
# 4 2

print(seq.run_lengths)
# [(1, 2), (0, 2), (1, 2)]

print(seq & BinarySequence("111000").bits)
# (1, 1, 0, 0, 0, 0)

print(seq ^ BinarySequence("111000").bits)
# (0, 0, 1, 0, 1, 1)

print(seq | BinarySequence("111000").bits)
# (1, 1, 1, 0, 1, 1)

print(~seq.bits)
# (0, 0, 1, 1, 0, 0)

seq.to_numpy()
# array([1, 1, 0, 0, 1, 1], dtype=uint8)

Roadmap

Planned additions include:

  • PRBS generators (Gold codes, Walsh-Hadamard, Kasami and more)
  • Autocorrelation and cross-correlation operations.
  • Property stats and checks, and guess at what types of codes you might have and if it fits the ideal properties.

License

MIT

Support

Found a bug or want a feature? Please open an issue on GitHub:
https://github.com/bloopy-code/bseqgen/issues

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

bseqgen-0.1.4.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bseqgen-0.1.4-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file bseqgen-0.1.4.tar.gz.

File metadata

  • Download URL: bseqgen-0.1.4.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for bseqgen-0.1.4.tar.gz
Algorithm Hash digest
SHA256 42a3eef722569b8844f9828e1ecbeafb57b6bd7c437f573ce7c2f46f353a04fe
MD5 addcec1e0d42fde8198fef9b3babb0ad
BLAKE2b-256 fe4f91ff472cc0a0282401bbe17dd27385273e00a09b6018c62e989f61c8de5d

See more details on using hashes here.

File details

Details for the file bseqgen-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: bseqgen-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for bseqgen-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2d338c7992f6001596088f21f5f8a555ebf47cf78906ccb0532059b5924fc3df
MD5 02348270516e0f2bef576b9e005c6639
BLAKE2b-256 3d345e710f36093523bb6b93e8b369169379079e215d82800f3af0c7e569537b

See more details on using hashes here.

Supported by

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