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/pull/6823#issuecomment-1203860057,https://api.github.com/repos/pydata/xarray/issues/6823,1203860057,IC_kwDOAMm_X85HwXJZ,14808389,2022-08-03T12:03:44Z,2022-08-08T12:32:21Z,MEMBER,"> But it won't feel very consistent once string formatting are used though. I guess we could introduce some sort of `xarray` specific formatting mini-language to solve that? For example: - `f""{arr:r}""`: print the object's `repr` (the default) - `f""{arr:b}""`: print the array backend's `repr` (only for `DataArray` / `Variable`)","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1316549018 https://github.com/pydata/xarray/pull/6823#issuecomment-1204216812,https://api.github.com/repos/pydata/xarray/issues/6823,1204216812,IC_kwDOAMm_X85HxuPs,5635139,2022-08-03T16:46:19Z,2022-08-03T16:46:19Z,MEMBER,Great idea — doing anything that's expensive on `repr` has caught us a couple of times and can be a frustrating perf issue. Thanks @Illviljan !,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1316549018 https://github.com/pydata/xarray/pull/6823#issuecomment-1204156997,https://api.github.com/repos/pydata/xarray/issues/6823,1204156997,IC_kwDOAMm_X85HxfpF,14371165,2022-08-03T16:05:10Z,2022-08-03T16:05:10Z,MEMBER,"> I guess we could introduce some sort of `xarray` specific formatting mini-language to solve that? For example: > > * `f""{arr:r}"": print the object's `repr` (the default) > > * `f""{arr:b}"": print the array backend's `repr`(only for`DataArray`/`Variable`) Interesting idea. I was thinking just adding `format_spec` to `formatting.array_repr` so the repr can handle `__format__` as well should be enough. It seemed much more involved though. Anyway that's for another PR. I think this PR is ready now, I think it should handle the main request in #5976 without being so intrusive in other cases.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1316549018 https://github.com/pydata/xarray/pull/6823#issuecomment-1200289273,https://api.github.com/repos/pydata/xarray/issues/6823,1200289273,IC_kwDOAMm_X85HivX5,14371165,2022-07-30T20:31:01Z,2022-07-30T20:31:01Z,MEMBER,"This is how it behaves right now. I believe this should be the same behavior as previously now with the extra possibility to format scalar arrays: ```python import pandas as pd import xarray as xr s = pd.Series( range(4), index=pd.MultiIndex.from_product([list(""ab""), list(""cd"")]), ) da = xr.DataArray.from_series(s, sparse=True) # Handle sparse: print(f""Error: {da} is sparse"") Error: Coordinates: * level_0 (level_0) object 'a' 'b' * level_1 (level_1) object 'c' 'd' is sparse # Handle format_spec: da = xr.DataArray([1, 2, 3]) print(f'{da[0]}') array(1) print(f'{da[0]:d}') 1 print(f'{da[0]:f}') 1.000000 da = xr.DataArray([1, 2, 3]) print(f'{da:.f}') Traceback (most recent call last): (...) NotImplementedError: Using format_spec is only supported when shape is (). Got shape = (3,). ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1316549018 https://github.com/pydata/xarray/pull/6823#issuecomment-1193853083,https://api.github.com/repos/pydata/xarray/issues/6823,1193853083,IC_kwDOAMm_X85HKMCb,14371165,2022-07-25T10:15:16Z,2022-07-25T10:15:16Z,MEMBER,"Hmm, I'm not a fan that f-strings by default uses the backend array only: ```python import pandas as pd import xarray as xr s = pd.Series( range(4), index=pd.MultiIndex.from_product([list(""ab""), list(""cd"")]), ) da = xr.DataArray.from_series(s, sparse=True) # Uses __format__: print(f""Error: {da} is sparse"") Error: is sparse ``` Should it by default just use the repr instead? But it won't feel very consistent once string formatting are used though.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1316549018