From 875efa0d3bb4ef682b736f92816a75fc378d5a6e Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Fri, 4 Sep 2020 12:56:04 +0100 Subject: [PATCH] Sort imports in another 9 notebooks (#4074) * another 10 notebooks * 10th notebook * put magic at bottom of cell * separate first-party imports --- docs/source/notebooks/GLM-robust.ipynb | 4 +--- docs/source/notebooks/GP-MeansAndCovs.ipynb | 12 ++++++------ .../notebooks/bayes_param_survival_pymc3.ipynb | 3 ++- .../notebooks/dependent_density_regression.ipynb | 9 +++++---- docs/source/notebooks/dp_mix.ipynb | 2 +- docs/source/notebooks/factor_analysis.ipynb | 5 +++-- docs/source/notebooks/getting_started.ipynb | 4 +++- docs/source/notebooks/multilevel_modeling.ipynb | 3 ++- .../probabilistic_matrix_factorization.ipynb | 11 ++++++----- 9 files changed, 29 insertions(+), 24 deletions(-) diff --git a/docs/source/notebooks/GLM-robust.ipynb b/docs/source/notebooks/GLM-robust.ipynb index 3105205e3a4..e591436f6b6 100644 --- a/docs/source/notebooks/GLM-robust.ipynb +++ b/docs/source/notebooks/GLM-robust.ipynb @@ -40,11 +40,9 @@ "source": [ "%matplotlib inline\n", "\n", - "import pymc3 as pm\n", - "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "\n", + "import pymc3 as pm\n", "import theano" ] }, diff --git a/docs/source/notebooks/GP-MeansAndCovs.ipynb b/docs/source/notebooks/GP-MeansAndCovs.ipynb index 21301b1c73b..0be730c7c72 100644 --- a/docs/source/notebooks/GP-MeansAndCovs.ipynb +++ b/docs/source/notebooks/GP-MeansAndCovs.ipynb @@ -11,16 +11,16 @@ }, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", "import matplotlib.cm as cmap\n", - "%matplotlib inline\n", - "\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "np.random.seed(206)\n", - "\n", + "import pymc3 as pm\n", "import theano\n", "import theano.tensor as tt\n", - "import pymc3 as pm" + "\n", + "%matplotlib inline\n", + "\n", + "np.random.seed(206)" ] }, { diff --git a/docs/source/notebooks/bayes_param_survival_pymc3.ipynb b/docs/source/notebooks/bayes_param_survival_pymc3.ipynb index 57537dab5c6..4f38de7248e 100644 --- a/docs/source/notebooks/bayes_param_survival_pymc3.ipynb +++ b/docs/source/notebooks/bayes_param_survival_pymc3.ipynb @@ -30,7 +30,8 @@ "from matplotlib import pyplot as plt\n", "from matplotlib.ticker import StrMethodFormatter\n", "from statsmodels import datasets\n", - "from theano import shared, tensor as tt\n", + "from theano import shared\n", + "from theano import tensor as tt\n", "\n", "print('Running on PyMC3 v{}'.format(pm.__version__))" ] diff --git a/docs/source/notebooks/dependent_density_regression.ipynb b/docs/source/notebooks/dependent_density_regression.ipynb index 456ebd0f3ed..c3214c9193d 100644 --- a/docs/source/notebooks/dependent_density_regression.ipynb +++ b/docs/source/notebooks/dependent_density_regression.ipynb @@ -39,8 +39,10 @@ "import seaborn as sns\n", "\n", "from IPython.display import HTML\n", - "from matplotlib import animation as ani, pyplot as plt\n", - "from theano import shared, tensor as tt\n", + "from matplotlib import animation as ani\n", + "from matplotlib import pyplot as plt\n", + "from theano import shared\n", + "from theano import tensor as tt\n", "\n", "print('Running on PyMC3 v{}'.format(pm.__version__))" ] @@ -1109,8 +1111,7 @@ "\n", "with model:\n", " step = pm.Metropolis()\n", - " trace = pm.sample(SAMPLES, step, chains=1, tune=BURN, random_seed=SEED)\n", - " " + " trace = pm.sample(SAMPLES, step, chains=1, tune=BURN, random_seed=SEED)" ] }, { diff --git a/docs/source/notebooks/dp_mix.ipynb b/docs/source/notebooks/dp_mix.ipynb index f494f962287..7f1d5eb5024 100644 --- a/docs/source/notebooks/dp_mix.ipynb +++ b/docs/source/notebooks/dp_mix.ipynb @@ -82,8 +82,8 @@ "import numpy as np\n", "import pandas as pd\n", "import pymc3 as pm\n", - "import seaborn as sns\n", "import scipy as sp\n", + "import seaborn as sns\n", "\n", "from matplotlib import pyplot as plt\n", "from theano import tensor as tt\n", diff --git a/docs/source/notebooks/factor_analysis.ipynb b/docs/source/notebooks/factor_analysis.ipynb index b348d140f4d..3332131514a 100644 --- a/docs/source/notebooks/factor_analysis.ipynb +++ b/docs/source/notebooks/factor_analysis.ipynb @@ -14,17 +14,18 @@ } ], "source": [ + "import warnings\n", + "\n", "import arviz as az\n", "import matplotlib\n", "import numpy as np\n", "import pymc3 as pm\n", - "import seaborn as sbn\n", "import scipy as sp\n", "import scipy.sparse\n", "import scipy.sparse.linalg\n", + "import seaborn as sbn\n", "import theano as T\n", "import theano.tensor as tt\n", - "import warnings\n", "\n", "from matplotlib import pyplot as plt\n", "\n", diff --git a/docs/source/notebooks/getting_started.ipynb b/docs/source/notebooks/getting_started.ipynb index 5c16d6ef461..c2fdcb153b7 100644 --- a/docs/source/notebooks/getting_started.ipynb +++ b/docs/source/notebooks/getting_started.ipynb @@ -875,6 +875,7 @@ ], "source": [ "import warnings\n", + "\n", "with warnings.catch_warnings():\n", " warnings.filterwarnings('ignore', category=UserWarning)\n", " returns.plot(figsize=(10, 6))\n", @@ -3407,7 +3408,7 @@ " labels = [label.get_text() for label in ax.get_xticklabels()]\n", " ax.set_xticklabels(labels, rotation=45, ha='right')\n", " break\n", - "plt.draw() " + "plt.draw()" ] }, { @@ -3491,6 +3492,7 @@ "outputs": [], "source": [ "import theano.tensor as tt\n", + "\n", "from theano.compile.ops import as_op\n", "\n", "\n", diff --git a/docs/source/notebooks/multilevel_modeling.ipynb b/docs/source/notebooks/multilevel_modeling.ipynb index 638b02cebbe..af61e709981 100644 --- a/docs/source/notebooks/multilevel_modeling.ipynb +++ b/docs/source/notebooks/multilevel_modeling.ipynb @@ -64,13 +64,14 @@ } ], "source": [ + "import warnings\n", + "\n", "import arviz as az\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", "import pymc3 as pm\n", "import xarray as xr\n", - "import warnings\n", "\n", "from theano import tensor as tt\n", "\n", diff --git a/docs/source/notebooks/probabilistic_matrix_factorization.ipynb b/docs/source/notebooks/probabilistic_matrix_factorization.ipynb index 9db22bb635d..cfd6ca06e69 100644 --- a/docs/source/notebooks/probabilistic_matrix_factorization.ipynb +++ b/docs/source/notebooks/probabilistic_matrix_factorization.ipynb @@ -22,9 +22,10 @@ ], "source": [ "%matplotlib inline\n", - "import pymc3 as pm\n", "import numpy as np\n", "import pandas as pd\n", + "import pymc3 as pm\n", + "\n", "from matplotlib import pyplot as plt\n", "\n", "plt.style.use('seaborn-darkgrid')\n", @@ -767,11 +768,11 @@ "metadata": {}, "outputs": [], "source": [ - "import time\n", "import logging\n", - "import theano\n", - "import scipy as sp\n", + "import time\n", "\n", + "import scipy as sp\n", + "import theano\n", "\n", "# Enable on-the-fly graph computations, but ignore\n", "# absence of intermediate test values.\n", @@ -1056,7 +1057,7 @@ " Method = baseline_methods[name]\n", " method = Method(train)\n", " baselines[name] = method.rmse(test)\n", - " print('%s RMSE:\\t%.5f' % (method, baselines[name]))\n" + " print('%s RMSE:\\t%.5f' % (method, baselines[name]))" ] }, {