pull_requests: 779238754
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
779238754 | PR_kwDOAMm_X84ucj1i | 5981 | closed | 0 | Allow string formatting of scalar DataArrays | 10050469 | - [x] Closes https://github.com/pydata/xarray/issues/5976 - [x] Tests added - [x] Passes `pre-commit run --all-files` - [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst` This is a first try at formatting dataarray scalars. Here is the current behavior: ```python In [1]: import xarray as xr ...: import numpy as np In [2]: a = np.array(1) ...: da = xr.DataArray(a) In [3]: print(a) 1 In [4]: print(da) <xarray.DataArray ()> array(1) In [5]: print('{}'.format(a)) 1 In [6]: print('{}'.format(da)) <xarray.DataArray ()> array(1) In [7]: print('{:.3f}'.format(a)) 1.000 In [8]: print('{:.3f}'.format(da)) 1.000 In [9]: a = np.array([1, 2]) ...: da = xr.DataArray(a) In [10]: print('{}'.format(a)) [1 2] In [11]: print('{}'.format(da)) <xarray.DataArray (dim_0: 2)> array([1, 2]) Dimensions without coordinates: dim_0 In [12]: print('{:.3f}'.format(a)) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-12-c5afc7863e89> in <module> ----> 1 print('{:.3f}'.format(a)) TypeError: unsupported format string passed to numpy.ndarray.__format__ In [13]: print('{:.3f}'.format(da)) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-13-bddebd8462bd> in <module> ----> 1 print('{:.3f}'.format(da)) ~/disk/Dropbox/HomeDocs/git/xarray/xarray/core/common.py in __format__(self, format_spec) 162 return formatting.array_repr(self) 163 # Else why fall back to numpy --> 164 return self.values.__format__(format_spec) 165 166 def _iter(self: Any) -> Iterator[Any]: TypeError: unsupported format string passed to numpy.ndarray.__format__ ``` I don't think there is any backwards compatibility issue but lets see if the tests pass | 2021-11-12T09:44:43Z | 2022-05-09T15:25:25Z | 2022-05-09T15:25:02Z | 2022-05-09T15:25:02Z | bbb14a5d8383520f1a1e7e6d885c03ecddfbcf47 | 0 | 34a38b1657599ad2a7c406f6746e754e989ca4f5 | 126051f2bf2ddb7926a7da11b047b852d5ca6b87 | MEMBER | 13221727 | https://github.com/pydata/xarray/pull/5981 |
Links from other tables
- 1 row from pull_requests_id in labels_pull_requests