Skip to content

Commit

Permalink
Use lazy formatting for logger messages
Browse files Browse the repository at this point in the history
This fixes some linter complaints.
  • Loading branch information
peanutfun committed Jul 7, 2022
1 parent 939968b commit b110a94
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions climada/hazard/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def from_raster_netcdf(
"""
# If the data is a string, open the respective file
if not isinstance(data, xr.Dataset):
LOGGER.info(f"Loading Hazard from file: {data}")
LOGGER.info("Loading Hazard from file: %s", data)
data = xr.open_dataset(data)
else:
LOGGER.info("Loading Hazard from xarray Dataset")
Expand Down Expand Up @@ -445,13 +445,13 @@ def from_raster_netcdf(
)

# Read the intensity data and flatten it in spatial dimensions
LOGGER.debug(f"Loading Hazard intensity from DataArray '{intensity}'")
LOGGER.debug("Loading Hazard intensity from DataArray '%s'", intensity)
hazard.intensity = sparse.csr_matrix(data[intensity])
hazard.intensity.eliminate_zeros()

# Use fraction data or apply callable
if isinstance(fraction, str):
LOGGER.debug(f"Loading Hazard fraction from DataArray '{fraction}'")
LOGGER.debug("Loading Hazard fraction from DataArray '%s'", fraction)
fraction_arr = data[fraction]
elif isinstance(fraction, Callable):
LOGGER.debug("Computing Hazard fraction from callable")
Expand All @@ -470,7 +470,7 @@ def from_raster_netcdf(
# TODO: hazard.unit

# Done!
LOGGER.debug(f"Hazard successfully loaded. Number of events: {num_events}")
LOGGER.debug("Hazard successfully loaded. Number of events: %i", num_events)
return hazard

@classmethod
Expand Down

0 comments on commit b110a94

Please sign in to comment.