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/2315#issuecomment-408263759,https://api.github.com/repos/pydata/xarray/issues/2315,408263759,MDEyOklzc3VlQ29tbWVudDQwODI2Mzc1OQ==,868027,2018-07-26T23:17:26Z,2018-07-26T23:17:26Z,CONTRIBUTOR,I can work on a PR tomorrow. Does the benefit of having the same behavior as the netCDF4 library warrant a potentially breaking change for existing code which relies on the current behavior of `filter_by_attrs()`? This might need adding a new method with the same behavior as netCDF4 and keeping the existing one as is (with appropriate documentation updates).,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,344631360
https://github.com/pydata/xarray/issues/2315#issuecomment-408260961,https://api.github.com/repos/pydata/xarray/issues/2315,408260961,MDEyOklzc3VlQ29tbWVudDQwODI2MDk2MQ==,868027,2018-07-26T23:01:44Z,2018-07-26T23:01:44Z,CONTRIBUTOR,"I'm fairly certain that the `netCDF4.Dataset.get_variables_by_attributes` behaves as a logical AND.
Here is the currently implementation body from https://github.com/Unidata/netcdf4-python/blob/master/netCDF4/_netCDF4.pyx#L2868
```python
vs = []
has_value_flag = False
# this is a hack to make inheritance work in MFDataset
# (which stores variables in _vars)
_vars = self.variables
if _vars is None: _vars = self._vars
for vname in _vars:
var = _vars[vname]
for k, v in kwargs.items():
if callable(v):
has_value_flag = v(getattr(var, k, None))
if has_value_flag is False:
break
elif hasattr(var, k) and getattr(var, k) == v:
has_value_flag = True
else:
has_value_flag = False
break
if has_value_flag is True:
vs.append(_vars[vname])
return vs
```
The difference appears to be in the presence of that `has_value_flag` and the breaks in the innermost loop. I must admit I had a little trouble following the above code, but it seems that when any of they key=value tests fails, it will stop checking the current variable (DataArray in the xarray context) and check the next variable.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,344631360