Skip to content

Commit

Permalink
[numpy] Fix test failures under NumPy 2.1.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 680593399
  • Loading branch information
hawkinsp authored and copybara-github committed Sep 30, 2024
1 parent 15075c8 commit 81a7d6c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions baselines/drug_cardiotoxicity/augmentation_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ def _check_no_nonzero_features(self,
else:
# Dropped edge.
features_of_dropped_edge = features[dropped_idx[0], dropped_idx[1]]
self.assertEqual(0, np.nonzero(features_of_dropped_edge)[0].shape[0])
self.assertEqual(
0, np.nonzero(np.atleast_1d(features_of_dropped_edge))[0].shape[0]
)

def _check_nonzero_features_exist_for_edge(self, features: np.ndarray,
added_edge_idx: np.ndarray):
Expand All @@ -216,7 +218,9 @@ def _check_nonzero_features_exist_for_edge(self, features: np.ndarray,
added_edge_idx: Numpy array representing index of edge, e.g. [0, 1].
"""
features_of_added_edges = features[added_edge_idx[0], added_edge_idx[1]]
self.assertGreater(np.nonzero(features_of_added_edges)[0].shape[0], 0)
self.assertGreater(
np.nonzero(np.atleast_1d(features_of_added_edges))[0].shape[0], 0
)

def test_update_features_of_dropped_nodes(self):
idx_drop = np.asarray([[0], [2], [3], [5], [7], [8]])
Expand Down

0 comments on commit 81a7d6c

Please sign in to comment.