Skip to content

Commit feef193

Browse files
Change occurrences of format() to f-strings
1 parent 9617e6f commit feef193

File tree

6 files changed

+9
-11
lines changed

6 files changed

+9
-11
lines changed

c-blosc

Submodule c-blosc updated 432 files

numcodecs/abc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ def __repr__(self):
120120

121121
r = '%s(' % type(self).__name__
122122
params = [
123-
'{}={!r}'.format(k, getattr(self, k))
124-
for k in sorted(self.__dict__)
125-
if not k.startswith('_')
123+
f'{k}={getattr(self, k)!r}' for k in sorted(self.__dict__) if not k.startswith('_')
126124
]
127125
r += ', '.join(params) + ')'
128126
return r

numcodecs/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def ensure_contiguous_ndarray_like(buf, max_buffer_size=None, flatten=True) -> N
115115
raise ValueError("an array with contiguous memory is required")
116116

117117
if max_buffer_size is not None and arr.nbytes > max_buffer_size:
118-
msg = "Codec does not support buffers of > {} bytes".format(max_buffer_size)
118+
msg = f"Codec does not support buffers of > {max_buffer_size} bytes"
119119
raise ValueError(msg)
120120

121121
return arr

numcodecs/delta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def get_config(self):
9191
return dict(id=self.codec_id, dtype=self.dtype.str, astype=self.astype.str)
9292

9393
def __repr__(self):
94-
r = '{}(dtype={!r}'.format(type(self).__name__, self.dtype.str)
94+
r = f'{type(self).__name__}(dtype={self.dtype.str!r}'
9595
if self.astype != self.dtype:
9696
r += ', astype=%r' % self.astype.str
9797
r += ')'

numcodecs/json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ def get_config(self):
9999
def __repr__(self):
100100
params = ['encoding=%r' % self._text_encoding]
101101
for k, v in sorted(self._encoder_config.items()):
102-
params.append('{}={!r}'.format(k, v))
102+
params.append(f'{k}={v!r}')
103103
for k, v in sorted(self._decoder_config.items()):
104-
params.append('{}={!r}'.format(k, v))
104+
params.append(f'{k}={v!r}')
105105
classname = type(self).__name__
106106
r = '{}({})'.format(classname, ', '.join(params))
107107
r = textwrap.fill(r, width=80, break_long_words=False, subsequent_indent=' ')

numcodecs/tests/common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, pref
258258

259259
# save fixture data
260260
for i, arr in enumerate(arrays):
261-
arr_fn = os.path.join(fixture_dir, 'array.{:02d}.npy'.format(i))
261+
arr_fn = os.path.join(fixture_dir, f'array.{i:02d}.npy')
262262
if not os.path.exists(arr_fn): # pragma: no cover
263263
np.save(arr_fn, arr)
264264

@@ -278,7 +278,7 @@ def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, pref
278278
pytest.skip("codec has been removed")
279279

280280
# setup a directory to hold encoded data
281-
codec_dir = os.path.join(fixture_dir, 'codec.{:02d}'.format(j))
281+
codec_dir = os.path.join(fixture_dir, f'codec.{j:02d}')
282282
if not os.path.exists(codec_dir): # pragma: no cover
283283
os.makedirs(codec_dir)
284284

@@ -293,7 +293,7 @@ def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, pref
293293
config = _json.load(cf)
294294
assert codec == get_codec(config)
295295

296-
enc_fn = os.path.join(codec_dir, 'encoded.{:02d}.dat'.format(i))
296+
enc_fn = os.path.join(codec_dir, f'encoded.{i:02d}.dat')
297297

298298
# one time encode and save array
299299
if not os.path.exists(enc_fn): # pragma: no cover

0 commit comments

Comments
 (0)