@@ -1445,34 +1445,52 @@ def test_is_scalar_builtin_nonscalars(self):
14451445 assert not is_scalar (slice (None ))
14461446 assert not is_scalar (Ellipsis )
14471447
1448- def test_is_scalar_numpy_array_scalars (self ):
1449- assert is_scalar (np .int64 (1 ))
1450- assert is_scalar (np .float64 (1.0 ))
1451- assert is_scalar (np .int32 (1 ))
1452- assert is_scalar (np .complex64 (2 ))
1453- assert is_scalar (np .object_ ("foobar" ))
1454- assert is_scalar (np .str_ ("foobar" ))
1455- assert is_scalar (np .unicode_ ("foobar" ))
1456- assert is_scalar (np .bytes_ (b"foobar" ))
1457- assert is_scalar (np .datetime64 ("2014-01-01" ))
1458- assert is_scalar (np .timedelta64 (1 , "h" ))
1459-
1460- def test_is_scalar_numpy_zerodim_arrays (self ):
1461- for zerodim in [
1462- np .array (1 ),
1463- np .array ("foobar" ),
1464- np .array (np .datetime64 ("2014-01-01" )),
1465- np .array (np .timedelta64 (1 , "h" )),
1466- np .array (np .datetime64 ("NaT" )),
1467- ]:
1468- assert not is_scalar (zerodim )
1469- assert is_scalar (lib .item_from_zerodim (zerodim ))
1470-
1448+ @pytest .mark .parametrize ("start" , (
1449+ np .int64 (1 ),
1450+ np .float64 (1.0 ),
1451+ np .int32 (1 ),
1452+ np .complex64 (2 ),
1453+ np .object_ ("foobar" ),
1454+ np .str_ ("foobar" ),
1455+ np .unicode_ ("foobar" ),
1456+ np .bytes_ (b"foobar" ),
1457+ np .datetime64 ("2014-01-01" ),
1458+ np .timedelta64 (1 , "h" ),
1459+ ))
1460+ @pytest .mark .parametrize ("numpy_like" , (True , False ))
1461+ def test_is_scalar_numpy_array_scalars (self , start , numpy_like ):
1462+ if numpy_like :
1463+ start = MockNumpyLikeArray (start )
1464+
1465+ assert is_scalar (start )
1466+
1467+ @pytest .mark .parametrize ("zerodim" , (
1468+ np .array (1 ),
1469+ np .array ("foobar" ),
1470+ np .array (np .datetime64 ("2014-01-01" )),
1471+ np .array (np .timedelta64 (1 , "h" )),
1472+ np .array (np .datetime64 ("NaT" )),
1473+ ))
1474+ @pytest .mark .parametrize ("numpy_like" , (True , False ))
1475+ def test_is_scalar_numpy_zerodim_arrays (self , zerodim , numpy_like ):
1476+ if numpy_like :
1477+ zerodim = MockNumpyLikeArray (zerodim )
1478+
1479+ assert not is_scalar (zerodim )
1480+ assert is_scalar (lib .item_from_zerodim (zerodim ))
1481+
1482+ @pytest .mark .parametrize ("start" , (
1483+ np .array ([]),
1484+ np .array ([[]]),
1485+ np .matrix ("1; 2" ),
1486+ ))
1487+ @pytest .mark .parametrize ("numpy_like" , (True , False ))
14711488 @pytest .mark .filterwarnings ("ignore::PendingDeprecationWarning" )
1472- def test_is_scalar_numpy_arrays (self ):
1473- assert not is_scalar (np .array ([]))
1474- assert not is_scalar (np .array ([[]]))
1475- assert not is_scalar (np .matrix ("1; 2" ))
1489+ def test_is_scalar_numpy_arrays (self , start , numpy_like ):
1490+ if numpy_like :
1491+ start = MockNumpyLikeArray (start )
1492+
1493+ assert not is_scalar (start )
14761494
14771495 def test_is_scalar_pandas_scalars (self ):
14781496 assert is_scalar (Timestamp ("2014-01-01" ))
0 commit comments