Phase 2b: rename grids/shocks packages and process leaf classes#362
Closed
hmgaudecker wants to merge 5 commits into
Closed
Phase 2b: rename grids/shocks packages and process leaf classes#362hmgaudecker wants to merge 5 commits into
hmgaudecker wants to merge 5 commits into
Conversation
`lcm/grids/` is internal grid infrastructure (ABCs, validators, coordinate helpers, the leaf classes whose user-facing copies live in `lcm/api/grids.py`). The leading underscore signals "private — don't import from user code"; users keep reaching for grid classes through `from lcm import LinSpacedGrid` or `from lcm.api.grids import LinSpacedGrid`. Pure rename via `git mv` to preserve blame. Sed-rewrite of `from lcm.grids` / `import lcm.grids` / `lcm.grids.` across src and tests. Update docstring references in `api/grids.py` and `api/categorical.py`. Step A of `Phase 2 — api Reorganisation.md`'s deferred internal restructure. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…_ProcessGrid*
`lcm/shocks/` is internal process infrastructure (the `_ShockGrid`
ABC hierarchy plus the seven leaf distribution / discretization
classes). The leading underscore matches the `lcm/_grids/` rename
from step A — these are private packages users shouldn't reach into
directly.
Renames:
- `lcm/shocks/` → `lcm/_processes/`
- `_ShockGrid` → `_ProcessGrid`
- `_ShockGridIID` → `_ProcessGridIID`
- `_ShockGridAR1` → `_ProcessGridAR1`
Sed-rewrite of `from lcm.shocks` / `import lcm.shocks` /
`lcm.shocks.` and the three internal class names across src, tests,
and lcm_examples. `lcm/__init__.py` drops `from lcm import shocks`
and the `"shocks"` entry from `__all__` — the public surface is now
exclusively `from lcm import UniformIIDProcess` (etc.) via
`api/processes.py`.
`lcm_examples/precautionary_savings.py` and
`lcm_examples/mahler_yum_2024/_model.py` had bare-attribute access
to `lcm.shocks.{iid,ar1}.{Normal,Uniform,Rouwenhorst,Tauchen}`;
those rewrite to top-level imports (`NormalIIDProcess`,
`UniformIIDProcess`, `RouwenhorstAR1Process`, `TauchenAR1Process`)
because `lcm._processes` is private and ruff (rightly) flags the
underscore access. The internal class names themselves
(`Uniform`, `Tauchen`, ...) are renamed in step D; today the
`*Process` names are aliases declared in `api/processes.py`.
Step B of `Phase 2 — api Reorganisation.md`'s deferred internal
restructure.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ShockName → ProcessName Rename the derived attribute and type-alias names so the codebase speaks one language: `process` for any stochastic-process state. - `VariableInfo.is_shock` → `VariableInfo.is_process` - `Variables.shock_names` → `Variables.process_names` - `typing.ShockName` → `typing.ProcessName` - `non_shock_names` local var in `api/regime.py` → `non_process_names` - `test_shock_names_filters_is_shock` → `test_process_names_filters_is_process` Sed-rewrite across src and tests. Step C of `Phase 2 — api Reorganisation.md`'s deferred internal restructure. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…cess, ...) Rename the seven user-facing process leaf classes in their definition files to the canonical `<Distribution><Kind>Process` names. `api/processes.py` becomes a plain re-export without the `as ...` aliases. Tests that previously reached for the classes via `lcm._processes.iid.X` qualified access now import them from the top-level `lcm` namespace. Last step of `Phase 2 — api Reorganisation.md`'s deferred internal restructure. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Member
Author
|
Folded into #361 via fast-forward merge — all four Phase 2b commits (steps A, B, C, D) now live on the Phase 2 branch. Phase 2 description updated to cover the full restructure. |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on top of #361 (Phase 2). Merge #359 → #360 → #361 → this in order.
Summary
Land the internal restructure Phase 2 (#361) deferred to keep itself reviewable: rename the
lcm/grids/andlcm/shocks/packages to leading-underscore (private), rename the_ShockGrid*ABCs to_ProcessGrid*, rename theis_shock/shock_names/ShockNamederived names tois_process/process_names/ProcessName, and rename the seven leaf process classes themselves solcm/api/processes.pybecomes a plain re-export.lcm_examples/updated in-tree to use the new names. Downstream user code (outside this repo) will be handled separately by the user.Four commits
a47402bgit mv lcm/grids → lcm/_grids. Sed-rewritefrom lcm.grids/import lcm.grids/lcm.grids.across src and tests.591e955git mv lcm/shocks → lcm/_processes. Rename internal ABCs_ShockGrid→_ProcessGrid,_ShockGridIID→_ProcessGridIID,_ShockGridAR1→_ProcessGridAR1. Dropfrom lcm import shocksfromlcm/__init__.pyand the"shocks"entry from__all__. Updatelcm_examples/precautionary_savings.pyandlcm_examples/mahler_yum_2024/_model.pyto use top-levelfrom lcm import UniformIIDProcess, RouwenhorstAR1Process, ...(instead of the oldlcm.shocks.iid.Uniform/lcm.shocks.ar1.Rouwenhorstbare-attribute access).2e3e974VariableInfo.is_shock→is_process.Variables.shock_names→process_names.typing.ShockName→typing.ProcessName. Plus the matchingnon_shock_nameslocal-var and test-function-name renames.ee357b5_processes/iid.pyand_processes/ar1.py:Uniform→UniformIIDProcess,Normal→NormalIIDProcess,LogNormal→LogNormalIIDProcess,NormalMixture→NormalMixtureIIDProcess,Tauchen→TauchenAR1Process,Rouwenhorst→RouwenhorstAR1Process,TauchenNormalMixture→TauchenNormalMixtureAR1Process.api/processes.pydrops itsas ...aliases — plain re-export. Tests that usedlcm._processes.iid.Xqualified access switch to top-level imports.End state
from lcm import UniformIIDProcess, TauchenAR1Process, ...(unchanged from Phase 2; the alias indirection is now removed).lcm._grids/andlcm._processes/are the only homes for grid / process implementation. Both packages signal "private" via the leading underscore.lcm.shocksnamespace. No moreis_shock/shock_names/ShockNameidentifiers in source.What's NOT in this PR
from lcm.shocks.iid import Uniform→from lcm import UniformIIDProcessfrom lcm.shocks.ar1 import Tauchen→from lcm import TauchenAR1Processfrom lcm.grids import ...continues to work but should switch tofrom lcm import ...for public classes (the_gridspackage is now private).info.is_shock→info.is_processonVariableInfoinstances.variables.shock_names→variables.process_namesonVariablesinstances.Test plan
pixi run -e tests-cpu tests -n 7— 1001 passed, 10 skipped (unchanged)pixi run ty— all checks passprek run --all-files— all hooks passpython from lcm import UniformIIDProcess, TauchenAR1Process, RouwenhorstAR1Processlcm/package and a private_lcm/package #361) is merged before merging this PR🤖 Generated with Claude Code