Skip to content

Commit

Permalink
Fix issue probably-meant-fstring found at https://codereview.doctor
Browse files Browse the repository at this point in the history
  • Loading branch information
code-review-doctor committed Apr 24, 2022
1 parent 9613004 commit 932c53e
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion keras/applications/mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def MobileNet(input_shape=None,
if depth_multiplier != 1:
raise ValueError('If imagenet weights are being loaded, '
'depth multiplier must be 1. '
'Received depth_multiplier={depth_multiplier}')
f'Received depth_multiplier={depth_multiplier}')

if alpha not in [0.25, 0.50, 0.75, 1.0]:
raise ValueError('If imagenet weights are being loaded, '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def __init__(self, embed_dim, num_heads=8):
self.embed_dim = embed_dim
self.num_heads = num_heads
if embed_dim % num_heads != 0:
raise ValueError('embedding dimension = {embed_dim} should be divisible'
'by number of heads = {num_heads}')
raise ValueError(f'embedding dimension = {embed_dim} should be divisible'
f'by number of heads = {num_heads}')
self.projection_dim = embed_dim // num_heads
self.query_dense = tf.keras.layers.Dense(embed_dim)
self.key_dense = tf.keras.layers.Dense(embed_dim)
Expand Down
2 changes: 1 addition & 1 deletion keras/dtensor/layout_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __setitem__(self, key, layout):
'not use duplicated keys.')
if not isinstance(layout, dtensor.Layout):
raise ValueError(f'{layout} should be a dtensor.Layout type, '
'got {type(layout)}')
f'got {type(layout)}')

self._layout_map[key] = layout

Expand Down
2 changes: 1 addition & 1 deletion keras/dtensor/lazy_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __init__(
initial_value, "graph") and initial_value.graph.building_function:
raise ValueError(f"Argument `initial_value` ({initial_value}) could not "
"be lifted out of a `tf.function`. "
"(Tried to create variable with name='{name}'). "
f"(Tried to create variable with name='{name}'). "
"To avoid this error, when constructing `tf.Variable`s "
"inside of `tf.function` you can create the "
"`initial_value` tensor in a "
Expand Down
2 changes: 1 addition & 1 deletion keras/engine/base_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,7 @@ def _get_node_attribute_at_index(self, node_index, attr, attr_name):
"""
if not self._inbound_nodes:
raise RuntimeError(f'The layer {self.name} has never been called '
'and thus has no defined {attr_name}.')
f'and thus has no defined {attr_name}.')
if not len(self._inbound_nodes) > node_index:
raise ValueError(f'Asked to get {attr_name} at node '
f'{node_index}, but the layer has only '
Expand Down
2 changes: 1 addition & 1 deletion keras/layers/rnn/cell_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def tensor_and_const_value(v):
if const_prob < 0 or const_prob > 1:
raise ValueError(
f"Parameter {attr} must be between 0 and 1. "
"Received {const_prob}")
f"Received {const_prob}")
setattr(self, "_%s" % attr, float(const_prob))
else:
setattr(self, "_%s" % attr, tensor_prob)
Expand Down
2 changes: 1 addition & 1 deletion keras/layers/rnn/legacy_cell_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def tensor_and_const_value(v):
if const_prob < 0 or const_prob > 1:
raise ValueError(
f"Parameter {attr} must be between 0 and 1. "
"Received {const_prob}")
f"Received {const_prob}")
setattr(self, "_%s" % attr, float(const_prob))
else:
setattr(self, "_%s" % attr, tensor_prob)
Expand Down
2 changes: 1 addition & 1 deletion keras/layers/rnn/legacy_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def build(self, inputs_shape):
if inputs_shape[-1] is None:
raise ValueError(
"Expected inputs.shape[-1] to be known, "
"received shape: {inputs_shape}")
f"received shape: {inputs_shape}")
_check_supported_dtypes(self.dtype)
input_depth = inputs_shape[-1]
h_depth = self._num_units if self._num_proj is None else self._num_proj
Expand Down
2 changes: 1 addition & 1 deletion keras/optimizers/optimizer_v2/optimizer_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ def set_weights(self, weights):
params = self.weights
if len(params) != len(weights):
raise ValueError(
"You called `set_weights(weights)` on optimizer {self._name} "
f"You called `set_weights(weights)` on optimizer {self._name} "
f"with a weight list of length {str(len(weights))}, "
f"but the optimizer was expecting {str(len(params))} "
f"weights. Provided weights: {str(weights)[:50]}...")
Expand Down
2 changes: 1 addition & 1 deletion keras/saving/utils_v1/signature_def_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _supervised_signature_def(
ValueError: If inputs or outputs is `None`.
"""
if inputs is None or not inputs:
raise ValueError('f{method_name} `inputs` cannot be None or empty.')
raise ValueError(f'{method_name} `inputs` cannot be None or empty.')

signature_inputs = {key: tf.compat.v1.saved_model.build_tensor_info(tensor)
for key, tensor in inputs.items()}
Expand Down
4 changes: 2 additions & 2 deletions keras/utils/audio_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ def audio_dataset_from_directory(
if not isinstance(sampling_rate, int):
raise ValueError(
'`sampling_rate` should have an integer value. '
'Received: sampling_rate={sampling_rate}'
f'Received: sampling_rate={sampling_rate}'
)

if sampling_rate <= 0:
raise ValueError(
f'`sampling_rate` should be higher than 0. '
'Received: sampling_rate={sampling_rate}'
f'Received: sampling_rate={sampling_rate}'
)

if tfio is None:
Expand Down

0 comments on commit 932c53e

Please sign in to comment.