From b257d424619b3924ddf584c6a3b1873753a8cd49 Mon Sep 17 00:00:00 2001 From: Brett Date: Mon, 30 Oct 2023 13:34:17 -0400 Subject: [PATCH] allow control of memmapping for asdf files --- src/stdatamodels/model_base.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/stdatamodels/model_base.py b/src/stdatamodels/model_base.py index 4effdba8..8a958b76 100644 --- a/src/stdatamodels/model_base.py +++ b/src/stdatamodels/model_base.py @@ -94,8 +94,7 @@ def __init__(self, init=None, schema=None, memmap=False, will be used. memmap : bool - Turn memmap of FITS file on or off. (default: False). Ignored for - ASDF files. + Turn memmap of FITS/ASDF file on or off. (default: False). pass_invalid_values : bool or None If `True`, values that do not validate the schema @@ -240,6 +239,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) asdffile = self.open_asdf(init=init, **kwargs) else: @@ -568,7 +569,8 @@ def open_asdf(init=None, if isinstance(init, str): asdffile = asdf.open(init, ignore_version_mismatch=ignore_version_mismatch, - ignore_unrecognized_tag=ignore_unrecognized_tag) + ignore_unrecognized_tag=ignore_unrecognized_tag, + **kwargs) else: asdffile = AsdfFile(init,