File tree 2 files changed +10
-5
lines changed
2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 3
3
import warnings
4
4
5
5
from ._lib import _compat , _utils
6
- from ._lib ._compat import (
7
- array_namespace ,
8
- )
6
+ from ._lib ._compat import array_namespace
9
7
from ._lib ._typing import Array , ModuleType
10
8
11
9
__all__ = [
@@ -561,7 +559,8 @@ def pad(
561
559
pad_width : int
562
560
Pad the input array with this many elements from each side.
563
561
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`.
565
564
xp : array_namespace, optional
566
565
The standard-compatible namespace for `x`. Default: infer.
567
566
constant_values : python scalar, optional
@@ -574,7 +573,8 @@ def pad(
574
573
padded with ``pad_width`` elements equal to ``constant_values``.
575
574
"""
576
575
if mode != "constant" :
577
- raise NotImplementedError ()
576
+ msg = "Only `'constant'` mode is currently supported"
577
+ raise NotImplementedError (msg )
578
578
579
579
value = constant_values
580
580
Original file line number Diff line number Diff line change @@ -403,3 +403,8 @@ def test_ndim(self):
403
403
a = xp .reshape (xp .arange (2 * 3 * 4 ), (2 , 3 , 4 ))
404
404
padded = pad (a , 2 )
405
405
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" )
You can’t perform that action at this time.
0 commit comments