8000 review comments · numpy/numpy@f9baafb · GitHub
[go: up one dir, main page]

Skip to content

Commit f9baafb

Browse files
committed
review comments
1 parent 9ea773d commit f9baafb

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

numpy/_core/tests/test_indexing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,8 @@ def test_boolean_indexing_fast_path(self):
13521352
"size of axis is 3 but size of corresponding boolean axis is 1",
13531353
lambda: a[idx1])
13541354

1355-
# This used to incorrectly give a ValueError: operands could not be broadcast together # noqa: E501
1355+
# This used to incorrectly give a ValueError: operands could not be
1356+
# broadcast together
13561357
idx2 = np.array([[False] * 8 + [True]])
13571358
assert_raises_regex(IndexError,
13581359
"boolean index did not match indexed array along axis 0; "

numpy/_core/tests/test_mem_overlap.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ def check_may_share_memory_exact(a, b):
165165

166166
err_msg = ""
167167
if got != exact:
168+
base_delta = a.__array_interface__['data'][0] - b.__array_interface__['data'][0]
168169
err_msg = " " + "\n ".join([
169-
f"base_a - base_b = {a.__array_interface__['data'][0] - b.__array_interface__['data'][0]!r}", # noqa: E501
170+
f"base_a - base_b = {base_delta!r}",
170171
f"shape_a = {a.shape!r}",
171172
f"shape_b = {b.shape!r}",
172173
f"strides_a = {a.strides!r}",
@@ -402,7 +403,9 @@ def check(A, U, exists=None):
402403
exists = (X is not None)
403404

404405
if X is not None:
405-
assert_(sum(a * x for a, x in zip(A, X)) == sum(a * u // 2 for a, u in zip(A, U))) # noqa: E501
406+
sum_ax = sum(a * x for a, x in zip(A, X))
407+
sum_au_half = sum(a * u // 2 for a, u in zip(A, U))
408+
assert_(sum_ax == sum_au_half)
406409
assert_(all(0 <= x <= u for x, u in zip(X, U)))
407410
assert_(any(x != u // 2 for x, u in zip(X, U)))
408411

numpy/_typing/_dtype_like.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def dtype(self) -> _DTypeT_co: ...
5555

5656

5757
# A subset of `npt.DTypeLike` that can be parametrized w.r.t. `np.generic`
58-
_DTypeLike: TypeAlias = type[_ScalarT] | np.dtype[_ScalarT] | _SupportsDType[np.dtype[_ScalarT]] # noqa: E501
58+
_DTypeLike: TypeAlias = type[_ScalarT] | np.dtype[_ScalarT] | _SupportsDType[np.dtype[_ScalarT]]
5959

6060

6161
# Would create a dtype[np.void]

numpy/lib/tests/test_histograms.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ def test_outlier(self):
554554
assert_equal(len(a), numbins)
555555

556556
def test_scott_vs_stone(self):
557-
"""Verify that Scott's rule and Stone's rule converges for normally distributed data""" # noqa: E501
557+
# Verify that Scott's rule and Stone's rule converges for normally
558+
# distributed data
558559

559560
def nbins_ratio(seed, size):
560561
rng = np.random.RandomState(seed)
@@ -565,7 +566,8 @@ def nbins_ratio(seed, size):
565566
geom_space = np.geomspace(start=10, stop=100, num=4).round().astype(int)
566567
ll = [[nbins_ratio(seed, size) for size in geom_space] for seed in range(10)]
567568

568-
# the average difference between the two methods decreases as the dataset size increases. # noqa: E501
569+
# the average difference between the two methods decreases as the dataset
570+
# size increases.
569571 avg = abs(np.mean(ll, axis=0) - 0.5)
570572
assert_almost_equal(avg, [0.15, 0.09, 0.08, 0.03], decimal=2)
571573

ruff.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ ignore = [
6868
"_tempita.py" = ["B909"]
6969
"bench_*.py" = ["B015", "B018"]
7070
"test*.py" = ["B015", "B018", "E201", "E714"]
71+
7172
"benchmarks/benchmarks/bench_linalg.py" = ["E501"]
7273
"numpy/_core/tests/test_api.py" = ["E501"]
7374
"numpy/_core/tests/test_arrayprint.py" = ["E501"]
@@ -90,15 +91,18 @@ ignore = [
9091
"numpy/_core/_add_newdocs.py" = ["E501"]
9192
"numpy/_core/_add_newdocs_scalars.py" = ["E501"]
9293
"numpy/_core/code_generators/generate_umath.py" = ["E501"]
93-
"numpy/_typing/_array_like.py" = ["E501"]
9494
"numpy/lib/tests/test_function_base.py" = ["E501"]
9595
"numpy/lib/tests/test_format.py" = ["E501"]
9696
"numpy/lib/tests/test_io.py" = ["E501"]
9797
"numpy/lib/tests/test_polynomial.py" = ["E501"]
9898
"numpy/linalg/tests/test_linalg.py" = ["E501"]
9999
"numpy/tests/test_configtool.py" = ["E501"]
100-
"numpy*pyi" = ["E501"]
101100
"numpy/f2py/*py" = ["E501"]
101+
# for typing related files we follow https://typing.python.org/en/latest/guides/writing_stubs.html#maximum-line-length
102+
"numpy/_typing/_array_like.py" = ["E501"]
103+
"numpy/_typing/_dtype_like.py" = ["E501"]
104+
"numpy*pyi" = ["E501"]
105+
102106
"__init__.py" = ["F401", "F403", "F405"]
103107
"__init__.pyi" = ["F401"]
104108
"numpy/_core/defchararray.py" = ["F403", "F405"]

0 commit comments

Comments
 (0)
0