Add _repr_inline_ documentation to CustomIndex docs#11046
Add _repr_inline_ documentation to CustomIndex docs#11046sshekhar563 wants to merge 13 commits intopydata:mainfrom
_repr_inline_ documentation to CustomIndex docs#11046Conversation
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.
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.
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.
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.
Can this be a jupyter-execute block? to make sure this stays up to date
There was a problem hiding this comment.
@sshekhar563 can you address this comment please
…e block, improve phrasing
…ax_width responsibility
Co-authored-by: Julia Signell <jsignell@gmail.com>
Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
|
@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! |
|
Looks like the docs aren't building properly. You can run them locally using pixi: pixi run -e doc doc |
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