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

Print large value with suppress in printoptions #20807

Open
sh0416 opened this issue Apr 18, 2024 · 1 comment
Open

Print large value with suppress in printoptions #20807

sh0416 opened this issue Apr 18, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@sh0416
Copy link

sh0416 commented Apr 18, 2024

Description

import jax.numpy as jnp

jnp.set_printoptions(suppress=True)
print(jnp.full((3, 3), fill_value=109000000, dtype=jnp.float32))

outputs

[[1.e+08 1.e+08 1.e+08]
 [1.e+08 1.e+08 1.e+08]
 [1.e+08 1.e+08 1.e+08]]

.

suppress (bool, optional) – If True, always print floating point numbers using fixed point notation, in which case numbers equal to zero in the current precision will print as zero

Why the scientific notation is shown in this context?
Thank you

System info (python version, jaxlib version, accelerator, etc.)

jax:    0.4.25
jaxlib: 0.4.25
numpy:  1.26.4
python: 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0]
jax.devices (1 total, 1 local): [CpuDevice(id=0)]
process_count: 1
platform: uname_result(system='Linux', node='gpusystem', release='5.15.0-100-generic', version='#110-Ubuntu SMP Wed Feb 7 13:27:48 UTC 2024', machine='x86_64')
@sh0416 sh0416 added the bug Something isn't working label Apr 18, 2024
@rajasekharporeddy
Copy link
Contributor

rajasekharporeddy commented Apr 18, 2024

Hi @sh0416

Thanks for the question.

JAX leverages NumPy's implementation of set_printoptions directly by assigning it to jax.numpy.set_printoptions.
https://github.com/google/jax/blob/c4dea624cce95e2dcd288831eadd68d1aae4a05a/jax/_src/numpy/lax_numpy.py#L117C1-L117C39

From numpy/numpy#21653 (comment), it can be understood that numpy displays the numbers above 10^8 with the scientific notation by default when displaying numpy arrays.

suppress (bool, optional) – If True, always print floating point numbers using fixed point notation, in which case numbers equal to zero in the current precision will print as zero

AFAIK, it is documentation error, where it should have mentioned
If True, always print floating point numbers using fixed point notation, in which case the decimal numbers equal to zero in the current precision will print as zero.

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