-
Notifications
You must be signed in to change notification settings - Fork 39
add as_float, change repr(x) -> str(x) #214
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
Conversation
Closing-and-reopening this PR, in hopes that it will re-run the tests. |
@harmsm - I've cleaned-up the existing regression tests and added explicit tests for both major versions of NumPy, so you should see that while this PR doesn't break anything for NumPy 1, it hasn't fixed everything yet for NumPy 2 - could you take a look? Thanks, |
Yes, I'll check into it. |
Most of the failures traced back to The two remaining failures are both in features/image-visualization: "numpy 8 bit L image with colormap" and "pillow 8 bit L image with colormap". I'm struggling to understand the nature of the failure. The output and reference svg files have identical tags and look visually identical if I load them in Inkscape, but have different "data:image/png;base64" output strings. Presumably the images need to be binary identical for the test to pass? I'm going to keep working on it, but pushed changes now in case this is a problem with the test framework rather than a true problem with the library. |
Okay, odd. I have two tests failing on my local machine, but they're passing in the github workflow. 🤷 |
Yep, those images are supposed to be identical, but maybe there are some platform differences we should be aware of - what's your dev environment look like? In the meantime, passing tests are passing tests ... I'll merge the request. |
I'm testing in a fresh conda environment (Python 3.12, NumPy 2.0, and whatever was installed with Glad it's passing more generally. Thanks for the great library and merging the fix.
|
Fixes a bug that does not allow graphs to render when using numpy 2.0. This is because numpy changed the string representation of scalar values. (
repr(some_numpy_float)
now returns"np.float32(float_value)"
instead of"float_value"
). See Issue 213 for details.toyplot.require.as_float
andtoyplot.require.as_int
)float(value)
andint(value)
calls in the package with these new functions.repr(value)
calls intoyplot.html
withstr(value)
.I tested the new code in Python 2.11 with both numpy 1.26.4 and numpy 2.0. It successfully fixed the initial bug.
I ran the regression tests on both the main branch and my new commits. Not all tests were successful on the main branch; no new tests failed with my changes. (regression.py output gives: 2511 steps passed, 18 failed, 34 skipped, 0 undefined).