Skip to content

Table/issue 2868#3261

Closed
embray wants to merge 4 commits intoastropy:masterfrom
embray:table/issue-2868
Closed

Table/issue 2868#3261
embray wants to merge 4 commits intoastropy:masterfrom
embray:table/issue-2868

Conversation

@embray
Copy link
Copy Markdown
Member

@embray embray commented Dec 30, 2014

This finishes up @cherti's original PR at #3055 by rebasing on master and updating to work on master. I also fixed a few bugs and reformatted the code a bit. After I submit this PR I'm probably going to rebase again to collapse down some of @cherti's original commits, but will still make sure they get credit.

@embray
Copy link
Copy Markdown
Member Author

embray commented Dec 30, 2014

Rebased down to 3 commits representing the two major changes from @cherti plus my updates. If this passes we can target for 0.4.3 which I hope to release this week (along with maybe v1.0a1?)

@embray
Copy link
Copy Markdown
Member Author

embray commented Dec 30, 2014

Note: This also requires a changelog entry before it is merged.

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.

I would vote to just do the max_lines=1 testing even for the object case to avoid the possibility of serious performance impact for big arrays. Also, who knows, maybe there is a subset of rows for which the format is fine and user intends to select that subset prior to outputting. In that case the format string validation would be premature.

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.

Good point indeed.

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.

So just get rid of this branch entirely, and call self.pformat(max_lines=1) in all cases?

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.

@embray - yes I think that will be fine.

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.

That would, however, insist that the format has to match the first line of the column. If the case is considered that people may choose the lines of the column they want to print, this shouldn't be done, I think, for columns of type numpy.object etc.
Considering that the format shall match all entries, checking the first line could be a performance-optimized guess of consistency, though.

@embray
Copy link
Copy Markdown
Member Author

embray commented Dec 31, 2014

I don't think I'll have time in the next week to clean this up and finish it; in any case maybe this should be put off a bit longer as it does implement a change in behavior (albeit a desirable one, I think) that tables with invalid column formats will refuse to be instantiated (even if those columns are never displayed).

@taldcroft
Copy link
Copy Markdown
Member

@embray - good plan, I was also thinking about the issue you just raised.

@landscape-bot
Copy link
Copy Markdown

Code Health
Repository health increased by 10% when pulling 487b915 on embray:table/issue-2868 into 0233c22 on astropy:master.

cherti and others added 3 commits August 18, 2015 18:11
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).
@embray
Copy link
Copy Markdown
Member Author

embray commented Aug 19, 2015

Updated this to work against the current master. However, I have a question for @taldcroft: I didn't follow most of the ColumnInfo development, and it's not clear how the Column.format property in this PR interacts with Column.info.format and if there's anything more I need to do to fix that up.

Presumably if a column gets its format from its Column.info then updating Column.info.format should identically test that the format is valid for that column.

@taldcroft
Copy link
Copy Markdown
Member

@embray - Column.info gets all of ['name', 'unit', 'dtype', 'format', 'description', 'meta', 'parent_table'] from the parent column, so there should be no impact to this PR. See also:

if attr in self.attrs_from_parent and not isinstance(propobj, property):

In reviewing this again there are a couple of things that still need to be fixed up:

  • Check with self.pformat(max_lines=1) independent of dtype
  • Raise ValueError not TypeError

@embray
Copy link
Copy Markdown
Member Author

embray commented Aug 19, 2015

Thanks for the clarification--upon testing myself it seemed to work fine whether I went through col.format or col.info.format. I'll fix up the other things.

@taldcroft
Copy link
Copy Markdown
Member

Oh yeah, and so far I have pretty much stuck with the rule of grandfathering Column methods to continue using direct attribute access instead of going through info. Any code outside of Column classes should use info to be mixin-compliant.

@embray
Copy link
Copy Markdown
Member Author

embray commented Aug 19, 2015

Got it--I think so far this PR sticks with that.

@pllim
Copy link
Copy Markdown
Member

pllim commented May 11, 2017

Conflicts, incomplete (as I understand from the discussions), and unlikely to be completed. Original issue #2868 is still open.

@pllim pllim closed this May 11, 2017
bsipocz pushed a commit to bsipocz/astropy that referenced this pull request Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants