issue_comments
14 rows where issue = 1372035441 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 · 14 ✖
id | html_url | issue_url | node_id | user | created_at | updated_at ▲ | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
1249218631 | https://github.com/pydata/xarray/issues/7031#issuecomment-1249218631 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KdZBH | benbovy 4160723 | 2022-09-16T10:50:10Z | 2022-09-16T10:50:10Z | MEMBER |
I've created a I've extracted the boilerplate from @dcherian's
Yeah I guess it will work well with independent For multi-dimension coordinates with periodic boundaries this would probably be best handled by more specific indexes, e.g., xoak's s2point index that supports periodicity for lat/lon data (I think). |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Periodic Boundary Index 1372035441 | |
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 | |
1248354099 | https://github.com/pydata/xarray/issues/7031#issuecomment-1248354099 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KaF8z | headtr1ck 43316012 | 2022-09-15T16:43:29Z | 2022-09-15T16:43:29Z | COLLABORATOR |
One could split it into two calls to isel and concatenate the result. Not sure if that's possible with the given interface. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Periodic Boundary Index 1372035441 | |
1248259720 | https://github.com/pydata/xarray/issues/7031#issuecomment-1248259720 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KZu6I | dcherian 2448579 | 2022-09-15T15:26:14Z | 2022-09-15T15:26:14Z | MEMBER | In general, it seems like most (nearly all?) 1D indexing use cases can be handled by encapsulating a |
{ "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 | |
1247731386 | https://github.com/pydata/xarray/issues/7031#issuecomment-1247731386 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KXt66 | benbovy 4160723 | 2022-09-15T08:03:50Z | 2022-09-15T08:03:50Z | MEMBER | Great @TomNicholas! To avoid copying the body of ```python class PeriodicBoundaryIndex(PandasIndex): """ An index representing any 1D periodic numberline.
``` Note: I also added It should work in most cases I think: ```python lon_coord = xr.DataArray(data=np.linspace(-180, 180, 19), dims="lon") da = xr.DataArray(data=np.random.randn(19), dims="lon", coords={"lon": lon_coord}) note the period set hereworld = da.drop_indexes("lon").set_xindex("lon", index_cls=PeriodicBoundaryIndex, period=360) ``` ```python world.sel(lon=200, method="nearest") <xarray.DataArray ()>array(-0.86583185)Coordinates:lon float64 -160.0world.sel(lon=[200, 200], method="nearest") <xarray.DataArray (lon: 2)>array([-0.86583185, -0.86583185])Coordinates:* lon (lon) float64 -160.0 -160.0world.sel(lon=slice(180, 200), method="nearest") <xarray.DataArray (lon: 2)>array([-1.59829997, -0.86583185])Coordinates:* lon (lon) float64 -180.0 -160.0``` There's likely more things to do for slices as you point out. I don't think either that it's possible to pass two slices to If we really need more flexibility in Or like you suggest we could define some |
{ "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 | |
1246944137 | https://github.com/pydata/xarray/issues/7031#issuecomment-1246944137 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KUtuJ | benbovy 4160723 | 2022-09-14T15:30:59Z | 2022-09-14T16:31:29Z | MEMBER |
Yes that's indeed what I've written in #6975 and I realize now that this is confusing, especially for
So we can describe the implementation of
This omits a few implementation details (special cases for multi-index), but that's basically how it works. I think it would help if such "how label-based selection works in Xarray" high-level description was added somewhere in the "Xarray internals" documentation, along with other "how it works" sections for, e.g., alignment. |
{ "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Periodic Boundary Index 1372035441 | |
1246398771 | https://github.com/pydata/xarray/issues/7031#issuecomment-1246398771 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KSokz | benbovy 4160723 | 2022-09-14T08:08:26Z | 2022-09-14T08:08:26Z | MEMBER | tl;dr: Xarray There's a big difference now between
Most coordinate and data variables are still sliced via If we want to support periodic indexing with @TomNicholas your experiment makes it clear that the documentation on this part (#6975) should be improved. Thanks! |
{ "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 | |
1246008530 | https://github.com/pydata/xarray/issues/7031#issuecomment-1246008530 | https://api.github.com/repos/pydata/xarray/issues/7031 | IC_kwDOAMm_X85KRJTS | keewis 14808389 | 2022-09-13T22:23:01Z | 2022-09-13T22:26:16Z | MEMBER | shouldn't you implement (and call) |
{ "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 5