home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

8 rows where issue = 278453914 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: reactions, created_at (date), updated_at (date)

user 4

  • leeviannala 3
  • rabernat 2
  • shoyer 2
  • fmaussion 1

author_association 2

  • MEMBER 5
  • CONTRIBUTOR 3

issue 1

  • Is there a reason for why DataArray.swap_dims() cannot be done in place like Dataset.swap_dims? · 8 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
348716669 https://github.com/pydata/xarray/issues/1755#issuecomment-348716669 https://api.github.com/repos/pydata/xarray/issues/1755 MDEyOklzc3VlQ29tbWVudDM0ODcxNjY2OQ== shoyer 1217238 2017-12-02T20:09:17Z 2017-12-02T20:09:17Z MEMBER

How about deprecating these? Would that be too much of a change you think? (I never use them)

Yes, this is a good idea! Opened #1756 to keep track.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Is there a reason for why DataArray.swap_dims() cannot be done in place like Dataset.swap_dims? 278453914
348682403 https://github.com/pydata/xarray/issues/1755#issuecomment-348682403 https://api.github.com/repos/pydata/xarray/issues/1755 MDEyOklzc3VlQ29tbWVudDM0ODY4MjQwMw== fmaussion 10050469 2017-12-02T10:18:28Z 2017-12-02T10:18:28Z MEMBER

If I did it again, I would remove the inplace keyword argument from even Dataset methods.

How about deprecating these? Would that be too much of a change you think? (I never use them)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Is there a reason for why DataArray.swap_dims() cannot be done in place like Dataset.swap_dims? 278453914
348682194 https://github.com/pydata/xarray/issues/1755#issuecomment-348682194 https://api.github.com/repos/pydata/xarray/issues/1755 MDEyOklzc3VlQ29tbWVudDM0ODY4MjE5NA== leeviannala 25015426 2017-12-02T10:13:39Z 2017-12-02T10:13:39Z CONTRIBUTOR

Thank you for your explination. I will to look into my problem from another angle.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Is there a reason for why DataArray.swap_dims() cannot be done in place like Dataset.swap_dims? 278453914
348554537 https://github.com/pydata/xarray/issues/1755#issuecomment-348554537 https://api.github.com/repos/pydata/xarray/issues/1755 MDEyOklzc3VlQ29tbWVudDM0ODU1NDUzNw== shoyer 1217238 2017-12-01T17:19:53Z 2017-12-01T17:19:53Z MEMBER

If I did it again, I would remove the inplace keyword argument from even Dataset methods. Almost every method in xarray creates new underlying objects, so it's misleading to call them "inplace". (Most of our inplace methods actually create a new object and then assign its properties to an existing object.)

Why not make your accessor method return a new DataArray object? That would be more inline with how most xarray methods work. If you have any special attributes you've set on the accessor you can copy those over to the new result.

