Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6e129a4
Added seq as whole object page
goruha May 17, 2025
3d8147b
Added order as a property pag
goruha May 18, 2025
edabe82
Added order as a property pag
goruha May 18, 2025
aadf7e3
Added order as a property pag
goruha May 18, 2025
41eaac0
Added order as a property pag
goruha May 18, 2025
ea5d309
Update sequence_as_a_whole_object.md
ChainsManipulator May 19, 2025
22a3097
Fix text
goruha May 24, 2025
ab11212
Added Congeneric decomposition
goruha Jun 1, 2025
bbc3006
Interval as information unit
goruha Jun 7, 2025
130897a
Interval as information unit
goruha Jun 7, 2025
7032234
Finish ideas
goruha Jun 8, 2025
487b3e5
Finish ideas
goruha Jun 8, 2025
9b13402
Fix formulas
goruha Jun 9, 2025
cbaeeb8
Fix typo
goruha Jun 9, 2025
21ecb64
Update order_as_a_property.md
ChainsManipulator Jun 9, 2025
4fa9719
Added marmaid diagram
goruha Jun 14, 2025
419b344
Added intervals coloring
goruha Jun 14, 2025
746db16
Added latex table
goruha Jun 14, 2025
c993544
Finally use marmaide
goruha Jun 14, 2025
07fb4f6
Added binding and mode dedinitions
goruha Jun 23, 2025
6f0de88
Added binding and mode dedinitions
goruha Jun 23, 2025
caf7379
Added binding and mode dedinitions
goruha Jun 23, 2025
7a72e6f
Added temporary docs
goruha Jun 29, 2025
769bc6a
Added fundamentals
goruha Jul 4, 2025
d2a3bf3
Iterate intervals_chain
goruha Jul 6, 2025
110063b
Cleanup old docs
goruha Jul 6, 2025
668dcbe
Added documntation for distribution
goruha Jul 6, 2025
624da5a
Move characteristics to right place
goruha Jul 7, 2025
e3922c7
Restore characteristics
goruha Jul 7, 2025
315727c
Fix docs warnings
goruha Jul 7, 2025
0f2ae3f
Added docs for characteristics
goruha Jul 8, 2025
a30e509
Added Partials and congenerics
goruha Jul 27, 2025
2482332
Added fundamentals docs
goruha Aug 11, 2025
ef84278
Update initial README
goruha Aug 11, 2025
c7bc03f
Update initial README
goruha Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repos:
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
args: ['--unsafe']
- id: debug-statements
- id: end-of-file-fixer
- id: requirements-txt-fixer
Expand Down
129 changes: 111 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,120 @@
<!-- These are examples of badges you might want to add to your README:
please update the URLs accordingly
# foapy

[![Built Status](https://api.cirrus-ci.com/github/<USER>/foapy.svg?branch=main)](https://cirrus-ci.com/github/<USER>/foapy)
[![ReadTheDocs](https://readthedocs.org/projects/foapy/badge/?version=latest)](https://foapy.readthedocs.io/en/stable/)
[![Coveralls](https://img.shields.io/coveralls/github/<USER>/foapy/main.svg)](https://coveralls.io/r/<USER>/foapy)
[![PyPI-Server](https://img.shields.io/pypi/v/foapy.svg)](https://pypi.org/project/foapy/)
[![Conda-Forge](https://img.shields.io/conda/vn/conda-forge/foapy.svg)](https://anaconda.org/conda-forge/foapy)
[![Monthly Downloads](https://pepy.tech/badge/foapy/month)](https://pepy.tech/project/foapy)
[![Twitter](https://img.shields.io/twitter/url/http/shields.io.svg?style=social&label=Twitter)](https://twitter.com/foapy)
-->
Python library for Formal Order Analysis (FOA) of symbolic sequences.

[![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
## What is FOA?

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

```bash
pip install foapy
```

- From source (with tox workflows):

```bash
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:

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

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

- **Source Code:** [`./src`](./src)
- **Documentation:** [`./docs`](./docs)
- **Tests:** [`./tests`](./tests)

## Documentation

Online documentation: [intervals-mining-lab.github.io/foapy](https://intervals-mining-lab.github.io/foapy).

The documentation in [`./docs`](./docs) covers fundamentals, algorithms, characteristics, applications, and development notes.

Build and serve the docs locally (via tox):

> Formal order analysis library
```bash
# Build docs into docs/_build
tox -e docs

A longer description of your project goes here...
# Serve docs with live-reload for development
tox -e docsserve
```

## Testing

<!-- pyscaffold-notes -->
Run the test suite (via tox):

## Note
```bash
tox -e default

This project has been set up using PyScaffold 4.5. For details and usage
information on PyScaffold see https://pyscaffold.org/.
# Pass arguments to pytest after --, e.g. run a subset:
tox -e default -- -k order -q
```
4 changes: 3 additions & 1 deletion docs/assets/js/mathjax.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
window.MathJax = {
loader: {load: ['[tex]/colortbl']},
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
processEnvironments: true,
packages: {'[+]': ['colortbl']},
},
options: {
ignoreHtmlClass: ".*|",
Expand Down
3 changes: 0 additions & 3 deletions docs/fundamentals/characteristics/arithmetic_mean.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/fundamentals/characteristics/average_remoteness.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/fundamentals/characteristics/depth.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/fundamentals/characteristics/descriptive_information.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/fundamentals/characteristics/geometric_mean.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/fundamentals/characteristics/identifying_information.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/fundamentals/characteristics/index.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/fundamentals/characteristics/periodicity.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/fundamentals/characteristics/uniformity.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/fundamentals/characteristics/volume.md

This file was deleted.

Loading
Loading