home / github / pull_requests

Menu
  • GraphQL API
  • Search all tables

pull_requests: 128471998

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
128471998 MDExOlB1bGxSZXF1ZXN0MTI4NDcxOTk4 1469 closed 0 Argmin indexes 6815844 - [x] Closes #1388 - [x] Tests added / passed - [x] Passes ``git diff master | flake8 --diff`` - [x] Fully documented, including `whats-new.rst` for all changes and `api.rst` for new API With this PR, ValueError raises if `argmin()` is called by a multi-dimensional array. `argmin_indexes()` method is also added for `xr.DataArray`. Current API design for `argmin_indexes()` returns the argmin-indexes as an `OrderedDict` of `DataArray`s. Example: ```python In [1]: import xarray as xr ...: da = xr.DataArray([[1, 2], [-1, 40], [5, 6]], ...: [('x', ['c', 'b', 'a']), ('y', [1, 0])]) ...: ...: da.argmin_indexes() ...: Out[1]: OrderedDict([('x', <xarray.DataArray 'x' ()> array(1)), ('y', <xarray.DataArray 'y' ()> array(0))]) In [2]: da.argmin_indexes(dims='y') Out[2]: OrderedDict([('y', <xarray.DataArray 'y' (x: 3)> array([0, 0, 0]) Coordinates: * x (x) <U1 'c' 'b' 'a')]) ``` (Because the returned object is an `OrderedDict`, it is not beautifully printed. The returned type can be a `xr.Dataset` if we want.) Although in #1388 `argmin_indexes()` was originally suggested so that we can pass the result into `isel_point`, ```python da.isel_points(**da.argmin_indexes()) ``` current implementation of `isel_points` does **NOT** work for this case. This is mainly because 1. `isel_points` currently does not work for 0-dimensional or multi-dimensional input. 2. Even for 1-dimensional input (the second one in the above examples), we should also pass `x` as an indexer rather than the coordinate of indexer. For 1, I have prepared modification of `isel_points` to accept multi-dimensional arrays, but I guess it should be in another PR after the API decision. (It is related in #475, and #974.) For 2, we should either + change API of `argmin_indexes` to return not only the indicated dimension but also all the dimensions, like ```python In [2]: da.argmin_indexes(dims='y') Out[2]: OrderedDict([('y', array([0, 0, 0]), 'x', array(['c' 'b' 'a'])) ``` or + change API of `isel_point` so that it takes care of the `indexer`'s coordinate if `xr.DataArray` is passed for as `indexers`. I originally worked with the second option for the modification of `isel_points`, the second option breaks the backward-comaptibility and is somehow magical. Another alternertive is to + change API of `argmin_indexes` to return `xr.Dataset` rather than an `OrderedDict`, and also change API of `isel_points` to accept `xr.Dataset`. It keeps backward-compatibility. Any comments are welcome. 2017-07-01T01:23:31Z 2020-06-29T19:36:25Z 2020-06-29T19:36:25Z   ea61e19d4afcb3988eecbafdad28e1320995ce2c     0 81c61b733ea8892464c69b5c75aabb57b5e60989 bb87a9441d22b390e069d0fde58f297a054fd98a MEMBER   13221727 https://github.com/pydata/xarray/pull/1469  

Links from other tables

  • 1 row from pull_requests_id in labels_pull_requests
Powered by Datasette · Queries took 0.892ms