Skip to content

Commit

Permalink
allow control of memmapping for asdf files (spacetelescope#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored Dec 7, 2023
1 parent 1180473 commit bbc9016
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Changes to API
- Deprecate ``cast_arrays`` argument to ``from_fits_hdu`` and
``cast_fits_arrays`` argument to ``Datamodel.__init__`` [#214]

- Use ``DataModel.__init__`` ``memmap`` argument when opening ASDF
files [#232]

Other
-----

Expand Down
8 changes: 5 additions & 3 deletions src/stdatamodels/model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -244,6 +243,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:
Expand Down Expand Up @@ -575,7 +576,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,
Expand Down

0 comments on commit bbc9016

Please sign in to comment.