Skip to content

Commit 0d26a2d

Browse files
Improve f-strings
- Manual improvements. - Run `ruff check --extend-select ISC` to fix black reformatting.
1 parent b5e7693 commit 0d26a2d

6 files changed

Lines changed: 14 additions & 16 deletions

File tree

dask/array/_array_expr/_gufunc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ def apply_gufunc(
434434
#### Check if core dimensions consist of only one chunk
435435
if (dim in core_shapes) and (chunksizes[0][0] < core_shapes[dim]):
436436
raise ValueError(
437-
f"Core dimension `'{dim}'` consists of multiple chunks. To fix, rechunk into a single \
438-
chunk along this dimension or set `allow_rechunk=True`, but beware that this may increase memory usage \
439-
significantly."
437+
f"Core dimension `'{dim}'` consists of multiple chunks. To fix, rechunk into "
438+
"a single chunk along this dimension or set `allow_rechunk=True`, but beware "
439+
"that this may increase memory usage significantly."
440440
)
441441
#### Check if loop dimensions consist of same chunksizes, when they have sizes > 1
442442
relevant_chunksizes = list(
@@ -709,7 +709,7 @@ def __init__(
709709

710710
self.__doc__ = f"""
711711
Bound ``dask.array.gufunc``
712-
func: ``{str(self.pyfunc)}``
712+
func: ``{self.pyfunc}``
713713
signature: ``'{self.signature}'``
714714
715715
Parameters

dask/array/core.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,7 @@ def apply_infer_dtype(func, args, kwargs, funcname, suggest_dtype="dtype", nout=
492492
tb = "".join(traceback.format_tb(exc_traceback))
493493
suggest = (
494494
(
495-
"Please specify the dtype explicitly using the "
496-
f"`{suggest_dtype}` kwarg.\n\n"
495+
f"Please specify the dtype explicitly using the `{suggest_dtype}` kwarg.\n\n"
497496
)
498497
if suggest_dtype
499498
else ""
@@ -2052,7 +2051,7 @@ def _vindex(self, key):
20522051
key = (key,)
20532052
if any(k is None for k in key):
20542053
raise IndexError(
2055-
"vindex does not support indexing with None (np.newaxis), " f"got {key}"
2054+
f"vindex does not support indexing with None (np.newaxis), got {key}"
20562055
)
20572056
if all(isinstance(k, slice) for k in key):
20582057
if all(

dask/array/gufunc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,9 @@ def apply_gufunc(
432432
#### Check if core dimensions consist of only one chunk
433433
if (dim in core_shapes) and (chunksizes[0][0] < core_shapes[dim]):
434434
raise ValueError(
435-
f"Core dimension `'{dim}'` consists of multiple chunks. To fix, rechunk into a single \
436-
chunk along this dimension or set `allow_rechunk=True`, but beware that this may increase memory usage \
437-
significantly."
435+
f"Core dimension `'{dim}'` consists of multiple chunks. To fix, rechunk into "
436+
"a single chunk along this dimension or set `allow_rechunk=True`, but beware "
437+
"that this may increase memory usage significantly."
438438
)
439439
#### Check if loop dimensions consist of same chunksizes, when they have sizes > 1
440440
relevant_chunksizes = list(
@@ -674,7 +674,7 @@ def __init__(
674674

675675
self.__doc__ = f"""
676676
Bound ``dask.array.gufunc``
677-
func: ``{str(self.pyfunc)}``
677+
func: ``{self.pyfunc}``
678678
signature: ``'{self.signature}'``
679679
680680
Parameters

dask/array/linalg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ def svd(a, coerce_signs=True):
918918
nb = a.numblocks
919919
if a.ndim != 2:
920920
raise ValueError(
921-
"Array must be 2D.\n" f"Input shape: {a.shape}\n" f"Input ndim: {a.ndim}\n"
921+
f"Array must be 2D.\nInput shape: {a.shape}\nInput ndim: {a.ndim}\n"
922922
)
923923
if nb[0] > 1 and nb[1] > 1:
924924
raise NotImplementedError(

dask/bag/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ def take(self, k, npartitions=1, compute=True, warn=True):
14411441
npartitions = self.npartitions
14421442
if npartitions > self.npartitions:
14431443
raise ValueError(
1444-
f"only {self.npartitions} partitions, take " f"received {npartitions}"
1444+
f"only {self.npartitions} partitions, take received {npartitions}"
14451445
)
14461446

14471447
token = tokenize(self, k, npartitions)

dask/dataframe/io/hdf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,7 @@ def _one_path_one_key(path, key, start, stop, chunksize):
483483

484484
if start >= stop:
485485
raise ValueError(
486-
f"Start row number ({start}) is above or equal to stop "
487-
f"row number ({stop})"
486+
f"Start row number ({start}) is above or equal to stop row number ({stop})"
488487
)
489488

490489
return [
@@ -531,7 +530,7 @@ def _get_keys_stops_divisions(path, key, stop, sorted_index, chunksize, mode):
531530
stops.append(storer.nrows)
532531
elif stop > storer.nrows:
533532
raise ValueError(
534-
"Stop keyword exceeds dataset number " f"of rows ({storer.nrows})"
533+
f"Stop keyword exceeds dataset number of rows ({storer.nrows})"
535534
)
536535
else:
537536
stops.append(stop)

0 commit comments

Comments
 (0)