Skip to main content

Library for generating and working with binary sequences.

Project description

bseqgen

Current Version: 0.1.3

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)


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.

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.3.tar.gz (16.8 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.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bseqgen-0.1.3.tar.gz
Algorithm Hash digest
SHA256 389fb7e11fcadf0f9993aab194d1959cdd60251c84381d8f10c06006b803308c
MD5 236e65d4c66ef9183047e8dfdc6d19d6
BLAKE2b-256 779019c471bdd0eefbd54fbfd971ef4ae7591086691855525febbb7441507eed

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for bseqgen-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 19bf5a7a1700d19b36db56e5de45b59564306496081eb1a5c5902668666dcbc9
MD5 4568dffb7f45a576b379748dc9fe9b61
BLAKE2b-256 71f2212a0f1f216e90641cd3ccd23d9ea625c65883109326798ed2a17cf016f7

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