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