Reputation: 1350
I use astropy
to make calculations with units and I normally do these calculations in a jupyter notebook so the results are printed nicely. I would like to know how to control the number of digits that are displayed in the notebook. Take a look at this example:
The speed of light is defined to be exactly "c = 29,979,245,800 cm/s". However, when I print const.c.cgs
in a cell, I get "2.9979246 x 10^10 cm/s". It rounded it up. I know that the exact value is indeed stored in that constant as can be seen by printing it or accessing its value directly (e.g. print(const.c.cgs)
or simply const.c.cgs.value
which gives the exact value "29979245800 cm/s"), but it displays it with rounding up. I understand this behavior and it's fine for most cases, but there are cases like this where I'd like to see more digits. How can I change the number of digits that are printed in the cell? I want to have this pretty printing of jupyter, but I want to see the full value too.
Upvotes: 1
Views: 67
Reputation: 2542
Google on astropy quantity format
(for future reference) and then see:
https://docs.astropy.org/en/stable/units/format.html
Upvotes: 2