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 add mypackagepip install mypackagegit clone https://github.com/jejjohnson/pypackage_template.git
cd pypackage_template
uv run poe installQuickstart¶
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 - --jsonThe three layers¶
Design rules¶
The library follows four rules, and the test suite enforces all of them:
Pure where possible. Every function returns a new list and never mutates its input. Stateful objects confine their state to a
fitstep.Validate once, at the boundary. Public entry points coerce and check their inputs through
as_floatsand friends, so internal helpers can assume well-formed data.Fail with a typed exception. Everything raised derives from
MypackageErrorand from the closest standard-library exception, soexcept ValueErrorstill works.Structural, not nominal, typing.
Pipelineaccepts anything with anapplymethod — no base class, no registry.
Where to go next¶
| I want to… | Start here |
|---|---|
| See it all in 5 minutes | Quickstart |
| Understand the filters | Smoothing |
| Build my own transform | Transforms |
| Use it from the shell | CLI |
| Read the full API | API reference |
| Run an executable example | Guided tour |