Skip to content

Commit 470f8b4

Browse files
committed
Remove unsupported method
We can add it back later if we need it
1 parent 98570f6 commit 470f8b4

2 files changed

Lines changed: 18 additions & 28 deletions

File tree

src/array_api_extra/_delegation.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def quantile(
281281
The method to use for estimating the quantile. The available options are:
282282
'inverted_cdf', 'averaged_inverted_cdf', 'closest_observation',
283283
'interpolated_inverted_cdf', 'hazen', 'weibull', 'linear' (default),
284-
'median_unbiased', 'normal_unbiased', 'harrell-davis'.
284+
'median_unbiased', 'normal_unbiased'.
285285
xp : array_namespace, optional
286286
The standard-compatible namespace for `x` and `q`. Default: infer.
287287
@@ -301,6 +301,22 @@ def quantile(
301301
Array([[5., 8.],
302302
[1., 3.]], dtype=array_api_strict.float64)
303303
"""
304+
# We only support a subset of the methods supported by scipy.stats.quantile.
305+
# So we need to perform the validation here.
306+
methods = {
307+
"inverted_cdf",
308+
"averaged_inverted_cdf",
309+
"closest_observation",
310+
"hazen",
311+
"interpolated_inverted_cdf",
312+
"linear",
313+
"median_unbiased",
314+
"normal_unbiased",
315+
"weibull",
316+
}
317+
if method not in methods:
318+
raise ValueError(f"`method` must be one of {methods}") # noqa: EM102
319+
304320
xp = array_namespace(x, q) if xp is None else xp
305321

306322
try:

src/array_api_extra/_lib/_funcs.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,21 +1034,6 @@ def quantile(
10341034
else:
10351035
axis = int(axis)
10361036

1037-
methods = {
1038-
"inverted_cdf",
1039-
"averaged_inverted_cdf",
1040-
"closest_observation",
1041-
"hazen",
1042-
"interpolated_inverted_cdf",
1043-
"linear",
1044-
"median_unbiased",
1045-
"normal_unbiased",
1046-
"weibull",
1047-
"harrell-davis",
1048-
}
1049-
if method not in methods:
1050-
raise ValueError(f"`method` must be one of {methods}") # noqa: EM102
1051-
10521037
if keepdims not in {None, True, False}:
10531038
raise ValueError("If specified, `keepdims` must be True or False.") # noqa: EM101
10541039

@@ -1078,8 +1063,6 @@ def quantile(
10781063
"weibull",
10791064
}:
10801065
res = _quantile_hf(y, q, n, method, xp)
1081-
elif method == "harrell-davis":
1082-
res = _quantile_hd(y, q, n, xp)
10831066
else:
10841067
raise ValueError(f"Unknown method: {method}") # noqa: EM102
10851068

@@ -1112,7 +1095,7 @@ def quantile(
11121095
def _quantile_hf(
11131096
y: Array, p: Array, n: Array, method: str, xp: ModuleType
11141097
) -> Array: # numpydoc ignore=PR01,RT01
1115-
"""Helper function for Hyndman-Fan quantile methods."""
1098+
"""Helper function for Hyndman-Fan quantile method."""
11161099
ms = {
11171100
"inverted_cdf": 0,
11181101
"averaged_inverted_cdf": 0,
@@ -1154,12 +1137,3 @@ def _quantile_hf(
11541137
return (1 - g) * xp.take_along_axis(y, j, axis=-1) + g * xp.take_along_axis(
11551138
y, jp1, axis=-1
11561139
)
1157-
1158-
1159-
def _quantile_hd(
1160-
y: Array, p: Array, n: Array, xp: ModuleType
1161-
) -> Array: # numpydoc ignore=PR01,RT01
1162-
"""Helper function for Harrell-Davis quantile method."""
1163-
# For now, implement a simplified version that falls back to linear method
1164-
# since betainc is not available in the array API standard
1165-
return _quantile_hf(y, p, n, "linear", xp)

0 commit comments

Comments
 (0)