5
5
import warnings
6
6
from datetime import datetime
7
7
from inspect import getfullargspec
8
- from typing import Any , Iterable , Mapping
8
+ from typing import Any , Iterable , Mapping , Sequence
9
9
10
10
import numpy as np
11
11
import pandas as pd
@@ -502,7 +502,7 @@ def label_from_attrs(da, extra: str = "") -> str:
502
502
return "\n " .join (textwrap .wrap (name + extra + units , 30 ))
503
503
504
504
505
- def _interval_to_mid_points (array ) :
505
+ def _interval_to_mid_points (array : Iterable [ pd . Interval ]) -> np . ndarray :
506
506
"""
507
507
Helper function which returns an array
508
508
with the Intervals' mid points.
@@ -511,7 +511,7 @@ def _interval_to_mid_points(array):
511
511
return np .array ([x .mid for x in array ])
512
512
513
513
514
- def _interval_to_bound_points (array ) :
514
+ def _interval_to_bound_points (array : Sequence [ pd . Interval ]) -> np . ndarray :
515
515
"""
516
516
Helper function which returns an array
517
517
with the Intervals' boundaries.
@@ -523,7 +523,9 @@ def _interval_to_bound_points(array):
523
523
return array_boundaries
524
524
525
525
526
- def _interval_to_double_bound_points (xarray , yarray ):
526
+ def _interval_to_double_bound_points (
527
+ xarray : Iterable [pd .Interval ], yarray : Iterable
528
+ ) -> tuple [np .ndarray , np .ndarray ]:
527
529
"""
528
530
Helper function to deal with a xarray consisting of pd.Intervals. Each
529
531
interval is replaced with both boundaries. I.e. the length of xarray
@@ -533,13 +535,15 @@ def _interval_to_double_bound_points(xarray, yarray):
533
535
xarray1 = np .array ([x .left for x in xarray ])
534
536
xarray2 = np .array ([x .right for x in xarray ])
535
537
536
- xarray = list (itertools .chain .from_iterable (zip (xarray1 , xarray2 )))
537
- yarray = list (itertools .chain .from_iterable (zip (yarray , yarray )))
538
+ xarray_out = np . array ( list (itertools .chain .from_iterable (zip (xarray1 , xarray2 ) )))
539
+ yarray_out = np . array ( list (itertools .chain .from_iterable (zip (yarray , yarray ) )))
538
540
539
- return xarray , yarray
541
+ return xarray_out , yarray_out
540
542
541
543
542
- def _resolve_intervals_1dplot (xval , yval , kwargs ):
544
+ def _resolve_intervals_1dplot (
545
+ xval : np .ndarray , yval : np .ndarray , kwargs : dict
546
+ ) -> tuple [np .ndarray , np .ndarray , str , str , dict ]:
543
547
"""
544
548
Helper function to replace the values of x and/or y coordinate arrays
545
549
containing pd.Interval with their mid-points or - for step plots - double
0 commit comments