home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

5 rows where issue = 484089737 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 3

  • gwgundersen 2
  • max-sixty 2
  • shoyer 1

author_association 2

  • MEMBER 3
  • CONTRIBUTOR 2

issue 1

  • assign_coords adds coordinates without a new dimension if the value is scalar · 5 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
524617139 https://github.com/pydata/xarray/issues/3240#issuecomment-524617139 https://api.github.com/repos/pydata/xarray/issues/3240 MDEyOklzc3VlQ29tbWVudDUyNDYxNzEzOQ== gwgundersen 2818208 2019-08-25T10:02:39Z 2019-08-25T10:02:39Z CONTRIBUTOR

I see. This is because coordinates are just DataArray objects. So

```python

arr.coords['y'] = range(3) ```

is equivalent to

```python

new_coords = xr.DataArray(data=range(3)) arr.coords['y'] = new_coords ```

And the reason this is a ValueError is that new_coords has a default dimension dim_0 that is not on arr. However, this

```python

arr.coords['y'] = 1 ```

is equivalent to...

```python

new_coords = xr.DataArray(data=1, dims=[]) arr.coords['y'] = new_coords ```

And new_coords has no dimensions that are not on arr.

{
    "total_count": 2,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 1,
    "eyes": 0
}
  assign_coords adds coordinates without a new dimension if the value is scalar 484089737
524527361 https://github.com/pydata/xarray/issues/3240#issuecomment-524527361 https://api.github.com/repos/pydata/xarray/issues/3240 MDEyOklzc3VlQ29tbWVudDUyNDUyNzM2MQ== max-sixty 5635139 2019-08-24T07:09:04Z 2019-08-24T07:09:04Z MEMBER

In that example, y has no dimensions that aren't on the array. So while it is a bit unusual, the resulting object doesn't break any rules / invariants. Does that make sense?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  assign_coords adds coordinates without a new dimension if the value is scalar 484089737
524525841 https://github.com/pydata/xarray/issues/3240#issuecomment-524525841 https://api.github.com/repos/pydata/xarray/issues/3240 MDEyOklzc3VlQ29tbWVudDUyNDUyNTg0MQ== gwgundersen 2818208 2019-08-24T06:39:00Z 2019-08-24T06:39:00Z CONTRIBUTOR

@shoyer, maybe I am missing a nuance in your answer, but I think I already understand this bit about Xarray. My question was why is it is allowed to add a scalar:

```python

arr = xr.DataArray(range(3), dims=['x'], coords={'x': list('abc')}) arr.coords Coordinates: * x (x) <U1 'a' 'b' 'c' arr.coords['y'] = 1 # <----------- Why does this work? arr.coords Coordinates: * x (x) <U1 'a' 'b' 'c' y int64 1 ```

In this case, y are coordinates that do not share an existing dimension.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  assign_coords adds coordinates without a new dimension if the value is scalar 484089737
524399716 https://github.com/pydata/xarray/issues/3240#issuecomment-524399716 https://api.github.com/repos/pydata/xarray/issues/3240 MDEyOklzc3VlQ29tbWVudDUyNDM5OTcxNg== shoyer 1217238 2019-08-23T17:34:44Z 2019-08-23T17:34:44Z MEMBER

This was intentional. array.assign_coords(name=value) should be equivalent to array = array.copy(deep=False); array.coords[name] = value.

You are allowed to add new coordinates to a DataArray if they share existing dimensions. You are not allowed to add coordinates with new dimensions, because it is enforced as an invariant of the DataArray data model that all coordinate dimensions are found on the DataArray variable as well.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  assign_coords adds coordinates without a new dimension if the value is scalar 484089737
524025546 https://github.com/pydata/xarray/issues/3240#issuecomment-524025546 https://api.github.com/repos/pydata/xarray/issues/3240 MDEyOklzc3VlQ29tbWVudDUyNDAyNTU0Ng== max-sixty 5635139 2019-08-22T18:35:02Z 2019-08-22T18:35:02Z MEMBER

Interesting case, thanks for posting.

There's some logic that this could be allowed - it's a coord along no dimensions (whereas in the previous case it had to be on a dimension, unspecified).

But that's what attributes are, so I'm not sure whether this is something we should support.

Does anyone know whether this is a deliberate decision?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  assign_coords adds coordinates without a new dimension if the value is scalar 484089737

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