@@ -147,9 +147,12 @@ def test_can_cast(_from, to):
147147 assert out == expected , f"{ out = } , but should be { expected } { f_func } "
148148
149149
150- @pytest .mark .parametrize ("dtype" , dh .real_float_dtypes )
151- def test_finfo (dtype ):
152- out = xp .finfo (dtype )
150+ @pytest .mark .parametrize ("arg_type" , ["dtype" , "array" ])
151+ @pytest .mark .parametrize ("dtype" , dh .real_float_dtypes + dh .complex_dtypes )
152+ def test_finfo (dtype , arg_type ):
153+ arg = xp .asarray (1 , dtype = dtype ) if arg_type == "array" else dtype
154+ out = xp .finfo (arg )
155+
153156 f_func = f"[finfo({ dh .dtype_to_name [dtype ]} )]"
154157 for attr , stype in [
155158 ("bits" , int ),
@@ -164,12 +167,30 @@ def test_finfo(dtype):
164167 value , stype
165168 ), f"type(out.{ attr } )={ type (value )!r} , but should be { stype .__name__ } { f_func } "
166169 assert hasattr (out , "dtype" ), f"out has no attribute 'dtype' { f_func } "
167- # TODO: test values
170+
171+ assert isinstance (out .bits , int )
172+ assert isinstance (out .eps , float )
173+ assert isinstance (out .max , float )
174+ assert isinstance (out .min , float )
175+ assert isinstance (out .smallest_normal , float )
176+ if dtype == xp .complex64 :
177+ assert out .dtype == xp .float32
178+ elif dtype == xp .complex128 :
179+ assert out .dtype == xp .float64
180+ else :
181+ assert out .dtype == dtype
182+ # Guard vs. numpy.dtype.__eq__ lax comparison
183+ assert not isinstance (out .dtype , str )
184+ assert out .dtype is not float
185+ assert out .dtype is not complex
168186
169187
170- @pytest .mark .parametrize ("dtype" , dh .int_dtypes )
171- def test_iinfo (dtype ):
172- out = xp .iinfo (dtype )
188+ @pytest .mark .parametrize ("arg_type" , ["dtype" , "array" ])
189+ @pytest .mark .parametrize ("dtype" , dh .int_dtypes + dh .uint_dtypes )
190+ def test_iinfo (dtype , arg_type ):
191+ arg = xp .asarray (1 , dtype = dtype ) if arg_type == "array" else dtype
192+ out = xp .iinfo (arg )
193+
173194 f_func = f"[iinfo({ dh .dtype_to_name [dtype ]} )]"
174195 for attr in ["bits" , "max" , "min" ]:
175196 assert hasattr (out , attr ), f"out has no attribute '{ attr } ' { f_func } "
@@ -178,7 +199,14 @@ def test_iinfo(dtype):
178199 value , int
179200 ), f"type(out.{ attr } )={ type (value )!r} , but should be int { f_func } "
180201 assert hasattr (out , "dtype" ), f"out has no attribute 'dtype' { f_func } "
181- # TODO: test values
202+
203+ assert isinstance (out .bits , int )
204+ assert isinstance (out .max , int )
205+ assert isinstance (out .min , int )
206+ assert out .dtype == dtype
207+ # Guard vs. numpy.dtype.__eq__ lax comparison
208+ assert not isinstance (out .dtype , str )
209+ assert out .dtype is not int
182210
183211
184212def atomic_kinds () -> st .SearchStrategy [Union [DataType , str ]]:
0 commit comments