home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

14 rows where issue = 403326458 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 5

  • pletchm 5
  • shoyer 3
  • dcherian 3
  • barkls 2
  • TomNicholas 1

author_association 3

  • MEMBER 7
  • CONTRIBUTOR 5
  • NONE 2

issue 1

  • xarray.DataArray.expand_dims() can only expand dimension for a point coordinate · 14 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
589133779 https://github.com/pydata/xarray/issues/2710#issuecomment-589133779 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDU4OTEzMzc3OQ== pletchm 10720577 2020-02-20T15:35:22Z 2020-02-20T15:35:22Z CONTRIBUTOR

Yes, @TomNicholas. My PR got merged but I forgot to close the issue -- closing it now. Thanks for checking.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
588141090 https://github.com/pydata/xarray/issues/2710#issuecomment-588141090 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDU4ODE0MTA5MA== TomNicholas 35968931 2020-02-19T10:09:26Z 2020-02-19T10:09:26Z MEMBER

@pletchm was this issue closed by #2757?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
485545970 https://github.com/pydata/xarray/issues/2710#issuecomment-485545970 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ4NTU0NTk3MA== barkls 19350183 2019-04-22T20:44:26Z 2019-04-22T20:44:26Z NONE

@pletchm that is the solution I found as well. Thanks all for the suggestions!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
485544371 https://github.com/pydata/xarray/issues/2710#issuecomment-485544371 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ4NTU0NDM3MQ== pletchm 10720577 2019-04-22T20:39:17Z 2019-04-22T20:39:17Z CONTRIBUTOR

Another solution could be adding support for da.sel(dim1='a', squeeze=False) to avoid losing the dim1 dimension/coordinate in the first place

Or equivalently, you could just do da.sel(dim1=['a'])

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
485541551 https://github.com/pydata/xarray/issues/2710#issuecomment-485541551 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ4NTU0MTU1MQ== dcherian 2448579 2019-04-22T20:29:47Z 2019-04-22T20:29:57Z MEMBER

Another solution could be adding support for da.sel(dim1='a', squeeze=False) to avoid losing the dim1 dimension/coordinate in the first place

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
485540381 https://github.com/pydata/xarray/issues/2710#issuecomment-485540381 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ4NTU0MDM4MQ== shoyer 1217238 2019-04-22T20:26:03Z 2019-04-22T20:27:27Z MEMBER

@barkls I think da.expand_dims(list(da.coords)) should work for this use-case.

Previously, we only used the argument to expand_dims() as a sequence, but now we distinguish between mappings and other sequences.

I don't know what the best resolution would be here, but this seems to be a hazard of duck-typing. I did not anticipate that some users would already be iterating over mappings like .coords.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
485523566 https://github.com/pydata/xarray/issues/2710#issuecomment-485523566 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ4NTUyMzU2Ng== barkls 19350183 2019-04-22T19:29:56Z 2019-04-22T19:29:56Z NONE

Unfortunately this most recent change has broken my workflow. I was using expand_dims to add a named dimension back onto a DataArray, when the dimension had been previously removed with the sel method. I realize this may not be the best way of doing things, but I wanted to point out that there is a loss of functionality here.

python import xarray as xr da = xr.DataArray([0,1,2], dims=['dim1'], coords={'dim1':['a','b','c']}) print(da.dims) # returns ('dim1',) da = da.sel({'dim1':'a'}) print(da.dims) # returns () da = da.expand_dims(da.coords) # fails in 0.12.1 print(da.dims) # returns ('dim1',) in 0.12.0

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
458745457 https://github.com/pydata/xarray/issues/2710#issuecomment-458745457 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ1ODc0NTQ1Nw== shoyer 1217238 2019-01-29T23:13:33Z 2019-01-29T23:13:33Z MEMBER

Would it be alright if I opened a PR sometime soon that upgraded expand_dims to support the inserting/broadcasting dimensions with size > 1 (the first feature)?

Yes, that sounds welcome to me!

I think much of the underlying logic should already exist on the Variable.set_dims() method. See also the either_dict_or_kwargs utility in xarray.core.utils.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
458730514 https://github.com/pydata/xarray/issues/2710#issuecomment-458730514 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ1ODczMDUxNA== pletchm 10720577 2019-01-29T22:19:58Z 2019-01-29T22:19:58Z CONTRIBUTOR

Oh I see what you're saying. Yeah, that makes sense.

To get the equivalent of da.expand_dims(a=[9, 10, 11]), you'd do ```

new = da.expand_dims(a=3) new <xarray.DataArray (a: 3, b: 5, c: 3)> ... Coordinates: * b (b) int64 0 1 2 3 4 * c (c) int64 0 1 2 Dimensions without coordinates: a new["a"] = [9, 10, 11] ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
458718342 https://github.com/pydata/xarray/issues/2710#issuecomment-458718342 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ1ODcxODM0Mg== dcherian 2448579 2019-01-29T21:42:08Z 2019-01-29T21:42:08Z MEMBER

Well then I think they should be different.

