Skip to content

Commit 907b73c

Browse files
committed
MAIN: Enforce ruff E501 rule
1 parent bb9a48c commit 907b73c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

numpy/_core/tests/test_multithreading.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,15 @@ def closure(b):
272272
def test_nonzero(dtype):
273273
# See: gh-28361
274274
#
275-
# np.nonzero uses np.count_nonzero to determine the size of the output array
276-
# In a second pass the indices of the non-zero elements are determined, but they can have changed
275+
# np.nonzero uses np.count_nonzero to determine the size of the output.
276+
# array. In a second pass the indices of the non-zero elements are
277+
# determined, but they can have changed
277278
#
278-
# This test triggers a data race which is suppressed in the TSAN CI. The test is to ensure
279-
# np.nonzero does not generate a segmentation fault
279+
# This test triggers a data race which is suppressed in the TSAN CI.
280+
# The test is to ensure np.nonzero does not generate a segmentation fault
280281
x = np.random.randint(4, size=100).astype(dtype)
282+
expected_warning = ('number of non-zero array elements changed'
283+
' during function execution')
281284

282285
def func(index):
283286
for _ in range(10):
@@ -287,6 +290,6 @@ def func(index):
287290
try:
288291
_ = np.nonzero(x)
289292
except RuntimeError as ex:
290-
assert 'number of non-zero array elements changed during function execution' in str(ex)
293+
assert expected_warning in str(ex)
291294

292295
run_threaded(func, max_workers=10, pass_count=True, outer_iterations=5)

ruff.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ ignore = [
8181
"numpy/_core/tests/test_defchararray.py" = ["E501"]
8282
"numpy/_core/tests/test_einsum.py" = ["E501"]
8383
"numpy/_core/tests/test_multiarray.py" = ["E501"]
84-
"numpy/_core/tests/test_multithreading.py" = ["E501"]
8584
"numpy/_core/tests/test_nditer*py" = ["E501"]
8685
"numpy/_core/tests/test_ufunc*py" = ["E501"]
8786
"numpy/_core/tests/test_umath*py" = ["E501"]

0 commit comments

Comments
 (0)