-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add _repr_inline_ documentation to CustomIndex docs
#11046
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
base: main
Are you sure you want to change the base?
Add _repr_inline_ documentation to CustomIndex docs
#11046
Conversation
Closes pydata#11036 - Add new 'Custom representation' section explaining _repr_inline_ - Document method signature with max_width parameter - Include code example and real-world examples from RangeIndex/NDPointIndex - Update RasterIndex example to include _repr_inline_ implementation
|
Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient. |
jsignell
left a comment
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.
Thanks @sshekhar563! I just had one little suggestion.
| def _repr_inline_(self, max_width: int) -> str: | ||
| # Return a concise representation | ||
| return f"MyIndex (size={len(self._data)})" |
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.
Just a little nitpick. Prefer to use class name rather than hardcoding:
| return f"MyIndex (size={len(self._data)})" | |
| return f"{self.__class__.__name__} (size={len(self._data)})" |
ianhi
left a comment
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 great thanks @sshekhar563
I left a few suggestions but nothing crucial. I agree re the suggestion to use a classname instead of hardcoding.
| .. code-block:: none | ||
| <xarray.DataArray (x: 10)> | ||
| ... | ||
| Indexes: | ||
| x MyIndex (size=10) |
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.
Can this be a jupyter-execute block? to make sure this stays up to date
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.
@sshekhar563 can you address this comment please
…e block, improve phrasing
…ax_width responsibility
Co-authored-by: Julia Signell <[email protected]>
Co-authored-by: Deepak Cherian <[email protected]>
|
@dcherian My apologies for the oversight. I realized that the example block on line 165 was not updated in the previous commit. I’ve now revised the documentation to use a single, self-contained jupyter-execute block for the custom representation example. This ensures the output is generated dynamically and remains consistent with Xarray’s UI. Thank you for pointing this out! |
Closes #11036
As noted in #11035, the custom index docs page was missing information about
_repr_inline_.This PR adds:
_repr_inline_methodmax_widthparameterRangeIndexandNDPointIndexRasterIndexexample to include a_repr_inline_implementation