Skip to content

Commit 1ef7d5e

Browse files
authored
improve style
1 parent bd55318 commit 1ef7d5e

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/array_api_extra/_delegation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ def quantile(
320320
"weibull",
321321
}
322322
if method not in methods:
323-
raise ValueError(f"`method` must be one of {methods}") # noqa: EM102
323+
msg = f"`method` must be one of {methods}"
324+
raise ValueError(msg)
324325

325326
xp = array_namespace(x, q) if xp is None else xp
326327

src/array_api_extra/_lib/_quantile.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ def quantile(
2929
q_arr = cast(Array, q)
3030

3131
if not xp.isdtype(x.dtype, ("integral", "real floating")):
32-
raise ValueError("`x` must have real dtype.") # noqa: EM101
32+
msg = "`x` must have real dtype."
33+
raise ValueError(msg)
3334
if not xp.isdtype(q_arr.dtype, "real floating"):
34-
raise ValueError("`q` must have real floating dtype.") # noqa: EM101
35+
msg = "`q` must have real floating dtype."
36+
raise ValueError(msg)
3537

3638
# Promote to common dtype
3739
x = xp.astype(x, xp.float64)
@@ -47,14 +49,17 @@ def quantile(
4749
q_arr = xp.reshape(q_arr, (-1,))
4850
axis = 0
4951
elif not isinstance(axis, int): # pyright: ignore[reportUnnecessaryIsInstance]
50-
raise ValueError("`axis` must be an integer or None.") # noqa: EM101
52+
msg = "`axis` must be an integer or None."
53+
raise ValueError(msg)
5154
elif axis >= ndim or axis < -ndim:
52-
raise ValueError("`axis` is not compatible with the shapes of the inputs.") # noqa: EM101
55+
msg = "`axis` is not compatible with the shapes of the inputs."
56+
raise ValueError(msg)
5357
else:
5458
axis = int(axis)
5559

5660
if keepdims not in {None, True, False}:
57-
raise ValueError("If specified, `keepdims` must be True or False.") # noqa: EM101
61+
msg = "If specified, `keepdims` must be True or False."
62+
raise ValueError(msg)
5863

5964
if x.shape[axis] == 0:
6065
shape = list(x.shape)
@@ -135,7 +140,7 @@ def _quantile_hf(
135140
# Broadcast indices to match y shape except for the last axis
136141
if y.ndim > 1:
137142
# Create broadcast shape for indices
138-
broadcast_shape = list(y.shape[:-1]) + [1] # noqa: RUF005
143+
broadcast_shape = list(y.shape[:-1]).append(1)
139144
j = xp.broadcast_to(j, broadcast_shape)
140145
jp1 = xp.broadcast_to(jp1, broadcast_shape)
141146
g = xp.broadcast_to(g, broadcast_shape)

0 commit comments

Comments
 (0)