home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 203297784

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
203297784 MDU6SXNzdWUyMDMyOTc3ODQ= 1231 Consider accepting a positional dict argument in place of keyword arguments 1217238 closed 0     2 2017-01-26T05:57:43Z 2019-01-24T14:02:19Z 2019-01-24T14:02:19Z MEMBER      

Using **kwargs in xarray operations is incredibly convenient, but it means there is no way to use a keyword argument that conflicts with an existing argument name. For example, there is no way to use .sel to select along 'method', 'tolerance' or 'drop' dimensions.

For interactive use, this is fine -- these reserved names are rarely used and it's nice to save the keystrokes it takes to write dict(). But it's a problem for writing reliable complex software, which may be calling xarray methods from somewhere very different. In fact, knowing how this works, it's possible to trigger bugs without even using **kwargs, e.g., by indexing a DataArray: ``` In [34]: array = xr.DataArray([1, 2, 3], dims='drop')

result should be a scalar!

In [35]: array[0] Out[35]: <xarray.DataArray (drop: 3)> array([1, 2, 3]) Unindexed dimensions: drop ```

One option to resolve this is to make the first argument to every function like this (including sel, isel, sel_points, isel_points, stack, ...) accept a dictionary, which is interpreted exactly like **kwargs. In fact, we already do this in a highly inconsistent fashion for Dataset.reindex only. For all cases where axis names are set dynamically (and certainly within xarray), we could encourage using the dictionary form, e.g., array.isel(kwargs, drop=True) rather than array.isel(drop=True, **kwargs).

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1231/reactions",
    "total_count": 0,
    "+1": 0,
    "-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.557ms · About: xarray-datasette