Skip to content

Commit d90c634

Browse files
committed
add docstrings by codex
1 parent 2f44dda commit d90c634

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
- `src/physics_plot/` holds the package. `utils.py` exposes `Handles`, while `pp_base.mplstyle` defines the default Matplotlib theme and `py.typed` marks the package as typed.
5+
- `examples/` contains runnable demos (`bode-plot.py`, `violin-plot.ipynb`) and reference images; use these to validate visual regressions before shipping changes.
6+
- `uv.lock` captures the resolved dependency graph. Regenerate it only when you update dependencies with `uv`.
7+
8+
## Build, Test, and Development Commands
9+
- `uv sync --group dev` installs runtime and development dependencies. If `uv` is unavailable, fall back to `python -m pip install -e .` and install test/format tools manually.
10+
- `uv run python examples/bode-plot.py` executes the CLI example; use it to smoke-test style updates.
11+
- `uv run pytest` runs the test suite once it exists; pass `-k <pattern>` to focus.
12+
- `uv run ruff check src` and `uv run black --check src` guard linting/formatting. Run without `--check` to auto-fix.
13+
14+
## Coding Style & Naming Conventions
15+
- Target Python 3.11+ and keep modules, functions, and files in `snake_case`; classes stay in `PascalCase`.
16+
- Follow Black's 88-character line length and space indentation. Prefer double quotes (enforced by Ruff) and keep imports sorted.
17+
- Annotate public APIs with type hints—the package ships `py.typed`, so downstream users rely on them.
18+
- Document public interfaces with NumPy-style docstrings so contributors can extend utilities without guessing parameter semantics.
19+
20+
## Testing Guidelines
21+
- Use `pytest` for unit and functional tests. Mirror package paths under `tests/` (e.g., `tests/test_utils.py`).
22+
- Name tests `test_<behavior>` and parametrize when covering multiple inputs.
23+
- For plotting changes, save comparison images in `examples/` or a dedicated `tests/data/` fixture directory and document the workflow in the PR.
24+
25+
## Commit & Pull Request Guidelines
26+
- Keep commit subjects short, present-tense, and imperative (e.g., `update violin-plot filename`). Group related edits together.
27+
- Reference issues or discussion threads in the PR description, summarize visual/test results, and attach before/after screenshots for plotting tweaks.
28+
- Request review once CI passes, and respond to feedback with follow-up commits rather than force-pushes when possible.

src/physics_plot/utils.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
11
class Handles(list):
2+
"""Container for legend handles derived from Matplotlib artists."""
3+
24
def __init__(self, *args):
5+
"""Initialize the handle list with optional starting values.
6+
7+
Parameters
8+
----------
9+
*args :
10+
Positional arguments forwarded to :class:`list`.
11+
"""
312
super().__init__(*args)
413

514
def append_violinplot(self, violinplot, label):
15+
"""Append a legend patch constructed from a violin plot.
16+
17+
Parameters
18+
----------
19+
violinplot : dict[str, list]
20+
Mapping returned by :meth:`matplotlib.axes.Axes.violinplot`.
21+
label : str
22+
Legend label describing the violin plot.
23+
24+
Returns
25+
-------
26+
None
27+
"""
628
self.append(self._create_patch_from_violinplot(violinplot, label))
729

830
def _create_patch_from_violinplot(self, violinplot, label):
31+
"""Create a patch representing the first body of a violin plot.
32+
33+
Parameters
34+
----------
35+
violinplot : dict[str, list]
36+
Mapping returned by :meth:`matplotlib.axes.Axes.violinplot`.
37+
label : str
38+
Legend label describing the violin plot.
39+
40+
Returns
41+
-------
42+
matplotlib.patches.Patch
43+
Patch configured with the violin plot's face color and label.
44+
"""
945
from matplotlib.patches import Patch
1046

1147
body = violinplot["bodies"][0]

0 commit comments

Comments
 (0)