Skip to content

Table indexing should not affect Mixin classes except through info - #4222

Merged
mhvk merged 1 commit into
astropy:masterfrom
mhvk:table-index-slicing-fixup
Nov 8, 2015
Merged

mhvk merged 1 commit into
astropy:masterfrom
mhvk:table-index-slicing-fixup

Conversation

@mhvk

@mhvk mhvk commented Oct 5, 2015

Copy link
Copy Markdown
Contributor

#3915 introduced a very nice indexing system to Table, but as part of that __getitem__ is being changed in indentical ways in Quantity and Time. Separation of concerns suggests this should be factored out and done explicitly in Table itself, or (somehow) made part of the info class.

p.s. Noticed this because it causes a merge conflict for my shape-changing PR #4123. Raising this partially as a reminder to myself, partially as a general call-out to try hard to avoid creating tangled messes.

@mhvk mhvk mentioned this pull request Oct 5, 2015
@mhvk

mhvk commented Oct 5, 2015

Copy link
Copy Markdown
Contributor Author

With #4075 in place, it turns out to be reasonably trivial to remove the index-related cruft in [Quantity|Time].__getitem__. Passes all the table tests, at least locally. I can make this a PR to #4075 if that helps get it in still. cc @embray, @taldcroft.

@astrofrog astrofrog added the table label Oct 6, 2015
@mhvk
mhvk force-pushed the table-index-slicing-fixup branch from 58c4ff2 to 7a50abc Compare October 13, 2015 01:14
@mhvk

mhvk commented Oct 13, 2015

Copy link
Copy Markdown
Contributor Author

I rebased now that #4075 is merged, and this PR can be seen much more simply. Ideally, this would still go in 1.10; I'm labeling it as a bug, though it is more of a minor design flaw.

@mhvk mhvk added Bug Affects-dev PRs and issues that do not impact an existing Astropy release labels Oct 13, 2015
@mhvk mhvk added this to the v1.1.0 milestone Oct 13, 2015
@mhvk

mhvk commented Oct 24, 2015

Copy link
Copy Markdown
Contributor Author

@taldcroft - could you have a quick look at whether this is OK from the Table perspective?

@taldcroft

Copy link
Copy Markdown
Member

@mhvk - will do, hopefully tomorrow.

@taldcroft

Copy link
Copy Markdown
Member

@mhvk - this looks fine. The original implementation was intended to allow for propagating the index when a single column is sliced as opposed to the entire table. However that functionality is not tested (apparently) nor in the documentation. I agree that enforcing separation of concerns for mixins is a higher priority, and I can't think of a strong use case for needing the index on an individual sliced column.

@taldcroft

Copy link
Copy Markdown
Member

Does this have a performance impact on Quantity __getitem__?

@mhvk

mhvk commented Oct 27, 2015

Copy link
Copy Markdown
Contributor Author

Does this have a performance impact on Quantity __getitem__?

The addition introduced in #3915 should have made __getitem__ slower, since it creates the info object by checking whether there are indices. I don't quite know how much of a slow-down this would have been, but certainly removing the check for info.indices should return the speed to what it was before.

@taldcroft

Copy link
Copy Markdown
Member

Yes, I noticed the info creation.

I'm fine with merging this if you are happy with it.

@taldcroft

Copy link
Copy Markdown
Member

@astrofrog @embray - There is a question about getting this into 1.1. I would not classify this as a bug but since this change only fixes a performance regression from the user perspective. In theory we can put this into the 1.1.1 release, but 1.1 would be good.

@taldcroft taldcroft self-assigned this Oct 27, 2015
@mhvk

mhvk commented Oct 27, 2015

Copy link
Copy Markdown
Contributor Author

@taldcroft - yes, I think this is good to go as is; only simplifications to the code!
Agreed that it is not strictly a bug, but more a fixup of something that went in already; would be nice if it could still be part of 1.1.

@mhvk

mhvk commented Nov 8, 2015

Copy link
Copy Markdown
Contributor Author

Am merging this, since @taldcroft was OK with it. @astrofrog - if it is really unhandy to get this in 1.1.0 still, then just change the milestone.

mhvk added a commit that referenced this pull request Nov 8, 2015
Table indexing should not affect Mixin classes except through info
@mhvk
mhvk merged commit 25175f5 into astropy:master Nov 8, 2015
@mhvk
mhvk deleted the table-index-slicing-fixup branch November 8, 2015 16:55
mhvk added a commit that referenced this pull request Nov 9, 2015
Table indexing should not affect Mixin classes except through info
@eteq

eteq commented Nov 9, 2015

Copy link
Copy Markdown
Member

backported to v1.1.x in c5ece2d

@embray

embray commented Nov 12, 2015

Copy link
Copy Markdown
Member

@mhvk

The addition introduced in #3915 should have made __getitem__ slower, since it creates the info object by checking whether there are indices.

That's what #4075 was about.

@mhvk

mhvk commented Nov 13, 2015

Copy link
Copy Markdown
Contributor Author

@embray - this is actually a little different, since I want to avoid, e.g., a Quantity.info object being created even if the quantity is not part of a table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects-dev PRs and issues that do not impact an existing Astropy release Bug table

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants