home / github / pull_requests

Menu
  • GraphQL API
  • Search all tables

pull_requests: 251611039

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
251611039 MDExOlB1bGxSZXF1ZXN0MjUxNjExMDM5 2757 closed 0 Allow expand_dims() method to support inserting/broadcasting dimensions with size>1 10720577 This pull request enhances the `expand_dims` method for both `Dataset` and `DataArray` objects to support inserting/broadcasting dimensions with size > 1. It corresponds to this issue https://github.com/pydata/xarray/issues/2710. ## Changes: 1. dataset.expand_dims() method take dict like object where values represent length of dimensions or coordinates of dimesnsions 3. dataarray.expand_dims() method take dict like object where values represent length of dimensions or coordinates of dimesnsions 5. Add alternative option to passing a dict to the dim argument, which is now an optional kwarg, passing in each new dimension as its own kwarg 7. Add expand_dims enhancement from issue 2710 to whats-new.rst ## Included: - [ ] Tests added - [ ] Fully documented, including `whats-new.rst` for all changes and `api.rst` for new API ## What's new: All of the old functionality is still there, so it shouldn't break anyone's existing code that uses it. You can now pass a dim as a dict, where the keys are the new dimensions and the values are either integers (giving the length of the new dimensions) or iterables (giving the coordinates of the new dimensions). ``` import numpy as np import xarray as xr >>> original = xr.Dataset({'x': ('a', np.random.randn(3)), 'y': (['b', 'a'], np.random.randn(4, 3))}, coords={'a': np.linspace(0, 1, 3), 'b': np.linspace(0, 1, 4), 'c': np.linspace(0, 1, 5)}, attrs={'key': 'entry'}) >>> original <xarray.Dataset> Dimensions: (a: 3, b: 4, c: 5) Coordinates: * a (a) float64 0.0 0.5 1.0 * b (b) float64 0.0 0.3333 0.6667 1.0 * c (c) float64 0.0 0.25 0.5 0.75 1.0 Data variables: x (a) float64 -1.556 0.2178 0.6319 y (b, a) float64 0.5273 0.6652 0.3418 1.858 ... -0.3519 0.8088 0.8753 Attributes: key: entry >>> original.expand_dims({"d": 4, "e": ["l", "m", "n"]}) <xarray.Dataset> Dimensions: (a: 3, b: 4, c: 5, d: 4, e: 3) Coordinates: * e (e) <U1 'l' 'm' 'n' * a (a) float64 0.0 0.5 1.0 * b (b) float64 0.0 0.3333 0.6667 1.0 * c (c) float64 0.0 0.25 0.5 0.75 1.0 Dimensions without coordinates: d Data variables: x (d, e, a) float64 -1.556 0.2178 0.6319 ... -1.556 0.2178 0.6319 y (d, e, b, a) float64 0.5273 0.6652 0.3418 ... -0.3519 0.8088 0.8753 Attributes: key: entry ``` Or, equivalently, you can pass the new dimensions as kwargs instead of a dictionary. ``` original.expand_dims(d=4, e=["l", "m", "n"]) ``` 2019-02-08T21:59:36Z 2019-03-26T02:42:11Z 2019-03-26T02:41:48Z 2019-03-26T02:41:48Z 16a2c03bb23757a92f3f9b8e74c4d489e892e6d6     0 cac434e45781f39643f5b42eb96fd4c1f82fe8ed 164d20abb6ffc35eb3f314ce7fb5b9600cf9de3f CONTRIBUTOR   13221727 https://github.com/pydata/xarray/pull/2757  

Links from other tables

  • 0 rows from pull_requests_id in labels_pull_requests
Powered by Datasette · Queries took 0.715ms