home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 116406425

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/448#issuecomment-116406425 https://api.github.com/repos/pydata/xarray/issues/448 116406425 MDEyOklzc3VlQ29tbWVudDExNjQwNjQyNQ== 1217238 2015-06-29T03:13:33Z 2015-06-29T03:13:33Z MEMBER

Unfortunately, there's no way to make np.asarray return anything other than a numpy array without metadata -- that's kind of the entire point of asarray.

We do have some other options, though. The first two already work: - use xray.Dataset.apply to call a function, e.g., ds.apply(db2w) - write a numpy universal function using numba:

python @numba.vectorize def db2w(arr): return 10 ** (arr / 20.0) - we could write a modified version of asarray that passes through xray objects - we could write a decorator that transforms a function to preserve/restore xray metadata, e.g.,

``` python def keep_metadata(func): def wrapper(array, **kwargs): return array.array_wrap(func(array)) return wrapper

@keep_metadata def db2w(arr): return 10 ** (np.asarray(arr) / 20.0) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  91676831
Powered by Datasette · Queries took 85.502ms · About: xarray-datasette