10000 Avoid using getattr · scikit-learn/scikit-learn@021e07b · GitHub
[go: up one dir, main page]

Skip to content

Commit 021e07b

Browse files
committed
Avoid using getattr
1 parent 5074d55 commit 021e07b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sklearn/utils/tests/test_array_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def test_average(
187187
if np_version < parse_version("2.0.0") or np_version >= parse_version("2.1.0"):
188188
# NumPy 2.0 has a problem with the device attribute of scalar arrays:
189189
# https://github.com/numpy/numpy/issues/26850
190-
assert getattr(array_in, "device", None) == getattr(result, "device", None)
190+
assert device(array_in) == device(result)
191191

192192
result = _convert_to_numpy(result, xp)
193193
assert_allclose(result, expected, atol=_atol_for_type(dtype_name))
@@ -623,4 +623,4 @@ def test_count_nonzero(
623623
if np_version < parse_version("2.0.0") or np_version >= parse_version("2.1.0"):
624624
# NumPy 2.0 has a problem with the device attribute of scalar arrays:
625625
# https://github.com/numpy/numpy/issues/26850
626-
assert getattr(array_xp, "device", None) == getattr(result, "device", None)
626+
assert device(array_xp) == device(result)

0 commit comments

Comments
 (0)
0