Skip to content

Commit e965395

Browse files
hmgaudeckerclaude
andauthored
Output formatting (#84)
* Refactor model configuration to use frozen dataclasses instead of dicts Introduce strongly-typed dataclasses for model configuration: - Dimensions, Labels, Anchoring, EstimationOptions, TransitionInfo - FactorEndogenousInfo, EndogenousFactorsInfo This improves type safety and enables IDE autocompletion while keeping user-facing model_dict as a plain dictionary. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Use frozendict for immutable dict fields in dataclasses Replace dict fields with frozendict in frozen dataclasses to ensure true immutability: - Labels.aug_periods_to_periods - Labels.aug_stages_to_stages - Anchoring.outcomes - TransitionInfo.param_names, individual_functions, function_names - EndogenousFactorsInfo.aug_periods_to_aug_period_meas_types, factor_info 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Ignore ty false positive. * Return ProcessedModel dataclass from process_model() instead of dict Update process_model() to return a ProcessedModel frozen dataclass and update all consumers to use attribute access instead of dict access. This provides: - Better type safety with explicit typed fields - Immutability via frozen dataclass - IDE autocomplete support - Clear documentation of the model structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Rename FactorEndogenousInfo to FactorInfo 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Ensure complete typing in src/skillmodels. * Require Python 3.14 before fixing type annotations. * Move TESTS_DIR -> TEST_DATA_DIR, which points to a subdirectory of src so that config.TEST_DATA_DIR is valid also for skillmodels the package (as opposed to the project). * Fix more linting issues. * Make ruff rules much stricter. * Further tighten type annotations. Fix a missing run-time annotation of NDArray. * Move unsafe_fixes = false from .pre-commit config to pyproject. * Fix query in data simulation. * More fixes to imports, add test. * Use more tuples in place of lists to prevent errors. * Fix typing. * Dataclasses for user input. * Simplify. * Use modern rng everywhere. * Update CLAUDE.md * Get rid of if TYPE_CHECKING blocks * Update hooks and clean up * Call by name throughout. * Autogenerated docs, harmonised hooks / project configuration. * Get rid of model_dict. * Replace yaml model specifications by ModelSpec-s. * Next shot at fixing pickling. * Add improved output formatting. * Add variance decompositions. * Fix variance decomposition to use aug_period instead of period. The filtered_states DataFrame and params index both use aug_period as the period identifier, not period. This fixes KeyError when calling decompose_measurement_variance. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix diagnostic_plots double-processing of debug data. debug_loglike already returns processed debug data (it calls process_debug_data internally). Remove the redundant second call to process_debug_data which was causing AttributeError when trying to iterate over already-processed DataFrames. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Review comments 1: single EstimationOptions; improved dataclasses with all defaults set right there; get rid of remaining mutable types being passed around. * Review comments on docs; tighten typing of Mapping to MappingProxyType where we could do so. * Back to general implementation of ensure_containers_are_immutable. * Small fixes. * Latest boilerplate version. * Make optimagic a package dependency. * Latest boilerplate. * Make jupyterbook and pytask required deps. * Use dags 0.5.0 dev branch. * Update CLAUDE.md with complete API docs and actual application usage Document all 14 public exports, get_maximization_inputs return dict, ProcessedModel attributes, frequently used internal APIs, all 7 transition functions, and ModelSpec builder methods — based on how the package is actually used in skane-struct-bw and health-cognition. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Increase test coverage to close to 100%. * Fix bugs caught by review agent. * Call ty environment 'type-checking'. * Require dags 0.5, bump pandas, numpy and hooks, fix resulting issues. * Remove suppression of deprecation warning, which is unnecessary in Pandas 3.0 * Make ruff stricter. * Update boilerplate. * Update ty and remove a couple of unused-ignores. * Rename _sel to select_by_loc; fix stale docstring Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Allow passing states directly to get_transition_plots (health-cognition use case). * Fix aug_period/period bug in transition equation visualization The viz code assumed states DataFrames always have `aug_period` as a column, but pre-computed states (e.g. from health-cognition) may carry `period` in the index instead. Add `_normalize_states_columns` to promote index levels and rename `period` → `aug_period` when needed. Also document the period vs aug_period convention in CLAUDE.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Remove aug_periods from public-facing functions. * Previous commit was too greedy. * Use pixi 0.66 in CI; prek autoupdate. * CHORE: Approximation-tolerant floating point comparisons, remove pandas in-place operations. * Get rid of unnecessary block-comments. --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent fd70d45 commit e965395

57 files changed

Lines changed: 6371 additions & 3710 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ai-instructions

Submodule .ai-instructions added at f2744aa

.github/workflows/main.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,42 @@ jobs:
2323
- macos-latest
2424
- windows-latest
2525
python-version:
26-
- '3.13'
26+
- '3.14'
2727
steps:
2828
- uses: actions/checkout@v6
29-
- uses: prefix-dev/setup-pixi@v0.9.3
29+
- uses: prefix-dev/setup-pixi@v0.9.4
3030
with:
31-
pixi-version: v0.62.2
31+
pixi-version: v0.66.0
3232
cache: true
3333
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
34-
environments: test-cpu
34+
environments: tests-cpu
3535
activate-environment: true
3636
frozen: true
3737
- name: Run pytest
38-
if: runner.os != 'Linux' || matrix.python-version != '3.13'
38+
if: runner.os != 'Linux' || matrix.python-version != '3.14'
3939
shell: bash -l {0}
40-
run: pixi run -e test-cpu tests
40+
run: pixi run -e tests-cpu tests
4141
- name: Run pytest with coverage
42-
if: runner.os == 'Linux' && matrix.python-version == '3.13'
42+
if: runner.os == 'Linux' && matrix.python-version == '3.14'
4343
shell: bash -l {0}
44-
run: pixi run -e test-cpu tests-with-cov
44+
run: pixi run -e tests-cpu tests-with-cov
4545
- name: Upload coverage report
46-
if: runner.os == 'Linux' && matrix.python-version == '3.13'
46+
if: runner.os == 'Linux' && matrix.python-version == '3.14'
4747
uses: codecov/codecov-action@v5
4848
env:
4949
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
50+
run-ty:
51+
name: Run ty
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v6
55+
- uses: prefix-dev/setup-pixi@v0.9.4
56+
with:
57+
pixi-version: v0.66.0
58+
cache: true
59+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
60+
frozen: true
61+
environments: type-checking
62+
- name: Run ty
63+
run: pixi run -e type-checking ty
64+
shell: bash -el {0}

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Claude Code
2+
.claude/
3+
14
# Distribution / packaging
25
*.egg
36
*.egg-info/
@@ -13,7 +16,6 @@ wheels/
1316

1417
# Documentation
1518
docs/_build/
16-
_build/
1719

1820
# IDE
1921
.idea/
@@ -27,6 +29,7 @@ _build/
2729

2830
# pixi
2931
.pixi/
32+
node_modules/
3033

3134
# Python
3235
__pycache__/
@@ -48,5 +51,3 @@ htmlcov/
4851

4952
# Version file (generated by hatch-vcs)
5053
src/*/_version.py
51-
52-
.claude

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule ".ai-instructions"]
2+
path = .ai-instructions
3+
url = git@github.com:OpenSourceEconomics/ai-instructions.git
4+
branch = make-submodule

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ repos:
44
hooks:
55
- id: check-hooks-apply
66
- id: check-useless-excludes
7-
- repo: https://github.com/tox-dev/tox-toml-fmt
8-
rev: v1.2.2
7+
- repo: https://github.com/tox-dev/pyproject-fmt
8+
rev: v2.19.0
99
hooks:
10-
- id: tox-toml-fmt
10+
- id: pyproject-fmt
1111
- repo: https://github.com/lyz-code/yamlfix
1212
rev: 1.19.1
1313
hooks:
@@ -17,7 +17,7 @@ repos:
1717
hooks:
1818
- id: check-added-large-files
1919
args:
20-
- --maxkb=50000
20+
- --maxkb=10000
2121
- id: check-ast
2222
- id: check-case-conflict
2323
- id: check-docstring-first
@@ -47,7 +47,7 @@ repos:
4747
hooks:
4848
- id: yamllint
4949
- repo: https://github.com/astral-sh/ruff-pre-commit
50-
rev: v0.14.14
50+
rev: v0.15.6
5151
hooks:
5252
- id: ruff-check
5353
args:
@@ -62,7 +62,7 @@ repos:
6262
- pyi
6363
- python
6464
- repo: https://github.com/kynan/nbstripout
65-
rev: 0.9.0
65+
rev: 0.9.1
6666
hooks:
6767
- id: nbstripout
6868
args:
@@ -79,6 +79,6 @@ repos:
7979
args:
8080
- --wrap
8181
- '88'
82-
files: (CLAUDE\.md|README\.md)
82+
files: (AGENTS\.md|CLAUDE\.md|README\.md|modules/.*\.md|profiles/.*\.md)
8383
ci:
8484
autoupdate_schedule: monthly

.readthedocs.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ build:
1616
# Jupyter Book 2.0 builds site content to _build/html.
1717
# For ReadTheDocs, we build and then copy to the expected output location.
1818
- mkdir --parents $READTHEDOCS_OUTPUT/html/
19-
- BASE_URL="/$READTHEDOCS_LANGUAGE/$READTHEDOCS_VERSION" pixi run -e docs docs
19+
- >-
20+
BASE_URL="/$READTHEDOCS_LANGUAGE/$READTHEDOCS_VERSION"
21+
pixi run -e docs build-docs
2022
- cp -a docs/_build/html/. "$READTHEDOCS_OUTPUT/html" && rm -r docs/_build

.yamllint.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@ rules:
2929
quoted-strings: disable
3030
trailing-spaces: enable
3131
truthy:
32-
check-keys: false
3332
level: warning
3433
yaml-files:
3534
- '*.yaml'
3635
- '*.yml'
3736
- .yamllint
38-
ignore:
39-
- src/skillmodels/test_data/simplest_augmented_model.yaml

0 commit comments

Comments
 (0)