home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

12 rows where issue = 551344538 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 3

  • keewis 6
  • mikebyrne6 4
  • dcherian 2

author_association 2

  • MEMBER 8
  • NONE 4

issue 1

  • Error using reduce(): percentile() got an unexpected keyword argument 'axis' · 12 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
575737878 https://github.com/pydata/xarray/issues/3701#issuecomment-575737878 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTczNzg3OA== keewis 14808389 2020-01-17T18:17:59Z 2020-01-17T18:18:08Z MEMBER

here's the dask issue about np.percentile's missing axis parameter: dask/dask#2824

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575736943 https://github.com/pydata/xarray/issues/3701#issuecomment-575736943 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTczNjk0Mw== dcherian 2448579 2020-01-17T18:15:26Z 2020-01-17T18:15:26Z MEMBER

yes. you'll need to have 1 chunk along the dimension being reduced (here 'time').

The reason is that there is no approximate quantile algorithm implemented in dask. So this implementation is just calling np.nanpercentile on each block of the array. If you're reducing along time, each block must have the entire time axis for this to work.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575677825 https://github.com/pydata/xarray/issues/3701#issuecomment-575677825 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTY3NzgyNQ== mikebyrne6 57364981 2020-01-17T15:42:35Z 2020-01-17T18:00:03Z NONE

keewis' quantile function works fine on 1 year of data (as in the MVCE code sample) but does not like working on 10 years of data:

ValueError: dimension 'time' on 0th function argument to apply_ufunc with dask='parallelized' consists of multiple chunks, but is also a core dimension. To fix, rechunk into a single dask array chunk along this dimension, i.e., ``.chunk({'time': -1})``, but beware that this may significantly increase memory usage.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575671803 https://github.com/pydata/xarray/issues/3701#issuecomment-575671803 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTY3MTgwMw== keewis 14808389 2020-01-17T15:27:39Z 2020-01-17T15:27:39Z MEMBER

that would work if we would be working with variables, but Dataset.quantile does a lot more that I didn't want to copy.

We should issue a release soon though.

I agree

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575670529 https://github.com/pydata/xarray/issues/3701#issuecomment-575670529 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTY3MDUyOQ== dcherian 2448579 2020-01-17T15:24:48Z 2020-01-17T15:24:48Z MEMBER

seems to make quantile work, but it might be a bad idea to monkeypatch. T

Personally I would add this quantile function and then do quantile(ds, q=0.99, dim="SOMETHING"). We should issue a release soon though.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575655918 https://github.com/pydata/xarray/issues/3701#issuecomment-575655918 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTY1NTkxOA== mikebyrne6 57364981 2020-01-17T14:48:58Z 2020-01-17T14:48:58Z NONE

Thanks a lot for this!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575599184 https://github.com/pydata/xarray/issues/3701#issuecomment-575599184 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTU5OTE4NA== keewis 14808389 2020-01-17T12:01:18Z 2020-01-17T12:23:57Z MEMBER

sorry, my mistake. I've been testing on master which has #3559 merged and thus works with dask arrays. Unless someone has a better idea, I'd suggest copying that approach for now: using apply_ufunc to apply np.nanpercentile. ~~Ideally, that would change the quantile call to~~ python percentiles = quantile(ds, q=percentile / 100, dim="time") ~~I'll try to write a working quantile function.~~ Edit: see below, with that you should be able to use python ds.quantile(...)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575605008 https://github.com/pydata/xarray/issues/3701#issuecomment-575605008 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTYwNTAwOA== keewis 14808389 2020-01-17T12:21:30Z 2020-01-17T12:22:25Z MEMBER

This ```python def quantile(self, q, dim=None, interpolation="linear", keep_attrs=None): from xarray.core.computation import apply_ufunc from xarray.core import utils

scalar = utils.is_scalar(q) 
q = np.atleast_1d(np.asarray(q, dtype=np.float64)) 
if dim is None: 
    dim = self.dims

if utils.is_scalar(dim): 
    dim = [dim]

def _wrapper(npa, **kwargs): 
    # move quantile axis to end. required for apply_ufunc 
    return np.moveaxis(np.nanpercentile(npa, **kwargs), 0, -1)

axis = np.arange(-1, -1 * len(dim) - 1, -1) 
result = apply_ufunc( 
    _wrapper, 
    self, 
    input_core_dims=[dim], 
    exclude_dims=set(dim), 
    output_core_dims=[["quantile"]], 
    output_dtypes=[np.float64], 
    output_sizes={"quantile": len(q)}, 
    dask="parallelized", 
    kwargs={"q": q * 100, "axis": axis, "interpolation": interpolation}, 
)

# for backward compatibility 
result = result.transpose("quantile", ...) 
if scalar: 
    result = result.squeeze("quantile") 
if keep_attrs: 
    result.attrs = self._attrs

return result

xr.Variable.quantile = quantile `` seems to makequantile` work, but it might be a bad idea to monkeypatch. Thoughts, @dcherian?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575596237 https://github.com/pydata/xarray/issues/3701#issuecomment-575596237 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTU5NjIzNw== mikebyrne6 57364981 2020-01-17T11:51:28Z 2020-01-17T11:51:28Z NONE

Seems like I do need it:

python percentiles = ds.quantile(q=percentile / 100, dim="time") returns

TypeError: quantile does not work for arrays stored as dask arrays. Load the data via .compute() or .load() prior to calling this method.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575593711 https://github.com/pydata/xarray/issues/3701#issuecomment-575593711 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTU5MzcxMQ== keewis 14808389 2020-01-17T11:42:38Z 2020-01-17T11:49:51Z MEMBER

you should be able to just use quantile. I called compute to demonstrate it returns the same values as np.percentile, but you don't need it with quantile.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575593148 https://github.com/pydata/xarray/issues/3701#issuecomment-575593148 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTU5MzE0OA== mikebyrne6 57364981 2020-01-17T11:40:46Z 2020-01-17T11:40:46Z NONE

Thanks for that but ideally I wouldn't use compute(). The code worked using a previous version of dask (0.16.1) so I'm hoping there might be an easy fix for dask 2.9.0...

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538
575590320 https://github.com/pydata/xarray/issues/3701#issuecomment-575590320 https://api.github.com/repos/pydata/xarray/issues/3701 MDEyOklzc3VlQ29tbWVudDU3NTU5MDMyMA== keewis 14808389 2020-01-17T11:31:27Z 2020-01-17T11:31:27Z MEMBER

the reason for this is that the percentile implementation of dask arrays does not support axis. I think you can achieve the same thing by either using compute() (which is probably not desirable) or by using quantile: python In [13]: # Get the percentiles at each lat/lon: ...: ds = ds.compute() ...: percentiles = ds.reduce(np.percentile, q=percentile, dim='time') ...: quantiles = ds.quantile(q=percentile / 100, dim="time") ...: xr.testing.assert_identical(percentiles.drop_vars("height"), quantiles.drop_vars("quantile")) the only difference is that the unused coordinate height disappears and a quantile dimension is added.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Error using reduce(): percentile() got an unexpected keyword argument 'axis' 551344538

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