@@ -1311,47 +1311,13 @@ def _to_unmasked_float_array(x):
1311
1311
1312
1312
def _check_1d (x ):
1313
1313
"""Convert scalars to 1D arrays; pass-through arrays as is."""
1314
+ if hasattr (x , 'to_numpy' ):
1315
+ # if we are given an object that creates a numpy, we should use it...
1316
+ x = x .to_numpy ()
1314
1317
if not hasattr (x , 'shape' ) or len (x .shape ) < 1 :
1315
1318
return np .atleast_1d (x )
1316
1319
else :
1317
- try :
1318
- # work around
1319
- # https://github.com/pandas-dev/pandas/issues/27775 which
1320
- # means the shape of multi-dimensional slicing is not as
1321
- # expected. That this ever worked was an unintentional
1322
- # quirk of pandas and will raise an exception in the
1323
- # future. This slicing warns in pandas >= 1.0rc0 via
1324
- # https://github.com/pandas-dev/pandas/pull/30588
1325
- #
1326
- # < 1.0rc0 : x[:, None].ndim == 1, no warning, custom type
1327
- # >= 1.0rc1 : x[:, None].ndim == 2, warns, numpy array
1328
- # future : x[:, None] -> raises
1329
- #
1330
- # This code should correctly identify and coerce to a
1331
- # numpy array all pandas versions.
1332
- with warnings .catch_warnings (record = True ) as w :
1333
- warnings .filterwarnings (
1334
- "always" ,
1335
- category = Warning ,
1336
- message = 'Support for multi-dimensional indexing' )
1337
-
1338
- ndim = x [:, None ].ndim
1339
- # we have definitely hit a pandas index or series object
1340
- # cast to a numpy array.
1341
- if len (w ) > 0 :
1342
- return np .asanyarray (x )
1343
- # We have likely hit a pandas object, or at least
1344
- # something where 2D slicing does not result in a 2D
1345
- # object.
1346
- if ndim < 2 :
1347
- return np .atleast_1d (x )
1348
- return x
1349
- # In pandas 1.1.0, multidimensional indexing leads to an
1350
- # AssertionError for some Series objects, but should be
1351
- # IndexError as described in
1352
- # https://github.com/pandas-dev/pandas/issues/35527
1353
- except (AssertionError , IndexError , TypeError ):
1354
- return np .atleast_1d (x )
1320
+ return x
1355
1321
1356
1322
1357
1323
def _reshape_2D (X , name ):
@@ -1660,7 +1626,7 @@ def index_of(y):
1660
1626
The x and y values to plot.
1661
1627
"""
1662
1628
try :
1663
- return y .index .values , y .values
1629
+ return y .index .to_numpy () , y .to_numpy ()
1664
1630
except AttributeError :
1665
1631
pass
1666
1632
try :
0 commit comments