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