# rlabbe/filterpy architecture

> Architecture diagram of the GitHub repository rlabbe/filterpy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rlabbe/filterpy
- Repository: https://github.com/rlabbe/filterpy

## Overview

##### Project type and purpose
- This is an open-source Python library (“filterpy”) providing Kalman filters and related estimation filters (Extended KF, Unscented KF, g-h filters, Least Squares, discrete Bayes, etc.).
- It’s a modular, pedagogical codebase intended for import into user scripts, integration with numerical Python tools, and extension by researchers or students.

##### File structure
A. Top-level folders/files
– filterpy/             ← core source code, structured by filter category
– docs/                 ← Sphinx documentation source
– conda/                ← Conda packaging recipes
– setup.py, setup.cfg, requirements.txt ← PyPI packaging & dependency metadata
– README.rst            ← project overview, install & usage instructions
– tests (under each module) ← unit tests with pytest
– examples (under filterpy/examples) ← runnable demos
B. Core module breakdown
– filterpy/common      ← helper utilities (discretization, kinematics)
– filterpy/kalman      ← Kalman filters & smoothers
– filterpy/gh          ← g-h filters
– filterpy/discrete_bayes
– filterpy/leastsq
– filterpy/memory
– filterpy/monte_carlo
– filterpy/stats
C. Build & publishing
– conda/recipes        ← scripts and meta.yaml for conda-forge
– setup.py / MANIFEST.in ← PyPI distribution
– creating_a_release.rst ← release process docs
D. Documentation & CI
– docs/conf.py, Makefile ← Sphinx config
– Git triggers RTD builds on commit
– pytest invoked via “py.test”