{
    "total_count": 2,
    "+1": 2,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Is there a reason for why DataArray.swap_dims() cannot be done in place like Dataset.swap_dims? 278453914
348536836 https://github.com/pydata/xarray/issues/1755#issuecomment-348536836 https://api.github.com/repos/pydata/xarray/issues/1755 MDEyOklzc3VlQ29tbWVudDM0ODUzNjgzNg== leeviannala 25015426 2017-12-01T16:14:43Z 2017-12-01T16:14:43Z CONTRIBUTOR

Seems like I forgot a confusing line in my example. For example in dataarray_accessor, we have a need for in-place swap. python cube = xr.DataArray(arr, dims=['ya', 'x', 'y'], coords={'y':[1,3], 'ya':[1,2,3,6], 'x':[1,2,5]}) #First dataarray object. cube now referes to this. cube.coords['x2'] = ('x', [1,2,3]) cube = cube.swap_dims({'x':'x2'}) #Second dataarray object. cube now refers to this and first dataarray object is now forgotten vs: python cube = xr.DataArray(arr, dims=['ya', 'x', 'y'], coords={'y':[1,3], 'ya':[1,2,3,6], 'x':[1,2,5]}) #First dataarray object. cube now referes to this. cube.coords['x2'] = ('x', [1,2,3]) cube.swap_dims({'x':'x2'}, inline=True) #This just changes the first dataarray object. cube still refers to the first dataarray object

So the question again was, is there a reason, why the inline keyword is implemented on dataset, but not on dataarray.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Is there a reason for why DataArray.swap_dims() cannot be done in place like Dataset.swap_dims? 278453914
348504868 https://github.com/pydata/xarray/issues/1755#issuecomment-348504868 https://api.github.com/repos/pydata/xarray/issues/1755 MDEyOklzc3VlQ29tbWVudDM0ODUwNDg2OA== rabernat 1197350 2017-12-01T14:14:25Z 2017-12-01T14:14:25Z MEMBER

Ah right. So you would do python cube = cube.swap_dims({'x':'x2'})

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Is there a reason for why DataArray.swap_dims() cannot be done in place like Dataset.swap_dims? 278453914
348492848 https://github.com/pydata/xarray/issues/1755#issuecomment-348492848 https://api.github.com/repos/pydata/xarray/issues/1755 MDEyOklzc3VlQ29tbWVudDM0ODQ5Mjg0OA== leeviannala 25015426 2017-12-01T13:20:07Z 2017-12-01T13:20:07Z CONTRIBUTOR

@rabernat, please note that i'm working with dataarrays. There is no inplace keyword.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Is there a reason for why DataArray.swap_dims() cannot be done in place like Dataset.swap_dims? 278453914
348491227 https://github.com/pydata/xarray/issues/1755#issuecomment-348491227 https://api.github.com/repos/pydata/xarray/issues/1755 MDEyOklzc3VlQ29tbWVudDM0ODQ5MTIyNw== rabernat 1197350 2017-12-01T13:12:24Z 2017-12-01T13:12:24Z MEMBER

swap_dims is not an in-place operation http://xarray.pydata.org/en/stable/generated/xarray.Dataset.swap_dims.html

It returns a new dataset with swapped dims. If you want to do it in place, there is a keyword argument for that.

Sent from my iPhone

On Dec 1, 2017, at 7:37 AM, Leevi Annala notifications@github.com wrote:

Problem description

This is a problem if I want to swap_dims in DataArray Accessor.

Code Sample

This is what I'm forced to do:

import xarray as xr import numpy as np @xr.register_dataarray_accessor('testing') class TestAccessor(object): def init(self, xarray_obj): self._obj = xarray_obj def the_problem(self): self._obj = self._obj.swap_dims({'x':'x2'}) print(self._obj)

arr = np.random.rand(4,3,2) cube = xr.DataArray(arr, dims=['ya', 'x', 'y'], coords={'y':[1,3], 'ya':[1,2,3,6], 'x':[1,2,5]}) cube.coords['x2'] = ('x', [1,2,3]) cube.swap_dims({'x':'x2'}) cube.testing.the_problem() print(cube) this prints:

<xarray.DataArray (ya: 4, x2: 3, y: 2)> array([[[ 0.659583, 0.167555], [ 0.357974, 0.46081 ], [ 0.85115 , 0.845257]],

   [[ 0.280308,  0.777399],
    [ 0.512527,  0.542036],
    [ 0.838603,  0.799414]],

   [[ 0.572031,  0.350464],
    [ 0.205219,  0.812232],
    [ 0.687778,  0.984928]],

   [[ 0.803385,  0.63981 ],
    [ 0.089909,  0.499857],
    [ 0.25266 ,  0.967909]]])

Coordinates: * y (y) int32 1 3 * ya (ya) int32 1 2 3 6 x (x2) int32 1 2 5 * x2 (x2) int32 1 2 3 <xarray.DataArray (ya: 4, x: 3, y: 2)> array([[[ 0.659583, 0.167555], [ 0.357974, 0.46081 ], [ 0.85115 , 0.845257]],

   [[ 0.280308,  0.777399],
    [ 0.512527,  0.542036],
    [ 0.838603,  0.799414]],

   [[ 0.572031,  0.350464],
    [ 0.205219,  0.812232],
    [ 0.687778,  0.984928]],

   [[ 0.803385,  0.63981 ],
    [ 0.089909,  0.499857],
    [ 0.25266 ,  0.967909]]])

Coordinates: * y (y) int32 1 3 * ya (ya) int32 1 2 3 6 * x (x) int32 1 2 5 x2 (x) int32 1 2 3 where the two xarrays are clearly different.

I would want to do:

import xarray as xr import numpy as np @xr.register_dataarray_accessor('testing') class TestAccessor(object): def init(self, xarray_obj): self._obj = xarray_obj def the_problem(self): self._obj.swap_dims({'x':'x2'}, inplace = True) print(self._obj)

arr = np.random.rand(4,3,2) cube = xr.DataArray(arr, dims=['ya', 'x', 'y'], coords={'y':[1,3], 'ya':[1,2,3,6], 'x':[1,2,5]}) cube.coords['x2'] = ('x', [1,2,3]) cube.swap_dims({'x':'x2'}) cube.testing.the_problem() print(cube) this would keep the two xarrays the same, as they should be:

<xarray.DataArray (ya: 4, x2: 3, y: 2)> array([[[ 0.659583, 0.167555], [ 0.357974, 0.46081 ], [ 0.85115 , 0.845257]],

   [[ 0.280308,  0.777399],
    [ 0.512527,  0.542036],
    [ 0.838603,  0.799414]],

   [[ 0.572031,  0.350464],
    [ 0.205219,  0.812232],
    [ 0.687778,  0.984928]],

   [[ 0.803385,  0.63981 ],
    [ 0.089909,  0.499857],
    [ 0.25266 ,  0.967909]]])

Coordinates: * y (y) int32 1 3 * ya (ya) int32 1 2 3 6 x (x2) int32 1 2 5 * x2 (x2) int32 1 2 3 <xarray.DataArray (ya: 4, x: 3, y: 2)> array([[[ 0.659583, 0.167555], [ 0.357974, 0.46081 ], [ 0.85115 , 0.845257]],

   [[ 0.280308,  0.777399],
    [ 0.512527,  0.542036],
    [ 0.838603,  0.799414]],

   [[ 0.572031,  0.350464],
    [ 0.205219,  0.812232],
    [ 0.687778,  0.984928]],

   [[ 0.803385,  0.63981 ],
    [ 0.089909,  0.499857],
    [ 0.25266 ,  0.967909]]])

Coordinates: * y (y) int32 1 3 * ya (ya) int32 1 2 3 6 x (x) int32 1 2 5 * x2 (x) int32 1 2 3 I have version 0.10.0, the newest on conda-forge.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Is there a reason for why DataArray.swap_dims() cannot be done in place like Dataset.swap_dims? 278453914

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

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]);
Powered by Datasette · Queries took 721.549ms · About: xarray-datasette