Skip to content

Commit

Permalink
Remove a few more uses of .format
Browse files Browse the repository at this point in the history
  • Loading branch information
Armavica authored and ricardoV94 committed May 28, 2024
1 parent 3b3be49 commit 41b94e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
14 changes: 4 additions & 10 deletions pymc/distributions/shape_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,8 @@ def broadcast_dist_samples_shape(shapes, size=None):
if size is None:
broadcasted_shape = np.broadcast_shapes(*shapes)
if broadcasted_shape is None:
raise ValueError(
"Cannot broadcast provided shapes {} given size: {}".format(
", ".join([f"{s}" for s in shapes]), size
)
)
tmp = ", ".join([f"{s}" for s in shapes])
raise ValueError(f"Cannot broadcast provided shapes {tmp} given size: {size}")
return broadcasted_shape
shapes = [_check_shape_type(s) for s in shapes]
_size = to_tuple(size)
Expand All @@ -154,11 +151,8 @@ def broadcast_dist_samples_shape(shapes, size=None):
try:
broadcast_shape = np.broadcast_shapes(*sp_shapes)
except ValueError:
raise ValueError(
"Cannot broadcast provided shapes {} given size: {}".format(
", ".join([f"{s}" for s in shapes]), size
)
)
tmp = ", ".join([f"{s}" for s in shapes])
raise ValueError(f"Cannot broadcast provided shapes {tmp} given size: {size}")
broadcastable_shapes = []
for shape, sp_shape in zip(shapes, sp_shapes):
if _size == shape[: len(_size)]:
Expand Down
5 changes: 2 additions & 3 deletions pymc/gp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ def getter(self):
value = getattr(self, name, None)
if value is None:
raise AttributeError(
"'{}' not set. Provide as argument "
"to condition, or call 'prior' "
"first".format(name.lstrip("_"))
f"'{name.lstrip('_')}' not set. Provide as argument "
"to condition, or call 'prior' first"
)
else:
return value
Expand Down
12 changes: 6 additions & 6 deletions pymc/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ def str_for_dist(
else r"\\operatorname{Unknown}"
)
if include_params:
params = ",~".join([d.strip("$") for d in dist_args])
if print_name:
return r"${} \sim {}({})$".format(
print_name, op_name, ",~".join([d.strip("$") for d in dist_args])
)
return rf"${print_name} \sim {op_name}({params})$"
else:
return r"${}({})$".format(op_name, ",~".join([d.strip("$") for d in dist_args]))
return rf"${op_name}({params})$"

else:
if print_name:
Expand All @@ -83,10 +82,11 @@ def str_for_dist(
dist.owner.op._print_name[0] if hasattr(dist.owner.op, "_print_name") else "Unknown"
)
if include_params:
params = ", ".join(dist_args)
if print_name:
return r"{} ~ {}({})".format(print_name, dist_name, ", ".join(dist_args))
return rf"{print_name} ~ {dist_name}({params})"
else:
return r"{}({})".format(dist_name, ", ".join(dist_args))
return rf"{dist_name}({params})"
else:
if print_name:
return rf"{print_name} ~ {dist_name}"
Expand Down

0 comments on commit 41b94e2

Please sign in to comment.