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

[time] sunpy.time to astropy time #2638

Merged
merged 10 commits into from May 23, 2018

Conversation

Projects
None yet
5 participants
@vn-ki
Copy link
Member

commented May 22, 2018

This PR should fix sunpy.time(TimeRange, julian and utime).

@pep8speaks

This comment has been minimized.

Copy link

commented May 22, 2018

Hello @vn-ki! Thanks for updating the PR.

Line 33:101: E501 line too long (115 > 100 characters)

Comment last updated on May 23, 2018 at 13:08 Hours UTC
@@ -201,7 +195,8 @@ def __eq__(self, other):
result : `bool`
"""
if isinstance(other, TimeRange):
return (self.start == other.start) and (self.end == other.end)
return _is_time_equal(

This comment has been minimized.

Copy link
@Cadair

Cadair May 22, 2018

Member

This is a work around right? if so should have a comment

This comment has been minimized.

Copy link
@vn-ki

vn-ki May 22, 2018

Author Member

Yeah. I'll add it.

This comment has been minimized.

Copy link
@vn-ki

vn-ki May 22, 2018

Author Member

I added the comment to the doc string of the function.

def _is_time_equal(t1, t2):
if abs(t1 - t2) < 1 * u.nanosecond:
return True

This comment has been minimized.

Copy link
@Punyaslok

Punyaslok May 22, 2018

Member

Remove the blank line?

t1 = Time('1995-12-31T23:59:59', format='isot')
t2 = Time('1995-12-31T23:59:60', format='isot')

assert not _is_time_equal(t1, t2)

This comment has been minimized.

Copy link
@Punyaslok

Punyaslok May 22, 2018

Member

Maybe another test similar to the + TimeDelta(0*u.day) test. Check to see if fail happens if difference is ~1 ns ?

def test_julian_day():
assert julian.julian_day('1900-01-01 12:00') == 2415021.0
assert julian.julian_day(LANDING) == 2439159.5
result = julian.julian_day('2000-03-01 15:30:26')
assert_almost_equal(result, 2451605.1461111, decimal=3)


def test_julian_day1():
"""should return julian day for date 1"""
expected_day = 2415021.0

This comment has been minimized.

Copy link
@Punyaslok

Punyaslok May 22, 2018

Member

Either you use a newline after the doc string, or you don't. #ocd

Notes
-----
If time_string is an instance of float, then it is assumed to be in
unix time format.

This comment has been minimized.

Copy link
@nabobalis

nabobalis May 22, 2018

Contributor

What is the case now?

This comment has been minimized.

Copy link
@vn-ki

vn-ki May 22, 2018

Author Member

You have to specify the format yourself with the format keyword.

>>> sunpy.time.parse_time('2012/08/01')
datetime.datetime(2012, 8, 1, 0, 0)
>>> sunpy.time.parse_time('2005-08-04T00:01:02.000Z')
datetime.datetime(2005, 8, 4, 0, 1, 2)

This comment has been minimized.

Copy link
@nabobalis

nabobalis May 22, 2018

Contributor

Do we want these examples removed?

This comment has been minimized.

Copy link
@vn-ki

vn-ki May 22, 2018

Author Member

Yup. And proper ones were added in their place.

@Cadair

Cadair approved these changes May 23, 2018

@Cadair Cadair changed the title sunpy.time to astropy time [time] sunpy.time to astropy time May 23, 2018

@Cadair Cadair merged commit b1795bf into sunpy:time May 23, 2018

4 of 7 checks passed

ci/circleci: html-docs CircleCI is running your tests
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
ci/circleci: astropy-time Your tests passed on CircleCI!
Details
ci/circleci: egg-info-27 Your tests passed on CircleCI!
Details
ci/circleci: egg-info-35 Your tests passed on CircleCI!
Details
ci/circleci: egg-info-36 Your tests passed on CircleCI!
Details
@@ -127,7 +127,7 @@ def value(self):
for jd, out in iterator:
out[...] = timedelta(days=jd.item())

return self.mask_if_needed(iterator.operands[-1])
return iterator.operands[-1]

This comment has been minimized.

Copy link
@vn-ki

vn-ki May 23, 2018

Author Member

Note to self: astropy 3.1 has mask_if_needed while 3.0 don't.

@Cadair Cadair added this to the Time milestone May 31, 2018

@vn-ki vn-ki deleted the vn-ki:timerange-astropy-time branch May 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.