pull_requests: 1766894598
This data as json
id | node_id | number | state | locked | title | user | body | created_at | updated_at | closed_at | merged_at | merge_commit_sha | assignee | milestone | draft | head | base | author_association | auto_merge | repo | url | merged_by |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1766894598 | PR_kwDOAMm_X85pUKwG | 8821 | open | 0 | Add small test exposing issue from #7794 and suggestion for `_wrap_numpy_scalars` fix | 81219 | `_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 ``` <!-- Feel free to remove check-list items aren't relevant to your change --> - [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` | 2024-03-11T23:40:17Z | 2024-04-03T18:53:28Z | 06dd0ddbac632b48a45e2b933153a16cbba318e0 | 0 | 12217501029657ba8b6e90a4243bbe45dd73a228 | 90e00f0022c8d1871f441470d08c79bb3b03c164 | CONTRIBUTOR | 13221727 | https://github.com/pydata/xarray/pull/8821 |
Links from other tables
- 0 rows from pull_requests_id in labels_pull_requests