From 744fd3c6db24b6873826641732d1f9addbeb0c2e Mon Sep 17 00:00:00 2001 From: Kevin Languasco Date: Tue, 23 Feb 2021 21:30:29 -0500 Subject: [PATCH 1/2] fix: Subplot in Chapter 1 gives Matplotlib warning Fix a Matplotlib 3.3 deprecation warning given when the argument type of the subplot function is a float instead of an int. --- Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb | 2 +- Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb | 2 +- Chapter1_Introduction/Ch1_Introduction_Pyro.ipynb | 2 +- Chapter1_Introduction/Ch1_Introduction_TFP.ipynb | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb b/Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb index 26b7b71a..04b4acf9 100644 --- a/Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb +++ b/Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb @@ -205,7 +205,7 @@ "\n", "# For the already prepared, I'm using Binomial's conj. prior.\n", "for k, N in enumerate(n_trials):\n", - " sx = plt.subplot(len(n_trials) / 2, 2, k + 1)\n", + " sx = plt.subplot(int(len(n_trials) / 2), 2, k + 1)\n", " plt.xlabel(\"$p$, probability of heads\") \\\n", " if k in [0, len(n_trials) - 1] else None\n", " plt.setp(sx.get_yticklabels(), visible=False)\n", diff --git a/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb b/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb index be24102a..bfba17a1 100644 --- a/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb +++ b/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb @@ -209,7 +209,7 @@ "\n", "# For the already prepared, I'm using Binomial's conj. prior.\n", "for k, N in enumerate(n_trials):\n", - " sx = plt.subplot(len(n_trials)/2, 2, k+1)\n", + " sx = plt.subplot(int(len(n_trials)/2), 2, k+1)\n", " plt.xlabel(\"$p$, probability of heads\") \\\n", " if k in [0, len(n_trials)-1] else None\n", " plt.setp(sx.get_yticklabels(), visible=False)\n", diff --git a/Chapter1_Introduction/Ch1_Introduction_Pyro.ipynb b/Chapter1_Introduction/Ch1_Introduction_Pyro.ipynb index 32366073..914ee7aa 100644 --- a/Chapter1_Introduction/Ch1_Introduction_Pyro.ipynb +++ b/Chapter1_Introduction/Ch1_Introduction_Pyro.ipynb @@ -166,7 +166,7 @@ "\n", "# For the already prepared, I'm using Binomial's conj. prior.\n", "for k, N in enumerate(n_trials):\n", - " sx = plt.subplot(len(n_trials)/2, 2, k+1)\n", + " sx = plt.subplot(int(len(n_trials)/2), 2, k+1)\n", " plt.xlabel(\"$p$, probability of heads\") \\\n", " if k in [0, len(n_trials)-1] else None\n", " plt.setp(sx.get_yticklabels(), visible=False)\n", diff --git a/Chapter1_Introduction/Ch1_Introduction_TFP.ipynb b/Chapter1_Introduction/Ch1_Introduction_TFP.ipynb index 117da5e1..efedd004 100644 --- a/Chapter1_Introduction/Ch1_Introduction_TFP.ipynb +++ b/Chapter1_Introduction/Ch1_Introduction_TFP.ipynb @@ -437,7 +437,7 @@ "# For the already prepared, I'm using Binomial's conj. prior.\n", "plt.figure(figsize(16, 9))\n", "for i in range(len(num_trials)):\n", - " sx = plt.subplot(len(num_trials)/2, 2, i+1)\n", + " sx = plt.subplot(int(len(num_trials)/2), 2, i+1)\n", " plt.xlabel(\"$p$, probability of heads\") \\\n", " if i in [0, len(num_trials)-1] else None\n", " plt.setp(sx.get_yticklabels(), visible=False)\n", @@ -1435,4 +1435,4 @@ ] } ] -} \ No newline at end of file +} From b2499f1ba64e55deb28657cb8a3f2653bae7a816 Mon Sep 17 00:00:00 2001 From: Kevin Languasco Date: Tue, 23 Feb 2021 22:13:06 -0500 Subject: [PATCH 2/2] style: Use floor division instead of int casting --- Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb | 2 +- Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb | 2 +- Chapter1_Introduction/Ch1_Introduction_Pyro.ipynb | 2 +- Chapter1_Introduction/Ch1_Introduction_TFP.ipynb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb b/Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb index 04b4acf9..50b51fbb 100644 --- a/Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb +++ b/Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb @@ -205,7 +205,7 @@ "\n", "# For the already prepared, I'm using Binomial's conj. prior.\n", "for k, N in enumerate(n_trials):\n", - " sx = plt.subplot(int(len(n_trials) / 2), 2, k + 1)\n", + " sx = plt.subplot(len(n_trials) // 2, 2, k + 1)\n", " plt.xlabel(\"$p$, probability of heads\") \\\n", " if k in [0, len(n_trials) - 1] else None\n", " plt.setp(sx.get_yticklabels(), visible=False)\n", diff --git a/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb b/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb index bfba17a1..f13a04fd 100644 --- a/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb +++ b/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb @@ -209,7 +209,7 @@ "\n", "# For the already prepared, I'm using Binomial's conj. prior.\n", "for k, N in enumerate(n_trials):\n", - " sx = plt.subplot(int(len(n_trials)/2), 2, k+1)\n", + " sx = plt.subplot(len(n_trials)//2, 2, k+1)\n", " plt.xlabel(\"$p$, probability of heads\") \\\n", " if k in [0, len(n_trials)-1] else None\n", " plt.setp(sx.get_yticklabels(), visible=False)\n", diff --git a/Chapter1_Introduction/Ch1_Introduction_Pyro.ipynb b/Chapter1_Introduction/Ch1_Introduction_Pyro.ipynb index 914ee7aa..6ee1c268 100644 --- a/Chapter1_Introduction/Ch1_Introduction_Pyro.ipynb +++ b/Chapter1_Introduction/Ch1_Introduction_Pyro.ipynb @@ -166,7 +166,7 @@ "\n", "# For the already prepared, I'm using Binomial's conj. prior.\n", "for k, N in enumerate(n_trials):\n", - " sx = plt.subplot(int(len(n_trials)/2), 2, k+1)\n", + " sx = plt.subplot(len(n_trials)//2, 2, k+1)\n", " plt.xlabel(\"$p$, probability of heads\") \\\n", " if k in [0, len(n_trials)-1] else None\n", " plt.setp(sx.get_yticklabels(), visible=False)\n", diff --git a/Chapter1_Introduction/Ch1_Introduction_TFP.ipynb b/Chapter1_Introduction/Ch1_Introduction_TFP.ipynb index efedd004..96cf0f1a 100644 --- a/Chapter1_Introduction/Ch1_Introduction_TFP.ipynb +++ b/Chapter1_Introduction/Ch1_Introduction_TFP.ipynb @@ -437,7 +437,7 @@ "# For the already prepared, I'm using Binomial's conj. prior.\n", "plt.figure(figsize(16, 9))\n", "for i in range(len(num_trials)):\n", - " sx = plt.subplot(int(len(num_trials)/2), 2, i+1)\n", + " sx = plt.subplot(len(num_trials)//2, 2, i+1)\n", " plt.xlabel(\"$p$, probability of heads\") \\\n", " if i in [0, len(num_trials)-1] else None\n", " plt.setp(sx.get_yticklabels(), visible=False)\n",