From 42134659209102aaccac49ea42df0fdf0c7b865c Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Thu, 18 Jul 2024 09:54:08 -0400 Subject: [PATCH 1/3] replace usages of ``copy_arrays`` with ``memmap`` --- src/stdatamodels/jwst/datamodels/util.py | 2 +- src/stdatamodels/model_base.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stdatamodels/jwst/datamodels/util.py b/src/stdatamodels/jwst/datamodels/util.py index 20f919f4..81b9562e 100644 --- a/src/stdatamodels/jwst/datamodels/util.py +++ b/src/stdatamodels/jwst/datamodels/util.py @@ -128,7 +128,7 @@ def open(init=None, guess=True, memmap=False, **kwargs): return ModelContainer(init, **kwargs) elif file_type == "asdf": - asdffile = asdf.open(init, copy_arrays=not memmap) + asdffile = asdf.open(init, memmap=memmap) # Detect model type, then get defined model, and call it. new_class = _class_from_model_type(asdffile) diff --git a/src/stdatamodels/model_base.py b/src/stdatamodels/model_base.py index 17165789..2aea54e4 100644 --- a/src/stdatamodels/model_base.py +++ b/src/stdatamodels/model_base.py @@ -234,8 +234,8 @@ def __init__(self, init=None, schema=None, memmap=False, ) elif file_type == "asdf": - # use memmap argument of "copy_arrays" was not defined - kwargs["copy_arrays"] = kwargs.get("copy_arrays", not memmap) + # "copy_arrays" is deprecated; use "memmap" instead + kwargs["memmap"] = not kwargs.get("copy_arrays", not memmap) asdffile = self.open_asdf(init=init, **kwargs) else: From a3cf83c47bbe37f5955134f80b406fda8a9a3c86 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Thu, 18 Jul 2024 09:55:39 -0400 Subject: [PATCH 2/3] add change log entry --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 259b7edb..9ae135e7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,7 @@ 2.0.1 (unreleased) =================== -- +- replace usages of ``copy_arrays`` with ``memmap`` [#306] 2.0.0 (2024-06-24) =================== From f5c46d761c3ea876bcd60843e3811a7d4b744a56 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Thu, 18 Jul 2024 12:11:35 -0400 Subject: [PATCH 3/3] outsource copy_arrays deprecation warning to asdf --- src/stdatamodels/model_base.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/stdatamodels/model_base.py b/src/stdatamodels/model_base.py index 2aea54e4..787a726e 100644 --- a/src/stdatamodels/model_base.py +++ b/src/stdatamodels/model_base.py @@ -234,9 +234,7 @@ def __init__(self, init=None, schema=None, memmap=False, ) elif file_type == "asdf": - # "copy_arrays" is deprecated; use "memmap" instead - kwargs["memmap"] = not kwargs.get("copy_arrays", not memmap) - asdffile = self.open_asdf(init=init, **kwargs) + asdffile = self.open_asdf(init=init, memmap=memmap, **kwargs) else: # TODO handle json files as well