home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 514805244

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/525#issuecomment-514805244 https://api.github.com/repos/pydata/xarray/issues/525 514805244 MDEyOklzc3VlQ29tbWVudDUxNDgwNTI0NA== 14808389 2019-07-24T21:22:33Z 2019-07-24T21:22:33Z MEMBER

In that branch I left it as xfail because I came to the conclusion that there was nothing I could do (directly at least): when creating a DataArray, the coords get * passed through as_variable(), which puts the coord array in Variable and for dimensions at least * calls Variable.to_index_variable(). In there the variable is converted to an IndexVariable and the array is * wrapped by PandasIndexAdapter where the array is * first passed through np.asarray (this would probably have to be removed/changed) and then to pandas.Index, which is where the units get stripped -- which can be verified by directly passing a unit array to it.

The units of coordinates that are not dimensions are not stripped: ```python

ureg = pint.UnitRegistry() v = np.arange(10 * 20).reshape(10, 20) * ureg.m / ureg.s d = np.arange(10) * ureg.m d2 = d.to(ureg.cm) t = np.arange(20) * ureg.s array = xr.DataArray(data=v, dims=('d', 't'), coords={'d': d, 'd2': ('d', d2), 't': t}) array.d.data array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) array.d2.data <Quantity([ 0. 100. 200. 300. 400. 500. 600. 700. 800. 900.], 'centimeter')> ``` However, that branch is a quick hack, and I would suspect that supporting duck arrays has a similar effect.

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