Skip to content

Conversation

@timmens
Copy link
Member

@timmens timmens commented Sep 16, 2025

No description provided.

timmens and others added 12 commits September 12, 2025 20:41
- Add Model.solve(), Model.simulate(), Model.solve_and_simulate() methods
- Pre-compile all functions during Model.__post_init__()
- Add computed attributes: internal_model, params_template, etc.
- Deprecate get_lcm_function() with backward compatibility
- Add comprehensive test suite in test_model_methods.py
- Update CLAUDE.md documentation
- All existing tests pass with only deprecation warnings

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Replace get_model_config() with get_model() throughout test suite
- Consistently use 'model' instead of 'model_config' for fully initialized models
- Add backward compatibility alias get_model_config() with deprecation warning
- Extract Model initialization logic to separate helper module (model_initialization.py)
- Create robust frozen dataclass attribute setter utility
- Fix test issues caused by pre-compiled functions in Model.__post_init__
- Remove demo module as requested in review

All tests pass (293/293) with proper deprecation warnings for legacy functions.
Addresses all review feedback while maintaining backward compatibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@timmens timmens changed the base branch from main to refactor-entry-point September 16, 2025 20:52
timmens and others added 10 commits September 17, 2025 14:29
- Add Regime class with range-based active periods and validation
- Update Model class to support regimes parameter alongside legacy API
- Auto-derive computed_n_periods from regime periods
- Add deprecation warnings for legacy Model API
- Export Regime class from lcm package
- Create comprehensive test suite (some tests skipped pending full implementation)
- Fix type annotations and linting issues
- Maintain 100% backward compatibility - all existing tests pass

The regime infrastructure provides the foundation for multi-regime lifecycle
models while preserving existing functionality. Full regime model solving
and simulation will be implemented in follow-up commits.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove ModelBlock class entirely from user_model.py
- Remove all block-related fields from Model class
- Remove _initialize_block_model() method
- Remove ModelBlock from __init__.py exports and __all__ list
- Update design document to remove all Block terminology
- Simplify Model.__post_init__ to only handle regimes vs legacy
- Update error message to reflect regimes or legacy parameters only
- Fix remaining block comment references

This completes the terminology unification: there are now only Regimes
and Models (collections of Regimes). The old "Block" concept has been
entirely replaced by the more intuitive "Regime" terminology.

All tests still pass and backward compatibility is maintained.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Update both deprecation warnings to specify removal in version 0.1.0
- Update entry_point.py: get_lcm_function() deprecation warning
- Update user_model.py: Legacy Model API deprecation warning
- Fix test_model_methods.py deprecation warning test pattern
- Enable and fix test_legacy_api_deprecation_warning in test_regimes.py
- Use warnings.catch_warnings() pattern for complex test blocks
- Handle expected initialization failures gracefully with noqa annotations
- Fix line length issues and import organization for linting compliance

The deprecation warnings now clearly communicate the timeline for removal
and follow the established testing patterns from the existing codebase.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Update test_legacy_api_deprecation_warning to use pytest.warns() pattern
- Follow same approach as test_model_methods.py with re.escape() matching
- Combine with pytest.raises() for expected initialization failure
- Use specific ModelInitilizationError instead of generic Exception
- Fix line length issues and import organization for linting compliance
- Both deprecation tests now use consistent pytest.warns() patterns

This creates a unified testing approach across the codebase for
deprecation warning verification with proper exception handling.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Keep Model.n_periods as int | None for both regime and legacy APIs
- Allow Regime.active to be range | None (None = active in all periods)
- Implement sophisticated interaction logic:
  * If n_periods is None: derive from max(regime.active.stop) across regimes
  * If n_periods is not None: validate alignment, set None regimes to all periods
- Add comprehensive validation for period coverage and alignment
- Update docstrings to document the flexible interaction behavior
- Add extensive test coverage for all interaction scenarios:
  * Deriving n_periods from regime active ranges
  * Setting regimes with active=None to all periods
  * Validating alignment between explicit ranges and n_periods
  * Error cases for misaligned or missing active ranges
- Fix type annotations and linting issues
- Maintain backward compatibility with existing functionality

This creates a much more flexible and intuitive API where users can:
1. Let regimes define the total periods (n_periods=None)
2. Use n_periods to constrain regimes (regimes adapt to fit)
3. Mix explicit and implicit (None) active ranges naturally

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link
Member

@hmgaudecker hmgaudecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like a lot what I am seeing, thanks!

As in the other PR, the main thing is that we should be much more aggressive about implementing changes. Since we are not, I do not think I saw the currently-preferred way (which should be the only way) to set up a model in action, but maybe I did not look closely enough.

Base automatically changed from refactor-entry-point to main September 21, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants