Skip to content

Commit

Permalink
Check all elements from the footprints list
Browse files Browse the repository at this point in the history
  • Loading branch information
madamow committed Oct 5, 2023
1 parent 2fd085c commit 44fe914
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 13 additions & 11 deletions python/lsst/summit/utils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def plot(inputData,
imageData = inputData.image.array
case _:
raise TypeError("This function accepts numpy array, lsst.afw.image.Exposure components."
" Got {type(inputData)}")
f" Got {type(inputData)}")

if np.isnan(imageData).all():
raise ValueError("The imageData contains only NaN values.")
Expand Down Expand Up @@ -272,23 +272,25 @@ def plot(inputData,
match footprints:
case FootprintSet():
fs = FootprintSet.getFootprints(footprints)
xy = [_.getCentroid() for _ in fs]
case Footprint():
fs = [footprints]
xy = [footprints.getCentroid()]
case list():
try:
footprints[0].getCentroid()
fs = footprints
except AttributeError:
raise TypeError("Cannot get centroids for the first "
"element of the list of footprints. "
"Expected lsst.afw.detection.Footprint, "
f"got {type(footprints[0])}")
xy = []
for i, ft in enumerate(footprints):
try:
ft.getCentroid()
except AttributeError:
raise TypeError("Cannot get centroids for one of the "
"elements from the footprints list. "
"Expected lsst.afw.detection.Footprint, "
f"got {type(ft)} for footprints[{i}]")
xy.append(ft.getCentroid())
case _:
raise TypeError("This function works with FootprintSets, "
"single Footprints, and iterables of Footprints. "
f"Got {type(footprints)}")

xy = [_.getCentroid() for _ in fs]
ax.plot(*zip(*xy),
marker='x',
markeredgecolor='b',
Expand Down
4 changes: 1 addition & 3 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ def test_plot(self):
nparr[:, :] = np.nan
with self.assertRaisesRegex(ValueError,
r"^The imageData contains only NaN values.$"):
plot(nparr,
showCompass=False,
stretch=stretch)
plot(nparr)


def setup_module(module):
Expand Down

0 comments on commit 44fe914

Please sign in to comment.