Skip to content

Commit

Permalink
suppress futurewarnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ned2 committed Oct 7, 2023
1 parent e19dec8 commit 3c402a2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/python/plotly/_plotly_utils/basevalidators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io
import re
import sys
import warnings

from _plotly_utils.optional_imports import get_module

Expand Down Expand Up @@ -100,7 +101,9 @@ def copy_to_readonly_numpy_array(v, kind=None, force_numeric=False):
elif v.dtype.kind == "M":
# Convert datetime Series/Index to numpy array of datetimes
if isinstance(v, pd.Series):
v = v.dt.to_pydatetime()
with warnings.catch_warnings():
warnings.simplefilter("ignore", FutureWarning)
v = np.array(v.dt.to_pydatetime())
else:
# DatetimeIndex
v = v.to_pydatetime()
Expand All @@ -109,7 +112,12 @@ def copy_to_readonly_numpy_array(v, kind=None, force_numeric=False):
if dtype.kind in numeric_kinds:
v = v.values
elif dtype.kind == "M":
v = [row.dt.to_pydatetime().tolist() for i, row in v.iterrows()]
with warnings.catch_warnings():
warnings.simplefilter("ignore", FutureWarning)
v = [
nd.array(row.dt.to_pydatetime()).tolist()
for i, row in v.iterrows()
]

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

0 comments on commit 3c402a2

Please sign in to comment.