freq-pick 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. freq_pick-0.1.0/.python-version +1 -0
  2. freq_pick-0.1.0/AGENTS.md +156 -0
  3. freq_pick-0.1.0/LICENSE +21 -0
  4. freq_pick-0.1.0/PKG-INFO +97 -0
  5. freq_pick-0.1.0/README.md +87 -0
  6. freq_pick-0.1.0/artifacts/demo_pick.json +37 -0
  7. freq_pick-0.1.0/artifacts/demo_pick.png +0 -0
  8. freq_pick-0.1.0/artifacts/demo_spectrum.npz +0 -0
  9. freq_pick-0.1.0/docs/Screenshot_20260220_113740.png +0 -0
  10. freq_pick-0.1.0/docs/agent_executor_instructions_v_1.md +73 -0
  11. freq_pick-0.1.0/docs/handoff_260220_1.md +251 -0
  12. freq_pick-0.1.0/docs/monkey_test.md +7 -0
  13. freq_pick-0.1.0/docs/python_toolbox.md +164 -0
  14. freq_pick-0.1.0/docs/user-persona.md +44 -0
  15. freq_pick-0.1.0/main.py +6 -0
  16. freq_pick-0.1.0/progress_tracker.csv +29 -0
  17. freq_pick-0.1.0/pyproject.toml +29 -0
  18. freq_pick-0.1.0/scripts/make_fixture.py +37 -0
  19. freq_pick-0.1.0/scripts/run_picker_demo.py +43 -0
  20. freq_pick-0.1.0/src/freq_pick/__init__.py +13 -0
  21. freq_pick-0.1.0/src/freq_pick/__main__.py +7 -0
  22. freq_pick-0.1.0/src/freq_pick/artifacts.py +52 -0
  23. freq_pick-0.1.0/src/freq_pick/cli.py +78 -0
  24. freq_pick-0.1.0/src/freq_pick/core.py +296 -0
  25. freq_pick-0.1.0/src/freq_pick/mpl_ui.py +279 -0
  26. freq_pick-0.1.0/tests/test_artifacts.py +25 -0
  27. freq_pick-0.1.0/tests/test_cli_title_append.py +18 -0
  28. freq_pick-0.1.0/tests/test_display_conversion.py +17 -0
  29. freq_pick-0.1.0/tests/test_headless_png.py +18 -0
  30. freq_pick-0.1.0/tests/test_snap.py +18 -0
  31. freq_pick-0.1.0/tests/test_title_compose.py +17 -0
  32. freq_pick-0.1.0/tests/test_toggle.py +10 -0
  33. freq_pick-0.1.0/uv.lock +428 -0
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,156 @@
1
+ # AGENTS.md
2
+
3
+ This file guides agentic coding assistants working in this repository.
4
+
5
+ ## Repository Overview
6
+
7
+ - Project: `freq-pick`
8
+ - Language: Python
9
+ - Python version: 3.13 (from `pyproject.toml`)
10
+ - Package manager: `uv` (authoritative)
11
+ - Build backend: hatchling (authoritative)
12
+ - Current entry point: `main.py`
13
+ - Source tree: `src/` currently empty
14
+
15
+ ## Authoritative Rules (carry into all work)
16
+
17
+ These are sourced from `docs/python_toolbox.md` and `docs/agent_executor_instructions_v_1.md`.
18
+
19
+ - Use `uv` for all installs and runs. Do not use `pip`, `venv`, or `conda`.
20
+ - Treat handoff documents as the only contract; do not invent requirements.
21
+ - If requirements are ambiguous, stop and report the blocker.
22
+ - Run required tests without asking permission when executing a handoff.
23
+ - Do not skip the Definition of Done; report failures and stop.
24
+ - Avoid reflection or string-based magic (`getattr`, `setattr`, dynamic wiring).
25
+ - Keep modules and functions small and conceptually focused.
26
+
27
+ ## Cursor / Copilot Rules
28
+
29
+ - No `.cursor/rules/`, `.cursorrules`, or `.github/copilot-instructions.md` found.
30
+
31
+ ## Commands: Build / Lint / Test
32
+
33
+ The repository does not currently define tool configs in `pyproject.toml`.
34
+ Follow the toolbox defaults if tools are installed.
35
+
36
+ ### Environment Setup
37
+
38
+ - Install dependencies: `uv sync`
39
+ - Add dependency: `uv add <package>`
40
+ - Add dev dependency: `uv add --dev <package>`
41
+
42
+ ### Build
43
+
44
+ - Build package: `uv build`
45
+
46
+ ### Format
47
+
48
+ - Format all code: `uv run black .`
49
+
50
+ ### Type Check
51
+
52
+ - Run mypy: `uv run mypy .`
53
+
54
+ ### Lint (optional, only if introduced)
55
+
56
+ - Run ruff: `uv run ruff check .`
57
+
58
+ ### Test
59
+
60
+ - Run all tests: `uv run pytest`
61
+
62
+ ### Test: Single File
63
+
64
+ - Run a file: `uv run pytest tests/test_example.py`
65
+
66
+ ### Test: Single Test
67
+
68
+ - Run a test by node id:
69
+ `uv run pytest tests/test_example.py::test_name`
70
+
71
+ ### Test: By Keyword
72
+
73
+ - Run matching tests:
74
+ `uv run pytest -k "keyword"`
75
+
76
+ ## Code Style Guidelines
77
+
78
+ The project is minimal; follow the defaults below unless a handoff overrides them.
79
+
80
+ ### Formatting
81
+
82
+ - Use Black defaults for formatting.
83
+ - Prefer explicit, readable code over clever expressions.
84
+ - Avoid dense comprehensions when a simple loop is clearer.
85
+
86
+ ### Imports
87
+
88
+ - Standard library imports first, third-party next, local imports last.
89
+ - One import per line when it improves clarity.
90
+ - Avoid wildcard imports.
91
+ - Keep imports minimal and local to the module that uses them.
92
+
93
+ ### Typing
94
+
95
+ - Type hints are required for new or modified public APIs.
96
+ - Avoid `Any` unless justified and localized.
97
+ - Prefer explicit types to dynamic behavior.
98
+ - Public dataclasses and functions should be fully typed.
99
+
100
+ ### Naming
101
+
102
+ - Use `snake_case` for functions and variables.
103
+ - Use `PascalCase` for classes and dataclasses.
104
+ - Use `UPPER_CASE` for module constants.
105
+ - Name variables for intent, not type (`freq_hz`, not `arr1`).
106
+
107
+ ### Error Handling
108
+
109
+ - Validate inputs early and raise `ValueError` for bad arguments.
110
+ - Prefer explicit exceptions over silent fallback.
111
+ - In CLI entry points, convert errors to non-zero exits.
112
+ - Do not swallow exceptions unless the caller explicitly needs it.
113
+
114
+ ### Structure and Size
115
+
116
+ - Keep files focused by concept (core logic, UI, IO, CLI).
117
+ - Keep functions small and single-purpose.
118
+ - Avoid multi-responsibility "god" modules.
119
+
120
+ ### Reflection / Magic
121
+
122
+ - Do not use reflection or string-based wiring.
123
+ - Avoid dynamic attribute access and `getattr`/`setattr`.
124
+ - Prefer explicit dependencies and direct method calls.
125
+
126
+ ### Testing Conventions
127
+
128
+ - Tests live in `tests/`.
129
+ - Name test files `test_*.py`.
130
+ - Prefer small, deterministic tests with synthetic data.
131
+ - For matplotlib tests, use the Agg backend when headless.
132
+
133
+ ## Project Layout (recommended by toolbox)
134
+
135
+ ```text
136
+ project-root/
137
+ ├── pyproject.toml
138
+ ├── README.md
139
+ ├── src/
140
+ │ └── freq_pick/
141
+ │ ├── __init__.py
142
+ │ ├── core.py
143
+ │ ├── mpl_ui.py
144
+ │ ├── artifacts.py
145
+ │ └── cli.py
146
+ ├── tests/
147
+ │ └── test_*.py
148
+ └── docs/
149
+ ```
150
+
151
+ ## Notes for Agents
152
+
153
+ - Repository currently contains only `main.py` as a placeholder.
154
+ - No tests exist yet; create tests when adding new behavior.
155
+ - Keep dependency list minimal (the handoff allows numpy + matplotlib).
156
+ - Use `uv run <command>` for any execution.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 placerte
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,97 @@
1
+ Metadata-Version: 2.4
2
+ Name: freq-pick
3
+ Version: 0.1.0
4
+ Summary: Add your description here
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.13
7
+ Requires-Dist: matplotlib
8
+ Requires-Dist: numpy
9
+ Description-Content-Type: text/markdown
10
+
11
+ # freq-pick
12
+
13
+ Interactive frequency picker for a single spectrum. The API accepts a precomputed
14
+ frequency axis and magnitude array, launches a matplotlib UI, and returns a
15
+ deterministic list of selected bin indices and frequencies. Optional PNG/JSON
16
+ artifacts capture the selection.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ uv sync
22
+ ```
23
+
24
+ ## API (primary)
25
+
26
+ ```python
27
+ from pathlib import Path
28
+ import numpy as np
29
+
30
+ from freq_pick.core import Spectrum
31
+ from freq_pick.core import pick_freqs_matplotlib
32
+
33
+ f_hz = np.linspace(0.0, 200.0, 1001)
34
+ mag = np.sin(f_hz / 10.0) ** 2
35
+
36
+ spectrum = Spectrum(f_hz=f_hz, mag=mag, display_domain="linear")
37
+ selection = pick_freqs_matplotlib(
38
+ spectrum,
39
+ user_snap_hz=0.5,
40
+ xlim=(0.0, 200.0),
41
+ title="Demo",
42
+ title_append="[1/5]",
43
+ artifact_dir=Path("artifacts"),
44
+ artifact_stem="demo",
45
+ )
46
+
47
+ print(selection.selected_idx)
48
+ print(selection.selected_hz)
49
+ ```
50
+
51
+ ### Controls
52
+
53
+ - `shift + drag` rectangle: select max magnitude in the rectangle
54
+ - `q`: commit and quit
55
+ - `Esc`: cancel
56
+ - `c`: clear selection
57
+ - `x`: delete nearest selected peak to cursor
58
+ - `l`: toggle y scale (linear/dB)
59
+ - `h`: toggle help overlay
60
+
61
+ ## CLI
62
+
63
+ ```bash
64
+ uv run freq-pick \
65
+ --in spectrum.npz \
66
+ --out artifacts \
67
+ --stem run1 \
68
+ --snap-hz 0.5 \
69
+ --domain dB \
70
+ --xlim 0 200 \
71
+ --title "Spec A" \
72
+ --title-append "[3/10]"
73
+ ```
74
+
75
+ Input `.npz` must include `f_hz` and `mag` arrays.
76
+
77
+ ## Artifacts
78
+
79
+ When `artifact_dir` and `artifact_stem` are provided, the picker writes:
80
+
81
+ - `{stem}_pick.png`
82
+ - `{stem}_pick.json`
83
+
84
+ JSON keys:
85
+
86
+ - `schema_version`
87
+ - `selected_hz`
88
+ - `selected_idx`
89
+ - `settings`
90
+ - `spectrum_meta`
91
+ - `display_domain`
92
+
93
+ ## Development
94
+
95
+ ```bash
96
+ uv run pytest
97
+ ```
@@ -0,0 +1,87 @@
1
+ # freq-pick
2
+
3
+ Interactive frequency picker for a single spectrum. The API accepts a precomputed
4
+ frequency axis and magnitude array, launches a matplotlib UI, and returns a
5
+ deterministic list of selected bin indices and frequencies. Optional PNG/JSON
6
+ artifacts capture the selection.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ uv sync
12
+ ```
13
+
14
+ ## API (primary)
15
+
16
+ ```python
17
+ from pathlib import Path
18
+ import numpy as np
19
+
20
+ from freq_pick.core import Spectrum
21
+ from freq_pick.core import pick_freqs_matplotlib
22
+
23
+ f_hz = np.linspace(0.0, 200.0, 1001)
24
+ mag = np.sin(f_hz / 10.0) ** 2
25
+
26
+ spectrum = Spectrum(f_hz=f_hz, mag=mag, display_domain="linear")
27
+ selection = pick_freqs_matplotlib(
28
+ spectrum,
29
+ user_snap_hz=0.5,
30
+ xlim=(0.0, 200.0),
31
+ title="Demo",
32
+ title_append="[1/5]",
33
+ artifact_dir=Path("artifacts"),
34
+ artifact_stem="demo",
35
+ )
36
+
37
+ print(selection.selected_idx)
38
+ print(selection.selected_hz)
39
+ ```
40
+
41
+ ### Controls
42
+
43
+ - `shift + drag` rectangle: select max magnitude in the rectangle
44
+ - `q`: commit and quit
45
+ - `Esc`: cancel
46
+ - `c`: clear selection
47
+ - `x`: delete nearest selected peak to cursor
48
+ - `l`: toggle y scale (linear/dB)
49
+ - `h`: toggle help overlay
50
+
51
+ ## CLI
52
+
53
+ ```bash
54
+ uv run freq-pick \
55
+ --in spectrum.npz \
56
+ --out artifacts \
57
+ --stem run1 \
58
+ --snap-hz 0.5 \
59
+ --domain dB \
60
+ --xlim 0 200 \
61
+ --title "Spec A" \
62
+ --title-append "[3/10]"
63
+ ```
64
+
65
+ Input `.npz` must include `f_hz` and `mag` arrays.
66
+
67
+ ## Artifacts
68
+
69
+ When `artifact_dir` and `artifact_stem` are provided, the picker writes:
70
+
71
+ - `{stem}_pick.png`
72
+ - `{stem}_pick.json`
73
+
74
+ JSON keys:
75
+
76
+ - `schema_version`
77
+ - `selected_hz`
78
+ - `selected_idx`
79
+ - `settings`
80
+ - `spectrum_meta`
81
+ - `display_domain`
82
+
83
+ ## Development
84
+
85
+ ```bash
86
+ uv run pytest
87
+ ```
@@ -0,0 +1,37 @@
1
+ {
2
+ "display_domain": "dB",
3
+ "schema_version": "1",
4
+ "selected_hz": [
5
+ 25.0,
6
+ 60.0,
7
+ 69.5,
8
+ 120.0,
9
+ 175.0
10
+ ],
11
+ "selected_idx": [
12
+ 50,
13
+ 120,
14
+ 139,
15
+ 240,
16
+ 350
17
+ ],
18
+ "settings": {
19
+ "crop_to_xlim": true,
20
+ "df_hz": 0.5,
21
+ "effective_snap_hz": 1.5,
22
+ "modifier": "shift",
23
+ "picker_keymap": {
24
+ "cancel": "escape",
25
+ "clear": "c",
26
+ "commit": "q",
27
+ "delete_nearest": "x",
28
+ "help": "h"
29
+ },
30
+ "user_snap_hz": 0.5,
31
+ "xlim": [
32
+ 0.0,
33
+ 200.0
34
+ ]
35
+ },
36
+ "spectrum_meta": {}
37
+ }
Binary file
@@ -0,0 +1,73 @@
1
+ # Agent Executor – Instructions (v1)
2
+
3
+ You are an **execution agent** operating in a structured LLM workflow.
4
+
5
+ Your role is to implement, test, and report based **only** on written artifacts.
6
+
7
+ ---
8
+
9
+ ## Authority & Scope
10
+
11
+ - The **handoff document** is the sole contract.
12
+ - Chat history is not authoritative.
13
+ - You do not:
14
+ - invent requirements
15
+ - reinterpret scope
16
+ - make design decisions
17
+
18
+ If something is ambiguous or missing, **stop and report**.
19
+
20
+ ---
21
+
22
+ ## Your Responsibilities
23
+
24
+ When given a handoff file:
25
+
26
+ - Implement all specified specs
27
+ - Follow implementation constraints exactly
28
+ - Create missing tests when required
29
+ - Run all relevant tests without asking permission
30
+ - Satisfy the Definition of Done
31
+
32
+ Testing is part of execution, not an optional step.
33
+
34
+ ---
35
+
36
+ ## Definition of Done – Enforcement
37
+
38
+ A task is DONE only if:
39
+
40
+ - All specified tests are created (if missing)
41
+ - All tests are executed successfully
42
+ - All commands succeed
43
+ - No spec item remains partially implemented
44
+
45
+ If a DoD item cannot be satisfied:
46
+
47
+ - Stop execution
48
+ - Report the blocker
49
+ - Do not claim completion
50
+
51
+ ---
52
+
53
+ ## Stop Conditions
54
+
55
+ Stop when:
56
+
57
+ - The Definition of Done is fully satisfied, or
58
+ - A blocking ambiguity or failure is encountered and reported
59
+
60
+ Do not optimize, refactor, or polish unless explicitly requested in the handoff.
61
+
62
+ ---
63
+
64
+ ## Awareness of Upstream Role
65
+
66
+ - A web client acts as the design authority
67
+ - Your output feeds the next iteration via new handoffs
68
+ - You do not negotiate scope or intent
69
+
70
+ ---
71
+
72
+ **Status:** Agent Executor Instructions v1
73
+