-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Extend __str__
and __repr__
methods of BaseTableCoordinate
, ExtraCoords
, GlobalCoords
#453
Conversation
Hi @dhomeier. Thanks so much for tackling this issue. Any more progress recently? |
Hello @dhomeier! Thanks for updating this PR.
Comment last updated at 2021-08-13 13:46:03 UTC |
ndcube/ndcube.py
Outdated
@@ -667,7 +667,8 @@ def __str__(self): | |||
NDCube | |||
------ | |||
Dimensions: {self.dimensions} | |||
Physical Types of Axes: {self.array_axis_physical_types}""") | |||
Physical Types of Axes: {self.array_axis_physical_types} | |||
Data: Array{self.data.shape} [{self.unit}] '{self.data.dtype}'""") |
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.
Data: Array{self.data.shape} [{self.unit}] '{self.data.dtype}'""") | |
Unit: {self.unit} | |
Data Type: {self.data.dtype}""") |
I suggest his change because the data shape is already captured by the dimensions line, above.
I like what you've done wit |
This should have a changelog file named |
See what my comment today on #413 for a roadmap for this PR. |
That would be handled by the Quantity / numpy print settings, e.g. with
I have not tried to match the indentation level for the Or did you mean very long (multiple?) |
No, that's exactly what I meant. I think your decision makes sense. |
I followed the same for the *TableCoordinate representations, slightly inconsistent indenting but hopefully readable. <ndcube.extra_coords.table_coord.QuantityTableCoordinate object at 0x107a2c670>
QuantityTableCoordinate ['length', 'width'] ['custom:distance1', 'custom:distance2']:
<Quantity [0., 1., 2., 3., 4., 5., 6., 7., 8., 9.] km>, <Quantity [ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13.,
14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27.,
28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41.,
42., 43., 44., 45., 46., 47., 48., 49.] m>
<ndcube.extra_coords.table_coord.MultipleTableCoordinate object at 0x107b61d00>
MultipleTableCoordinate(tables=[QuantityTableCoordinate [None]:
<Quantity [0., 1., 2., 3., 4., 5., 6., 7., 8., 9.] km>, <Quantity [ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.,
13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25.,
26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38.,
39., 40., 41., 42., 43., 44., 45., 46., 47., 48., 49.] m>,
QuantityTableCoordinate [None]:
<Quantity [ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.,
13., 14., 15., 16., 17., 18., 19.] s>]) |
Keep up the good work! |
I don't think printing the content, or in fact doing anything which makes it assume it's a numpy array is a good idea. Printing the actual type of the array i.e. dask vs numpy might be useful though? |
I've been meaning to comment on this to say this would be a good opportunity to have support for the dask html repr in cases where the underlying array is a dask array. I'm not sure you would even need to special case for dask. You could presumably just pass through the html repr for the underlying array if it exists. |
Yeah that was one of the things I was hoping to achieve as well. |
Thanks for the comments on Dask arrays; I did have the pointer to its But in fact I had not realised that |
We pretty much don't do anything with the array at all in most places, so any "array-like" should work. The only real exceptions to this are reproject and the upcoming superpixel methods where we are actually modifying the data. If there are obvious cases in the docs where we are saying numpy array we should change that, and probably make more of a point of selling (and maintaining) good dask support. |
Sounds reasonable. I certainly don't think the representations would need anything beyond that. I am a bit less sure what other (inherited) |
Yeah it's decidedly possible that subclasses will assume ndarray, but that's ok :D |
I was thinking more about methods people might use that |
Yeah, the I don't think there are any other examples, but if there are we should fix them. |
Are there any tests using dask arrays as |
I am not sure, I don't think they are that comprehensive if they exist. |
__str__
and __repr__
methods__str__
and __repr__
methods of BaseTableCoordinate
, ExtraCoords,
GlobalCoords`
Marking this as ready now, since any real overhaul of |
__str__
and __repr__
methods of BaseTableCoordinate
, ExtraCoords,
GlobalCoords`__str__
and __repr__
methods of BaseTableCoordinate
, ExtraCoords
, GlobalCoords
🤔 Do we really have no examples of the |
Quite possible; not sure what documentation is needed on how to use it (it's what pops up when you just type |
Description
This is a WIP to improve and expand the string representations to begin addressing #413.
For a start adding
physical_types
information toExtraCoords
and get line breaks better in line with numpy standards for long arrays.The output could still be slightly prettified for empty
physical_types
, but havingNone
printed might be useful, too.Some information on
NDCube.data
should be added next; do we want to keep this at metadata or also print the content in a similar manner?