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

DM-45545: Fix np.Inf to np.inf for numpy2 compatibility #345

Merged
merged 2 commits into from
Feb 4, 2025
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
4 changes: 2 additions & 2 deletions python/lsst/analysis/tools/actions/scalar/scalarActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MedianAction(ScalarFromVectorAction):
def __call__(self, data: KeyedData, **kwargs) -> Scalar:
mask = self.getMask(**kwargs)
values = _dataToArray(data[self.vectorKey.format(**kwargs)])[mask]
med = nanMedian(values) if values.size else np.NaN
med = nanMedian(values) if values.size else np.nan

return med

Expand All @@ -94,7 +94,7 @@ class MeanAction(ScalarFromVectorAction):
def __call__(self, data: KeyedData, **kwargs) -> Scalar:
mask = self.getMask(**kwargs)
values = _dataToArray(data[self.vectorKey.format(**kwargs)])[mask]
mean = nanMean(values) if values.size else np.NaN
mean = nanMean(values) if values.size else np.nan

return mean

Expand Down
11 changes: 5 additions & 6 deletions tests/test_propertyMapPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from lsst.daf.butler import Butler, DataCoordinate, DatasetType, DeferredDatasetHandle
from lsst.daf.butler.tests.utils import makeTestTempDir, removeTestTempDir
from lsst.skymap.discreteSkyMap import DiscreteSkyMap
from mpl_toolkits import axisartist

# No display needed.
matplotlib.use("Agg")
Expand Down Expand Up @@ -162,7 +161,8 @@ def test_PerTractPropertyMapAnalysisTask(self):
self.assertTrue(isinstance(fig, plt.Figure), msg=f"Figure {key} is not a matplotlib figure.")

# Assert the number of axes in the figure. At least not empty.
self.assertEqual(len(fig.axes), 10)
# Varies between 7 and 10 based on skyproj version.
self.assertGreaterEqual(len(fig.axes), 7, f"Got axes: {fig.axes}")

# Verify some configuration parameters.
binsCount = atool.nBinsHist
Expand Down Expand Up @@ -273,13 +273,10 @@ def _validateFigureStructure(self, fig, atool, binsCount, xlabel, zoomFactors):

# Check the total number of each axis type.
totalSkyAxes = sum(isinstance(ax, skyproj.skyaxes.SkyAxes) for ax in axes)
totalAxisArtistAxes = sum(isinstance(ax, axisartist.axislines.Axes) for ax in axes)
totalColorbarAxes = sum(isinstance(ax, plt.Axes) and ax.get_label() == "<colorbar>" for ax in axes)

if totalSkyAxes != 3:
errors.append(f"Expected 3 SkyAxes but got {totalSkyAxes}.")
if totalAxisArtistAxes != 3:
errors.append(f"Expected 3 AxisArtist Axes but got {totalAxisArtistAxes}.")
if totalColorbarAxes != 3:
errors.append(f"Expected 3 colorbar Axes but got {totalColorbarAxes}.")

Expand Down Expand Up @@ -442,7 +439,9 @@ def test_SurveyWidePropertyMapAnalysisTask(self):
self.assertTrue(isinstance(fig, plt.Figure), msg=f"Figure {key} is not a matplotlib figure.")

# Assert the number of axes in the figure. At least not empty.
self.assertEqual(len(fig.axes), 3)
# There should be at least 2 axes.
# Some versions of skyproj have an additional axis.
self.assertGreaterEqual(len(fig.axes), 2, f"Got axes: {fig.axes}")


class MemoryTester(lsst.utils.tests.MemoryTestCase):
Expand Down
Loading