Skip to content

Commit 8f861c1

Browse files
committed
Merge branch 'zarr-developers-main'
2 parents 45fdddb + 8d4aea7 commit 8f861c1

22 files changed

+56
-74
lines changed

.github/workflows/wheel.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
submodules: true
2828

29-
- uses: pypa/cibuildwheel@v2.19.2
29+
- uses: pypa/cibuildwheel@v2.20.0
3030

3131
- uses: actions/upload-artifact@v4
3232
with:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default_language_version:
77
python: python3
88
repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: 'v0.5.2'
10+
rev: 'v0.6.2'
1111
hooks:
1212
- id: ruff
1313
args: ["--fix", "--show-fixes"]

docs/release.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Fix
2121

2222
Maintenance
2323
~~~~~~~~~~~
24+
* Change format() and old string formatting to f-strings.
25+
By :user:`Dimitri Papadopoulos Orfanos <DimitriPapadopoulos>`, :issue:`439`.
2426

2527
* Remove pin on Sphinx
2628
By :user:`Elliott Sales de Andrade <QuLogic>`, :issue:`552`.

notebooks/benchmark_vlen.ipynb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"source": [
2727
"import numpy as np\n",
2828
"import numcodecs\n",
29+
"\n",
2930
"numcodecs.__version__"
3031
]
3132
},
@@ -54,10 +55,10 @@
5455
" enc = codec.encode(a)\n",
5556
" print('decode')\n",
5657
" %timeit codec.decode(enc)\n",
57-
" print('size : {:,}'.format(len(enc)))\n",
58-
" print('size (zstd 1): {:,}'.format(len(zstd1.encode(enc))))\n",
59-
" print('size (zstd 5): {:,}'.format(len(zstd5.encode(enc))))\n",
60-
" print('size (zstd 9): {:,}'.format(len(zstd9.encode(enc))))"
58+
" print(f'size : {len(enc):,}')\n",
59+
" print(f'size (zstd 1): {len(zstd1.encode(enc)):,}')\n",
60+
" print(f'size (zstd 5): {len(zstd5.encode(enc)):,}')\n",
61+
" print(f'size (zstd 9): {len(zstd9.encode(enc)):,}')"
6162
]
6263
},
6364
{
@@ -67,6 +68,7 @@
6768
"outputs": [],
6869
"source": [
6970
"from numcodecs.tests.common import greetings\n",
71+
"\n",
7072
"msgpack_codec = numcodecs.MsgPack()\n",
7173
"json_codec = numcodecs.JSON()\n",
7274
"pickle_codec = numcodecs.Pickle()\n",
@@ -281,6 +283,7 @@
281283
"outputs": [],
282284
"source": [
283285
"from faker import Faker\n",
286+
"\n",
284287
"fake = Faker()"
285288
]
286289
},
@@ -554,8 +557,10 @@
554557
],
555558
"source": [
556559
"np.random.seed(42)\n",
557-
"data4 = np.array([np.random.randint(0, 100, size=np.random.randint(0, 20)).astype('i4')\n",
558-
" for i in range(100000)], dtype=object)\n",
560+
"data4 = np.array(\n",
561+
" [np.random.randint(0, 100, size=np.random.randint(0, 20)).astype('i4') for i in range(100000)],\n",
562+
" dtype=object,\n",
563+
")\n",
559564
"data4"
560565
]
561566
},

numcodecs/abc.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,9 @@ def __repr__(self):
118118
# by default, assume all non-private members are configuration
119119
# parameters and valid keyword arguments to constructor function
120120

121-
r = '%s(' % type(self).__name__
121+
r = f'{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/astype.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,4 @@ def get_config(self):
7373
}
7474

7575
def __repr__(self):
76-
return '{}(encode_dtype={!r}, decode_dtype={!r})'.format(
77-
type(self).__name__, self.encode_dtype.str, self.decode_dtype.str
78-
)
76+
return f'{type(self).__name__}(encode_dtype={self.encode_dtype.str!r}, decode_dtype={self.decode_dtype.str!r})'

numcodecs/categorize.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,4 @@ def __repr__(self):
9999
labels = repr(self.labels[:3])
100100
if len(self.labels) > 3:
101101
labels = labels[:-1] + ', ...]'
102-
r = '%s(dtype=%r, astype=%r, labels=%s)' % (
103-
type(self).__name__,
104-
self.dtype.str,
105-
self.astype.str,
106-
labels,
107-
)
108-
return r
102+
return f'{type(self).__name__}(dtype={self.dtype.str!r}, astype={self.astype.str!r}, labels={labels})'

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ 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:
96-
r += ', astype=%r' % self.astype.str
96+
r += f', astype={self.astype.str!r}'
9797
r += ')'
9898
return r

numcodecs/fixedscaleoffset.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class FixedScaleOffset(Codec):
1515
----------
1616
offset : float
1717
Value to subtract from data.
18-
scale : int
18+
scale : float
1919
Value to multiply by data.
2020
dtype : dtype
2121
Data type to use for decoded data.
@@ -126,13 +126,8 @@ def get_config(self):
126126
)
127127

128128
def __repr__(self):
129-
r = '%s(scale=%s, offset=%s, dtype=%r' % (
130-
type(self).__name__,
131-
self.scale,
132-
self.offset,
133-
self.dtype.str,
134-
)
129+
r = f'{type(self).__name__}(scale={self.scale}, offset={self.offset}, dtype={self.dtype.str!r}'
135130
if self.astype != self.dtype:
136-
r += ', astype=%r' % self.astype.str
131+
r += f', astype={self.astype.str!r}'
137132
r += ')'
138133
return r

0 commit comments

Comments
 (0)