issue_comments: 1247351003
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/pydata/xarray/issues/7031#issuecomment-1247351003 | https://api.github.com/repos/pydata/xarray/issues/7031 | 1247351003 | IC_kwDOAMm_X85KWRDb | 35968931 | 2022-09-14T22:10:01Z | 2022-09-14T22:15:26Z | MEMBER | I had another go and now I have this (the ```python from xarray.core.indexes import ( PandasIndex, is_scalar, as_scalar, get_indexer_nd, IndexSelResult, _query_slice, is_dict_like, normalize_label, ) class PeriodicBoundaryIndex(PandasIndex): """ An index representing any 1D periodic numberline.
``` This works for integer indexing with sel!
```python world = da.drop_indexes("lon").set_xindex("lon", index_cls=PeriodicBoundaryIndex) world.sel(lon=200, method="nearest")
Q: Best way to do this for slicing? I want this to work
So I guess I have to turn my slice into a list of specific integer positions and pass that to I guess I also want to reorder the result before returning it, otherwise the two sides of the dateline won't be stitched together in the right order... Q: Where should I pass in If I want the period of the Q: How to avoid just copying all of I find myself copying the entire implementation of Also pointing me to looking at the implementation of I wonder if these problems could be ameliorated by providing public entry methods in the ```python library codeclass NodeMixin: """Inherit from this to create your own TreeNode class with parent and children"""
user codeclass MyHappyTreeNode(NodeMixin): def _pre_attach_children(self, children): """Celebrates the gift of children""" print("A child is born!") ``` What if we put similar methods on the ```python class PandasIndex: def _post_process_label_value(self, label_value: float) -> float: """Method call after determining scalar label value.""" return label_value
``` Then in my case I would not have had to copy so much of the implementation, I could have simply done ```python class PeriodicBoundaryIndex(PandasIndex): period: float
``` Maybe this is a bad idea / doesn't make sense but I thought I would suggest it anyway. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1372035441 |