home / github

Menu
  • Search all tables
  • GraphQL API

issues

Table actions
  • GraphQL API for issues

2 rows where user = 5472566 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

state 2

  • closed 1
  • open 1

type 1

  • issue 2

repo 1

  • xarray 2
id node_id number title user state locked assignee milestone comments created_at updated_at ▲ closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
754413100 MDU6SXNzdWU3NTQ0MTMxMDA= 4634 Read of netCDF file fails with units attribute that is not of type string ajwdewit 5472566 open 0     5 2020-12-01T13:52:45Z 2020-12-01T19:29:36Z   NONE      

When opening a netCDF file which has a variable that has a units attribute with a definition of integer 1, xarray fails to open the file:

``` ~/bin/miniconda3/envs/py37_crucial/lib/python3.8/site-packages/xarray/conventions.py in _update_bounds_attributes(variables) 379 for v in variables.values(): 380 attrs = v.attrs --> 381 has_date_units = "units" in attrs and "since" in attrs["units"] 382 if has_date_units and "bounds" in attrs: 383 if attrs["bounds"] in variables:

TypeError: argument of type 'numpy.int64' is not iterable ```

This because line 381 will search for the word "since" in an integer type which fails. Of course assigning a integer as units attribute is not wise, but some people tend to assign integer 1 for variables which have no units.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4634/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 issue
401337638 MDU6SXNzdWU0MDEzMzc2Mzg= 2694 Alignment problems with f32/f64 coordinate variables ajwdewit 5472566 closed 0     3 2019-01-21T12:45:17Z 2019-08-15T15:14:49Z 2019-08-15T15:14:49Z NONE      

Code sample

The code below leads to an awkward result when combining two DataArrays. Despite the fact that both d1 and d2 are defined as (11,6) arrays, a multiplication results in a (3,2) array.

```python import xarray as xr import numpy as np d1 = np.full((11,6), 2., dtype=np.float64) d2 = np.full_like(d1, 5.0) lonf64 = np.arange(0,1.1,0.1, dtype=np.float64) latf64 = np.arange(0,0.6,0.1, dtype=np.float64) lonf32 = np.arange(0,1.1,0.1, dtype=np.float32) latf32 = np.arange(0,0.6,0.1, dtype=np.float32) d1 = xr.DataArray(d1, coords=[('lon', lonf64), ('lat', latf64)]) d2 = xr.DataArray(d2, coords=[('lon', lonf32), ('lat', latf32)])

In [21]: d1.shape Out[21]: (11, 6)

In [22]: d2.shape Out[22]: (11, 6)

In [20]: d1 * d2 Out[20]: <xarray.DataArray (lon: 3, lat: 2)> array([[10., 10.], [10., 10.], [10., 10.]]) Coordinates: * lon (lon) float64 0.0 0.5 1.0 * lat (lat) float64 0.0 0.5 ```

Problem description

The origin of this behaviour is that xarray cannot match the coordinate variables because of differences in precision between float32/64. Although they look the same: ```python In [24]: d1.lat.data[1] Out[24]: 0.1

In [25]: d2.lat.data[1] Out[25]: 0.1 ```

They are not: ```python In [27]: "%25.20f" % d1.lat.data[1] Out[27]: ' 0.10000000000000000555'

In [28]: "%25.20f" % d2.lat.data[1] Out[28]: ' 0.10000000149011611938' ```

Except for the coordinate values at 0.0, 0.5, 1.0 which can be both represented with full accuracy in f32 and f64: ```python In [30]: "%25.20f" % d1.lat.data[5] Out[30]: ' 0.50000000000000000000'

In [31]: "%25.20f" % d2.lat.data[5] Out[31]: ' 0.50000000000000000000' ```

Therefore the result of the multiplication is a (3,2) array because only the coordinates that match between d1 and d2 are returned.

A bit similar issue has already been raised in this issue where tolerance in alignment between coordinate variables was discussed.

Expected Output

You could argue that this behavior is the 'expected' output from this operation. However, from the "principle of least astonishment" I would argue that it would be better to either include a tolerance in matching coordinate variables, or to raise a TypeError indicating the incompatibility in the coordinate variables.

The results above were obtained with xarray 0.11.0 and numpy 1.14.2, while this behaviour did not occur in xarray version 0.10.4 with the same numpy version.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2694/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue

Advanced export

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

CSV options:

CREATE TABLE [issues] (
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [number] INTEGER,
   [title] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [state] TEXT,
   [locked] INTEGER,
   [assignee] INTEGER REFERENCES [users]([id]),
   [milestone] INTEGER REFERENCES [milestones]([id]),
   [comments] INTEGER,
   [created_at] TEXT,
   [updated_at] TEXT,
   [closed_at] TEXT,
   [author_association] TEXT,
   [active_lock_reason] TEXT,
   [draft] INTEGER,
   [pull_request] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [state_reason] TEXT,
   [repo] INTEGER REFERENCES [repos]([id]),
   [type] TEXT
);
CREATE INDEX [idx_issues_repo]
    ON [issues] ([repo]);
CREATE INDEX [idx_issues_milestone]
    ON [issues] ([milestone]);
CREATE INDEX [idx_issues_assignee]
    ON [issues] ([assignee]);
CREATE INDEX [idx_issues_user]
    ON [issues] ([user]);
Powered by Datasette · Queries took 6319.237ms · About: xarray-datasette