@@ -295,6 +295,40 @@ def test_empty_series(self):
295295 heatmapfigure (series , rasterized = True )
296296 self .assertEqual (str (cm .exception ), "Series cannot be empty" )
297297
298+ @compare_to_baseline
299+ def test_daily_max_false (self ):
300+ # daily_max=False omits the daily peak scatter (and the twinx axis)
301+ date_range = pd .date_range (
302+ "2020-01-01" , "2020-12-31 23:59:59" , freq = "15min" , tz = "UTC"
303+ )
304+ data = date_range .to_series ().apply (sinus_pattern )
305+ series = pd .Series (index = date_range , data = data )
306+ return heatmapfigure (series , rasterized = True , daily_max = False )
307+
308+ def test_non_series_raises (self ):
309+ with self .assertRaises (TypeError ) as cm :
310+ heatmapfigure ([0 , 1 , 2 ]) # ty: ignore[invalid-argument-type]
311+ self .assertEqual (str (cm .exception ), "series must be a pandas Series" )
312+
313+ def test_non_datetime_index_raises (self ):
314+ series = pd .Series ([0 , 1 , 2 ], index = [0 , 1 , 2 ])
315+ with self .assertRaisesRegex (ValueError , "DatetimeIndex" ):
316+ heatmapfigure (series , rasterized = True )
317+
318+ def test_missing_freq_raises (self ):
319+ index = pd .DatetimeIndex (["2020-01-01" , "2020-01-03" , "2020-01-04" ], tz = "UTC" )
320+ series = pd .Series ([0 , 1 , 2 ], index = index )
321+ with self .assertRaisesRegex (ValueError , "frequency" ):
322+ heatmapfigure (series , rasterized = True )
323+
324+ def test_invalid_daily_func_raises (self ):
325+ date_range = pd .date_range (
326+ "2020-01-01" , "2020-12-31 23:59:59" , freq = "15min" , tz = "UTC"
327+ )
328+ series = pd .Series (index = date_range , data = [0 , 1 ] * int (len (date_range ) / 2 ))
329+ with self .assertRaisesRegex (ValueError , "daily_func" ):
330+ heatmapfigure (series , rasterized = True , daily_func = "median" )
331+
298332
299333class TestSuntimes (unittest .TestCase ):
300334 """Test suite for sunrise and sunset time calculations."""
0 commit comments