Add unit tests (92% coverage) and fix E5/E6 bugs from issue #352#63
Merged
Conversation
Member
GernotMaier
commented
May 31, 2026
- Add 12 new test files covering all production modules
- Raise overall test coverage to 92%
- Fix E5: process_file_chunked uses features_tmva_style when tmva_style=True
- Fix E6: configure_training no longer raises AttributeError when energy_bins_log10_tev is absent (fallback changed from [] to {})
- Add regression tests for both bugs
- Add diagnostics/ to .gitignore
- Add 12 new test files covering all production modules
- Raise overall test coverage to 92%
- Fix E5: process_file_chunked uses features_tmva_style when tmva_style=True
- Fix E6: configure_training no longer raises AttributeError when
energy_bins_log10_tev is absent (fallback changed from [] to {})
- Add regression tests for both bugs
- Add diagnostics/ to .gitignore
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to substantially increase automated test coverage across Eventdisplay-ML while addressing two reported regressions (E5/E6 from issue #352) in the classification application/training configuration paths.
Changes:
- Add a broad suite of new unit tests spanning most production modules (utils, config, models, data_processing, evaluate, diagnostic_utils, geomag, and optimization helpers).
- Fix E5 by adding TMVA-style branch selection logic to
models.process_file_chunkedfor classification whentmva_style=True. - Fix E6 by changing the
energy_bins_log10_tevfallback inconfigure_trainingto avoid anAttributeErrorwhen the key is absent.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/eventdisplay_ml/models.py |
Adds TMVA-style feature branch selection in process_file_chunked for classification. |
src/eventdisplay_ml/config.py |
Adjusts fallback default for missing energy_bins_log10_tev when building classification pre-cuts. |
tests/test_config.py |
Adds coverage for configure_training / configure_apply, including an E6 regression test. |
tests/test_models_helpers.py |
Adds unit tests for model loading/applying helpers, including an E5 regression test. |
tests/test_utils.py |
Adds tests for utility helpers (path resolution, parsing, parameter loading, naming). |
tests/test_hyper_parameters.py |
Adds tests for hyperparameter dispatch and pre-cut construction. |
tests/test_features.py |
Adds tests for feature lists, exclusions, and TMVA-style feature variants. |
tests/test_geomag.py |
Adds tests for geomagnetic angle calculation correctness and error handling. |
tests/test_data_helpers.py |
Adds unit tests for pure helper functions used in data flattening/preprocessing. |
tests/test_data_processing_remaining.py |
Covers remaining data_processing branches (aliases, optional cols, TMVA-style load path). |
tests/test_evaluate_helpers.py |
Adds tests for evaluate.py helper functions and logging behavior. |
tests/test_evaluate_remaining.py |
Covers remaining evaluate.py branches (zenith grouping, SHAP-per-energy paths). |
tests/test_diagnostic_utils.py |
Adds tests for diagnostic metric computations. |
tests/test_diagnostic_utils_full.py |
Adds tests for cached metrics/importance loading and residual diagnostics utilities. |
tests/test_optimize_helpers.py |
Adds tests for helper functions used by scripts/optimize_classification.py. |
docs/changes/352.bugfix.md |
Towncrier fragment documenting the E5/E6 fixes. |
.gitignore |
Ignores diagnostics/ directory. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.