Skip to content

More f-strings, less format() #10474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions xarray/computation/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,11 @@ def __init__(
def __repr__(self) -> str:
"""provide a nice str repr of our rolling object"""

attrs = [
attrs = ",".join(
"{k}->{v}{c}".format(k=k, v=w, c="(center)" if c else "")
for k, w, c in zip(self.dim, self.window, self.center, strict=True)
]
return "{klass} [{attrs}]".format(
klass=self.__class__.__name__, attrs=",".join(attrs)
)
return f"{self.__class__.__name__} [{attrs}]"

def __len__(self) -> int:
return math.prod(self.obj.sizes[d] for d in self.dim)
Expand Down Expand Up @@ -1106,14 +1104,12 @@ def _get_keep_attrs(self, keep_attrs):
def __repr__(self) -> str:
"""provide a nice str repr of our coarsen object"""

attrs = [
attrs = ",".join(
f"{k}->{getattr(self, k)}"
for k in self._attributes
if getattr(self, k, None) is not None
]
return "{klass} [{attrs}]".format(
klass=self.__class__.__name__, attrs=",".join(attrs)
)
return f"{self.__class__.__name__} [{attrs}]"

def construct(
self,
Expand Down
Loading