Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dangerous default arguments #4006

Merged
merged 2 commits into from
May 23, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@
dask_version = "10.0"

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


def open_example_dataset(name, *args, **kwargs):
@@ -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
6 changes: 5 additions & 1 deletion xarray/tests/test_conventions.py
Original file line number Diff line number Diff line change
@@ -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)