home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 420584430

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
420584430 MDU6SXNzdWU0MjA1ODQ0MzA= 2808 Improving documentation on `apply_ufunc` 13205162 closed 0     9 2019-03-13T16:03:37Z 2022-04-27T20:09:06Z 2022-04-27T20:09:06Z CONTRIBUTOR      

This is just a suggestion to improve the documentation on apply_ufunc. The way I see it, this is one of the most powerful functions that xarray has to offer but (IMHO) the documentation is really small and with only a few examples.

From personal experience, every time I have to use it I get confused and it takes me a long time to figure out what important keywords like input_core_dims and output_core_dims actually do. After talking to some colleagues of mine I found that they share the same opinion so it appears that I'm not the only one.

PS: I honestly still don't quite understand what most (if not all) of the keywords do, so I'm not the man for the job.

EDIT

An example of something that could be improved upon is this function taken from the documentation:

def mean(obj, dim): # note: apply always moves core dimensions to the end return apply_ufunc(np.mean, obj, input_core_dims=[[dim]], kwargs={'axis': -1})

It's really easy to understand, but if I want to use it with more than one axis it doesn't work:

a=xr.DataArray(np.random.randn(3,3,3), dims=("x", "y", "z")) def mean(obj, dims): # note: apply always moves core dimensions to the end return xr.apply_ufunc(np.mean, obj, input_core_dims=[dims], kwargs={'axis': -1}) mean(a, "x") # works mean(a, ("x", "y")) # returns ValueError: applied function returned data with unexpected number of dimensions: 2 vs 1, for dimensions ('z',)

And I have no idea how to make the second, more general example work.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2808/reactions",
    "total_count": 5,
    "+1": 5,
    "-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
  • 9 rows from issue in issue_comments
Powered by Datasette · Queries took 238.81ms · About: xarray-datasette