From 0553f197066a757a2122b6b8048aa4fd0b34adb1 Mon Sep 17 00:00:00 2001 From: Liam Gray Date: Wed, 11 Dec 2024 10:41:46 -0700 Subject: [PATCH] style: run newest version of ruff --- caput/config.py | 11 ++++------- caput/memh5.py | 3 +-- caput/mpiarray.py | 7 +++---- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/caput/config.py b/caput/config.py index 6c7c368f..85b85416 100644 --- a/caput/config.py +++ b/caput/config.py @@ -380,21 +380,18 @@ def _prop(val): for ii, item in enumerate(val): if not isinstance(item, type_): raise CaputConfigError( - "Expected to receive a list with items of type %s, but got " - "'%s' of type '%s' at position %i" - % (type_, item, type(item), ii) + f"Expected to receive a list with items of type {type_!s}, but got " + f"'{item!s}' of type '{type(item)!s}' at position {ii}" ) if length and len(val) != length: raise CaputConfigError( - "List expected to be of length %i, but was actually length %i" - % (length, len(val)) + f"List expected to be of length {length}, but was actually length {len(val)}" ) if maxlength and len(val) > maxlength: raise CaputConfigError( - "Maximum length of list is %i is, but list was actually length %i" - % (maxlength, len(val)) + f"Maximum length of list is {maxlength} is, but list was actually length {len(val)}" ) return val diff --git a/caput/memh5.py b/caput/memh5.py index ee6ab1a3..cb37c24b 100644 --- a/caput/memh5.py +++ b/caput/memh5.py @@ -881,8 +881,7 @@ def dataset_common_to_distributed(self, name, distributed_axis=0): if dset.distributed: warnings.warn( - "%s is already a distributed dataset, redistribute it along the required axis %d" - % (name, distributed_axis) + f"{name!s} is already a distributed dataset, redistribute it along the required axis {distributed_axis}" ) dset.redistribute(distributed_axis) return dset diff --git a/caput/mpiarray.py b/caput/mpiarray.py index 65597f60..17d4a85f 100644 --- a/caput/mpiarray.py +++ b/caput/mpiarray.py @@ -968,7 +968,7 @@ def from_file( # Check that the axis is valid and wrap to an actual position if axis < -naxis or axis >= naxis: raise AxisException( - "Distributed axis %i not in range (%i, %i)" % (axis, -naxis, naxis - 1) + f"Distributed axis {axis} not in range ({-naxis}, {naxis - 1})" ) axis = naxis + axis if axis < 0 else axis @@ -1642,9 +1642,8 @@ def _partition_io(self, skip=False, threshold=1.99): break else: raise RuntimeError( - "Can't identify an IO partition less than %.2f GB in size: " - "shape=%s, distributed axis=%i" - % (threshold, self.global_shape, self.axis) + f"Can't identify an IO partition less than {threshold:.2f} GB in size: " + f"shape={self.global_shape!s}, distributed axis={self.axis}" ) axis_length = self.global_shape[split_axis]