From 2123db784a50d18e29c50612495f0b5cd5dbfb79 Mon Sep 17 00:00:00 2001 From: Peter Hawkins Date: Fri, 26 Jul 2024 08:10:08 -0700 Subject: [PATCH] [numpy] Fix users of NumPy APIs that are removed in NumPy 2.0. This change migrates users of APIs removed in NumPy 2.0 to their recommended replacements (https://numpy.org/devdocs/numpy_2_0_migration_guide.html). PiperOrigin-RevId: 656405338 --- tensorflow_datasets/core/features/audio_feature_test.py | 2 +- tensorflow_datasets/image_classification/corruptions.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_datasets/core/features/audio_feature_test.py b/tensorflow_datasets/core/features/audio_feature_test.py index 89a35c8f9c4..7130bd030ca 100644 --- a/tensorflow_datasets/core/features/audio_feature_test.py +++ b/tensorflow_datasets/core/features/audio_feature_test.py @@ -247,7 +247,7 @@ def _write_audio_file(np_audio, path, file_format): f'`{np_audio.dtype}`.' ) - data = array.array(np.sctype2char(dtype), np_audio.reshape((-1,))) + data = array.array(np.dtype(dtype).char, np_audio.reshape((-1,))) sample_width = np.dtype(dtype).alignment num_channels = np_audio.shape[1] if len(np_audio.shape) == 2 else 1 diff --git a/tensorflow_datasets/image_classification/corruptions.py b/tensorflow_datasets/image_classification/corruptions.py index c9eef90a9af..5c589a3239a 100644 --- a/tensorflow_datasets/image_classification/corruptions.py +++ b/tensorflow_datasets/image_classification/corruptions.py @@ -132,7 +132,7 @@ def plasma_fractal(mapsize=512, wibbledecay=3): """ if mapsize & (mapsize - 1) != 0: raise ValueError('mapsize must be a power of two.') - maparray = np.empty((mapsize, mapsize), dtype=np.float_) + maparray = np.empty((mapsize, mapsize), dtype=np.float64) maparray[0, 0] = 0 stepsize = mapsize wibble = 100