Fixing exception for Table formatting type mismatch#6385
Fixing exception for Table formatting type mismatch#6385bsipocz merged 8 commits intoastropy:masterfrom
Conversation
|
Hi there @bsipocz 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labelled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃. Everything looks good from my point of view! 👍 |
35c3dd0 to
9793532
Compare
|
this is a weird one, apparently locally it's seemingly randomly fails with |
|
@bsipocz - thanks for picking this up. Please see comments: |
taldcroft
left a comment
There was a problem hiding this comment.
OK, apart from my comments (and the bot) looks generally good.
astropy/table/column.py
Outdated
| Copy key column attributes from ``obj`` to self | ||
| """ | ||
| for attr in ('name', 'unit', 'format', 'description'): | ||
| for attr in ('_name', '_unit', '_format', 'description'): |
There was a problem hiding this comment.
This seems unrelated to this PR, but more importantly seems related to test failures. I suggest reverting.
astropy/table/column.py
Outdated
| self._format = None | ||
| return | ||
|
|
||
| try: |
There was a problem hiding this comment.
prev_format = getattr(self, '_format', None)
astropy/table/pprint.py
Outdated
| from ..extern.six import text_type | ||
| from ..extern.six.moves import zip, range | ||
|
|
||
| import itertools |
astropy/table/column.py
Outdated
| try: | ||
| # test whether it formats without error exemplarily | ||
| self.pformat(max_lines=1) | ||
|
|
There was a problem hiding this comment.
Even though this is formally correct to do the full pre-checking here, I think it is better to not have a very expensive operation. One could end up formatting a billion lines just to set theformat attribute, which is not a good thing.
Column implementation in master. This also made a few changes to methods like __array_finalize__ and __setstate__ to not go through the setters for name, unit, and format--these are copying/recreating Columns from existing objects that should presumably already have valid values for those attributes. This also addresses my comment on the original PR here: astropy#3055 (comment) Finally, in order for this to pass testing several existing tests needed to be updated, now that we no longer allow a Column with an invalid format to be created in the first place (a change I support).
…dded a docstring for Column.format
9793532 to
dfd7e7a
Compare
|
@taldcroft - I've mostly addressed your comments after redid the PR rebase fixes. I think most of the original comments were already dealt with, but please give it another review when you have time. I'll add a changelog, too once the CI passed. |
taldcroft
left a comment
There was a problem hiding this comment.
Just the last long-standing comment about the change from ValueError to TypeError. This should be reverted.
Thanks for sticking with this!
astropy/table/pprint.py
Outdated
| # None of the possible string functions passed muster. | ||
| raise ValueError('Unable to parse format string {0}' | ||
| .format(format_)) | ||
| raise TypeError('unable to parse format string {0} for its ' |
There was a problem hiding this comment.
Keep as ValueError. This is consistent with Python behavior. The problem is not the type of the column but the value of the format string.
astropy/table/pprint.py
Outdated
| try: | ||
| yield format_col_str(idx) | ||
| except TypeError: | ||
| raise TypeError( |
There was a problem hiding this comment.
Catch ValueError and raise ValueError.
|
@taldcroft - Done.
No problem, this was a low hanging fruit for my occasional triaging of reducing the number of open issues. |
|
@bsipocz - Sorry, I had not noticed before this was milestoned for 2.0.2, but I think it should be 3.0. The changelog could be something like: |
|
Thanks @taldcroft! I meant to come back to this, but it slipped through... |
I'm very familiar with this phenomenon. |
Rebased version of #3261
Based on the comment #3261 (comment) I think that PR was good to go, just got merge conflicts.
fixes #2868