Skip to main content

Formal order analysis library

Project description

foapy

Python library for Formal Order Analysis (FOA) of symbolic sequences.

What is FOA?

Formal Order Analysis (FOA) studies the structure of symbolic sequences by:

  • Mapping a sequence to its order and alphabet (the set of unique symbols in order of first appearance).
  • Extracting intervals between repeated occurrences of the same symbol under different boundary modes.
  • Quantifying structure with characteristics (e.g., arithmetic/geometric means, volume, average remoteness, depth, descriptive/identifying information, regularity, uniformity).

This enables robust analysis for text, biological sequences, musical motifs, logs, and any categorical time series.

Features

  • Alphabets and Orders: Define alphabets and compute orders of sequences.
  • Intervals and Chains: Extract intervals for multiple binding and boundary modes.
  • Congeneric Decomposition: Decompose sequences into congeneric components.
  • Mathematical Characteristics: Arithmetic mean, geometric mean, volume, average remoteness, depth, descriptive and identifying information, regularity, uniformity.
  • Masked-array Support: FOA on partially observed sequences via foapy.ma.
  • Extensive Documentation: Theory, algorithms, and examples.

Installation

  • From PyPI:
pip install foapy
  • From source (with tox workflows):
git clone https://github.com/intervals-mining-lab/foapy.git
cd foapy
python -m pip install --upgrade pip
python -m pip install tox

# Run tests (isolated env)
tox -e default

# Build distribution artifacts (sdist and wheel)
tox -e build

# Optionally clean build artifacts
tox -e clean

Quick start

Compute order, intervals, and a characteristic:

import foapy

# 1) Order and alphabet
source = ['a', 'b', 'a', 'c', 'd']
order = foapy.order(source)
print(order)  # [0 1 0 2 3]

order_arr, alphabet = foapy.order(source, True)
print(order_arr, alphabet)  # [0 1 0 2 3] ['a' 'b' 'c' 'd']

# 2) Intervals (binding to start, normal mode)
from foapy import binding, mode
intervals = foapy.intervals(['a', 'b', 'a', 'c', 'a', 'd'], binding.start, mode.normal)
print(intervals)  # [1 2 2 3 2 5]

# 3) A characteristic (volume = product of intervals)
val = foapy.characteristics.volume(intervals)
print(val)  # 192

Masked arrays (optional):

import numpy as np
import numpy.ma as ma
import foapy

seq = ma.masked_array(['a', 'b', 'a', 'c', 'd'], mask=[0, 1, 0, 0, 0])
order_ma = foapy.ma.order(seq)
intervals_grouped = foapy.ma.intervals(order_ma, foapy.binding.start, foapy.mode.normal)
u = foapy.characteristics.uniformity(intervals_grouped)
print(u)

Project Structure

Documentation

Online documentation: intervals-mining-lab.github.io/foapy.

The documentation in ./docs covers fundamentals, algorithms, characteristics, applications, and development notes.

Build and serve the docs locally (via tox):

# Build docs into docs/_build
tox -e docs

# Serve docs with live-reload for development
tox -e docsserve

Testing

Run the test suite (via tox):

tox -e default

# Pass arguments to pytest after --, e.g. run a subset:
tox -e default -- -k order -q

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

foapy-0.0.20.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

foapy-0.0.20-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file foapy-0.0.20.tar.gz.

File metadata

  • Download URL: foapy-0.0.20.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for foapy-0.0.20.tar.gz
Algorithm Hash digest
SHA256 b11a3fa6462817b1babbc8983c8725d26d82ba4f1a530c8cfbaa1d22ad219c3a
MD5 a747cf3ebc6150c3399a67a43dbeb351
BLAKE2b-256 d68c02a014fa0ca18d5f1abb0ee29c43ac51a40c45a529b77bb6b6f73207bcb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for foapy-0.0.20.tar.gz:

Publisher: ci.yml on intervals-mining-lab/foapy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file foapy-0.0.20-py3-none-any.whl.

File metadata

  • Download URL: foapy-0.0.20-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for foapy-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 64308c3c68d459c85edaa45164ee27b16bd34b93d54853f6d78c55883400e840
MD5 02a291daf076b5f04e81a882faa1e4f4
BLAKE2b-256 b1cb0f1c583324457bf6dcc9a1636b6d27370186da0228f4505b5d0afc8cdf91

See more details on using hashes here.

Provenance

The following attestation bundles were made for foapy-0.0.20-py3-none-any.whl:

Publisher: ci.yml on intervals-mining-lab/foapy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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