Skip to content

Commit faaa2b6

Browse files
committed
tweaks
1 parent 5aac0b4 commit faaa2b6

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/array_api_extra/_funcs.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import warnings
44

55
from ._lib import _compat, _utils
6-
from ._lib._compat import (
7-
array_namespace,
8-
)
6+
from ._lib._compat import array_namespace
97
from ._lib._typing import Array, ModuleType
108

119
__all__ = [
@@ -561,7 +559,8 @@ def pad(
561559
pad_width : int
562560
Pad the input array with this many elements from each side.
563561
mode : str, optional
564-
Only "constant" mode is currently supported.
562+
Only "constant" mode is currently supported, which pads with
563+
the value passed to `constant_values`.
565564
xp : array_namespace, optional
566565
The standard-compatible namespace for `x`. Default: infer.
567566
constant_values : python scalar, optional
@@ -574,7 +573,8 @@ def pad(
574573
padded with ``pad_width`` elements equal to ``constant_values``.
575574
"""
576575
if mode != "constant":
577-
raise NotImplementedError()
576+
msg = "Only `'constant'` mode is currently supported"
577+
raise NotImplementedError(msg)
578578

579579
value = constant_values
580580

tests/test_funcs.py

+5
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,8 @@ def test_ndim(self):
403403
a = xp.reshape(xp.arange(2 * 3 * 4), (2, 3, 4))
404404
padded = pad(a, 2)
405405
assert padded.shape == (6, 7, 8)
406+
407+
def test_mode_not_implemented(self):
408+
a = xp.arange(3)
409+
with pytest.raises(NotImplementedError, match="Only `'constant'`"):
410+
pad(a, 2, mode="edge")

0 commit comments

Comments
 (0)