Skip to content

Commit 9b1f3e5

Browse files
authored
CLN, STYLE fix imports in gp-maunaloa until rugby analytics (#4079)
* fix gp-maunaloa until rugby analytics * move %env after imports
1 parent 3159da7 commit 9b1f3e5

10 files changed

+58
-34
lines changed

docs/source/notebooks/GP-MaunaLoa.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,10 @@
383383
"import pymc3 as pm\n",
384384
"import theano.tensor as tt\n",
385385
"\n",
386-
"from bokeh.plotting import figure, show\n",
387-
"from bokeh.models import BoxAnnotation, Span, Label, Legend\n",
388386
"from bokeh.io import output_notebook\n",
387+
"from bokeh.models import BoxAnnotation, Label, Legend, Span\n",
389388
"from bokeh.palettes import brewer\n",
389+
"from bokeh.plotting import figure, show\n",
390390
"\n",
391391
"output_notebook()"
392392
]

docs/source/notebooks/GP-MaunaLoa2.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,9 +1550,10 @@
15501550
"metadata": {},
15511551
"outputs": [],
15521552
"source": [
1553-
"from datetime import datetime as dt\n",
15541553
"import time\n",
15551554
"\n",
1555+
"from datetime import datetime as dt\n",
1556+
"\n",
15561557
"\n",
15571558
"def toYearFraction(date):\n",
15581559
" date = pd.to_datetime(date)\n",

docs/source/notebooks/GP-TProcess.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
}
4141
],
4242
"source": [
43+
"import matplotlib.pyplot as plt\n",
44+
"import numpy as np\n",
4345
"import pymc3 as pm\n",
4446
"import theano.tensor as tt\n",
45-
"import numpy as np\n",
4647
"\n",
47-
"import matplotlib.pyplot as plt\n",
4848
"%matplotlib inline"
4949
]
5050
},
@@ -298,6 +298,7 @@
298298
"source": [
299299
"fig = plt.figure(figsize=(12,5)); ax = fig.gca()\n",
300300
"from pymc3.gp.util import plot_gp_dist\n",
301+
"\n",
301302
"plot_gp_dist(ax, np.square(pred_samples[\"f_pred\"]), X_new);\n",
302303
"plt.plot(X, np.square(f_true), \"dodgerblue\", lw=3, label=\"True f\");\n",
303304
"plt.plot(X, y, 'ok', ms=3, alpha=0.5, label=\"Observed data\");\n",

docs/source/notebooks/ODE_API_shapes_and_benchmarking.ipynb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"outputs": [],
1818
"source": [
1919
"import os\n",
20+
"\n",
2021
"os.environ[\"THEANO_FLAGS\"] = \"floatX=float64\""
2122
]
2223
},
@@ -27,14 +28,15 @@
2728
"outputs": [],
2829
"source": [
2930
"import logging\n",
30-
"import numpy as np\n",
31-
"import matplotlib.pyplot as plt\n",
32-
"from scipy.integrate import odeint\n",
3331
"\n",
32+
"import matplotlib.pyplot as plt\n",
33+
"import numpy as np\n",
3434
"import pymc3 as pm\n",
3535
"import theano\n",
3636
"import theano.tensor as tt\n",
3737
"\n",
38+
"from scipy.integrate import odeint\n",
39+
"\n",
3840
"# this notebook show DEBUG log messages\n",
3941
"logging.getLogger('pymc3').setLevel(logging.DEBUG)\n",
4042
"\n",
@@ -318,6 +320,7 @@
318320
"outputs": [],
319321
"source": [
320322
"from theano import d3viz\n",
323+
"\n",
321324
"d3viz.d3viz(model.logpt, 'ODE_API_shapes_and_benchmarking.html')"
322325
]
323326
},

docs/source/notebooks/ODE_with_manual_gradients.ipynb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"from scipy.integrate import odeint\n",
10-
"import numpy as np\n",
11-
"import theano \n",
12-
"from theano import *\n",
139
"import matplotlib.pyplot as plt\n",
10+
"import numpy as np\n",
1411
"import pymc3 as pm\n",
12+
"import theano\n",
13+
"\n",
14+
"from scipy.integrate import odeint\n",
15+
"from theano import *\n",
1516
"\n",
1617
"THEANO_FLAGS='optimizer=fast_compile'"
1718
]
@@ -657,6 +658,7 @@
657658
],
658659
"source": [
659660
"import pandas as pd\n",
661+
"\n",
660662
"summary = pm.summary(trace)\n",
661663
"STAN_mus = [0.549, 0.028, 0.797, 0.024, 33.960, 5.949, 0.248, 0.252]\n",
662664
"STAN_sds = [0.065, 0.004, 0.091, 0.004, 2.909, 0.533, 0.045, 0.044]\n",
@@ -856,8 +858,10 @@
856858
"outputs": [],
857859
"source": [
858860
"import theano.tensor as tt\n",
861+
"\n",
859862
"from theano.compile.ops import as_op\n",
860863
"\n",
864+
"\n",
861865
"@as_op(itypes=[tt.dscalar,tt.dscalar,tt.dscalar], otypes=[tt.dmatrix])\n",
862866
"def th_forward_model(param1,param2,param3):\n",
863867
" \n",

docs/source/notebooks/hierarchical_partial_pooling.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"import pandas as pd\n",
5454
"import pymc3 as pm\n",
5555
"import theano.tensor as tt\n",
56+
"\n",
5657
"%matplotlib inline"
5758
]
5859
},

