-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Proof of concept for Table mixins - Time and FunctionColumn #1833
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
Conversation
|
@taldcroft - as you'll see, @wkerzendorf and I had been working on the same problem, but from quite a different angle (#1835). I'll look at your implementation in more detail tomorrow. |
|
@taldcroft so basically your Column is a time object. I'm was wondering - what do we need Columns for then? We have |
|
@wkerzendorf - currently Basically my view on any fundamental changes to Table is that they satisfy:
Even though One thing I have taken away from #1835 is the question of whether we might do away with the underlying structured array that contains the table data in favor of a list of Column or MaskedColumn objects (where I mean the current versions). That might actually simplify things a fair bit, at the expense of making the row access code more complex and slower. A lot of the subtlety in the current code is maintaining the columns as views into the structured array. That might not be needed and would make support for generalized columns much easier. |
|
@taldcroft - While I agree generally with your conditions, I think it is important to note that some current behaviour of Table is wrong. In particular, I would argue that if a |
|
I think that treating a column with units as |
|
@taldcroft Maybe, I should clarify - I didn't mean that a Column would be |
|
@taldcroft - I'm not sure I agree on the ability to have columns with a unit that are not Anyway, I'm not sure we need to decide this now;; I really need to look at what you do in some detail, and think it would be more productive to focus first on, e.g., the |
|
@mhvk - on the second point of what to decide now, I think we are actually not so far apart in the general view. The idea is that a class like Time needs to be able to participate in all the supported operations of a Table. You did this with a wrapper class
Then there is the Having done all this, I'm not convinced my approach of putting the internal data into the table For these mixin columns there is perhaps no reason to store the internal data in the table As mentioned earlier one can go further and not have a |
|
@taldcroft - indeed, the background ideas are definitely similar, with the class simply needing to provide the ability to be turned into correctly sequentiable The part that I perhaps like most about what I did, is that any But better back to some astronomy now... |
|
Passing tests now (at least locally). |
|
This will need rebasing now that #1842 has been merged (it makes Travis work again) |
|
I need to take a closer look at this, but 👍 in principle. This might end up being very, very useful for FITS tables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps rather than do all this, it would be better to make a TableMixin abstract base class with this all marked as abstract methods/properties as appropriate. With the appropriate TableMixin.__subclasshook__ classes that we want to use as Table columns don't even need to subclass TableMixin directly (as is currently the case).
This is an initial demonstration of the idea of Table mixin columns. These are table columns that are not subclassed from
Columnorndarraybut which implement a protocol that allows them to be part of a Table. Essentially they have a sufficiently close API and can do the operations required by the Table API.The implementation for Time is the primary demonstration.
There is also a
FunctionColumnclass that demonstrates defining a virtual column which is the functional output of any table columns. This also shows roughly the minimal implementation of the "mixin protocol".Lastly there is the beginnings of a Coordinates mixin. Unfortunately there is a technical snag that I don't understand.
One of the key concepts here is that (where applicable, e.g. in
Time) the internal representation of the object should be stored within thendarraythat is the basis of the Table instance. But now as I'm writing this, maybe that isn't really a hard requirement and everything might just be simpler without doing that. Hmm.In any case here it is for discussion.