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/6124#issuecomment-1007746645,https://api.github.com/repos/pydata/xarray/issues/6124,1007746645,IC_kwDOAMm_X848EP5V,221526,2022-01-07T21:16:20Z,2022-01-07T21:16:20Z,CONTRIBUTOR,"$0.02 from the peanut gallery is that my mental model of `Dataset` is that it's a dictionary on steroids, so following the `Mapping` protocol (including `__bool__`) makes sense to me. I put ""I don't know"" for @shoyer's poll, but if the question was ""should"" then I would have said ""number of variables"".
While I'm not going to sit here and argue that `if ds:` is a common operation and important feature (I don't often open files that result in empty datasets), I'd personally want a truly compelling argument for breaking from the `Mapping` protocol. Right now it's ""`Dataset` works like `dict` *plus* some stuff"". It would change to be ""`Dataset` works like `dict` for all things except `__bool__`, plus some stuff"". The latter to me requires more mental effort since I'm no longer strictly supplementing past experience.","{""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1090229430
https://github.com/pydata/xarray/issues/6124#issuecomment-1002777049,https://api.github.com/repos/pydata/xarray/issues/6124,1002777049,IC_kwDOAMm_X847xSnZ,3698640,2021-12-29T21:09:12Z,2021-12-29T21:09:12Z,CONTRIBUTOR,"I realize this may be a larger discussion, but the implementation is so easy I went ahead and filed a PR that issues a PendingDeprecationWarning in `Dataset.__bool__`.","{""total_count"": 1, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 1, ""rocket"": 0, ""eyes"": 0}",,1090229430
https://github.com/pydata/xarray/issues/6124#issuecomment-1002673070,https://api.github.com/repos/pydata/xarray/issues/6124,1002673070,IC_kwDOAMm_X847w5Ou,3698640,2021-12-29T16:22:10Z,2021-12-29T16:22:10Z,CONTRIBUTOR,"> If there's a synthesis of keeping the truthiness while reducing the chance of these mistakes, that would be very welcome.
@max-sixty im not sure what this would look like. Do you mean a warning or are you hinting that the bar that would need to be met is a silver bullet that preserves bool(ds) but somehow isn’t confusing?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1090229430
https://github.com/pydata/xarray/issues/6124#issuecomment-1002671461,https://api.github.com/repos/pydata/xarray/issues/6124,1002671461,IC_kwDOAMm_X847w41l,3698640,2021-12-29T16:18:35Z,2021-12-29T16:18:35Z,CONTRIBUTOR,"Yeah… I do understand how it’s currently working and why, and the behavior is certainly intuitive to those who appreciate the mapping inheritance.
That said, I feel I have to make a last stand argument because this trips people up quite often (on my team and elsewhere). I haven’t yet come across an example of anyone using this correctly, but I see users misusing it all the time.
The examples and behavior you’re showing @Illviljan seem to me like more the natural result of an implementation detail than a critical principle of the dataset design. While it’s obvious why `bool(ds)` resolves to True or False in the current implementation, I still think it’s not used and is out of step with how most users think of a dataset. The fact that nothing in the package requires a change in order to pass tests (the broken tests and the pathological case aside) reaffirms for me that this is not a useful feature.
I don’t know much about the mapping protocol or how closely it must be followed. Is the idea here that packages building on xarray (or interoperability features in e.g. numpy or dask) depend on a strict adherence to the full spec? ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1090229430