docs/source/notebooks/lasso_block_update.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
"outputs": [],
2121
"source": [
2222
"%matplotlib inline\n",
23+
"import numpy as np\n",
24+
"\n",
2325
"from matplotlib.pylab import *\n",
24-
"from pymc3 import * \n",
25-
"import numpy as np \n",
26+
"from pymc3 import *\n",
2627
"\n",
2728
"d = np.random.normal(size=(3, 30))\n",
2829
"d1 = d[0] + 4\n",

docs/source/notebooks/lda-advi-aevb.ipynb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,31 @@
3636
],
3737
"source": [
3838
"%matplotlib inline\n",
39-
"import sys, os\n",
40-
"# unfortunately I was not able to run it on GPU due to overflow problems\n",
41-
"%env THEANO_FLAGS=device=cpu,floatX=float64\n",
42-
"import theano\n",
39+
"import os\n",
40+
"import sys\n",
4341
"\n",
4442
"from collections import OrderedDict\n",
4543
"from copy import deepcopy\n",
46-
"import numpy as np\n",
4744
"from time import time\n",
48-
"from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer\n",
49-
"from sklearn.datasets import fetch_20newsgroups\n",
45+
"\n",
5046
"import matplotlib.pyplot as plt\n",
47+
"import numpy as np\n",
48+
"import pymc3 as pm\n",
5149
"import seaborn as sns\n",
52-
"from theano import shared\n",
50+
"import theano\n",
5351
"import theano.tensor as tt\n",
54-
"from theano.sandbox.rng_mrg import MRG_RandomStreams\n",
5552
"\n",
56-
"import pymc3 as pm\n",
57-
"from pymc3 import math as pmmath\n",
5853
"from pymc3 import Dirichlet\n",
54+
"from pymc3 import math as pmmath\n",
5955
"from pymc3.distributions.transforms import t_stick_breaking\n",
56+
"from sklearn.datasets import fetch_20newsgroups\n",
57+
"from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer\n",
58+
"from theano import shared\n",
59+
"from theano.sandbox.rng_mrg import MRG_RandomStreams\n",
60+
"\n",
61+
"# unfortunately I was not able to run it on GPU due to overflow problems\n",
62+
"%env THEANO_FLAGS=device=cpu,floatX=float64\n",
63+
"\n",
6064
"plt.style.use('seaborn-darkgrid')"
6165
]
6266
},

docs/source/notebooks/normalizing_flows_overview.ipynb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
"outputs": [],
2424
"source": [
2525
"%matplotlib inline\n",
26+
"from collections import Counter\n",
27+
"\n",
2628
"import matplotlib.pyplot as plt\n",
27-
"import seaborn as sns\n",
28-
"import pymc3 as pm\n",
2929
"import numpy as np\n",
30+
"import pymc3 as pm\n",
31+
"import seaborn as sns\n",
3032
"import theano\n",
3133
"import theano.tensor as tt\n",
32-
"from collections import Counter\n",
3334
"\n",
3435
"pm.set_tt_rng(42)\n",
3536
"np.random.seed(42)"
@@ -392,6 +393,8 @@
392393
"outputs": [],
393394
"source": [
394395
"from pymc3.distributions.dist_math import bound\n",
396+
"\n",
397+
"\n",
395398
"def cust_logp(z):\n",
396399
" #return bound(-pot1(z), z>-5, z<5)\n",
397400
" return -pot1(z)\n",
@@ -648,9 +651,10 @@
648651
"metadata": {},
649652
"outputs": [],
650653
"source": [
651-
"from collections import defaultdict, OrderedDict\n",
654+
"from collections import OrderedDict, defaultdict\n",
652655
"from itertools import count\n",
653656
"\n",
657+
"\n",
654658
"@theano.configparser.change_flags(compute_test_value='off')\n",
655659
"def get_tracker(inference):\n",
656660
" numbers = defaultdict(count)\n",

docs/source/notebooks/rugby_analytics.ipynb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,19 @@
4444
"\n",
4545
"import numpy as np\n",
4646
"import pandas as pd\n",
47+
"\n",
4748
"try:\n",
4849
" from StringIO import StringIO\n",
4950
"except ImportError:\n",
5051
" from io import StringIO\n",
51-
"import pymc3 as pm, theano.tensor as tt\n",
52+
"\n",
5253
"import matplotlib.pyplot as plt\n",
53-
"from matplotlib.ticker import StrMethodFormatter\n",
54+
"import pymc3 as pm\n",
5455
"import seaborn as sns\n",
56+
"import theano.tensor as tt\n",
57+
"\n",
58+
"from matplotlib.ticker import StrMethodFormatter\n",
59+
"\n",
5560
"%matplotlib inline"
5661
]
5762
},
@@ -349,7 +354,7 @@
349354
" \n",
350355
" .plot(kind='bar', title='Average magnitude of scores difference Six Nations', yerr=df_all.groupby('year')['difference'].std())\n",
351356
" .set_ylabel('Average (abs) point difference'));\n",
352-
" \n"
357+
" "
353358
]
354359
},
355360
{
@@ -512,7 +517,7 @@
512517
" .rename_axis(\"Home_Team\")\n",
513518
" .plot(kind='bar', rot=0, legend=False)\n",
514519
" .set_ylabel('Score difference Home team and away team')\n",
515-
");\n"
520+
");"
516521
]
517522
},
518523
{
@@ -545,7 +550,7 @@
545550
" .rename_axis(\"Away_Team\")\n",
546551
" .plot(kind='bar', rot=0, legend=False)\n",
547552
" .set_ylabel('Score difference Home team and away team')\n",
548-
");\n"
553+
");"
549554
]
550555
},
551556
{

0 commit comments

Comments
 (0)