Skip to content

Commit 84ecff2

Browse files
Change occurrences of format() to f-strings
1 parent cb15543 commit 84ecff2

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

numcodecs/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __repr__(self):
121121
# parameters and valid keyword arguments to constructor function
122122

123123
r = '%s(' % type(self).__name__
124-
params = ['{}={!r}'.format(k, getattr(self, k))
124+
params = [f'{k}={getattr(self, k)!r}'
125125
for k in sorted(self.__dict__)
126126
if not k.startswith('_')]
127127
r += ', '.join(params) + ')'

numcodecs/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def ensure_contiguous_ndarray_like(
117117
raise ValueError("an array with contiguous memory is required")
118118

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

123123
return arr

numcodecs/delta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_config(self):
9797
)
9898

9999
def __repr__(self):
100-
r = '{}(dtype={!r}'.format(type(self).__name__, self.dtype.str)
100+
r = f'{type(self).__name__}(dtype={self.dtype.str!r}'
101101
if self.astype != self.dtype:
102102
r += ', astype=%r' % self.astype.str
103103
r += ')'

numcodecs/json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ def get_config(self):
8181
def __repr__(self):
8282
params = ['encoding=%r' % self._text_encoding]
8383
for k, v in sorted(self._encoder_config.items()):
84-
params.append('{}={!r}'.format(k, v))
84+
params.append(f'{k}={v!r}')
8585
for k, v in sorted(self._decoder_config.items()):
86-
params.append('{}={!r}'.format(k, v))
86+
params.append(f'{k}={v!r}')
8787
classname = type(self).__name__
8888
r = '{}({})'.format(classname, ', '.join(params))
8989
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
@@ -243,7 +243,7 @@ def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, pref
243243

244244
# save fixture data
245245
for i, arr in enumerate(arrays):
246-
arr_fn = os.path.join(fixture_dir, 'array.{:02d}.npy'.format(i))
246+
arr_fn = os.path.join(fixture_dir, f'array.{i:02d}.npy')
247247
if not os.path.exists(arr_fn): # pragma: no cover
248248
np.save(arr_fn, arr)
249249

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

267267
# setup a directory to hold encoded data
268-
codec_dir = os.path.join(fixture_dir, 'codec.{:02d}'.format(j))
268+
codec_dir = os.path.join(fixture_dir, f'codec.{j:02d}')
269269
if not os.path.exists(codec_dir): # pragma: no cover
270270
os.makedirs(codec_dir)
271271

@@ -280,7 +280,7 @@ def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, pref
280280
config = _json.load(cf)
281281
assert codec == get_codec(config)
282282

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

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

0 commit comments

Comments
 (0)