Skip to content

Conversation

@mhvk
Copy link
Contributor

@mhvk mhvk commented Apr 11, 2015

With Time becoming multidimensional (#3138), it has acquired a shape and size. This could be taken further and TIme could also acquire other ndarray shape-associated properties and methods, such as reshape, ravel, transpose, etc. This is not difficult in principle, though some care must be taken with properly reshaping other array properties as well (location, _delta_ut1_utc, _delta_tdb_tt).

EDIT: for Table mixin purposes with grouping, sorting would also be good (including argsort).

@mhvk
Copy link
Contributor Author

mhvk commented Apr 11, 2015

@taldcroft - I got to implementing the Time shape manipulation routines, using a new private version of replicate, which can not only copy but also do other tricks. As a side benefit, this also ensures __getitem__ works properly even in the presence of attributes that have different (but broadcastable) shape.

With this in place, it will become quite easy to support min, max, and sorting.

@mhvk mhvk added this to the v1.1.0 milestone Apr 11, 2015
@mhvk mhvk force-pushed the time-shape-changing branch 4 times, most recently from b1b33fc to baa9a7f Compare April 11, 2015 17:17
@taldcroft
Copy link
Member

@mhvk - cool! I did a quick scan to see what's happening, and hope to have a more detailed look in the next few days.

@mhvk
Copy link
Contributor Author

mhvk commented Apr 13, 2015

@taldcroft - thanks! One question to ponder: In the present PR, I'm going somewhat out of my way to keep the shape of location, _delta_ut1_utc and _delta_tdb_tt close to how they were given. I think it may actually be a bit excessive. If you think it is better, I could also rewrite such that there is only a difference between scalar values and arrays, with the latter already broadcasted to the shape of the jd1, jd2 arrays when they are defined.

@mhvk mhvk force-pushed the time-shape-changing branch 2 times, most recently from de4b658 to e037ad8 Compare April 13, 2015 19:01
@mhvk mhvk mentioned this pull request Apr 13, 2015
@mhvk
Copy link
Contributor Author

mhvk commented Apr 13, 2015

@taldcroft - one more thing: now that I'm adding more methods, I'm starting to wonder whether I put the documentation for reshape, etc., in the right place. Do you think it would be better to just start a new section at the very end?

@taldcroft
Copy link
Member

@mhvk - Re: broadcasting of Time vals like location, I agree that keeping just a scalar version or the array version broadcasted to the jd1 shape would be fine, particularly if it cleans up the code logic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per your question about location of these docs, I think it would be good to just make a new section here entitled Numpy method analogs. In this section explicitly list all the numpy-like methods that are supported. Discuss when memory is shared or not (i.e. just say that it is the same as Numpy, but some readers won't necessarily know what that means offhand). I don't think of take as a "shape-changing" method as much as an item selection method, but anyway calling these "Numpy analogs" seems more clear to me.

@taldcroft
Copy link
Member

@mhvk - finished my review with relatively minor comments, this is awesome work! This is a good example of writing a (rather complicated) numpy container class as opposed to subclassing. You can start having fun filling in all the methods! 😄

Slightly OT, I wonder if it would be possible to factor things out so we don't just have a monster core.py file.

@mhvk
Copy link
Contributor Author

mhvk commented Apr 17, 2015

@taldcroft - thanks for the comments. I'll try to get to them shortly.

In the meantime:

Slightly OT, I wonder if it would be possible to factor things out so we don't just have a monster core.py file.

Agreed. I think we could have the different time formats separately (formats.py?) and move the double-precision routines to an utils.py or so. That would leave just the top-level Time and TimeDelta classes, plus stuff related to time scales.

@taldcroft
Copy link
Member

@mhvk - the refactor suggestion makes sense.

@taldcroft
Copy link
Member

@mhvk - just want to check that you're not waiting on me for this. I just had a few minor comments. I was going to try writing a TimeColumnInfo subclass in #3731 that does the right thing for stats, but then realized that the min/max funcs are not in yet. I was going to review #3681 after this PR gets merged. In the mean time this one needs rebasing.

@mhvk
Copy link
Contributor Author

mhvk commented May 25, 2015

@taldcroft - the delay is solely because of other obligations. Hope to get to this and the column info class later this week.

@mhvk mhvk force-pushed the time-shape-changing branch from e037ad8 to a28ed8d Compare June 20, 2015 20:48
@mhvk mhvk force-pushed the time-shape-changing branch 2 times, most recently from 957af15 to ea95e98 Compare June 21, 2015 16:23
@mhvk
Copy link
Contributor Author

mhvk commented Jun 21, 2015

@taldcroft - finally got around to updating the shape-changing methods for Time. As always, getting links to work in the documentation was the hardest part. Anyway, it should be all OK now.

@mhvk mhvk force-pushed the time-shape-changing branch from 5b75ea2 to 2af18f4 Compare June 24, 2015 23:01
@mhvk
Copy link
Contributor Author

mhvk commented Jun 26, 2015

@taldcroft - with appveyer now working again, this passes all tests. Could you have a last look? I did end up just broadcasting dimensions for location, etc. (unless they were single elements), making the code quite a bit simpler.

taldcroft added a commit that referenced this pull request Jun 26, 2015
Allow reshape, ravel, transpose etc. of Time objects
@taldcroft taldcroft merged commit 250d2fa into astropy:master Jun 26, 2015
@mhvk mhvk deleted the time-shape-changing branch June 26, 2015 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants