Bug fix/sserr#32
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis pull request modernizes the project's Python type annotations to use PEP 604 syntax (replacing Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes Areas requiring extra attention:
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro Disabled knowledge base sources:
⛔ Files ignored due to path filters (1)
📒 Files selected for processing (23)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR modernizes type hints to use Python 3.10+ native syntax (replacing typing.List, typing.Dict, etc. with list, dict), fixes SSERR evaluation logic, migrates CI/CD workflows to use uv for faster dependency management, and adds comprehensive development setup documentation.
Key Changes:
- Modernized type hints across the codebase to use native Python 3.10+ syntax (
list[T]instead ofList[T]) - Updated SSERR evaluation to properly configure touchdown mode and use correct segment lengths
- Migrated all GitHub Actions workflows from pip to uv for dependency management
- Added detailed development setup guide in README including uv installation and usage
Reviewed changes
Copilot reviewed 22 out of 24 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/utils/weac_reference_runner.py | Modernized type hints from typing module to native Python 3.10+ syntax |
| tests/test_regression_simulation.py | Updated test to use Config(touchdown=True) and adjusted baseline values for SSERR calculations |
| tests/analysis/test_criteria_evaluator.py | Updated test to use Config(touchdown=True) for SSERR evaluation |
| src/weac/utils/snowpilot_parser.py | Modernized type hints from typing.List/Tuple to native list/tuple syntax |
| src/weac/logging_config.py | Modernized type hint from Optional[str] to str | None |
| src/weac/core/unknown_constants_solver.py | Modernized type hints and reformatted multi-line type annotations |
| src/weac/core/system_model.py | Modernized type hints and updated isinstance check to use Sequence |
| src/weac/core/slab_touchdown.py | Modernized type hints from Optional to union syntax |
| src/weac/core/slab.py | Modernized List[Layer] to list[Layer] type hints |
| src/weac/core/scenario.py | Modernized type hints and imported Sequence from collections.abc |
| src/weac/core/eigensystem.py | Modernized type hints, though introduced invalid np.ndarray[dtype] syntax |
| src/weac/components/model_input.py | Modernized type hints and updated field descriptions |
| src/weac/analysis/plotter.py | Modernized type hints and added validation for matching weak layer/slab counts |
| src/weac/analysis/criteria_evaluator.py | Modernized type hints, updated SSERR logic with proper touchdown configuration and segment lengths |
| pyproject.toml | Moved build tools from dev dependencies to separate build extra |
| README.md | Added comprehensive development setup section documenting uv usage |
| .python-version | Added Python version specification file (3.12) |
| .gitignore | Removed .python-version from gitignore to track it in repository |
| .github/workflows/tests.yml | Migrated from pip to uv, updated action versions (though to non-existent v6) |
| .github/workflows/release.yml | Migrated to uv for building and publishing |
| .github/workflows/pylint.yml | Migrated to uv for dependency installation |
| .github/workflows/format.yml | Migrated to uv for running ruff |
| .github/workflows/docs.yml | Migrated to uv for building Sphinx documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| layers: List[Layer] = Field( | ||
| default_factory=lambda: [Layer(rho=250, h=100)], description="List of layers" | ||
| layers: list[Layer] = Field( | ||
| default_factory=lambda: [Layer(rho=250, h=100)], description="list of layers" |
There was a problem hiding this comment.
[nitpick] The description changed from "List of layers" to "list of layers" (lowercase). While this matches the type hint change, it's inconsistent with other field descriptions like "Weak layer" (line 49) and "Scenario configuration" (line 55) which use capitalization. Consider keeping consistent capitalization across all field descriptions.
| default_factory=lambda: [Layer(rho=250, h=100)], description="list of layers" | |
| default_factory=lambda: [Layer(rho=250, h=100)], description="List of layers" |
| ewC: np.ndarray[np.complex128] # shape (k): Complex Eigenvalues | ||
| ewR: np.ndarray[np.float64] # shape (k): Real Eigenvalues | ||
| evC: np.ndarray[np.complex128] # shape (6, k): Complex Eigenvectors | ||
| evR: np.ndarray[np.float64] # shape (6, k): Real Eigenvectors |
There was a problem hiding this comment.
The type hint syntax np.ndarray[np.complex128] and np.ndarray[np.float64] is invalid. NumPy arrays should be typed as np.ndarray (without dtype specification) or using the correct numpy typing syntax like npt.NDArray[np.complex128] (requires from numpy.typing import NDArray). The current syntax will cause type checking errors.
|
|
||
| def calc_eigenvalues_and_eigenvectors( | ||
| self, system_matrix: NDArray[np.float64] | ||
| self, system_matrix: np.ndarray[np.float64] |
There was a problem hiding this comment.
The type hint np.ndarray[np.float64] is invalid. NumPy arrays should be typed as np.ndarray (without dtype specification) or using the correct numpy typing syntax like npt.NDArray[np.float64] (requires from numpy.typing import NDArray). The current syntax will cause type checking errors.
| Solution vector (6xN) at position x. | ||
| """ | ||
| if isinstance(x, (list, tuple, np.ndarray)): | ||
| if isinstance(x, (np.ndarray, Sequence)): |
There was a problem hiding this comment.
The isinstance check order is problematic. np.ndarray should be checked before Sequence because np.ndarray is a Sequence in Python's abstract base class hierarchy. This could lead to incorrect behavior when the order matters. The original code had (list, tuple, np.ndarray) which was more explicit. Consider changing to (list, tuple, np.ndarray) or check np.ndarray first.
| if isinstance(x, (np.ndarray, Sequence)): | |
| if isinstance(x, (list, tuple, np.ndarray)): |
| cut_length=2 * l_BC, | ||
| ) | ||
| system_copy.config.touchdown = True | ||
| # system_copy.config.touchdown = True |
There was a problem hiding this comment.
Commented-out code should be removed. Line 687 contains # system_copy.config.touchdown = True which is redundant since line 674 already sets this.
| # system_copy.config.touchdown = True |
| sR: np.ndarray[ | ||
| np.float64 | ||
| ] # shape (k): Real positive eigenvalue shifts (for numerical robustness) | ||
| sC: NDArray[ | ||
| sC: np.ndarray[ | ||
| np.float64 | ||
| ] # shape (k): Complex positive eigenvalue shifts (for numerical robustness) |
There was a problem hiding this comment.
The type hint syntax np.ndarray[np.float64] is invalid. NumPy arrays should be typed as np.ndarray (without dtype specification) or using the correct numpy typing syntax like npt.NDArray[np.float64] (requires from numpy.typing import NDArray). The current syntax will cause type checking errors.
| self, kn: Optional[float], kt: Optional[float] | ||
| ) -> NDArray[np.float64]: | ||
| self, kn: float | None, kt: float | None | ||
| ) -> np.ndarray[np.float64]: |
There was a problem hiding this comment.
The return type hint np.ndarray[np.float64] is invalid. NumPy arrays should be typed as np.ndarray (without dtype specification) or using the correct numpy typing syntax like npt.NDArray[np.float64] (requires from numpy.typing import NDArray). The current syntax will cause type checking errors.
| np.ndarray[np.complex128], | ||
| np.ndarray[np.float64], | ||
| np.ndarray[np.complex128], | ||
| np.ndarray[np.float64], | ||
| np.ndarray[np.float64], | ||
| np.ndarray[np.float64], |
There was a problem hiding this comment.
The return type hints use np.ndarray[np.complex128] and np.ndarray[np.float64] which are invalid. NumPy arrays should be typed as np.ndarray (without dtype specification) or using the correct numpy typing syntax like npt.NDArray[np.complex128] (requires from numpy.typing import NDArray). The current syntax will cause type checking errors.
| system_copy = copy.deepcopy(system) | ||
| system_copy.config.touchdown = True | ||
| system_copy.update_scenario(scenario_config=ScenarioConfig(phi=0.0)) | ||
| l_BC = system.slab_touchdown.l_BC |
There was a problem hiding this comment.
This line accesses system.slab_touchdown.l_BC before ensuring that slab_touchdown is computed. If the original system was created with config.touchdown=False, then system.slab_touchdown will be None, causing an AttributeError. The touchdown is only enabled on system_copy in line 674, but line 676 accesses the original system. This should access system_copy.slab_touchdown.l_BC instead, or ensure touchdown is enabled on the original system first.
| l_BC = system.slab_touchdown.l_BC | |
| l_BC = system_copy.slab_touchdown.l_BC |
Fix Sphinx Docs
Summary by CodeRabbit
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.