Skip to content

Commit 5ec1ace

Browse files
Check datatype consistency
1 parent 0fa325f commit 5ec1ace

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

labellines/core.py

+4
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ def labelLines(
191191
# Convert datetime objects to numeric values for linspace/geomspace
192192
x_is_datetime = isinstance(xmin, datetime) or isinstance(xmax, datetime)
193193
if x_is_datetime:
194+
if not isinstance(xmin, datetime) or not isinstance(xmax, datetime):
195+
raise ValueError(
196+
f"Cannot mix datetime and numeric values in xvals: {xvals}"
197+
)
194198
xmin = plt.matplotlib.dates.date2num(xmin)
195199
xmax = plt.matplotlib.dates.date2num(xmax)
196200

0 commit comments

Comments
 (0)