Currently, da.expand_dims('a') gives <xarray.DataArray (a: 1, b: 5, c: 3)> array([[[1., 1., 1.], [1., 1., 1.], [1., 1., 1.], [1., 1., 1.], [1., 1., 1.]]]) Coordinates: * b (b) int64 0 1 2 3 4 * c (c) int64 0 1 2 Dimensions without coordinates: a

da.expand_dims(a=3) should give <xarray.DataArray (a: 3, b: 5, c: 3)> ... Coordinates: * b (b) int64 0 1 2 3 4 * c (c) int64 0 1 2 Dimensions without coordinates: a

da.expand_dims(a=[9, 10, 11]) should give <xarray.DataArray (a: 3, b: 5, c: 3)> ... Coordinates: * a (a) int64 9 10 11 * b (b) int64 0 1 2 3 4 * c (c) int64 0 1 2 i.e. in this last case, the user has specified co-ordinate labels and so the returned DataArray has a new co-ordinate a.

{
    "total_count": 2,
    "+1": 2,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
458638827 https://github.com/pydata/xarray/issues/2710#issuecomment-458638827 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ1ODYzODgyNw== pletchm 10720577 2019-01-29T17:49:55Z 2019-01-29T17:49:55Z CONTRIBUTOR

Those would be equivalent, I think, assuming they're both manipulating the same da object (I meant for them to be separate calls not sequential, but even if they were sequential, expand_dims doesn't and wouldn't alter da, but instead return a new xarray object). I edited my above post to clarify what da is.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
458609172 https://github.com/pydata/xarray/issues/2710#issuecomment-458609172 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ1ODYwOTE3Mg== pletchm 10720577 2019-01-29T16:32:36Z 2019-01-29T17:44:25Z CONTRIBUTOR

Hi, Thanks for replying. I see what you mean about the 2 separate features.

Would it be alright if I opened a PR sometime soon that upgraded expand_dims to support the inserting/broadcasting dimensions with size > 1 (the first feature)?

I would use your suggested API, i.e. not requiring explicit coordinate names -- that makes sense. However, it feels like the dimension kwargs (i.e. the new dimension/dimensions), should be allowed to be given implicit or explicit coordinates, in case the user doesn't want 0-based integer coordinates for the new dimension. For example, da.expand_dims(a=3) is equivalent to da.expand_dims(a=[0, 1, 2]) but this will also work da.expand_dims(a=['w', 'x', 'y', 'z']) where da is ```

coords = {"b": range(5), "c": range(3)} da = xr.DataArray(np.ones([5, 3]), coords=coords, dims=list(coords.keys())) da <xarray.DataArray (b: 5, c: 3)> array([[1., 1., 1.], [1., 1., 1.], [1., 1., 1.], [1., 1., 1.], [1., 1., 1.]]) Coordinates: * b (b) int64 0 1 2 3 4 * c (c) int64 0 1 2 ```` Does that make sense?

Thank you! Martin

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
458629817 https://github.com/pydata/xarray/issues/2710#issuecomment-458629817 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ1ODYyOTgxNw== dcherian 2448579 2019-01-29T17:25:26Z 2019-01-29T17:25:26Z MEMBER

da.expand_dims(a=3) should not be equivalent to da.expand_dims(a=[0, 1, 2]) because the latter will also create a co-ordinate a. Am I understanding this right?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458
457799138 https://github.com/pydata/xarray/issues/2710#issuecomment-457799138 https://api.github.com/repos/pydata/xarray/issues/2710 MDEyOklzc3VlQ29tbWVudDQ1Nzc5OTEzOA== shoyer 1217238 2019-01-26T03:55:39Z 2019-01-26T03:55:39Z MEMBER

broadcast the data across 1 or more new dimensions

Yes, this feels in scope for expand_dims(). But I think there are two separate features here: 1. Support inserting/broadcasting dimensions with size > 1. 2. Specify the size of the new dimension implicitly, by providing coordinate labels.

I think we would want both to be supported -- you should not be required to supply coordinate labels in order to expand to a dimension of size > 1. We can imagine the first being spelled like da.expand_dims({'a': 3}) or da.expand_dims(a=3).

expand an existing dimension to include 1 or more new coordinates

This feels a little different from expand_dims to me. Here the fundamental operation is alignment/reindexing, not broadcasting across a new dimension. The result also looks different, because you get all the NaN values.

I would probably write this with reindex, e.g., In [12]: da.reindex(b=list(da.b.values)+[5, 6]) Out[12]: <xarray.DataArray (b: 7, c: 3)> array([[ 1., 1., 1.], [ 1., 1., 1.], [ 1., 1., 1.], [ 1., 1., 1.], [ 1., 1., 1.], [nan, nan, nan], [nan, nan, nan]]) Coordinates: * b (b) int64 0 1 2 3 4 5 6 * c (c) int64 0 1 2

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.DataArray.expand_dims() can only expand dimension for a point coordinate  403326458

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 14.003ms · About: xarray-datasette