Skip to main content

Python wrapper for fLZc complexity measure (based on https://github.com/lcbarnett/fLZc)

Project description

fLZc_python — Fast Lempel–Ziv Complexity for Python

A Python wrapper around the fLZc C library, implementing the original LZ76c1 and LZ78c2 versions of complexity measures (with optional normalisation) in optimized C, exposed via a clean Python API.

Features

  • LZ76c & LZ78c: exact implementations of the original Lempel–Ziv algorithms
  • Running complexity: compute the complexity profile along a sequence
  • Dictionary output: retrieve the phrase dictionary used by the algorithm
  • Normalisation: theoretical or empirical scaling factors (as in the original fLZc)
  • Pure-Python API built on C for maximum speed (via ctypes)
  • Works out-of-the-box on macOS & Linux; Windows support untested

Installation (Development Mode)

This project uses scikit-build-core + CMake under PEP 517.

Prerequisites

  • Python 3.8–3.13
  • pip, a C99-compatible compiler, and CMake ≥ 3.15
  • macOS or Linux (Windows support not yet tested)

Step by step

Clone and install in editable mode:

git clone https://github.com/romybeaute/fLZc_python.git
cd fLZc_python
python -m venv .flzcvenv
source .flzcvenv/bin/activate

# clean previous builds (optional)
rm -rf build/ dist/ _skbuild/ fLZc_python/liblzc.*

# install in editable mode (builds & places the shared library)
pip install -e .

Examples & Testing

  • Demo:\ fLZc_python/examples/lzc_demo.py provides an end-to-end example (including plotting).

  • Unit tests:\ Run pytest tests/ to verify correctness on canonical sequences.

Implementation Details

  • LZ76c follows the algorithm of Kaspar & Schuster 1, with optional dictionary retrieval and running-profile support.
  • LZ78c leverages the khashl hash-map for linear-time parsing and also supports dictionary & running outputs.
  • Normalisation factors are precomputed (via MATLAB data) for alphabets up to size 10; see the original MATLAB repo for details.

Acknowledgements

Wraps the original fLZc library by Lionel Barnett (University of Sussex).

License

Distributed under the MIT License. See LICENSE for details.

References

  1. A. Lempel & J. Ziv, “On the Complexity of Finite Sequences,” IEEE Trans. Inf. Theory 22(1), 1976.
  2. A. Lempel & J. Ziv, “Compression of Individual Sequences via Variable-Rate Coding,” IEEE Trans. Inf. Theory 24(5), 1978.
  3. F. Kaspar & H. G. Schuster, “Easily Calculable Measure for the Complexity of Spatiotemporal Patterns,” Phys. Rev. A 36(2), 1987.

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

flzc-0.1.5.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

flzc-0.1.5-cp313-cp313-macosx_14_0_arm64.whl (25.9 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

File details

Details for the file flzc-0.1.5.tar.gz.

File metadata

  • Download URL: flzc-0.1.5.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for flzc-0.1.5.tar.gz
Algorithm Hash digest
SHA256 5e7d329a1bdfbb6ccbc971881a6b1954448594b2de42ebd247bb401638e2d772
MD5 0c4ab3571ecaa2434aafaf808c7ca949
BLAKE2b-256 95ec10bb3fede2c59c1d75ee4483699ec95112d6d051f0eca0fb53d667ab35c8

See more details on using hashes here.

File details

Details for the file flzc-0.1.5-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for flzc-0.1.5-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7f5d5dba2b63f8f001df40238b6e81f797d04bb90aa10eeaeedb00fd23df9c63
MD5 5f98677e126e3d34e1a5dce87c5c9693
BLAKE2b-256 6ad406c2e6364fee71a9d95995f276ba88d3471bba08775bfffa52300b9f06c3

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