Skip to content

Commit 7a7934c

Browse files
committed
Remove duplicated code
1 parent c3501e8 commit 7a7934c

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/array_api_extra/_delegation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def quantile(
256256
/,
257257
*,
258258
axis: int | None = None,
259-
keepdims: bool = False,
259+
keepdims: bool = None, # noqa: RUF013
260260
method: str = "linear",
261261
xp: ModuleType | None = None,
262262
) -> Array:
@@ -304,7 +304,7 @@ def quantile(
304304
"""
305305
# We only support a subset of the methods supported by scipy.stats.quantile.
306306
# So we need to perform the validation here.
307-
methods = { # pylint: disable=duplicate-code
307+
methods = {
308308
"inverted_cdf",
309309
"averaged_inverted_cdf",
310310
"closest_observation",

src/array_api_extra/_lib/_quantile.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def quantile(
1414
/,
1515
*,
1616
axis: int | None = None,
17-
keepdims: bool = False,
17+
keepdims: bool = None, # noqa: RUF013
1818
method: str = "linear",
1919
xp: ModuleType | None = None,
2020
) -> Array: # numpydoc ignore=PR01,RT01
@@ -68,20 +68,7 @@ def quantile(
6868

6969
n = xp.asarray(y.shape[-1], dtype=dtype, device=_compat.device(y))
7070

71-
if method in { # pylint: disable=duplicate-code
72-
"inverted_cdf",
73-
"averaged_inverted_cdf",
74-
"closest_observation",
75-
"hazen",
76-
"interpolated_inverted_cdf",
77-
"linear",
78-
"median_unbiased",
79-
"normal_unbiased",
80-
"weibull",
81-
}:
82-
res = _quantile_hf(y, q, n, method, xp)
83-
else:
84-
raise ValueError(f"Unknown method: {method}") # noqa: EM102
71+
res = _quantile_hf(y, q, n, method, xp)
8572

8673
# Handle NaN output for invalid q values
8774
p_mask = (q > 1) | (q < 0) | xp.isnan(q)

0 commit comments

Comments
 (0)