Skip to content

fix: avoid mutable default argument in ExactStringPerCategoryMatchMetric - #15953

Closed
andrewwhitecdw wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:fix-mutable-default-categories-classification-accuracy
Closed

fix: avoid mutable default argument in ExactStringPerCategoryMatchMetric#15953
andrewwhitecdw wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:fix-mutable-default-categories-classification-accuracy

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

Replaces the mutable default argument categories=[] with categories=None and instantiates a fresh list inside the constructor. This prevents shared state across metric instances.

  • nemo/collections/common/metrics/classification_accuracy.py: changed default and added None guard
  • Added regression tests in tests/collections/common/test_metrics.py

Tested:

uv run python -m pytest tests/collections/common/test_metrics.py::TestCommonMetrics::test_exact_string_per_category_match_metric_default_categories_is_none tests/collections/common/test_metrics.py::TestCommonMetrics::test_exact_string_per_category_match_metric_tracks_categories -v
# 2 passed

cc @nithinraok for common/core review

@copy-pr-bot

copy-pr-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@andrewwhitecdw

Copy link
Copy Markdown
Author

Could a maintainer please add the Run CICD label to trigger CI? As an outside contributor I don't have permission to apply labels myself. Thanks!

@nithinraok

Copy link
Copy Markdown
Member

These are all blind AI generated PRs. Why do we need a test case to test None as default?

@nithinraok nithinraok closed this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants