home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 408260961

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/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
Powered by Datasette · Queries took 0.737ms · About: xarray-datasette