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

Custom floats do not respect np.set_printoptions #125

Open
jakevdp opened this issue Dec 5, 2023 · 0 comments
Open

Custom floats do not respect np.set_printoptions #125

jakevdp opened this issue Dec 5, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jakevdp
Copy link
Collaborator

jakevdp commented Dec 5, 2023

Reported in jax-ml/jax#18820

The repr code is here:

PyObject* PyCustomFloat_Repr(PyObject* self) {
T x = reinterpret_cast<PyCustomFloat<T>*>(self)->value;
float f = static_cast<float>(x);
std::ostringstream s;
s << (std::isnan(f) ? std::abs(f) : f);
return PyUnicode_FromString(s.str().c_str());
}

@hawkinsp points out that we could probably make this work by printing via np.float32 rather than via python float

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants