-
Notifications
You must be signed in to change notification settings - Fork 21
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
Construct ModelContainer from a Sequence #164
Construct ModelContainer from a Sequence #164
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #164 +/- ##
==========================================
+ Coverage 96.72% 96.74% +0.01%
==========================================
Files 8 8
Lines 1100 1106 +6
==========================================
+ Hits 1064 1070 +6
Misses 36 36
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the Change log.
d8383c9
to
45956f2
Compare
In addition, you need to add the PLWishMaster regression test run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@PaulHuwe Here's the regression test. And thanks again for the help! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also fix the merge conflict in CHANGES.rst
src/roman_datamodels/datamodels.py
Outdated
@@ -405,7 +405,7 @@ def __init__(self, init=None, iscopy=False, memmap=False, return_open=True, save | |||
if init is None: | |||
# don't populate container | |||
pass | |||
elif isinstance(init, list): | |||
elif isinstance(init, (list, Sequence)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elif isinstance(init, (list, Sequence)): | |
elif isinstance(init, Iterable): |
This will allow it to handle anything that follows the iterable protocol, the later checks will cover off any cases where this does not make sense.
Note Iterable
is a part of the abc.collections
builtin Python module, so line 16 will need to be updated in addition to this change in order for it to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with @WilliamJamieson's comments.
8e2de07
to
dd06dd1
Compare
I'll rebase to fix the new conflict, but @PaulHuwe / @WilliamJamieson: could you confirm that the last remaining test failure is unrelated? Thanks. |
The failure should have been fixed by #174. Try rebasing again with those changes included. |
dd06dd1
to
e1f319f
Compare
I'm merging this before anything else breaks stuff (I think spacetelescope/rad#255 just did but the CI is green now). |
Thanks @WilliamJamieson et al! |
It's occasionally convenient to construct a
ModelContainer
with aninit
arg that may be either (1) a string path/DataModel
; or also (2) an existingModelContainer
instance. (1) is currently supported inroman_datamodels
andjwst
, while (2) is supported injwst
but notroman_datamodels
.In this tiny PR, I've allowed rdm
ModelContainer
s to be constructed fromlist
s or subclasses ofcollections.abc.Sequence
, so that the expected behavior is recovered.Checklist
CHANGES.rst
under the corresponding subsection