Skip to content
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

fix mk_level2_image for 3d shape #378

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.22.0 (2024-08-06)
===================

- Fix mk_level2_image utility for 3d shape. [#378]

0.21.0 (2024-08-06)
===================

Expand Down
2 changes: 1 addition & 1 deletion src/roman_datamodels/maker_utils/_datamodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def mk_level2_image(*, shape=(4088, 4088), n_groups=8, filepath=None, **kwargs):
roman_datamodels.stnode.WfiImage
"""
if len(shape) > 2:
shape = shape[1:3]
n_groups = shape[0]
shape = shape[1:3]

warnings.warn(
f"{MESSAGE} assuming the first entry is n_groups followed by y, x. The remaining is thrown out!", UserWarning
Expand Down
11 changes: 11 additions & 0 deletions tests/test_maker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,14 @@ def test_keyword_only(node_class):
assert param.kind == inspect.Parameter.VAR_KEYWORD
else:
assert param.kind == inspect.Parameter.KEYWORD_ONLY


@pytest.mark.filterwarnings("ignore:This function assumes shape is 2D")
def test_mk_level2_image_shape():
"""
Regression test for https://github.com/spacetelescope/roman_datamodels/issues/377
where n_groups was incorrect when provided a 3d shape
"""
n = maker_utils.mk_level2_image(shape=(2, 3, 4))
assert n.amp33.shape == (2, 4096, 128)
assert n.data.shape == (3, 4)