Skip to main content

Library for generating and working with binary sequences.

Project description

bseqgen

Current Version: 0.1.2

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bseqgen-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b09ce47ef0a213efb824f9fdc80986ad25b2a3ccab80454bc69eeba672a22838
MD5 24ee6d5ba40d05f80261a2c19a7adb89
BLAKE2b-256 286289264540c1312e07babf583d27d23739cb39936c58843b4260103977d468

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bseqgen-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d8f1559f87e4439ccc7b4f3de7d514bbc8534e850d8c082ad354dc3eb95e93f6
MD5 fdb11038bd8473804c4a04816820b88e
BLAKE2b-256 b37b951e8cd4b15ede9d468e4748970ce52436844caaf05793f5b923da72a482

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