Silence xarray FutureWarning by adding compat parameter#446
Conversation
Agent-Logs-Url: https://github.com/nunnsy/cfgrib/sessions/6c98bc19-b97c-4086-abdf-6963f21ecec3 Co-authored-by: nunnsy <762488+nunnsy@users.noreply.github.com>
…mpat Silence xarray FutureWarning by explicitly passing `compat='no_conflicts'` to `xr.merge`
| for i, o in enumerate(merged): | ||
| if all(o.attrs[k] == ds.attrs[k] for k in o.attrs): | ||
| try: | ||
| o = xr.merge([o, ds], **kwargs) |
There was a problem hiding this comment.
It's possible to move the change here if desirable. Thought best to keep generic given other kwargs were in the call already amended.
|
@iainrussell for your review :) |
|
Commenting to lend support to this PR, can't wait for these FutureWarnings to go away. Thanks @nunnsy for being on top of it! Personally, I would move not just the new That said, the fix as initially suggested would be the smallest required change to fix the FutureWarnings issue, and be consistent with the current approach of controlling the |
|
Oops, I seem to have missed this PR when I submitted #447 on this last week. Thanks all for being on top of that, I add +1 support for this PR for silencing these very noisy warnings. I will close that issue when this is merged 😄 |
|
@iainrussell would you have a moment to take a look at this PR? |
Description
xarray is changing the default
compatargument forxr.mergefrom'no_conflicts'to'override', triggering aFutureWarningon every call throughmerge_datasets(). Explicitly passingcompat='no_conflicts'preserves the current strict behaviour (conflicting variable values raise) and silences the warning.Exact warning example
Change
cfgrib/xarray_store.py— addedcompat="no_conflicts"to themerge_datasets(...)call inopen_datasets():compat='override'is intentionally avoided — it would silently accept conflicting variable values, which is a regression in safety.Contributor Declaration
By opening this pull request, I affirm the following: