@@ -147,9 +147,12 @@ def test_can_cast(_from, to):
147
147
assert out == expected , f"{ out = } , but should be { expected } { f_func } "
148
148
149
149
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
+
153
156
f_func = f"[finfo({ dh .dtype_to_name [dtype ]} )]"
154
157
for attr , stype in [
155
158
("bits" , int ),
@@ -164,12 +167,30 @@ def test_finfo(dtype):
164
167
value , stype
165
168
), f"type(out.{ attr } )={ type (value )!r} , but should be { stype .__name__ } { f_func } "
166
169
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
168
186
169
187
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
+
173
194
f_func = f"[iinfo({ dh .dtype_to_name [dtype ]} )]"
174
195
for attr in ["bits" , "max" , "min" ]:
175
196
assert hasattr (out , attr ), f"out has no attribute '{ attr } ' { f_func } "
@@ -178,7 +199,14 @@ def test_iinfo(dtype):
178
199
value , int
179
200
), f"type(out.{ attr } )={ type (value )!r} , but should be int { f_func } "
180
201
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
182
210
183
211
184
212
def atomic_kinds () -> st .SearchStrategy [Union [DataType , str ]]:
0 commit comments