Skip to content

Commit e4496fe

Browse files
authored
small string fixes (#8598)
1 parent b35f761 commit e4496fe

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

xarray/coding/cftimeindex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def shift(self, n: int | float, freq: str | timedelta):
553553
return self + n * to_offset(freq)
554554
else:
555555
raise TypeError(
556-
"'freq' must be of type " f"str or datetime.timedelta, got {freq}."
556+
f"'freq' must be of type str or datetime.timedelta, got {freq}."
557557
)
558558

559559
def __add__(self, other):

xarray/core/combine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def _check_shape_tile_ids(combined_tile_ids):
179179
raise ValueError(
180180
"The supplied objects do not form a hypercube "
181181
"because sub-lists do not have consistent "
182-
"lengths along dimension" + str(dim)
182+
f"lengths along dimension {dim}"
183183
)
184184

185185

xarray/core/computation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ def func(*arrays):
811811
pass
812812
else:
813813
raise ValueError(
814-
"unknown setting for chunked array handling in " f"apply_ufunc: {dask}"
814+
f"unknown setting for chunked array handling in apply_ufunc: {dask}"
815815
)
816816
else:
817817
if vectorize:
@@ -1383,7 +1383,7 @@ def cov(
13831383
)
13841384
if weights is not None:
13851385
if not isinstance(weights, DataArray):
1386-
raise TypeError("Only xr.DataArray is supported." f"Given {type(weights)}.")
1386+
raise TypeError(f"Only xr.DataArray is supported. Given {type(weights)}.")
13871387
return _cov_corr(da_a, da_b, weights=weights, dim=dim, ddof=ddof, method="cov")
13881388

13891389

@@ -1487,7 +1487,7 @@ def corr(
14871487
)
14881488
if weights is not None:
14891489
if not isinstance(weights, DataArray):
1490-
raise TypeError("Only xr.DataArray is supported." f"Given {type(weights)}.")
1490+
raise TypeError(f"Only xr.DataArray is supported. Given {type(weights)}.")
14911491
return _cov_corr(da_a, da_b, weights=weights, dim=dim, method="corr")
14921492

14931493

xarray/core/dataarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,7 @@ def interp(
22962296
"""
22972297
if self.dtype.kind not in "uifc":
22982298
raise TypeError(
2299-
"interp only works for a numeric type array. " f"Given {self.dtype}."
2299+
f"interp only works for a numeric type array. Given {self.dtype}."
23002300
)
23012301
ds = self._to_temp_dataset().interp(
23022302
coords,
@@ -2423,7 +2423,7 @@ def interp_like(
24232423
"""
24242424
if self.dtype.kind not in "uifc":
24252425
raise TypeError(
2426-
"interp only works for a numeric type array. " f"Given {self.dtype}."
2426+
f"interp only works for a numeric type array. Given {self.dtype}."
24272427
)
24282428
ds = self._to_temp_dataset().interp_like(
24292429
other, method=method, kwargs=kwargs, assume_sorted=assume_sorted

xarray/core/dataset.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7159,9 +7159,9 @@ def to_pandas(self) -> pd.Series | pd.DataFrame:
71597159
if len(self.dims) == 1:
71607160
return self.to_dataframe()
71617161
raise ValueError(
7162-
"cannot convert Datasets with %s dimensions into "
7162+
f"cannot convert Datasets with {len(self.dims)} dimensions into "
71637163
"pandas objects without changing the number of dimensions. "
7164-
"Please use Dataset.to_dataframe() instead." % len(self.dims)
7164+
"Please use Dataset.to_dataframe() instead."
71657165
)
71667166

71677167
def _to_dataframe(self, ordered_dims: Mapping[Any, int]):
@@ -7564,9 +7564,7 @@ def from_dict(cls, d: Mapping[Any, Any]) -> Self:
75647564
for k, v in variables
75657565
}
75667566
except KeyError as e:
7567-
raise ValueError(
7568-
"cannot convert dict without the key " f"'{str(e.args[0])}'"
7569-
)
7567+
raise ValueError(f"cannot convert dict without the key '{str(e.args[0])}'")
75707568
obj = cls(variable_dict)
75717569

75727570
# what if coords aren't dims?

xarray/core/formatting_html.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def format_dims(dim_sizes, dims_with_index) -> str:
4747
}
4848

4949
dims_li = "".join(
50-
f"<li><span{dim_css_map[dim]}>" f"{escape(str(dim))}</span>: {size}</li>"
50+
f"<li><span{dim_css_map[dim]}>{escape(str(dim))}</span>: {size}</li>"
5151
for dim, size in dim_sizes.items()
5252
)
5353

@@ -56,7 +56,7 @@ def format_dims(dim_sizes, dims_with_index) -> str:
5656

5757
def summarize_attrs(attrs) -> str:
5858
attrs_dl = "".join(
59-
f"<dt><span>{escape(str(k))} :</span></dt>" f"<dd>{escape(str(v))}</dd>"
59+
f"<dt><span>{escape(str(k))} :</span></dt><dd>{escape(str(v))}</dd>"
6060
for k, v in attrs.items()
6161
)
6262

0 commit comments

Comments
 (0)