66from numpy ._core .numerictypes import (
77 issctype , sctype2char , maximum_sctype , sctypes
88)
9- from numpy .testing import assert_ , assert_equal , assert_raises , IS_PYPY
9+ from numpy .testing import (
10+ assert_ , assert_equal , assert_raises , assert_raises_regex , IS_PYPY
11+ )
1012
1113# This is the structure of the table used for plain objects:
1214#
@@ -416,20 +418,6 @@ def test_nondtype_nonscalartype(self):
416418 assert np .issubdtype (np .float32 , "f" )
417419
418420
419- @pytest .mark .parametrize (
420- "dtype,close_dtype" ,
421- [
422- (np .int64 , np .int32 ), (np .uint64 , np .uint32 ),
423- (np .float64 , np .float32 ), (np .complex128 , np .complex64 )
424- ]
425- )
426- @pytest .mark .parametrize (
427- "dtype_group" ,
428- [
429- None , "signed integer" , "unsigned integer" , "integral" ,
430- "real floating" , "complex floating" , "numeric"
431- ]
432- )
433421class TestIsDType :
434422 """
435423 Check correctness of `np.isdtype`. The test considers different argument
@@ -448,6 +436,20 @@ class TestIsDType:
448436 )
449437 }
450438
439+ @pytest .mark .parametrize (
440+ "dtype,close_dtype" ,
441+ [
442+ (np .int64 , np .int32 ), (np .uint64 , np .uint32 ),
443+ (np .float64 , np .float32 ), (np .complex128 , np .complex64 )
444+ ]
445+ )
446+ @pytest .mark .parametrize (
447+ "dtype_group" ,
448+ [
449+ None , "signed integer" , "unsigned integer" , "integral" ,
450+ "real floating" , "complex floating" , "numeric"
451+ ]
452+ )
451453 def test_isdtype (self , dtype , close_dtype , dtype_group ):
452454 # First check if same dtypes return `true` and different ones
453455 # give `false` (even if they're close in the dtype hierarchy!)
@@ -464,6 +466,12 @@ def test_isdtype(self, dtype, close_dtype, dtype_group):
464466 else :
465467 assert not np .isdtype (dtype , dtype_group )
466468
469+ def test_isdtype_invalid_args (self ):
470+ with assert_raises_regex (TypeError , r".*must be a dtype.*" ):
471+ np .isdtype ("int64" , np .int64 )
472+ with assert_raises_regex (TypeError , r".*kind argument must.*" ):
473+ np .isdtype (np .int64 , "int64" )
474+
467475
468476class TestSctypeDict :
469477 def test_longdouble (self ):
0 commit comments