home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 189998469

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
189998469 MDU6SXNzdWUxODk5OTg0Njk= 1130 pipe, apply should call maybe_wrap_array, possibly resolve dim->axis 941907 closed 0     6 2016-11-17T10:04:10Z 2019-01-24T18:34:38Z 2019-01-24T18:34:37Z NONE      

While pipe and Dataset.apply (btw, why not call them both the same?) specify that they expected DataArray returning functions, it would be very convenient to have them call maybe_wrap_array anyways.

I've often tried piping functions which at first looked like ufuncs only to find out that they forgot to call __array_wrap__ (I'm looking at you np.angle). The extra call to maybe_wrap_array is cheap, does not break anything and would be very useful. It would greatly enlarge the set of functions that can be readily applied to DataArray objects without any need for writing function wrappers (motivated in part by #1080).

Since many such functions expect an axis argument, some syntax for dim -> axis resolution could be also added. I see some options

1) check if axis argument is a string and coerce it to a number, something like python axis = kwargs.get('axis') if axis is not None: if isinnstance(axis, str): kwargs['axis'] = darray.get_axis_num(axis)

Simple, but specifying axis='smth' is not very explicit and may mean something else for certain funcs, it assumes a lot about function signatures.

2) similar to 1., but only if both dim and axis='dim' are specified. Still possible conflict of specific meaning, but less likely.

python if kwargs.get('axis') == 'dim': kwargs['axis'] = darray.get_axis_num(kwargs['dim'])

Other coding might be possible.

3) use some syntax similar to pipe((f, 'arg2', ('axis', dim)), *args, **kwargs), but that's getting complicated and less readable.

Let me know what you think and perhaps you'll come up with some nicer syntax for dim-> axis resolution.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1130/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

  • 1 row from issues_id in issues_labels
  • 6 rows from issue in issue_comments
Powered by Datasette · Queries took 0.741ms · About: xarray-datasette