Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent iteration over metrics #1320

Merged
merged 3 commits into from
Nov 8, 2022
Merged

Prevent iteration over metrics #1320

merged 3 commits into from
Nov 8, 2022

Conversation

SkafteNicki
Copy link
Member

@SkafteNicki SkafteNicki commented Nov 8, 2022

What does this PR do?

Fixes #1319
Prevents users from accidentally end up in a infinite loop if they try to iterate over a single metric.
The reason currently is that we implement the __getitem__ method to create compositional metrics for indexing and we therefore need to explicit prevent iteration.

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@SkafteNicki SkafteNicki added the bug / fix Something isn't working label Nov 8, 2022
@SkafteNicki SkafteNicki added this to the v0.10 milestone Nov 8, 2022
src/torchmetrics/metric.py Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 8, 2022

Codecov Report

Merging #1320 (3844b25) into master (920fe0f) will increase coverage by 0%.
The diff coverage is 100%.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1320   +/-   ##
======================================
  Coverage      87%     87%           
======================================
  Files         195     195           
  Lines       11346   11348    +2     
======================================
+ Hits         9838    9840    +2     
  Misses       1508    1508           

@mergify mergify bot added the ready label Nov 8, 2022
@justusschock justusschock enabled auto-merge (squash) November 8, 2022 11:03
@justusschock justusschock merged commit 00bb1ed into master Nov 8, 2022
@justusschock justusschock deleted the bugfix/no_iter_allowed branch November 8, 2022 14:01
Borda pushed a commit that referenced this pull request Nov 16, 2022
* fix

* changelog

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

(cherry picked from commit 00bb1ed)
Borda pushed a commit that referenced this pull request Nov 16, 2022
* fix

* changelog

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

(cherry picked from commit 00bb1ed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / fix Something isn't working ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Iteration over a metric never ends
4 participants