File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,15 @@ def _convert_timedeltas(coords, lims):
6565 lims = {x : [] for x in dims_r }
6666 for dim in dims_r :
6767 array = coords [dim ]
68- lims [dim ] += [array .min (), array .max ()]
68+ # Use nanmin/nanmax to handle NaN/NaT values in coordinates
69+ with suppress_warnings (RuntimeWarning ):
70+ array_min = np .nanmin (array )
71+ array_max = np .nanmax (array )
72+ # If all values are NaN/NaT, fall back to index-based extents
73+ if np .isnan (array_min ) or np .isnan (array_max ):
74+ array_min = 0
75+ array_max = len (array ) - 1
76+ lims [dim ] += [array_min , array_max ]
6977 # find datetime coords and convert to numpy mtimes
7078 _convert_datetimes (coords , lims )
7179 _convert_timedeltas (coords , lims )
Original file line number Diff line number Diff line change @@ -179,3 +179,14 @@ def test_log(self, random_patch):
179179 assert (
180180 cb_label == expected_label
181181 ), f"Expected '{ expected_label } ', but got '{ cb_label } '"
182+
183+ def test_incomplete_time_coord (self ):
184+ """Test waterfall plot with incomplete time coordinates (issue #534)."""
185+ # Create a patch with aggregated time dimension (all NaN coordinates)
186+ spool = dc .get_example_spool ()
187+ sub = spool .chunk (time = 2 , overlap = 1 )
188+ aggs = dc .spool ([x .max ("time" ) for x in sub ]).concatenate (time = None )[0 ]
189+ # This should not raise an error
190+ ax = aggs .viz .waterfall ()
191+ assert ax is not None
192+ assert isinstance (ax , plt .Axes )
You can’t perform that action at this time.
0 commit comments