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 2180447578,PR_kwDOAMm_X85pUKwG,8821,Add small test exposing issue from #7794 and suggestion for `_wrap_numpy_scalars` fix,81219,open,0,,,1,2024-03-11T23:40:17Z,2024-04-03T18:53:28Z,,CONTRIBUTOR,,0,pydata/xarray/pulls/8821,"`_wrap_numpy_scalars` relies on `np.isscalar`, which incorrectly labels a single cftime object as not a scalar. ```python import cftime import numpy as np c = cftime.datetime(2000, 1, 1, calendar='360_day') np.isscalar(c) # False ``` The PR adds logic to handle non-numpy objects using the `np.ndim` function. The logic for built-ins and numpy objects should remain the same. The function logic could possibly be rewritten more clearly as ```python if hasattr(array, ""dtype""): if np.isscalar(array): return np.array(array) else: return array if np.ndim(array) == 0: return np.array(array) return array ``` - [x] Closes #7794 - [x] Tests added - [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst` - [ ] New functions/methods are listed in `api.rst` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8821/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 354535284,MDU6SXNzdWUzNTQ1MzUyODQ=,2385,Resample with default argument,81219,open,0,,,6,2018-08-28T01:24:54Z,2023-09-27T08:42:26Z,,CONTRIBUTOR,,,,"#### Code Sample, a copy-pastable example if possible ```python time = pd.date_range('2000-01-01', freq='D', periods=365 * 3) ds = xr.Dataset({'foo': ('time', np.arange(365 * 3)), 'time': time}) ds.foo.resample(time=None) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in () ----> 1 ds.foo.resample(time=None) /home/david/src/anaconda3/lib/python2.7/site-packages/xarray/core/common.pyc in resample(self, freq, dim, how, skipna, closed, label, base, keep_attrs, **indexer) 678 ""was passed %r"" % dim) 679 group = DataArray(dim, [(dim.dims, dim)], name=RESAMPLE_DIM) --> 680 grouper = pd.Grouper(freq=freq, closed=closed, label=label, base=base) 681 resampler = self._resample_cls(self, group=group, dim=dim_name, 682 grouper=grouper, TypeError: __init__() got an unexpected keyword argument 'base' ``` #### Problem description Although None is the default value (0v.10.6) for freq, actually using None as the freq raises an error. #### Expected Output I would like `resample(time=None)` to return ds.foo itself, or a DataArrayResample instance that includes the entire array. #### Output of ``xr.show_versions()``
INSTALLED VERSIONS ------------------ commit: None python: 2.7.14.final.0 python-bits: 64 OS: Linux OS-release: 4.15.0-30-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_CA.UTF-8 LOCALE: None.None xarray: 0.10.6 pandas: 0.23.0 numpy: 1.14.3 scipy: 1.0.0 netCDF4: 1.3.1 h5netcdf: 0.5.1 h5py: 2.8.0 Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: 1.0.0 dask: 0.17.5 distributed: 1.21.8 matplotlib: 2.2.2 cartopy: None seaborn: 0.8.1 setuptools: 39.2.0 pip: 9.0.3 conda: 4.4.11 pytest: 3.6.0 IPython: 5.7.0 sphinx: 1.7.4
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2385/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue