Add unit tests and GitHub Actions CI workflow#1
Conversation
Co-authored-by: Gregor Kržmanc <gregor.krzmanc@cern.ch>
- 87 unit tests across 4 test modules:
- test_jetfinder: PseudoJet, NPHistory, NPPseudoJets, anti-kt clustering,
distance matrices (Lorentz, cosine), HDBSCAN clustering
- test_object_cond: calc_eta_phi, huber loss, isin, reincrementalize,
get_clustering (numpy & torch), scatter_counts_to_indices, safe_index
- test_dataset: spherical_to_cartesian, renumber_clusters, TensorCollection,
to_tensor, EventPFCands kinematics
- test_utils: get_path with env vars and fallback, import_module
- GitHub Actions workflow (.github/workflows/tests.yml):
- Runs on push/PR to main
- Python 3.10, CPU-only PyTorch 2.5.0
- Ruff lint check (syntax errors) + pytest
Co-authored-by: Gregor Kržmanc <gregor.krzmanc@cern.ch>
…in deprecated code Co-authored-by: Gregor Kržmanc <gregor.krzmanc@cern.ch>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ca19d05. Configure here.
|
|
||
| - name: Lint with ruff | ||
| run: | | ||
| ruff check --select E9,F63,F7 --output-format=github tests/ |
There was a problem hiding this comment.
CI ruff check missing F82 undefined-name rule
Medium Severity
The ruff check command in the CI workflow is missing the F82 rule from its --select argument. This means the CI won't catch NameError-class bugs (e.g., undefined names), which are valuable lint checks that were intended for enforcement.
Reviewed by Cursor Bugbot for commit ca19d05. Configure here.
| basicjetfinder, | ||
| find_closest_jets, | ||
| inclusive_jets, | ||
| add_step_to_history, |
There was a problem hiding this comment.
Unused imports of untested functions in test file
Low Severity
inclusive_jets and add_step_to_history are imported from src.jetfinder.basicjetfinder but never used in any test. This creates the misleading impression that these functions have dedicated test coverage when they don't (they're only exercised indirectly via basicjetfinder).
Reviewed by Cursor Bugbot for commit ca19d05. Configure here.


Summary
Adds a comprehensive test suite (87 unit tests) and a GitHub Actions CI workflow for automated testing on every push/PR to main.
Tests added (
tests/)test_jetfinder.pyPseudoJetproperties/addition,NPHistory,NPPseudoJets, anti-kt jet finding, Lorentz/cosine distance matrices, HDBSCAN clusteringtest_object_cond.pycalc_eta_phi,huberloss,safe_index,assert_no_nans,isin,reincrementalize,get_clustering_np/get_clustering,scatter_counts_to_indicestest_dataset.pyspherical_to_cartesian,renumber_clusters,TensorCollection,to_tensor,EventPFCandskinematicstest_utils.pyget_pathwith env vars/fallback,import_modulewith temp filesGitHub Actions CI (
.github/workflows/tests.yml)mainruff check --select E9,F63,F7,F82for syntax/fatal errorspytest tests/ -v --tb=shortAlso includes
AGENTS.mdwith Cursor Cloud development environment instructionsLocal test run
All 87 tests pass: