From ba5a93248564e1494d77e489427975ff8dbe8d97 Mon Sep 17 00:00:00 2001 From: Peter Hawkins Date: Mon, 5 Aug 2024 11:42:25 -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/doc/stable/numpy_2_0_migration_guide.html). This CL makes the following changes in colab notebooks: * np.NaN -> np.nan * np.NAN -> np.nan * np.Inf -> np.inf * np.Infinity -> np.inf * np.infty -> np.inf * np.NINF -> -np.inf PiperOrigin-RevId: 659627325 --- agent_based_epidemic_sim/learning/BUILD | 2 +- agent_based_epidemic_sim/learning/risk_score_learning.ipynb | 2 +- agent_based_epidemic_sim/port/deps/status_builder.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/agent_based_epidemic_sim/learning/BUILD b/agent_based_epidemic_sim/learning/BUILD index 9aeb812a..2b3db953 100644 --- a/agent_based_epidemic_sim/learning/BUILD +++ b/agent_based_epidemic_sim/learning/BUILD @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") load("@pip//:requirements.bzl", "requirement") +load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") licenses(["notice"]) diff --git a/agent_based_epidemic_sim/learning/risk_score_learning.ipynb b/agent_based_epidemic_sim/learning/risk_score_learning.ipynb index 3883df49..d1fc4586 100644 --- a/agent_based_epidemic_sim/learning/risk_score_learning.ipynb +++ b/agent_based_epidemic_sim/learning/risk_score_learning.ipynb @@ -327,7 +327,7 @@ "\n", "def project(params):\n", " \"\"\"Project residual parameters to nonnegative orthant.\"\"\"\n", - " params = np.clip(params, 0, np.infty)\n", + " params = np.clip(params, 0, np.inf)\n", " return params\n", "\n", "def train(data, labels, weights_init, batch_size=100, num_iters=1000, lr=0.01):\n", diff --git a/agent_based_epidemic_sim/port/deps/status_builder.h b/agent_based_epidemic_sim/port/deps/status_builder.h index b3db38bd..8d9165e7 100644 --- a/agent_based_epidemic_sim/port/deps/status_builder.h +++ b/agent_based_epidemic_sim/port/deps/status_builder.h @@ -220,7 +220,7 @@ class ABSL_MUST_USE_RESULT StatusBuilder { } template auto With(Adaptor&& adaptor) && -> decltype(std::forward(adaptor)( - std::move(*this))) { + std::move(*this))) { return std::forward(adaptor)(std::move(*this)); }