Skip to content

Commit 94a7957

Browse files
More f-strings, less format() (#10474)
1 parent 0d81d7a commit 94a7957

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

xarray/computation/rolling.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,11 @@ def __init__(
131131
def __repr__(self) -> str:
132132
"""provide a nice str repr of our rolling object"""
133133

134-
attrs = [
134+
attrs = ",".join(
135135
"{k}->{v}{c}".format(k=k, v=w, c="(center)" if c else "")
136136
for k, w, c in zip(self.dim, self.window, self.center, strict=True)
137-
]
138-
return "{klass} [{attrs}]".format(
139-
klass=self.__class__.__name__, attrs=",".join(attrs)
140137
)
138+
return f"{self.__class__.__name__} [{attrs}]"
141139

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

1109-
attrs = [
1107+
attrs = ",".join(
11101108
f"{k}->{getattr(self, k)}"
11111109
for k in self._attributes
11121110
if getattr(self, k, None) is not None
1113-
]
1114-
return "{klass} [{attrs}]".format(
1115-
klass=self.__class__.__name__, attrs=",".join(attrs)
11161111
)
1112+
return f"{self.__class__.__name__} [{attrs}]"
11171113

11181114
def construct(
11191115
self,

0 commit comments

Comments
 (0)