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)
- 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^, &, |). invertedto get inverted sequence (or use~).to_numpy()andfrom_numpy()for NumPy interop.- Use
random_sequenceto generate a random binary sequence.
pip install bseqgenfrom 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)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.
MIT
Found a bug or want a feature? Please open an issue on GitHub:
https://github.com/bloopy-code/bseqgen/issues