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

Add Astropy view support to afw.table (DM-5641) #64

Merged
merged 2 commits into from May 17, 2016
Merged

Conversation

TallJimbo
Copy link
Member

This adds an asAstropy method to get a astropy.table.Table or astropy.table.QTable view directly, as well as an __astropy_table__ that will allow the Astropy table constructors to accept LSST Catalog objects (once astropy/astropy#4885 is complete).

The astropy PR has not quite been finalized, but I'm confident that any further changes will be minor, and hence it should be fine to review this now. I will delay the merge of this ticket until the astropy PR is finalized (they also have a feature freeze this weekend, so I don't think we'll have to wait long).

#

"""
Tests for Astropy views into afw.table Catalogs
Copy link
Member

Choose a reason for hiding this comment

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

Am I correct in thinking that these tests are not testing the new functionality in Astropy but are testing that the asAstropy method does the right thing. ie we are not (yet) depending on Astropy v1.2 for this to work. When v1.2 is released shouldn't we be able to instantiate an astropy.table directly with asAstropy being a private method? Or did I misunderstand?

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically correct. The tests do not exercise any new Astropy functionality. We do have a method that will hopefully work with v1.2, but that's untested.

But even once v1.2 is out, I'd like to keep the asAstropy (or whatever we call it) method public, as it provides useful customization options that will likely never be available through the Astropy table constructors (since they'd require API changes to those constructors).

Copy link
Member

Choose a reason for hiding this comment

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

As I say above, I would prefer it if we just said "you pass this afw table to the astropy table constructor" rather than "you call this special exporter routine because it has an extra feature". Getting some extra **kwargs passed in to __astropy_table__ would seem feasible if we asked about it quickly. We'd then have a transitional APIs that would allow people to use table views before 1.2 astropy is released but with the expectation that in the future we'd use the astropy constructor.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, and my main comment here was that I'd like a comment in this test explaining that it's not actually testing the Astropy native constructor.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment added.

@taldcroft
Copy link

OK astropy/astropy#4885 is merged with **kwarg keyword passthrough supported and will be in 1.2.

We normally return read-only bool arrays when accessing
Flag columns in Python, even though the arrays are copies
and safe to edit, to prevent users from thinking they can
modify Flag field values via the array interface.

However, in an astropy.table view, users will generally
asking for a copy, and in that case we don't want to
restrict what they can do with it.
The __astropy_table__ method is called by the Astropy Table
constructor (in Astropy >= v1.2) to support the syntax:

t = astropy.table.Table(catalog)

We also provide our own direct interface that returns an Astropy Table
(or QTable) as an "asAstropy" method.
def __astropy_table__(self, cls, copy, **kwds):
"""Implement interface called by Astropy table constructors to construct a view or copy.
"""
return _syntax.BaseCatalog_asAstropy(cls=cls, copy=copy)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the kwargs have been forwarded on here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thought I did that, but apparently not. I'll create a mini-ticket to fix.

@ktlim ktlim deleted the tickets/DM-5641 branch August 25, 2018 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants