Skip to content

Add support for sorting table with non-mutable columns - #9549

Merged
taldcroft merged 4 commits into
astropy:masterfrom
taldcroft:table-sort-non-mutable
Nov 7, 2019
Merged

taldcroft merged 4 commits into
astropy:masterfrom
taldcroft:table-sort-non-mutable

Conversation

@taldcroft

@taldcroft taldcroft commented Nov 6, 2019 •

Copy link
Copy Markdown
Member

Fixes #9536

EDIT: Close #9537

@taldcroft taldcroft added the table label Nov 6, 2019
@taldcroft taldcroft added this to the v4.0 milestone Nov 6, 2019
@taldcroft
taldcroft requested a review from mhvk November 6, 2019 18:18
Comment thread astropy/table/table.py
try:
col[:] = new_col
except Exception:
self[col.info.name] = new_col

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I tried setting to the new column in all cases but this caused problems with indexes which would require a deeper dive to understand / fix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OK - I think here having a solution is definitely much better than worry about perfection. Maybe a new issue, though?

@hamogu hamogu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, but I leave formal approval to a table maintainer.

Comment thread astropy/table/table.py
new_col = col.take(indexes, axis=0)
try:
col[:] = new_col
except Exception:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could you make it to the specific exception?

Suggested change
except Exception:
except TypeError:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This exception can be raised by arbitrary user-defined mixin columns, so I have no idea what exception class they might raise in this case.

@bsipocz

bsipocz commented Nov 6, 2019

Copy link
Copy Markdown
Member

Looks good, one tiny comment on the exception

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is great! I have one request for a more elaborate comment, but it is not essential, so approving.

Comment thread astropy/table/table.py
try:
col[:] = new_col
except Exception:
self[col.info.name] = new_col

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OK - I think here having a solution is definitely much better than worry about perfection. Maybe a new issue, though?

Comment thread astropy/table/tests/test_table.py Resolved
@taldcroft
taldcroft force-pushed the table-sort-non-mutable branch from b6394b9 to 084d434 Compare November 6, 2019 23:04
@taldcroft

Copy link
Copy Markdown
Member Author

I think I have addressed review comments.

@bsipocz - we need to do something, anything about the changelog conflict mess. 😈 I just got hit with a conflict again.

@taldcroft

Copy link
Copy Markdown
Member Author

Maybe a new issue, though?

#9553

@taldcroft
taldcroft merged commit 6f31b28 into astropy:master Nov 7, 2019
@taldcroft
taldcroft deleted the table-sort-non-mutable branch November 7, 2019 10:13
@bsipocz

bsipocz commented Nov 7, 2019

Copy link
Copy Markdown
Member

we need to do something, anything about the changelog conflict mess.

This is really unfortunate, I agree. I'll try to play a bit with the rebase github action, it may just address the biggest painpoints we have.

(But just as with the json approach, one doesn't need to insert the new entry at the very bottom of the section 🤷‍♀ )

@hamogu

hamogu commented Nov 7, 2019

Copy link
Copy Markdown
Member

I thought new entries where supposed to be ordered by PR number. If that's not the case, things do get easier...

@bsipocz

bsipocz commented Nov 7, 2019

Copy link
Copy Markdown
Member

No, there are no rules on ordering. Traditionally they are ordered by the order of merging, but that's that the same as the PR number, and the conflicts are coming from the fact that one usually adds the new entry at the bottom of a section and git is very careful to not auto-merge these, but flag them as conflict. The rebase bot should easily handle it.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table with mixin column with SkyCoords can't be sorted

4 participants