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

list index out of range in _sync_dist #1218

Closed
geoffrey-g-delhomme opened this issue Sep 13, 2022 · 2 comments · Fixed by #1219
Closed

list index out of range in _sync_dist #1218

geoffrey-g-delhomme opened this issue Sep 13, 2022 · 2 comments · Fixed by #1219
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Milestone

Comments

@geoffrey-g-delhomme
Copy link
Contributor

🐛 Bug

list index out of range out of range error when using a list state with a default=[].

To Reproduce

self.add_state("p_true_positives", default=[], dist_reduce_fx="cat")

when no value is added during update, it raises a list index out of range when hitting:

if isinstance(output_dict[attr][0], Tensor): in metric.py (l. 374).

Code sample

See above

Expected behavior

Just add a len() > 0 check before

Environment

  • TorchMetrics version (and how you installed TM, e.g. conda, pip, build from source): 0.9.3, installed with pip
  • Python & PyTorch Version (e.g., 1.0): torch 1.12.1 / python 3.10.4
  • Any other relevant information such as OS (e.g., Linux): Linux

Additional context

@geoffrey-g-delhomme geoffrey-g-delhomme added bug / fix Something isn't working help wanted Extra attention is needed labels Sep 13, 2022
@github-actions
Copy link

Hi! thanks for your contribution!, great first issue!

geoffrey-g-delhomme pushed a commit to geoffrey-g-delhomme/metrics that referenced this issue Sep 13, 2022
geoffrey-g-delhomme pushed a commit to geoffrey-g-delhomme/metrics that referenced this issue Sep 13, 2022
@stancld
Copy link
Contributor

stancld commented Sep 14, 2022

Hi @geoffrey-g-delhomme, can you share some minimal reproducible code please :]

@SkafteNicki SkafteNicki added this to the v0.10 milestone Sep 14, 2022
Borda pushed a commit that referenced this issue Sep 15, 2022
* fix ##1218
* tests
* changelog

Co-authored-by: Aws user for bootstrap <aws_install@ip-10-102-147-234.ef73-poctrustai.aws.cloud.airbus-v.corp>
Co-authored-by: SkafteNicki <skaftenicki@gmail.com>
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 help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants