Refactor dimfilter to follow the new coding conventions
@@ -135,10 +135,10 @@ def dimfilter(grid, **kwargs):
with Session() as lib:
file_context = lib.virtualfile_from_data(check_kind=None, data=grid)
with file_context as infile:
- if "G" not in kwargs: # if outgrid is unset, output to tempfile
- kwargs.update({"G": tmpfile.name})
- outgrid = kwargs["G"]
- arg_str = " ".join([infile, build_arg_string(kwargs)])
- lib.call_module(module="dimfilter", args=arg_str)
+ if (outgrid := kwargs.get("G")) is None:
+ kwargs["G"] = outgrid = tmpfile.name # output to tmpfile
+ lib.call_module(
+ module="dimfilter", args=build_arg_string(kwargs, infile=infile)
+ )
return load_dataarray(outgrid) if outgrid == tmpfile.name else None
