Skip to content

Commit fed060e

Browse files
marcenacpThe TensorFlow Datasets Authors
authored andcommitted
Make TFDS's dataset compatible with NumPy v2.4.
PiperOrigin-RevId: 853257272
1 parent 23a0911 commit fed060e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tensorflow_datasets/datasets/smallnorb/smallnorb_dataset_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def read_binary_matrix(filename):
176176
int32_dtype = np.dtype("int32").newbyteorder("<")
177177

178178
# The first 4 bytes contain a magic code that specifies the data type.
179-
magic = int(np.frombuffer(s, dtype=int32_dtype, count=1))
179+
magic = np.frombuffer(s, dtype=int32_dtype, count=1).item()
180180
if magic == 507333717:
181181
data_dtype = np.dtype("uint8") # uint8 does not have a byte order.
182182
elif magic == 507333716:
@@ -186,7 +186,7 @@ def read_binary_matrix(filename):
186186

187187
# The second 4 bytes contain an int32 with the number of dimensions of the
188188
# stored array.
189-
ndim = int(np.frombuffer(s, dtype=int32_dtype, count=1, offset=4))
189+
ndim = np.frombuffer(s, dtype=int32_dtype, count=1, offset=4).item()
190190

191191
# The next ndim x 4 bytes contain the shape of the array in int32.
192192
dims = np.frombuffer(s, dtype=int32_dtype, count=ndim, offset=8)

0 commit comments

Comments
 (0)