Skip to content

Commit

Permalink
Small nits
Browse files Browse the repository at this point in the history
  • Loading branch information
fchollet committed Nov 24, 2023
1 parent b4c3a0e commit 9620d23
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
6 changes: 3 additions & 3 deletions keras/backend/jax/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@ def pad(x, pad_width, mode="constant", constant_values=None):
if constant_values is not None:
if mode != "constant":
raise ValueError(
"Argument 'constant_values' can only be "
"provided when mode == 'constant'. "
f"Received mode '{mode}'"
"Argument `constant_values` can only be "
"provided when `mode == 'constant'`. "
f"Received: mode={mode}"
)
kwargs["constant_values"] = constant_values
return jnp.pad(x, pad_width, mode=mode, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions keras/backend/numpy/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,9 @@ def pad(x, pad_width, mode="constant", constant_values=None):
if constant_values is not None:
if mode != "constant":
raise ValueError(
"Argument 'constant_values' can only be "
"provided when mode == 'constant'. "
f"Received mode '{mode}'"
"Argument `constant_values` can only be "
"provided when `mode == 'constant'`. "
f"Received: mode={mode}"
)
kwargs["constant_values"] = constant_values
return np.pad(x, pad_width, mode=mode, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions keras/backend/tensorflow/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,9 +1065,9 @@ def pad(x, pad_width, mode="constant", constant_values=None):
if constant_values is not None:
if mode != "constant":
raise ValueError(
"Argument 'constant_values' can only be "
"provided when mode == 'constant'. "
f"Received mode '{mode}'"
"Argument `constant_values` can only be "
"provided when `mode == 'constant'`. "
f"Received: mode={mode}"
)
kwargs["constant_values"] = constant_values
return tfnp.pad(x, pad_width, mode=mode, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions keras/backend/torch/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,9 @@ def pad(x, pad_width, mode="constant", constant_values=None):
if constant_values is not None:
if mode != "constant":
raise ValueError(
"Argument 'constant_values' can only be "
"provided when mode == 'constant'. "
f"Received mode '{mode}'"
"Argument `constant_values` can only be "
"provided when `mode == 'constant'`. "
f"Received: mode={mode}"
)
kwargs["value"] = constant_values
x = convert_to_tensor(x)
Expand Down
10 changes: 6 additions & 4 deletions keras/ops/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4190,8 +4190,8 @@ def _process_pad_width(self, pad_width):
for i, pw in enumerate(pad_width):
if len(pw) != first_len:
raise ValueError(
"`pad_width` should be a list of tuples of length 2 or "
f"1, but received {pad_width}."
"`pad_width` should be a list of tuples of length "
f"1 or 2. Received: pad_width={pad_width}"
)
if len(pw) == 1:
pad_width[i] = (pw[0], pw[0])
Expand All @@ -4213,8 +4213,10 @@ def compute_output_spec(self, x, constant_values=None):
pad_width = self.pad_width
else:
raise ValueError(
"`pad_width` must have the same length as `x.shape`, but "
f"received {len(self.pad_width)} and {len(x.shape)}."
"`pad_width` must have the same length as `x.shape`. "
f"Received: pad_width={self.pad_width} "
f"(of length {len(self.pad_width)}) and x.shape={x.shape} "
f"(of length {len(x.shape)})"
)

for i in range(len(output_shape)):
Expand Down
4 changes: 2 additions & 2 deletions keras/ops/numpy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3553,8 +3553,8 @@ def test_pad(self, dtype, mode, constant_values):
if constant_values is not None:
with self.assertRaisesRegex(
ValueError,
"Argument 'constant_values' can only be "
"provided when mode == 'constant'",
"Argument `constant_values` can only be "
"provided when `mode == 'constant'`",
):
knp.pad(
x, pad_width, mode=mode, constant_values=constant_values
Expand Down

0 comments on commit 9620d23

Please sign in to comment.