question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Precision issue when adding 0 seconds to a Time

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lrm25commented, Oct 24, 2018

Hi. Hacktoberfest brought me here. I just reproduced this. I’ll take a look at it.

0reactions
mhvkcommented, Mar 25, 2019

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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found