home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

5 rows where author_association = "MEMBER" and issue = 282000017 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 2

  • fmaussion 4
  • shoyer 1

issue 1

  • DataArray.plot raises exception if contents are all NaN · 5 ✖

author_association 1

  • MEMBER · 5 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
351825070 https://github.com/pydata/xarray/issues/1780#issuecomment-351825070 https://api.github.com/repos/pydata/xarray/issues/1780 MDEyOklzc3VlQ29tbWVudDM1MTgyNTA3MA== fmaussion 10050469 2017-12-14T20:21:18Z 2017-12-14T20:21:18Z MEMBER

imshow with all NaNs works for me on matplotlib 1.5.2

ups yes, I might have been confused by the warning, but it does work with latest mpl yes. The warning says:

``` In [1]: import numpy as np

In [2]: import matplotlib.pyplot as plt

In [3]: a = np.full((2, 2), np.NaN)

In [4]: plt.imshow(a)
Out[4]: <matplotlib.image.AxesImage at 0x7f6e2a8ba710>

In [5]: plt.show() /home/mowglie/.pyvirtualenvs/py3/lib/python3.5/site-packages/matplotlib/colors.py:897: UserWarning: Warning: converting a masked element to nan. dtype = np.min_scalar_type(value) /home/mowglie/.pyvirtualenvs/py3/lib/python3.5/site-packages/numpy/ma/core.py:748: UserWarning: Warning: converting a masked element to nan. data = np.array(a, copy=False, subok=subok) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArray.plot raises exception if contents are all NaN 282000017
351785207 https://github.com/pydata/xarray/issues/1780#issuecomment-351785207 https://api.github.com/repos/pydata/xarray/issues/1780 MDEyOklzc3VlQ29tbWVudDM1MTc4NTIwNw== shoyer 1217238 2017-12-14T17:46:20Z 2017-12-14T17:46:20Z MEMBER

@fmaussion what version of matplotlib are you using? imshow with all NaNs works for me on matplotlib 1.5.2 (yes, we're stuck in the dark ages). This might be a regression in matplotlib.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArray.plot raises exception if contents are all NaN 282000017
351678963 https://github.com/pydata/xarray/issues/1780#issuecomment-351678963 https://api.github.com/repos/pydata/xarray/issues/1780 MDEyOklzc3VlQ29tbWVudDM1MTY3ODk2Mw== fmaussion 10050469 2017-12-14T11:01:04Z 2017-12-14T12:15:34Z MEMBER

I'm willing to write the patch, if that helps!

Yes, thanks! The best place to start would be to add a test to Common2dMixin (https://github.com/pydata/xarray/blob/master/xarray/tests/test_plot.py#L560).

I investigated a bit and it seems that in the case of all nan data you would probably have to force add_colorbar to False and do other things for matplotlib to accept your all nan data.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArray.plot raises exception if contents are all NaN 282000017
351663421 https://github.com/pydata/xarray/issues/1780#issuecomment-351663421 https://api.github.com/repos/pydata/xarray/issues/1780 MDEyOklzc3VlQ29tbWVudDM1MTY2MzQyMQ== fmaussion 10050469 2017-12-14T09:57:51Z 2017-12-14T09:57:51Z MEMBER

Actually I changed my mind a little bit ;-). Matplotlib won't plot all NaNs images either:

```python import numpy as np import matplotlib.pyplot as plt

a = np.full((2, 2), np.NaN) plt.imshow(a)
plt.show() # raises an error ``` So we have to decide if it's worth to add a bunch of logic in xarray to handle these cases or if it's the user's responsibility to check the data before plotting.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArray.plot raises exception if contents are all NaN 282000017
351661580 https://github.com/pydata/xarray/issues/1780#issuecomment-351661580 https://api.github.com/repos/pydata/xarray/issues/1780 MDEyOklzc3VlQ29tbWVudDM1MTY2MTU4MA== fmaussion 10050469 2017-12-14T09:51:01Z 2017-12-14T09:51:01Z MEMBER

Yes, I agree. We inherited the logic from seaborn, which also has this problem:

```python In [2]: import seaborn as sns In [3]: import numpy as np In [4]: a = np.zeros((2, 2)) * np.NaN In [6]: sns.heatmap(a)


ValueError Traceback (most recent call last) <ipython-input-6-9ef15135ade2> in <module>() ----> 1 sns.heatmap(a)

~/.pyvirtualenvs/py3/lib/python3.5/site-packages/seaborn/matrix.py in heatmap(data, vmin, vmax, cmap, center, robust, annot, fmt, annot_kws, linewidths, linecolor, cbar, cbar_kws, cbar_ax, square, xticklabels, yticklabels, mask, ax, **kwargs) 515 plotter = _HeatMapper(data, vmin, vmax, cmap, center, robust, annot, fmt, 516 annot_kws, cbar, cbar_kws, xticklabels, --> 517 yticklabels, mask) 518 519 # Add the pcolormesh kwargs here

~/.pyvirtualenvs/py3/lib/python3.5/site-packages/seaborn/matrix.py in init(self, data, vmin, vmax, cmap, center, robust, annot, fmt, annot_kws, cbar, cbar_kws, xticklabels, yticklabels, mask) 166 # Determine good default values for the colormapping 167 self._determine_cmap_params(plot_data, vmin, vmax, --> 168 cmap, center, robust) 169 170 # Sort out the annotations

~/.pyvirtualenvs/py3/lib/python3.5/site-packages/seaborn/matrix.py in _determine_cmap_params(self, plot_data, vmin, vmax, cmap, center, robust) 205 calc_data = plot_data.data[~np.isnan(plot_data.data)] 206 if vmin is None: --> 207 vmin = np.percentile(calc_data, 2) if robust else calc_data.min() 208 if vmax is None: 209 vmax = np.percentile(calc_data, 98) if robust else calc_data.max()

~/.pyvirtualenvs/py3/lib/python3.5/site-packages/numpy/core/_methods.py in _amin(a, axis, out, keepdims) 27 28 def _amin(a, axis=None, out=None, keepdims=False): ---> 29 return umr_minimum(a, axis, None, out, keepdims) 30 31 def _sum(a, axis=None, dtype=None, out=None, keepdims=False):

ValueError: zero-size array to reduction operation minimum which has no identity

```

Will try to submit a fix later today

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArray.plot raises exception if contents are all NaN 282000017

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