Skip to content

Commit

Permalink
Remove tests warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristobal Pio Garcia committed Apr 2, 2024
1 parent aaf8cfd commit 79e19f2
Show file tree
Hide file tree
Showing 7 changed files with 2,385 additions and 13 deletions.
1 change: 1 addition & 0 deletions config/quickLookIsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
config.doSaturationInterpolation = True
config.overscan.fitType = "MEDIAN_PER_ROW"
config.overscan.doParallelOverscan = True
# config.brighterFatterMaxIter = 2 # Uncomment this to remove test warning
8 changes: 5 additions & 3 deletions python/lsst/summit/utils/butlerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def fillDataId(butler, dataId):
dataId, _ = butler._rewrite_data_id(dataId, butler.get_dataset_type("raw"))

# now expand and turn back to a dict
dataId = butler.registry.expandDataId(dataId, detector=0).full # this call is VERY slow
dataId = butler.registry.expandDataId(dataId, detector=0).mapping # this call is VERY slow
dataId = _assureDict(dataId)

missingExpId = getExpId(dataId) is None
Expand Down Expand Up @@ -470,10 +470,12 @@ def _assureDict(dataId):
"""
if isinstance(dataId, dict):
return dataId
elif hasattr(dataId, "mapping"): # dafButler.dimensions.DataCoordinate
return {str(k): v for k, v in dataId.mapping.items()}
elif hasattr(dataId, "items"): # dafButler.dimensions.DataCoordinate
return {str(k): v for k, v in dataId.items()} # str() required due to full names
elif hasattr(dataId, "dataId"): # dafButler.dimensions.DimensionRecord
return {str(k): v for k, v in dataId.dataId.items()}
return {str(k): v for k, v in dataId.dataId.mapping.items()}
else:
raise RuntimeError(f"Failed to coerce {type(dataId)} to dict")

Expand Down Expand Up @@ -757,7 +759,7 @@ def isOnSky(expRecord):
dataIds = [r.dataId for r in filter(isOnSky, itertools.chain(*recordSets))]
if full:
expandedIds = [
updateDataIdOrDataCord(butler.registry.expandDataId(dataId, detector=0).full)
updateDataIdOrDataCord(butler.registry.expandDataId(dataId, detector=0).mapping)
for dataId in dataIds
]
filledIds = [fillDataId(butler, dataId) for dataId in expandedIds]
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/summit/utils/nightReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def plotPerObjectAirMass(self, objects=None, airmassOneAtTop=True, saveFig=""):

objects = ensure_iterable(objects)

plt.figure(figsize=(10, 6))
plt.figure(figsize=(16, 12))
for star in objects:
if star in CALIB_VALUES:
continue
Expand Down Expand Up @@ -707,7 +707,7 @@ def makeAltAzCoveragePlot(self, objects=None, withLines=False, saveFig=""):
objects = self.stars
objects = ensure_iterable(objects)

_ = plt.figure(figsize=(14, 10))
_ = plt.figure(figsize=(16, 12))

for obj in objects:
if obj in CALIB_VALUES:
Expand All @@ -730,7 +730,7 @@ def makeAltAzCoveragePlot(self, objects=None, withLines=False, saveFig=""):
)
lgnd = ax.legend(bbox_to_anchor=(1.05, 1), prop={"size": 15}, loc="upper left")
ax.set_title("Axial coverage - azimuth (theta, deg) vs zenith angle (r, deg)", size=20)
for h in lgnd.legendHandles:
for h in lgnd.legend_handles:
size = 14
if "-" in marker:
size += 5
Expand Down
1,432 changes: 1,432 additions & 0 deletions tests/data/cassettes/setUpClass.yaml

Large diffs are not rendered by default.

924 changes: 924 additions & 0 deletions tests/data/cassettes/test_noDataBehaviour.yaml

Large diffs are not rendered by default.

25 changes: 19 additions & 6 deletions tests/test_butlerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@

import copy
import datetime
import matplotlib.pyplot as plt
import os
import random
import unittest
from typing import Iterable

import lsst.daf.butler as dafButler
import lsst.utils.tests
from lsst.daf.butler import DatasetRef, NamedKeyMapping
from lsst.daf.butler import DatasetRef
from collections.abc import Mapping
from lsst.resources import ResourcePath
from lsst.summit.utils.butlerUtils import removeDataProduct # noqa: F401
from lsst.summit.utils.butlerUtils import (
Expand Down Expand Up @@ -64,6 +66,17 @@
)


def custom_show(*args, **kwargs):
pass


# Override the show function with our custom one
# to avoid getting the next Warning:
# UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
# plt.show()
plt.show = custom_show


class ButlerUtilsTestCase(lsst.utils.tests.TestCase):
"""A test case for testing sky position offsets for exposures."""

Expand Down Expand Up @@ -112,9 +125,9 @@ def setUp(self):
self.dataCoordMinimal = self.butler.registry.expandDataId(self.rawDataIdNoDayObSeqNum, detector=0)
self.dataCoordFullView = self.butler.registry.expandDataId(
self.rawDataIdNoDayObSeqNum, detector=0
).full
).mapping
self.assertIsInstance(self.dataCoordMinimal, dafButler.dimensions.DataCoordinate)
self.assertIsInstance(self.dataCoordFullView, NamedKeyMapping)
self.assertIsInstance(self.dataCoordFullView, Mapping)

def test_getLatissDefaultCollections(self):
defaultCollections = getLatissDefaultCollections()
Expand Down Expand Up @@ -244,9 +257,9 @@ def test_getExpId(self):
self.assertTrue(getExpId(bad) is None)

def test_datasetExists(self):
self.assertTrue(datasetExists(self.butler, "raw", self.rawDataId))
self.assertTrue(datasetExists(self.butler, "raw", self.expIdOnly))
self.assertTrue(datasetExists(self.butler, "raw", self.dayObsSeqNumIdOnly))
self.assertTrue(self.butler.exists("raw", self.rawDataId))
self.assertTrue(self.butler.exists("raw", self.expIdOnly))
self.assertTrue(self.butler.exists("raw", self.dayObsSeqNumIdOnly))
return

def test_sortRecordsByDayObsThenSeqNum(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tmaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def test_endToEnd(self):
@vcr.use_cassette()
def test_noDataBehaviour(self):
eventMaker = self.tmaEventMaker
noDataDayObs = 19500101 # do not use 19700101 - there is data for that day!
noDataDayObs = 19600101 # do not use 19700101 - there is data for that day!
with self.assertLogs(level="WARNING") as cm:
correctMsg = f"No EFD data found for dayObs={noDataDayObs}"
events = eventMaker.getEvents(noDataDayObs)
Expand Down

0 comments on commit 79e19f2

Please sign in to comment.