home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

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

  • dcherian 2
  • max-sixty 1
  • DWesl 1
  • ellesmith88 1

author_association 2

  • MEMBER 3
  • CONTRIBUTOR 2

issue 1

  • Can't remove coordinates attribute from DataArrays · 5 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
866314326 https://github.com/pydata/xarray/issues/5510#issuecomment-866314326 https://api.github.com/repos/pydata/xarray/issues/5510 MDEyOklzc3VlQ29tbWVudDg2NjMxNDMyNg== DWesl 22566757 2021-06-22T20:33:44Z 2021-06-22T20:37:53Z CONTRIBUTOR

~encoding is where that information is stored between reading a dataset in from disk and saving it back out again.~ _encode_coordinates can take a default value from either of encoding or attrs, but a falsy value will be overwritten. Setting .attrs["coordinates"] = " " should work.

```python

import numpy as np, xarray as xr data = xr.DataArray(np.random.randn(2, 3), dims=("x", "y"), coords={"x": [10, 20]}) ds = xr.Dataset({"foo": data, "bar": ("x", [1, 2]), "fake": 10}) ds = ds.assign_coords({"reftime":np.array("2004-11-01T00:00:00", dtype=np.datetime64)}) ds = ds.assign({"test": 1}) ds.test.encoding["coordinates"] = " " ds.to_netcdf("file.nc") bash $ ncdump -h file.nc netcdf file { dimensions: x = 2 ; y = 3 ; variables: int64 x(x) ; double foo(x, y) ; foo:_FillValue = NaN ; foo:coordinates = "reftime" ; int64 bar(x) ; bar:coordinates = "reftime" ; int64 fake ; fake:coordinates = "reftime" ; int64 reftime ; reftime:units = "days since 2004-11-01 00:00:00" ; reftime:calendar = "proleptic_gregorian" ; int64 test ; test:coordinates = " " ; } `` As mentioned above, the XArray data model associates coordinates with dimensions rather than with variables, so any time you read the dataset back in again, thetestvariable will gainreftimeas a coordinate, because the dimensions ofreftime(()), are a subset of the dimensions oftest(also()`).

Not producing a coordinates attribute for variables mentioned in another variable's bounds attribute (or a few other attributes, for that matter) would be entirely doable within the function linked above, and should be straightforward if you want to make a PR for that.

Making realization and the bounds show up in ds.coords rather than ds.data_vars may also skip setting the coordinates attribute, though I'm less sure of that. It would, however, add realization to the coordinates attributes of every other data_var unless you overrode that, which may not be what you want.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Can't remove coordinates attribute from DataArrays  927336712
866175750 https://github.com/pydata/xarray/issues/5510#issuecomment-866175750 https://api.github.com/repos/pydata/xarray/issues/5510 MDEyOklzc3VlQ29tbWVudDg2NjE3NTc1MA== dcherian 2448579 2021-06-22T17:14:34Z 2021-06-22T17:14:34Z MEMBER

This is the function to look at if you wanted to fix it: https://github.com/pydata/xarray/blob/1f5c63379e1a3e803515f467d9dcc0c9f7b1a0db/xarray/conventions.py#L707

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Can't remove coordinates attribute from DataArrays  927336712
866116219 https://github.com/pydata/xarray/issues/5510#issuecomment-866116219 https://api.github.com/repos/pydata/xarray/issues/5510 MDEyOklzc3VlQ29tbWVudDg2NjExNjIxOQ== max-sixty 5635139 2021-06-22T16:00:52Z 2021-06-22T16:48:24Z MEMBER

Coords are on the dataset rather than the variable, so it requires something like ds = ds.reset_coords()

Thanks for the clear example!

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Can't remove coordinates attribute from DataArrays  927336712
866140391 https://github.com/pydata/xarray/issues/5510#issuecomment-866140391 https://api.github.com/repos/pydata/xarray/issues/5510 MDEyOklzc3VlQ29tbWVudDg2NjE0MDM5MQ== ellesmith88 40183561 2021-06-22T16:28:56Z 2021-06-22T16:29:32Z CONTRIBUTOR

@dcherian thanks! I've tried overriding with .attrs["coordinates"] = None, .attrs["coordinates"] = "" and .attrs["coordinates"] = False but that doesn't seem to work either. Would be great if that worked and would solve my problem!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Can't remove coordinates attribute from DataArrays  927336712
866121561 https://github.com/pydata/xarray/issues/5510#issuecomment-866121561 https://api.github.com/repos/pydata/xarray/issues/5510 MDEyOklzc3VlQ29tbWVudDg2NjEyMTU2MQ== dcherian 2448579 2021-06-22T16:07:27Z 2021-06-22T16:08:35Z MEMBER

I am not sure there is a good solution here.

As @max-sixty says, xarray does not carry around information that links a specific variable to a subset of coordinate variables (like a coordinates attribute). So in effect, all variables are associated with all coordinate variables.

We could special-case bounds variables (we do this in some places in the encoding/decoding functions) but realization will always be a problem. I think you can override it by explicitly setting the coordinates="" attribute. Perhaps .attrs["coordinates"] = None will avoid writing the attribute, if not we could make it work?

cc @DWesl

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Can't remove coordinates attribute from DataArrays  927336712

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