Metadata-Version: 2.4
Name: bseqgen
Version: 0.1.4
Summary: Library for generating and working with binary sequences.
Project-URL: Homepage, https://github.com/bloopy-code/bseqgen
Project-URL: Repository, https://github.com/bloopy-code/bseqgen.git
Project-URL: Issues, https://github.com/bloopy-code/bseqgen/issues
Project-URL: Changelog, https://github.com/bloopy-code/bseqgen/blob/main/CHANGELOG.md
Author: bloopycode
License-File: LICENSE
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# 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](https://img.shields.io/pypi/v/bseqgen)

[![CI](https://github.com/bloopy-code/bseqgen/actions/workflows/main.yml/badge.svg)](https://github.com/bloopy-code/bseqgen/actions/workflows/main.yml)

---

## 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

```bash
pip install bseqgen
```

---

## Quick Examples

```python
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>
