Skip to content

Commit 3c402a2

Browse files
committed
suppress futurewarnings
1 parent e19dec8 commit 3c402a2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: packages/python/plotly/_plotly_utils/basevalidators.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io
88
import re
99
import sys
10+
import warnings
1011

1112
from _plotly_utils.optional_imports import get_module
1213

@@ -100,7 +101,9 @@ def copy_to_readonly_numpy_array(v, kind=None, force_numeric=False):
100101
elif v.dtype.kind == "M":
101102
# Convert datetime Series/Index to numpy array of datetimes
102103
if isinstance(v, pd.Series):
103-
v = v.dt.to_pydatetime()
104+
with warnings.catch_warnings():
105+
warnings.simplefilter("ignore", FutureWarning)
106+
v = np.array(v.dt.to_pydatetime())
104107
else:
105108
# DatetimeIndex
106109
v = v.to_pydatetime()
@@ -109,7 +112,12 @@ def copy_to_readonly_numpy_array(v, kind=None, force_numeric=False):
109112
if dtype.kind in numeric_kinds:
110113
v = v.values
111114
elif dtype.kind == "M":
112-
v = [row.dt.to_pydatetime().tolist() for i, row in v.iterrows()]
115+
with warnings.catch_warnings():
116+
warnings.simplefilter("ignore", FutureWarning)
117+
v = [
118+
nd.array(row.dt.to_pydatetime()).tolist()
119+
for i, row in v.iterrows()
120+
]
113121

114122
if not isinstance(v, np.ndarray):
115123
# v has its own logic on how to convert itself into a numpy array

0 commit comments

Comments
 (0)