issue_comments
7 rows where author_association = "MEMBER", issue = 1372035441 and user = 35968931 sorted by updated_at descending
This data as json, CSV (advanced)
Suggested facets: reactions, created_at (date), updated_at (date)
issue 1
- Periodic Boundary Index · 7 ✖
id | html_url | issue_url | node_id | user | created_at | updated_at ▲ | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
1248876262 | https://github.com/pydata/xarray/issues/7031#issuecomment-1248876262 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KcFbm | TomNicholas 35968931 | 2022-09-16T03:24:59Z | 2022-09-16T03:31:50Z | MEMBER | I think this version does something sensible for all slice cases ```python from xarray.core.indexes import ( PandasIndex, IndexSelResult, _query_slice ) from xarray.core.indexing import _expand_slice class PeriodicBoundaryIndex(PandasIndex): """ An index representing any 1D periodic numberline.
``` ```python lon_coord = xr.DataArray(data=np.linspace(-180, 180, 19), dims="lon") da = xr.DataArray(data=np.sin(180*lon_coord), dims="lon", coords={"lon": lon_coord}) world = da.drop_indexes("lon").set_xindex("lon", index_cls=PeriodicBoundaryIndex, period=360) ``` ```python world.sel(lon=slice(60, 120), method="nearest") <xarray.DataArray (lon: 4)>array([-0.71424378, -0.87270922, -0.9701637 , -0.99979417])Coordinates:* lon (lon) float64 60.0 80.0 100.0 120.0``` ```python world.sel(lon=slice(160, 210), method="nearest") <xarray.DataArray (lon: 4)>array([-0.85218366, -0.68526211, 0.68526211, 0.85218366])Coordinates:* lon (lon) float64 160.0 180.0 -180.0 -160.0``` ```python world.sel(lon=slice(-210, -160), method="nearest") <xarray.DataArray (lon: 4)>array([-0.85218366, -0.68526211, 0.68526211, 0.85218366])Coordinates:* lon (lon) float64 160.0 180.0 -180.0 -160.0``` Unsure as to whether this next one counts as an "intuitive" result or not ```python world.sel(lon=slice(-210, 210), method="nearest") <xarray.DataArray (lon: 4)>array([-0.85218366, -0.68526211, 0.68526211, 0.85218366])Coordinates:* lon (lon) float64 160.0 180.0 -180.0 -160.0``` ```python world.sel(lon=slice(120, 60), method="nearest") <xarray.DataArray (lon: 0)>array([], dtype=float64)Coordinates:* lon (lon) float64``` |
{ "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Periodic Boundary Index 1372035441 | |
1248518310 | https://github.com/pydata/xarray/issues/7031#issuecomment-1248518310 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KauCm | TomNicholas 35968931 | 2022-09-15T19:24:26Z | 2022-09-15T19:51:46Z | MEMBER | Okay I think this design could work for slicing across boundaries: ```python from xarray.core.indexes import PandasIndex, IndexSelResult, _query_slice from xarray.core.indexing import _expand_slice class PeriodicBoundaryIndex(PandasIndex): """ An index representing any 1D periodic numberline.
``` ```python world.sel(lon=slice(60, 120), method="nearest") <xarray.DataArray (lon: 4)>array([-0.71424378, -0.87270922, -0.9701637 , -0.99979417])Coordinates:* lon (lon) float64 60.0 80.0 100.0 120.0``` This works even for slices that cross the dateline ```python world.sel(lon=slice(160, 210), method="nearest") <xarray.DataArray (lon: 4)>array([-0.85218366, -0.68526211, 0.68526211, 0.85218366])Coordinates:* lon (lon) float64 160.0 180.0 -180.0 -160.0``` This isn't general yet, there are lots of edge cases this would fail on, but I think it shows that as long as each case is captured we always could use this approach to remap back to index values that do lie within the range? What do people think? EDIT:
I believe what I've done here is the closest thing to that that is possible with the given interface. |
{ "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Periodic Boundary Index 1372035441 | |
1248224096 | https://github.com/pydata/xarray/issues/7031#issuecomment-1248224096 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KZmNg | TomNicholas 35968931 | 2022-09-15T14:59:09Z | 2022-09-15T14:59:09Z | MEMBER | Nice @benbovy ! That seems useable already - I'll open a PR to work on it more. It's also much neater :smile:
Great, I was hoping there was some functionality like that.
That would be a shame IMO, so I'll have more of think about how to handle slicing across the dateline.
All good points. The other thing I will think about is whether anything special needs to happen for 2D+ periodicity. I suspect that for integers you could just use independent 1D indexes along each dim but for slicing across the "dateline" it might get messy in higher dimensions... |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Periodic Boundary Index 1372035441 | |
1247351003 | https://github.com/pydata/xarray/issues/7031#issuecomment-1247351003 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KWRDb | TomNicholas 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 } |
Periodic Boundary Index 1372035441 | |
1246913319 | https://github.com/pydata/xarray/issues/7031#issuecomment-1246913319 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KUmMn | TomNicholas 35968931 | 2022-09-14T15:09:16Z | 2022-09-14T20:35:57Z | MEMBER | Thank you for the clear explanation @benbovy! @keewis you were right, as ever, but now I understand why!)
So
The situation would be a bit clearer if we did deprecate that, but I imagine that would come with a significant backwards compatibility cost. I think if possible each method on both Dataset and Index should have a note in the docstring about which methods it calls or is called by, as well as major gotchas pointed out in the custom indexes docs version via warnings/notes.
This would be cool, but doesn't really seem worth it, at least for an initial experiment. Presumably I can still make a periodic index that works when doing
label-based indexing? If my Dataset had a non-dimension coordinate On Wed, 14 Sep 2022, 04:08 Benoit Bovy, @.***> wrote:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Periodic Boundary Index 1372035441 | |
1247058071 | https://github.com/pydata/xarray/issues/7031#issuecomment-1247058071 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KVJiX | TomNicholas 35968931 | 2022-09-14T17:02:46Z | 2022-09-14T17:02:46Z | MEMBER | That's very helpful, and should definitely go in the docs somewhere! On Wed, 14 Sep 2022, 11:31 Benoit Bovy, @.***> wrote:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Periodic Boundary Index 1372035441 | |
1246023925 | https://github.com/pydata/xarray/issues/7031#issuecomment-1246023925 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KRND1 | TomNicholas 35968931 | 2022-09-13T22:48:48Z | 2022-09-14T03:03:34Z | MEMBER | I was thinking I want it to work periodically even in integer index space too - surely I need isel for that? I might be misunderstanding something fundamental here though. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Periodic Boundary Index 1372035441 |
Advanced export
JSON shape: default, array, newline-delimited, object
CREATE TABLE [issue_comments] ( [html_url] TEXT, [issue_url] TEXT, [id] INTEGER PRIMARY KEY, [node_id] TEXT, [user] INTEGER REFERENCES [users]([id]), [created_at] TEXT, [updated_at] TEXT, [author_association] TEXT, [body] TEXT, [reactions] TEXT, [performed_via_github_app] TEXT, [issue] INTEGER REFERENCES [issues]([id]) ); CREATE INDEX [idx_issue_comments_issue] ON [issue_comments] ([issue]); CREATE INDEX [idx_issue_comments_user] ON [issue_comments] ([user]);
user 1