From e4d99fdfad16912e5d5bace0a06d5378bd6c66bc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 Aug 2025 06:31:51 +0000 Subject: [PATCH 1/2] Initial plan From 30ee27cfac8b055d2515f0ef01413876b894191f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 Aug 2025 06:46:02 +0000 Subject: [PATCH 2/2] Fix Python warnings: handle empty arrays and suppress JAX fork warnings Co-authored-by: mmcky <8263752+mmcky@users.noreply.github.com> --- lectures/back_prop.md | 8 +++++--- lectures/status.md | 15 ++++++++++++--- lectures/two_auctions.md | 9 +++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lectures/back_prop.md b/lectures/back_prop.md index 9780ef8c3..56a630948 100644 --- a/lectures/back_prop.md +++ b/lectures/back_prop.md @@ -32,9 +32,11 @@ In addition to what's included in base Anaconda, we need to install the followin ```{code-cell} ipython3 :tags: [hide-output] - -!pip install kaleido -!conda install -y -c plotly plotly plotly-orca retrying +import warnings +with warnings.catch_warnings(): + warnings.filterwarnings("ignore", message=".*os.fork.*") + !pip install kaleido + !conda install -y -c plotly plotly plotly-orca retrying ``` ```{note} diff --git a/lectures/status.md b/lectures/status.md index ca1d9dd2e..ab3981b09 100644 --- a/lectures/status.md +++ b/lectures/status.md @@ -23,14 +23,20 @@ These lectures are built on `linux` instances through `github actions`. These lectures are using the following python version ```{code-cell} ipython -!python --version +import warnings +with warnings.catch_warnings(): + warnings.filterwarnings("ignore", message=".*os.fork.*") + !python --version ``` and the following package versions ```{code-cell} ipython :tags: [hide-output] -!conda list +import warnings +with warnings.catch_warnings(): + warnings.filterwarnings("ignore", message=".*os.fork.*") + !conda list ``` You can check the backend used by JAX using: @@ -44,5 +50,8 @@ print(f"JAX backend: {jax.devices()[0].platform}") and this lecture series also has access to the following GPU ```{code-cell} ipython -!nvidia-smi +import warnings +with warnings.catch_warnings(): + warnings.filterwarnings("ignore", message=".*os.fork.*") + !nvidia-smi ``` \ No newline at end of file diff --git a/lectures/two_auctions.md b/lectures/two_auctions.md index 0f2ed02c8..0829548f8 100644 --- a/lectures/two_auctions.md +++ b/lectures/two_auctions.md @@ -403,6 +403,11 @@ def evaluate_largest(v_hat, array, order=1): array_conditional=array_residual[:,index].copy() array_conditional=np.sort(array_conditional, axis=0) + + # Handle empty array case to avoid "Mean of empty slice" warning + if array_conditional.shape[1] == 0: + return np.nan + return array_conditional[-order,:].mean() ``` @@ -561,6 +566,10 @@ class bid_price_solution: array_conditional=np.sort(array_conditional, axis=0) + # Handle empty array case to avoid "Mean of empty slice" warning + if array_conditional.shape[1] == 0: + return np.nan + return array_conditional[-order,:].mean() def compute_optimal_bid_FPSB(self):