Skip to content

Add unit tests (92% coverage) and fix E5/E6 bugs from issue #352#63

Merged
GernotMaier merged 6 commits into
mainfrom
unit-tests
May 31, 2026
Merged

Add unit tests (92% coverage) and fix E5/E6 bugs from issue #352#63
GernotMaier merged 6 commits into
mainfrom
unit-tests

Conversation

@GernotMaier
Copy link
Copy Markdown
Member

  • 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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_chunked for classification when tmva_style=True.
  • Fix E6 by changing the energy_bins_log10_tev fallback in configure_training to avoid an AttributeError when 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.

Comment thread src/eventdisplay_ml/models.py
Comment thread src/eventdisplay_ml/config.py
Comment thread tests/test_config.py Outdated
Comment thread tests/test_hyper_parameters.py Outdated
Comment thread tests/test_utils.py Outdated
GernotMaier and others added 5 commits May 31, 2026 12:56
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>
@GernotMaier GernotMaier marked this pull request as ready for review May 31, 2026 11:03
@GernotMaier GernotMaier merged commit 1aa23e5 into main May 31, 2026
2 of 3 checks passed
@GernotMaier GernotMaier deleted the unit-tests branch May 31, 2026 11:03
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.

2 participants