Skip to content

Commit fae072f

Browse files
committed
Updates references to numpy deprecated type aliases. (#6140)
Numpy library deprecated some type aliases in version 1.20.0 [1], and then removed them in version 1.24.0 [2], which was released on Dec 18, 2022. Without this change, our build would be broken when using numpy version >= 1.24.0, with error `AttributeError: module 'numpy' has no attribute 'float'`. The fix suggested in release notes from numpy version 1.20.0 is to replace these types with the equivalent primitive python types. (In this case, simply `float`.) [1] http://numpy.org/doc/stable/release/1.20.0-notes.html#using-the-aliases-of-builtin-types-like-np-int-is-deprecated [2] http://numpy.org/doc/stable/release/1.24.0-notes.html#expired-deprecations * Motivation for features / changes Newer numpy versions break our build. This code is exactly equivalent, as the identifiers used previously were aliases for the same type. * Technical description of changes Replace occurrences of `np.float` for the primitive type `float`. * Screenshots of UI changes N/A * Detailed steps to verify changes work correctly (as executed by you) Ran tests. * Alternate designs / implementations considered N/A. (cherry picked from commit 7bcc5e8)
1 parent 1445d28 commit fae072f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tensorboard/plugins/npmi/csv_to_plugin_data_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def convert_file(file_path):
7070
for row in csv_reader:
7171
annotations.append(row[0])
7272
values.append(row[1:])
73-
values = np.array(values).astype(np.float)
73+
values = np.array(values).astype(float)
7474

7575
writer = tf.summary.create_file_writer(os.path.dirname(file_path))
7676
with writer.as_default():

tensorboard/plugins/pr_curve/summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def pb(
215215

216216
# Compute bins of true positives and false positives.
217217
bucket_indices = np.int32(np.floor(predictions * (num_thresholds - 1)))
218-
float_labels = labels.astype(np.float)
218+
float_labels = labels.astype(float)
219219
histogram_range = (0, num_thresholds - 1)
220220
tp_buckets, _ = np.histogram(
221221
bucket_indices,

0 commit comments

Comments
 (0)