Skip to content

Commit

Permalink
style: apply ruff f-string rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ljgray committed May 1, 2024
1 parent 89bb7ea commit 3a059dc
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion draco/analysis/dayenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def setup(self, telescope):
"""
self.telescope = io.get_telescope(telescope)

self.log.info("Instrumental delay cut set to %0.3f micro-sec." % self.tauw)
self.log.info(f"Instrumental delay cut set to {self.tauw:.3f} micro-sec.")

if self.atten_threshold > 0.0:
self.log.info(
Expand Down
2 changes: 1 addition & 1 deletion draco/analysis/powerspectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def process(self, klmodes):
if not isinstance(klmodes, containers.KLModes):
raise ValueError(
"Input container must be instance of "
"KLModes (received %s)" % klmodes.__class__
f"KLModes (received {klmodes.__class__!s})"
)

klmodes.redistribute("m")
Expand Down
2 changes: 1 addition & 1 deletion draco/analysis/sidereal.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def process(self, sdata):
self.sum_coeff_sq = np.zeros_like(self.stack.weight[:].view(np.ndarray))

# Accumulate
self.log.info("Adding to stack LSD(s): %s" % input_lsd)
self.log.info(f"Adding to stack LSD(s): {input_lsd!s}")

self.lsd_list += input_lsd

Expand Down
2 changes: 1 addition & 1 deletion draco/analysis/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def setup(self, tel):
Telescope object to use
"""
if self.weight not in ["natural", "uniform", "inverse_variance"]:
KeyError("Do not recognize weight = %s" % self.weight)
KeyError(f"Do not recognize weight = {self.weight!s}")

self.telescope = io.get_telescope(tel)

Expand Down
14 changes: 7 additions & 7 deletions draco/core/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _list_of_filelists(files: Union[List[str], List[List[str]]]) -> List[List[st
for filelist in files:
if isinstance(filelist, str):
if "*" not in filelist and not os.path.isfile(filelist):
raise ConfigError("File not found: %s" % filelist)
raise ConfigError(f"File not found: {filelist!s}")
filelist = glob.glob(filelist)
elif isinstance(filelist, list):
for i in range(len(filelist)):
Expand Down Expand Up @@ -116,12 +116,12 @@ def _list_or_glob(files: Union[str, List[str]]) -> List[str]:
)
else:
if not os.path.isfile(files):
raise ConfigError("File not found: %s" % files)
raise ConfigError(f"File not found: {files!s}")

return [files]

raise ConfigError(
"Argument must be list, glob pattern, or file path, got %s" % repr(files)
f"Argument must be list, glob pattern, or file path, got {files!r}"
)


Expand Down Expand Up @@ -167,11 +167,11 @@ def _list_of_filegroups(groups: Union[List[Dict], Dict]) -> List[Dict]:

for fname in files:
if "*" not in fname and not os.path.isfile(fname):
raise ConfigError("File not found: %s" % fname)
raise ConfigError(f"File not found: {fname!s}")
flist += glob.glob(fname)

if not len(flist):
raise ConfigError("No files in group exist (%s)." % files)
raise ConfigError(f"No files in group exist ({files!s}).")

group["files"] = flist

Expand Down Expand Up @@ -1164,7 +1164,7 @@ def get_telescope(obj):
if isinstance(obj, telescope.TransitTelescope):
return obj

raise RuntimeError("Could not get telescope instance out of %s" % repr(obj))
raise RuntimeError(f"Could not get telescope instance out of {obj!r}")


def get_beamtransfer(obj):
Expand All @@ -1178,4 +1178,4 @@ def get_beamtransfer(obj):
if isinstance(obj, manager.ProductManager):
return obj.beamtransfer

raise RuntimeError("Could not get BeamTransfer instance out of %s" % repr(obj))
raise RuntimeError(f"Could not get BeamTransfer instance out of {obj!r}")
2 changes: 1 addition & 1 deletion draco/core/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def process(self, tstream, gain):
gain, (containers.CommonModeGainData, containers.CommonModeSiderealGainData)
):
raise ValueError(
"Cannot apply input-dependent gains to stacked data: %s" % tstream
f"Cannot apply input-dependent gains to stacked data: {tstream!s}"
)

if isinstance(gain, containers.StaticGainData):
Expand Down
8 changes: 4 additions & 4 deletions draco/core/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _log_level(x):
if isinstance(x, str) and x in level_dict:
return level_dict[x.upper()]

raise ValueError("Logging level %s not understood" % repr(x))
raise ValueError(f"Logging level {x!r} not understood")


class SetMPILogging(pipeline.TaskBase):
Expand Down Expand Up @@ -334,7 +334,7 @@ def __init__(self):

def next(self, *input):
"""Should not need to override. Implement `process` instead."""
self.log.info("Starting next for task %s" % self.__class__.__name__)
self.log.info(f"Starting next for task {self.__class__.__name__}")

self.comm.Barrier()

Expand Down Expand Up @@ -376,7 +376,7 @@ def next(self, *input):
# Increment internal counter
self._count = self._count + 1

self.log.info("Leaving next for task %s" % self.__class__.__name__)
self.log.info(f"Leaving next for task {self.__class__.__name__}")

# Return the output for the next task
return output
Expand Down Expand Up @@ -678,7 +678,7 @@ def process(self, x):
"""
import gc

self.log.info("Deleting %s" % type(x))
self.log.info(f"Deleting {type(x)!s}")
del x
gc.collect()

Expand Down
2 changes: 1 addition & 1 deletion draco/util/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def find_inputs(input_index, inputs, require_match=False):
)

if field_to_match not in inputs.dtype.fields:
raise ValueError("`inputs` array does not have a `%s` field." % field_to_match)
raise ValueError(f"`inputs` array does not have a `{field_to_match!s}` field.")

return find_keys(
input_index[field_to_match], inputs[field_to_match], require_match=require_match
Expand Down

0 comments on commit 3a059dc

Please sign in to comment.