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-469437857,https://api.github.com/repos/pydata/xarray/issues/2791,469437857,MDEyOklzc3VlQ29tbWVudDQ2OTQzNzg1Nw==,6815844,2019-03-04T21:57:04Z,2019-03-04T21:57:04Z,MEMBER,"@yohai , sorry, I misunderstood `__format__` and `__repr__`.
I like shoyer's
> vectorize format() over each element of the array (the proposal in the linked numpy issue)
as I feel it more consistent with the existing xarray `__repr__`.
I sometimes want a 0d-dataarray to behave as a native scalar.
`format` is one of a typical case, but there are several other cases, e.g., `np.ones(xr.DataArray([0])[0])`.
Therefore, I always needs to be carefule whether the scalar is xarray object or not.
I am a bit worrying if printing 0d-dataarray as a scalar would confuse me as it is a scalar not a 0d-array.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,415209776
https://github.com/pydata/xarray/issues/2791#issuecomment-469325571,https://api.github.com/repos/pydata/xarray/issues/2791,469325571,MDEyOklzc3VlQ29tbWVudDQ2OTMyNTU3MQ==,1217238,2019-03-04T16:48:03Z,2019-03-04T16:48:03Z,MEMBER,"Here's a related NumPy issue: https://github.com/numpy/numpy/issues/5543
I guess there are two possible behaviors for `'{:d}'.format(x)` where `x` is a DataArray object:
- coerce scalar arrays to native Python numbers and format it like a `float`
- vectorize `format()` over each element of the array (the proposal in the linked numpy issue)
These behaviors would definitely conflict for scalar objects -- in the second case, we would still want to include some indication that it's an `xarray.DataArray`. NumPy doesn't have a conflict because indexing an array results in a NumPy scalars, which prints like Python builtin scalars.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,415209776
https://github.com/pydata/xarray/issues/2791#issuecomment-469160334,https://api.github.com/repos/pydata/xarray/issues/2791,469160334,MDEyOklzc3VlQ29tbWVudDQ2OTE2MDMzNA==,6815844,2019-03-04T08:23:42Z,2019-03-04T08:23:42Z,MEMBER,"I agree that it is a bit annoying that 1d DataArray prints much information especially we want to embed the value into a string.
However, I'm a bit worried whether it would be surprising if an object that looks a native scalar is actually an xr.DataArray of one element, especially when working in an interactive environment.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,415209776
https://github.com/pydata/xarray/issues/2791#issuecomment-469155529,https://api.github.com/repos/pydata/xarray/issues/2791,469155529,MDEyOklzc3VlQ29tbWVudDQ2OTE1NTUyOQ==,1217238,2019-03-04T08:05:53Z,2019-03-04T08:05:53Z,MEMBER,"Yes, I think this would be a nice addition. This would entail implementing a `__format__` method on `xarray.DataArray`:
https://docs.python.org/3/reference/datamodel.html#object.__format__","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,415209776