Improve tests to avoid leaving leftovers.#244
Conversation
Improving tests type hints.
There was a problem hiding this comment.
Pull request overview
This PR updates the cluster-richness analysis tests and CLI/library plumbing so test-generated analysis artifacts can be redirected away from the repository root. It mainly adds explicit typing in tests and introduces an --output-dir path that is threaded through the analysis pipeline.
Changes:
- Add
--output-dirto the cluster-richness CLI and pass it through to real-analysis and mock-study output generation. - Extend
CutAnalyzer,MockStudy, andBestfitDatabasepath handling to usePathobjects and base directories for generated files. - Tighten Python test type hints and update several app tests to use
tmp_pathfor output isolation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/python/app/test_cluster_richness_app.py |
Adds type annotations and updates several CLI tests to pass --output-dir/tmp_path. |
tests/python/analysis/test_cluster_richness_diagnostics.py |
Adds return/parameter annotations and minor local variable renames in diagnostics tests. |
tests/python/analysis/test_cluster_richness_analyzer.py |
Adds fixture/test type hints and small local variable renames in analyzer tests. |
numcosmo_py/app/cluster_richness.py |
Introduces CLI --output-dir and forwards it into analysis/mock-study execution. |
numcosmo_py/analysis/cluster_richness/_mock_study.py |
Adds base_dir/Path handling for output files and cached database location. |
numcosmo_py/analysis/cluster_richness/_database.py |
Changes database path typing from str to Path. |
numcosmo_py/analysis/cluster_richness/_analyzer.py |
Adds base_dir support when writing MCMC/bootstrap FITS outputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self.base_dir = base_dir if base_dir is not None else Path(".") | ||
| self.mock_results: list[dict[float, CutAnalysisResult]] = [] | ||
| self.fiducial_results = fiducial_results | ||
| self.verbose = verbose |
| "--output-prefix", | ||
| output_prefix, | ||
| "test_output", | ||
| "--output-dir", | ||
| tmp_path.as_posix(), |
| help="Directory for output files (default: current directory).", | ||
| ), | ||
| ] = None | ||
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #244 +/- ##
==========================================
+ Coverage 77.44% 77.49% +0.04%
==========================================
Files 663 663
Lines 110623 110631 +8
==========================================
+ Hits 85676 85734 +58
+ Misses 24947 24897 -50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Improve tests to avoid leaving leftovers.
Improving tests type hints.