home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 471136862

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/2791#issuecomment-471136862 https://api.github.com/repos/pydata/xarray/issues/2791 471136862 MDEyOklzc3VlQ29tbWVudDQ3MTEzNjg2Mg== 6164157 2019-03-09T02:14:53Z 2019-03-09T02:15:40Z CONTRIBUTOR

To make things concrete, the solution that I have in mind is as simple as adding this function to DataArray:

python def __format__(self, format_spec): return self.values.__format__(format_spec)

Here's one use case I have encountered: python ds=xr.Dataset({'A':(['x','y','z'], np.random.rand(40,40,3)), 'B':(['z'], np.random.randn(3))}, coords={'z':[31,42,45]}) fg=ds.A.plot(col='z') for ax, d in zip(fg.axes.flat, fg.name_dicts.flat): t=ax.get_title() ax.set_title('{} and B(z)={:1.2}'.format(t, ds.sel(**d).B))

This way, if you want to vectorize a __format__ on an array can you not simply do ```python ar = xr.DataArray([39, 103, id(xr)]) print('{:3.3f} {:3.3e} {:x}'.format(*ar))

prints 39.000 1.030e+02 10e5bb548

```

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