Skip to content

Do not rely on repr() of np.float64 - #1506

Open
musicinmybrain wants to merge 1 commit into
nschloe:mainfrom
musicinmybrain:numpy-2.2-dolfin
Open

Do not rely on repr() of np.float64#1506
musicinmybrain wants to merge 1 commit into
nschloe:mainfrom
musicinmybrain:numpy-2.2-dolfin

Conversation

@musicinmybrain

Copy link
Copy Markdown

Use .item() to extract a float before applying repr().

Fixes a regression in numpy 2.2:

 FAILED tests/test_dolfin.py::test_dolfin[mesh3] - ValueError: could not convert string to float: 'np.float64(63.69616873214543)'

See #1499.

Use `.item()` to extract a `float` before applying `repr()`.

Fixes a regression in numpy 2.2:

   FAILED tests/test_dolfin.py::test_dolfin[mesh3] - ValueError: could
   not convert string to float: 'np.float64(63.69616873214543)'
@mgorny

mgorny commented Mar 17, 2025

Copy link
Copy Markdown

@musicinmybrain, I've submitted a slightly different fix (using str()) in #1513. Not sure, but I think it's more reliable than using .item().

@musicinmybrain

Copy link
Copy Markdown
Author

Thanks! Hopefully @nschloe will investigate and choose an approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants