Precision issue when adding 0 seconds to a Time
See original GitHub issueI’m running into a weird issue on 32-bit systems
>>> from astropy.time import Time
>>> from astropy import units as u
>>> t = Time('2016-03-22T12:30:31.000')
>>> t == t
True
>>> t + 0 * u.s == t
False
It looks like jd2 is being modified even though the offset is 0:
>>> t.jd1
2457470.0
>>> t.jd2
0.021192129629629575
>>> (t + 0 * u.s).jd1
2457470.0
>>> (t + 0 * u.s).jd2
0.02119212962962962
To reproduce, do this in the astropy repo:
docker run -v $PWD:/repo -it quay.io/pypa/manylinux1_i686 /bin/bash
then this in the docker image shell:
/opt/python/cp36-cp36m/bin/pip install numpy scipy "pytest<3.7" pytest-astropy pytest-xdist Cython jinja2
/opt/python/cp36-cp36m/bin/python setup.py develop
/opt/python/cp36-cp36m/bin/python
then run the code above.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
High-Precision Time: how to use fractional seconds in MySQL ...
In this example, the timestamp of the record pasted in here has no fractional seconds part. This is because the input value has...
Read more >Time in Excel (algorithmic repeat the floating-point precision ...
Let's make an enumeration of seconds in the first column of the Excel sheet [A1..] = 0.5 , 1.0 , 1.5 , 2.0...
Read more >ISO datetime, loss of precision - Power Platform Community
When it saves, during the save process, it converts it to a more standard date/time format, and looses precision (ie the decimal after...
Read more >How to preserve nanosecond precision in datetime ...
I am trying to maintain this precision throughout the calculations, but I lose the precision because the precision of the numbers exceed double...
Read more >Don't Store That in a Float | Random ASCII - WordPress.com
The one-true answer. Store elapsed game time in a double, starting at 2^32 seconds. You will get constant precision of better than a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi. Hacktoberfest brought me here. I just reproduced this. I’ll take a look at it.
Looking back through the text here, the bug was for a specific 32-bit version, but more generally represented UTC and TAI not perfectly round-tripping. I’ll close this in favour of #6970, which deals with that as well (and a bit more generally).