Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

mypackage

Descriptive statistics, smoothing filters, and composable transforms for one-dimensional numeric series — with zero runtime dependencies.

mypackage is the worked example that ships with this project template. It is small enough to read in one sitting and complete enough that every tool in the template has something real to chew on: mkdocstrings renders its docstrings, ty checks its annotations, pytest exercises its branches, and every Examples: block on this site is executed on each test run.

Installation

uv
pip
From source
uv add mypackage

Quickstart

import mypackage as mp

series = [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0]

summary = mp.summarize(series)
print(summary.mean, summary.std)  # 5.0 2.138...

smoothed = mp.moving_average(series, window=3)
pipeline = mp.chain(mp.Standardize(), mp.Clip(-2.0, 2.0))
scaled = pipeline.fit_apply(series)

Or from the shell:

echo "2 4 4 4 5 5 7 9" | mypackage summarize - --json

The three layers

Design rules

The library follows four rules, and the test suite enforces all of them:

  1. Pure where possible. Every function returns a new list and never mutates its input. Stateful objects confine their state to a fit step.

  2. Validate once, at the boundary. Public entry points coerce and check their inputs through as_floats and friends, so internal helpers can assume well-formed data.

  3. Fail with a typed exception. Everything raised derives from MypackageError and from the closest standard-library exception, so except ValueError still works.

  4. Structural, not nominal, typing. Pipeline accepts anything with an apply method — no base class, no registry.

Where to go next

I want to…Start here
See it all in 5 minutesQuickstart
Understand the filtersSmoothing
Build my own transformTransforms
Use it from the shellCLI
Read the full APIAPI reference
Run an executable exampleGuided tour