home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 277498232

This data as json

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
277498232 MDU6SXNzdWUyNzc0OTgyMzI= 1744 Assignment with vectorized indexing doesn't work with a scalar right-hand-side 1217238 closed 0     2 2017-11-28T18:53:13Z 2017-12-09T03:30:52Z 2017-12-09T03:30:52Z MEMBER      

Building on the example from #1743, I tried a version only using xarray.Variable objects on the left-hand-side. To my surprise, this still doesn't work: ``` In [8]: xarr.variable[l_indices.variable, c_indices.variable] = 2


AxisError Traceback (most recent call last) <ipython-input-8-75558576dcaf> in <module>() ----> 1 xarr.variable[l_indices.variable, c_indices.variable] = 2

~/dev/xarray/xarray/core/variable.py in setitem(self, key, value) 653 value = np.moveaxis(value, new_order, range(len(new_order))) 654 --> 655 self._indexable_data[index_tuple] = value 656 657 @property

~/dev/xarray/xarray/core/indexing.py in setitem(self, key, value) 660 def setitem(self, key, value): 661 array, key = self._indexing_array_and_key(key) --> 662 array[key] = value 663 664

~/dev/xarray/xarray/core/nputils.py in setitem(self, key, value) 132 mixed_positions, vindex_positions = _advanced_indexer_subspaces(key) 133 self._array[key] = np.moveaxis(value, vindex_positions, --> 134 mixed_positions)

~/conda/envs/xarray-dev/lib/python3.5/site-packages/numpy/core/numeric.py in moveaxis(a, source, destination) 1599 transpose = a.transpose 1600 -> 1601 source = normalize_axis_tuple(source, a.ndim, 'source') 1602 destination = normalize_axis_tuple(destination, a.ndim, 'destination') 1603 if len(source) != len(destination):

~/conda/envs/xarray-dev/lib/python3.5/site-packages/numpy/core/numeric.py in normalize_axis_tuple(axis, ndim, argname, allow_duplicate) 1534 except TypeError: 1535 axis = tuple(axis) -> 1536 axis = tuple(normalize_axis_index(ax, ndim, argname) for ax in axis) 1537 if not allow_duplicate and len(set(axis)) != len(axis): 1538 if argname:

~/conda/envs/xarray-dev/lib/python3.5/site-packages/numpy/core/numeric.py in <genexpr>(.0) 1534 except TypeError: 1535 axis = tuple(axis) -> 1536 axis = tuple(normalize_axis_index(ax, ndim, argname) for ax in axis) 1537 if not allow_duplicate and len(set(axis)) != len(axis): 1538 if argname:

AxisError: source: axis 0 is out of bounds for array of dimension 0 Assignment *does* work when the right-hand-side argument is an `xarray.Variable`, e.g., In [11]: xarr.variable[l_indices.variable, c_indices.variable] = xr.Variable((), 100)

In [12]: xarr Out[12]: <xarray.DataArray (y: 5, x: 5)> array([[ 0, 100, 2, 3, 4], [ 5, 6, 7, 100, 9], [100, 11, 12, 13, 14], [ 15, 16, 100, 18, 19], [ 20, 21, 22, 23, 24]]) Dimensions without coordinates: y, x ```

Apparently we need a little more test coverage for assignment with vectorized indexing :).

CC @fujiisoup

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1744/reactions",
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 2 rows from issue in issue_comments
Powered by Datasette · Queries took 0.943ms · About: xarray-datasette