-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Set units and descriptions in Table init #9671
Conversation
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.
Yes, this looks good. And would propagate automatically?
eafb0b6
to
4e0eea0
Compare
I added kwargs to |
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.
This looks very good - only a total nitpick (which I think may matter for sphinx) and what I believe is an incorrect example. Probably good to turn on testing!
16ecf28
to
ab311f9
Compare
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.
Looks very good! Really only some missing periods, which I am not even sure are important...
@@ -33,6 +33,10 @@ class TableRead(registry.UnifiedReadWrite): | |||
first argument is typically the input filename. | |||
format : str | |||
File format specifier. | |||
units : list, dict, optional | |||
List or dict of units to apply to columns |
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.
Missing the periods at the end here too....
if not values: | ||
return | ||
|
||
if isinstance(values, Row): |
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.
For future, perhaps we should have Rows.items()
so there isn't a need to special-case it.
# For a Row object transform to an equivalent dict. | ||
values = {name: values[name] for name in values.colnames} | ||
|
||
if not isinstance(values, dict): |
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.
Might even register Row
as collections.abc.Mapping
, and then do the instance
on that (I'm a bit puzzled it is considered a Sequence
now, since one cannot index with the column number anyway; similarly, Row.__iter__
is weird.
But really out of scope here! See #9687
@adrn , now you can do it with dev astropy! |
This allows explicitly setting both the
units
anddescriptions
of specified table columns from theTable.__init__()
andTable.read()
methods.Closes #9639
It provides some mitigation for #9665 (read units row from ASCII table) by making it easier to do that: