Skip to content

Commit

Permalink
Merge branch 'master' into jp-2104-no-group-candidates-wfsc
Browse files Browse the repository at this point in the history
  • Loading branch information
tapastro authored Jun 8, 2021
2 parents 8c69ec9 + e58967b commit c2b6e83
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ associations

- Ensure no Lv3_WFSC associations created on group candidates [#6131]

datamodels
----------

- Convert incoming Path objects to strings in datamodels.open [#6130]



Expand Down
11 changes: 11 additions & 0 deletions jwst/datamodels/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ def make_models(tmp_path):
}


def test_init_from_pathlib(tmp_path):
"""Test initializing model from a Path object"""
path = tmp_path / "pathlib.fits"
model1 = datamodels.ImageModel((50, 50))
model1.save(path)
model = datamodels.open(path)

# Test is basically, did we open the model?
assert isinstance(model, ImageModel)


@pytest.mark.parametrize('which_file, skip_fits_update, expected_exp_type',
[
('just_fits', None, 'FGS_DARK'),
Expand Down
4 changes: 4 additions & 0 deletions jwst/datamodels/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import warnings
import os
from os.path import basename
from pathlib import Path
from platform import system as platform_system
import psutil
import traceback
Expand Down Expand Up @@ -87,6 +88,9 @@ def open(init=None, memmap=False, **kwargs):
# Get special cases for opening a model out of the way
# all special cases return a model if they match

if isinstance(init, Path):
init = str(init)

if init is None:
return model_base.JwstDataModel(None)

Expand Down

0 comments on commit c2b6e83

Please sign in to comment.