Skip to content

Commit

Permalink
f-strings
Browse files Browse the repository at this point in the history
Co-authored-by: Connor Ward <[email protected]>
  • Loading branch information
JHopeCollins and connorjward authored Dec 3, 2024
1 parent a2a9448 commit fdf6dc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions firedrake/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ def _components(self):
return tuple((self, ))
else:
if self.dof_dset.cdim == 1:
return tuple((CoordinatelessFunction(self.function_space().sub(0), val=self.dat,
name="view[%d](%s)" % (0, self.name())),))
return (CoordinatelessFunction(self.function_space().sub(0), val=self.dat,
name=f"view[0]({self.name()})"),)
else:
return tuple(CoordinatelessFunction(self.function_space().sub(i), val=op2.DatView(self.dat, j),
name="view[%d](%s)" % (i, self.name()))
name=f"view[{i}]({self.name()})")
for i, j in enumerate(np.ndindex(self.dof_dset.dim)))

@PETSc.Log.EventDecorator()
Expand All @@ -151,7 +151,7 @@ def sub(self, i):
data = self.subfunctions if mixed else self._components
bound = len(data)
if i < 0 or i >= bound:
raise IndexError("Invalid component %d, not in [0, %d)" % (i, bound))
raise IndexError(f"Invalid component {i}, not in [0, {bound})")
return data[i]

@property
Expand Down Expand Up @@ -356,7 +356,7 @@ def sub(self, i):
data = self.subfunctions if mixed else self._components
bound = len(data)
if i < 0 or i >= bound:
raise IndexError("Invalid component %d, not in [0, %d)" % (i, bound))
raise IndexError(f"Invalid component {i}, not in [0, {bound})")
return data[i]

@PETSc.Log.EventDecorator()
Expand Down
6 changes: 3 additions & 3 deletions firedrake/functionspaceimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def sub(self, i):
data = self.subfunctions if mixed else self._components
bound = len(data)
if i < 0 or i >= bound:
raise IndexError("Invalid component %d, not in [0, %d)" % (i, bound))
raise IndexError(f"Invalid component {i}, not in [0, {bound})")
return data[i]

@utils.cached_property
Expand Down Expand Up @@ -641,7 +641,7 @@ def __str__(self):
@utils.cached_property
def subfunctions(self):
r"""Split into a tuple of constituent spaces."""
return tuple((self, ))
return (self, )

def split(self):
import warnings
Expand All @@ -665,7 +665,7 @@ def sub(self, i):
r"""Return a view into the ith component."""
bound = len(self._components)
if i < 0 or i >= bound:
raise IndexError("Invalid component %d, not in [0, %d)" % (i, bound))
raise IndexError(f"Invalid component {i}, not in [0, {bound})")
return self._components[i]

def __mul__(self, other):
Expand Down

0 comments on commit fdf6dc4

Please sign in to comment.