issues: 1413425793
This data as json
| id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1413425793 | PR_kwDOAMm_X85BBvaI | 7185 | indexes section in the HTML repr | 14808389 | closed | 0 | 4 | 2022-10-18T15:25:34Z | 2022-10-20T06:59:05Z | 2022-10-19T21:12:46Z | MEMBER | 0 | pydata/xarray/pulls/7185 | To see the effect, try this:
```python
import xarray as xr
from xarray.core.indexes import Index
class CustomIndex(Index):
def __init__(self, names, options):
self.names = names
self.options = options
@classmethod
def from_variables(cls, variables, options):
names = list(variables.keys())
return cls(names, options)
def __repr__(self):
options = (
{"names": repr(self.names)}
| {str(k): str(v) for k, v in self.options.items()}
)
return f"CustomIndex({', '.join(k + '=' + v for k, v in options.items())})"
def _repr_html_(self):
header_row = "<tr><td>KDTree params</td></tr>"
option_rows = [
f"<tr><td>{option}</td><td>{value}</td></tr>"
for option, value in self.options.items()
]
return f"<left><table>{header_row}{''.join(option_rows)}</table></left>"
ds = xr.tutorial.open_dataset("rasm")
ds1 = ds.set_xindex(["xc", "yc"], CustomIndex, param1="a", param2="b")
with xr.set_options(display_style="text"):
display(ds1)
with xr.set_options(display_style="html"):
display(ds1)
```
~The repr looks a bit strange because I've been borrowing the variable CSS classes.~ Edit: @benbovy fixed that for me Also, the discussion about what
|
{
"url": "https://api.github.com/repos/pydata/xarray/issues/7185/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} |
13221727 | pull |