home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

7 rows where issue = 499196320 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 6

  • dcherian 2
  • shoyer 1
  • max-sixty 1
  • mathause 1
  • rhkleijn 1
  • davidggphy 1

author_association 3

  • MEMBER 5
  • CONTRIBUTOR 1
  • NONE 1

issue 1

  • Changing dtype on v0.13.0 causes Dataset attributes to be lost · 7 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
750934788 https://github.com/pydata/xarray/issues/3348#issuecomment-750934788 https://api.github.com/repos/pydata/xarray/issues/3348 MDEyOklzc3VlQ29tbWVudDc1MDkzNDc4OA== mathause 10194086 2020-12-24T17:47:34Z 2020-12-24T17:47:34Z MEMBER

Yes, this is fixed so I am closing. Thanks for noting @rhkleijn

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Changing dtype on v0.13.0 causes Dataset attributes to be lost 499196320
750929476 https://github.com/pydata/xarray/issues/3348#issuecomment-750929476 https://api.github.com/repos/pydata/xarray/issues/3348 MDEyOklzc3VlQ29tbWVudDc1MDkyOTQ3Ng== rhkleijn 32801740 2020-12-24T17:12:15Z 2020-12-24T17:12:15Z CONTRIBUTOR

Dataset.astype() preserves attributes by default since xarray 0.16.1 with #4314. Running the scripts above with 0.16.2 I get the output below, which confirms attributes are now preserved. Can this issue be closed?

Output 1 <xarray.Dataset> Dimensions: (location: 3, time: 731) Coordinates: * time (time) datetime64[ns] 2000-01-01 2000-01-02 ... 2001-12-31 * location (location) <U2 'IA' 'IN' 'IL' Data variables: tmin (time, location) float32 -8.03737 -1.7884412 ... -4.543927 tmax (time, location) float32 12.980549 3.3104093 ... 3.8052793 Attributes: CRS: EPSG:4326

Output 2 ``` Original xr.DataArray attrs: {'at_str': 'at1_value', 'at_float': 123.0, 'at_int': 123} dtype: int64

After casting to int64: {'at_str': 'at1_value', 'at_float': 123.0, 'at_int': 123} After casting to int32: {'at_str': 'at1_value', 'at_float': 123.0, 'at_int': 123} After casting to float32: {'at_str': 'at1_value', 'at_float': 123.0, 'at_int': 123}

Changing the np.array attrs: {'at_str': 'at1_value', 'at_float': 123.0, 'at_int': 123} dtype: float32 ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Changing dtype on v0.13.0 causes Dataset attributes to be lost 499196320
586959508 https://github.com/pydata/xarray/issues/3348#issuecomment-586959508 https://api.github.com/repos/pydata/xarray/issues/3348 MDEyOklzc3VlQ29tbWVudDU4Njk1OTUwOA== davidggphy 37239554 2020-02-17T11:52:32Z 2020-02-17T11:52:32Z NONE

The problem is still there, as it is quite unexpected.

I hacked it using .astype() directly in the np.array

Test code

```python import xarray as xr

da = xr.DataArray( np.arange(56).reshape((7, 8)), coords={ 'x': list('abcdefg'), 'y': 10 * np.arange(8) }, dims=['x', 'y'], attrs={"at_str":"at1_value","at_float":123.,"at_int":123} )

print("Original xr.DataArray") print(f"attrs: {da.attrs}") print(f"dtype: {da.dtype}")

print(f"\nAfter casting to int64: {da.astype(np.int64).attrs}" ) print(f"After casting to int32: {da.astype(np.int32).attrs}" ) print(f"After casting to float32: {da.astype(np.float32).attrs}")

da.values = da.values.astype(np.float32) print("\nChanging the np.array") print(f"attrs: {da.attrs}") print(f"dtype: {da.dtype}") ```

Output:

``` Original xr.DataArray attrs: {'at_str': 'at1_value', 'at_float': 123.0, 'at_int': 123} dtype: int64

After casting to int64: {} After casting to int32: {} After casting to float32: {}

Changing the np.array attrs: {'at_str': 'at1_value', 'at_float': 123.0, 'at_int': 123} dtype: float32 ```

xr.show_versions()

``` INSTALLED VERSIONS


commit: None python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 14:38:56) [Clang 4.0.1 (tags/RELEASE_401/final)] python-bits: 64 OS: Darwin OS-release: 18.7.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.6.2

xarray: 0.15.0 pandas: 1.0.1 numpy: 1.18.1 scipy: 1.3.0 netCDF4: 1.5.1.2 pydap: installed h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: None distributed: None matplotlib: 3.1.0 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 41.0.1 pip: 19.1.1 conda: None pytest: 5.0.1 IPython: 7.7.0 sphinx: None ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Changing dtype on v0.13.0 causes Dataset attributes to be lost 499196320
536118536 https://github.com/pydata/xarray/issues/3348#issuecomment-536118536 https://api.github.com/repos/pydata/xarray/issues/3348 MDEyOklzc3VlQ29tbWVudDUzNjExODUzNg== shoyer 1217238 2019-09-27T22:43:48Z 2019-09-27T22:43:48Z MEMBER

It's also not clear to me how this managed to change/break but I think we should consider it a bug.

I agree that the right fix is to write an explicit astype method, but I don't think there's a good reason for keep_attrs=False in this case. astype isn't really changing the data, just changing how the data is represented so I think it makes sense to always preserve attributes.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Changing dtype on v0.13.0 causes Dataset attributes to be lost 499196320
535999921 https://github.com/pydata/xarray/issues/3348#issuecomment-535999921 https://api.github.com/repos/pydata/xarray/issues/3348 MDEyOklzc3VlQ29tbWVudDUzNTk5OTkyMQ== max-sixty 5635139 2019-09-27T16:01:57Z 2019-09-27T16:01:57Z MEMBER

Should we switch keep_attrs to True by default or be determined by the global keep_attrs setting? (also I don't know why this worked in 0.12.1)

Do we have a view that this should be False by default, or is it the case for historical reasons?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Changing dtype on v0.13.0 causes Dataset attributes to be lost 499196320
535981805 https://github.com/pydata/xarray/issues/3348#issuecomment-535981805 https://api.github.com/repos/pydata/xarray/issues/3348 MDEyOklzc3VlQ29tbWVudDUzNTk4MTgwNQ== dcherian 2448579 2019-09-27T15:13:32Z 2019-09-27T15:13:32Z MEMBER

I guess the simpler solution is to just add an astype method to Dataset and specify keep_attrs=True like

https://github.com/pydata/xarray/blob/6ece6a1cf424c3080e216fad8fc8058d3b70aadc/xarray/core/dataset.py#L5062-L5063

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Changing dtype on v0.13.0 causes Dataset attributes to be lost 499196320
535979151 https://github.com/pydata/xarray/issues/3348#issuecomment-535979151 https://api.github.com/repos/pydata/xarray/issues/3348 MDEyOklzc3VlQ29tbWVudDUzNTk3OTE1MQ== dcherian 2448579 2019-09-27T15:06:47Z 2019-09-27T15:06:47Z MEMBER

Should we switch keep_attrs to True by default or be determined by the global keep_attrs setting? (also I don't know why this worked in 0.12.1)

https://github.com/pydata/xarray/blob/6ece6a1cf424c3080e216fad8fc8058d3b70aadc/xarray/core/dataset.py#L4388-L4401

The more general solution for DataArrays is to finish up #2070 (see also #2049). @robbibt are you you up for doing this?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Changing dtype on v0.13.0 causes Dataset attributes to be lost 499196320

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 25.321ms · About: xarray-datasette
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows