Skip to content

Commit

Permalink
fix dangerous default arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
pnijhara committed May 13, 2020
1 parent bd84186 commit feef24d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 13 additions & 2 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
dask_version = "10.0"

ON_WINDOWS = sys.platform == "win32"
default_value = object()


def open_example_dataset(name, *args, **kwargs):
Expand Down Expand Up @@ -3604,11 +3605,21 @@ def create_tmp_geotiff(
ny=3,
nz=3,
transform=None,
transform_args=[5000, 80000, 1000, 2000.0],
crs={"units": "m", "no_defs": True, "ellps": "WGS84", "proj": "utm", "zone": 18},
transform_args=default_value,
crs=default_value,
open_kwargs=None,
additional_attrs=None,
):
if transform_args is default_value:
transform_args = [5000, 80000, 1000, 2000.0]
if crs is default_value:
crs = {
"units": "m",
"no_defs": True,
"ellps": "WGS84",
"proj": "utm",
"zone": 18,
}
# yields a temporary geotiff file and a corresponding expected DataArray
import rasterio
from rasterio.transform import from_origin
Expand Down
6 changes: 5 additions & 1 deletion xarray/tests/test_conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,12 @@ def create_store(self):

@contextlib.contextmanager
def roundtrip(
self, data, save_kwargs={}, open_kwargs={}, allow_cleanup_failure=False
self, data, save_kwargs=None, open_kwargs=None, allow_cleanup_failure=False
):
if save_kwargs is None:
save_kwargs = {}
if open_kwargs is None:
open_kwargs = {}
store = CFEncodedInMemoryStore()
data.dump_to_store(store, **save_kwargs)
yield open_dataset(store, **open_kwargs)
Expand Down

0 comments on commit feef24d

Please sign in to comment.