##### Readme insights
- Emphasis on pedagogical clarity over micro-optimizations
- Dependencies: NumPy, SciPy, Matplotlib (optional), Python 3.5+ (2.7 legacy)
- Testing: basic asserts & pytest suite
- Distribution: PyPI & conda-forge

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    subgraph "External Dependencies"
        NumPy(["NumPy"]):::external
        SciPy(["SciPy"]):::external
        Matplotlib(["Matplotlib"]):::external
    end

    %% Core Library Modules
    subgraph "Core Library Modules"
        Common(["Common Utilities"]):::core
        Kalman(["Kalman Filters & Smoothers"]):::core
        GH(["g-h Filters"]):::core
        DiscreteBayes(["Discrete Bayes Filters"]):::core
        LeastSq(["Least Squares Filters"]):::core
        Memory(["Memory Filters"]):::core
        MonteCarlo(["Monte Carlo Methods"]):::core
        Stats(["Statistical Utilities"]):::core
    end

    %% Consumers
    subgraph "Consumers"
        Examples(["Examples & Demos"]):::tool
        subgraph "Testing Suite"
            CommonTests(["Common Tests"]):::tool
            KalmanTests(["Kalman Tests"]):::tool
            GHTests(["g-h Tests"]):::tool
            DiscreteBayesTests(["Discrete Bayes Tests"]):::tool
            LeastSqTests(["Least Squares Tests"]):::tool
            MemoryTests(["Memory Tests"]):::tool
            MonteCarloTests(["Monte Carlo Tests"]):::tool
            StatsTests(["Statistics Tests"]):::tool
        end
        Docs(["Sphinx Documentation"]):::tool
    end

    %% Packaging & Release
    subgraph "Packaging & Release"
        PyPI(["PyPI Packaging"]):::tool
        CondaRecipes(["Conda-Forge Recipes"]):::tool
        ReleaseDocs(["Release Process Docs"]):::artifact
    end

    %% CI / Version Control
    subgraph "CI / Version Control"
        GitHub(["GitHub Repository"]):::tool
        CI(["CI Pipeline"]):::tool
    end

    %% Artifacts
    subgraph "Artifacts"
        PyPIPackage(["PyPI Package"]):::artifact
        CondaPackage(["Conda Package"]):::artifact
        RTD(["ReadTheDocs Site"]):::artifact
    end

    %% Relationships
    NumPy -->|import| Common
    SciPy -->|import| Common
    NumPy -->|import| Kalman
    SciPy -->|import| Kalman
    NumPy -->|import| GH
    SciPy -->|import| GH
    NumPy -->|import| DiscreteBayes
    SciPy -->|import| DiscreteBayes
    NumPy -->|import| LeastSq
    SciPy -->|import| LeastSq
    NumPy -->|import| Memory
    SciPy -->|import| Memory
    NumPy -->|import| MonteCarlo
    SciPy -->|import| MonteCarlo
    NumPy -->|import| Stats
    SciPy -->|import| Stats
    Matplotlib -->|optional import| Examples

    Common -->|used by| Examples
    Kalman -->|used by| Examples
    GH -->|used by| Examples
    DiscreteBayes -->|used by| Examples
    LeastSq -->|used by| Examples
    Memory -->|used by| Examples
    MonteCarlo -->|used by| Examples
    Stats -->|used by| Examples

    Common -->|tested by| CommonTests
    Kalman -->|tested by| KalmanTests
    GH -->|tested by| GHTests
    DiscreteBayes -->|tested by| DiscreteBayesTests
    LeastSq -->|tested by| LeastSqTests
    Memory -->|tested by| MemoryTests
    MonteCarlo -->|tested by| MonteCarloTests
    Stats -->|tested by| StatsTests

    Common -->|documented by| Docs
    Kalman -->|documented by| Docs
    GH -->|documented by| Docs
    DiscreteBayes -->|documented by| Docs
    LeastSq -->|documented by| Docs
    Memory -->|documented by| Docs
    MonteCarlo -->|documented by| Docs
    Stats -->|documented by| Docs

    Docs -->|builds| RTD
    PyPI -->|packages| PyPIPackage
    CondaRecipes -->|builds| CondaPackage

    GitHub -->|on commit| CI
    CI -->|runs tests| CommonTests
    CI -->|runs tests| KalmanTests
    CI -->|runs tests| GHTests
    CI -->|runs tests| DiscreteBayesTests
    CI -->|runs tests| LeastSqTests
    CI -->|runs tests| MemoryTests
    CI -->|runs tests| MonteCarloTests
    CI -->|runs tests| StatsTests
    CI -->|builds docs| Docs
    CI -->|publishes to| PyPI
    CI -->|publishes to| CondaRecipes

    %% Click Events
    click Common "https://github.com/rlabbe/filterpy/tree/master/filterpy/common/"
    click Kalman "https://github.com/rlabbe/filterpy/tree/master/filterpy/kalman/"
    click GH "https://github.com/rlabbe/filterpy/tree/master/filterpy/gh/"
    click DiscreteBayes "https://github.com/rlabbe/filterpy/tree/master/filterpy/discrete_bayes/"
    click LeastSq "https://github.com/rlabbe/filterpy/tree/master/filterpy/leastsq/"
    click Memory "https://github.com/rlabbe/filterpy/tree/master/filterpy/memory/"
    click MonteCarlo "https://github.com/rlabbe/filterpy/tree/master/filterpy/monte_carlo/"
    click Stats "https://github.com/rlabbe/filterpy/tree/master/filterpy/stats/"
    click Examples "https://github.com/rlabbe/filterpy/tree/master/filterpy/examples/"
    click CommonTests "https://github.com/rlabbe/filterpy/tree/master/filterpy/common/tests/"
    click KalmanTests "https://github.com/rlabbe/filterpy/tree/master/filterpy/kalman/tests/"
    click GHTests "https://github.com/rlabbe/filterpy/tree/master/filterpy/gh/tests/"
    click DiscreteBayesTests "https://github.com/rlabbe/filterpy/tree/master/filterpy/discrete_bayes/tests/"
    click LeastSqTests "https://github.com/rlabbe/filterpy/tree/master/filterpy/leastsq/tests/"
    click MemoryTests "https://github.com/rlabbe/filterpy/tree/master/filterpy/memory/tests/"
    click MonteCarloTests "https://github.com/rlabbe/filterpy/tree/master/filterpy/monte_carlo/tests/"
    click StatsTests "https://github.com/rlabbe/filterpy/tree/master/filterpy/stats/tests/"
    click Docs "https://github.com/rlabbe/filterpy/tree/master/docs/"
    click CondaRecipes "https://github.com/rlabbe/filterpy/tree/master/conda/"
    click ReleaseDocs "https://github.com/rlabbe/filterpy/blob/master/creating_a_release.rst"

    %% Styles
    classDef core fill:#AED6F1,stroke:#1B4F72,color:#1B2631
    classDef external fill:#A9DFBF,stroke:#145A32,color:#145A32
    classDef tool fill:#F5B041,stroke:#7D6608,color:#7D6608
    classDef artifact fill:#D5D8DC,stroke:#566573,color:#1C2833
```
