Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Catch ValueError to support pytorch (and others) plotting#26807

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tacaswell merged 1 commit intomatplotlib:mainfromoscargus:torchfix
Sep 18, 2023

Conversation

@oscargus
Copy link
Member

@oscargusoscargus commentedSep 18, 2023
edited
Loading

PR summary

Closes#26806

Not sure we should add it, but will probably help other libraries as well (that we do not formally support).

No way of testing on the CI as we do not want to install torch, but I promise that it works locally. 😉

PR checklist

Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

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

This seems fine. For patches like this, though, it would be nice to know why it broke in the first place to be sure that the raise was unintentional.

@tacaswell
Copy link
Member

This is numpy and pytorch making different choices about what to do when cast to a Python scalar

In [1]:importnumpyasnpIn [2]:float(np.array([[1,2], [3,5]]))---------------------------------------------------------------------------TypeErrorTraceback (mostrecentcalllast)CellIn[2],line1---->1float(np.array([[1,2], [3,5]]))TypeError:onlylength-1arrayscanbeconvertedtoPythonscalars

@jklymak
Copy link
Member

This was last changed in#26303, and it indeed was made more strict there, though I think inadvertently. (Not a huge fan of micro optimizations for the reason of unintended consequences).

I don't see the harm in allowing a ValueError through, OTOH, pytorch should probably return an error consistent with numpy if they want maximum compatibility.

jklymak added a commit that referenced this pull requestSep 18, 2023
…807-on-v3.8.xBackport PR#26807 on branch v3.8.x (Catch ValueError to support pytorch (and others) plotting)
@oscargusoscargus deleted the torchfix branchSeptember 18, 2023 16:36
@tacaswell
Copy link
Member

OTOH, pytorch should probably return an error consistent with numpy

yeah, but then they have a changed-behavior and deprecation problem. Guess they could raise a multiply inherited exception from bothTypeError andValueError 😈

@ksundenksunden mentioned this pull requestNov 2, 2023
5 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jklymakjklymakjklymak approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

v3.8.1

Development

Successfully merging this pull request may close these issues.

[Bug]: ValueError when plotting 2D pytorch tensor using matplotlib==3.8.0

3 participants

@oscargus@tacaswell@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp