Skip to content

Commit

Permalink
small string fixes (#8598)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathause authored Jan 8, 2024
1 parent b35f761 commit e4496fe
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion xarray/coding/cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def shift(self, n: int | float, freq: str | timedelta):
return self + n * to_offset(freq)
else:
raise TypeError(
"'freq' must be of type " f"str or datetime.timedelta, got {freq}."
f"'freq' must be of type str or datetime.timedelta, got {freq}."
)

def __add__(self, other):
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _check_shape_tile_ids(combined_tile_ids):
raise ValueError(
"The supplied objects do not form a hypercube "
"because sub-lists do not have consistent "
"lengths along dimension" + str(dim)
f"lengths along dimension {dim}"
)


Expand Down
6 changes: 3 additions & 3 deletions xarray/core/computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ def func(*arrays):
pass
else:
raise ValueError(
"unknown setting for chunked array handling in " f"apply_ufunc: {dask}"
f"unknown setting for chunked array handling in apply_ufunc: {dask}"
)
else:
if vectorize:
Expand Down Expand Up @@ -1383,7 +1383,7 @@ def cov(
)
if weights is not None:
if not isinstance(weights, DataArray):
raise TypeError("Only xr.DataArray is supported." f"Given {type(weights)}.")
raise TypeError(f"Only xr.DataArray is supported. Given {type(weights)}.")
return _cov_corr(da_a, da_b, weights=weights, dim=dim, ddof=ddof, method="cov")


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


Expand Down
4 changes: 2 additions & 2 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2296,7 +2296,7 @@ def interp(
"""
if self.dtype.kind not in "uifc":
raise TypeError(
"interp only works for a numeric type array. " f"Given {self.dtype}."
f"interp only works for a numeric type array. Given {self.dtype}."
)
ds = self._to_temp_dataset().interp(
coords,
Expand Down Expand Up @@ -2423,7 +2423,7 @@ def interp_like(
"""
if self.dtype.kind not in "uifc":
raise TypeError(
"interp only works for a numeric type array. " f"Given {self.dtype}."
f"interp only works for a numeric type array. Given {self.dtype}."
)
ds = self._to_temp_dataset().interp_like(
other, method=method, kwargs=kwargs, assume_sorted=assume_sorted
Expand Down
8 changes: 3 additions & 5 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7159,9 +7159,9 @@ def to_pandas(self) -> pd.Series | pd.DataFrame:
if len(self.dims) == 1:
return self.to_dataframe()
raise ValueError(
"cannot convert Datasets with %s dimensions into "
f"cannot convert Datasets with {len(self.dims)} dimensions into "
"pandas objects without changing the number of dimensions. "
"Please use Dataset.to_dataframe() instead." % len(self.dims)
"Please use Dataset.to_dataframe() instead."
)

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

# what if coords aren't dims?
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/formatting_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def format_dims(dim_sizes, dims_with_index) -> str:
}

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

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

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

Expand Down

0 comments on commit e4496fe

Please sign in to comment.