Skip to content

Commit 6fc2c0e

Browse files
committed
clean up tutorial notebook
__
1 parent 6b43a9b commit 6fc2c0e

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

docs/tutorial/getting_started.ipynb

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131
"collapsed": true
3232
},
3333
"outputs": [],
34+
"source": [
35+
"%matplotlib inline"
36+
]
37+
},
38+
{
39+
"cell_type": "code",
40+
"execution_count": null,
41+
"metadata": {
42+
"collapsed": false
43+
},
44+
"outputs": [],
3445
"source": [
3546
"import warnings\n",
3647
"warnings.simplefilter('ignore')\n",
@@ -41,8 +52,7 @@
4152
"import seaborn\n",
4253
"\n",
4354
"clear_bkgd = {'axes.facecolor':'none', 'figure.facecolor':'none'}\n",
44-
"seaborn.set(style='ticks', context='notebook', rc=clear_bkgd)\n",
45-
"%matplotlib inline"
55+
"seaborn.set(style='ticks', context='notebook', rc=clear_bkgd)"
4656
]
4757
},
4858
{
@@ -94,7 +104,7 @@
94104
"ax2.set_xlabel(\"Base 2\")\n",
95105
"ax2.set_yticks([])\n",
96106
"\n",
97-
"seaborn.despine(fig=fig, left=True)\n"
107+
"seaborn.despine(fig=fig, left=True)"
98108
]
99109
},
100110
{
@@ -133,14 +143,15 @@
133143
"cell_type": "markdown",
134144
"metadata": {},
135145
"source": [
136-
"It works after importing. Probability scales default to the standard normal distribution. Not that the formatting is a percentage-based probability."
146+
"To access probability scales, simply import :py:mod:`probscale`."
137147
]
138148
},
139149
{
140150
"cell_type": "code",
141151
"execution_count": null,
142152
"metadata": {
143-
"collapsed": false
153+
"collapsed": false,
154+
"scrolled": false
144155
},
145156
"outputs": [],
146157
"source": [
@@ -156,9 +167,11 @@
156167
"cell_type": "markdown",
157168
"metadata": {},
158169
"source": [
170+
"Probability scales default to the standard normal distribution (ote that the formatting is a percentage-based probability)\n",
171+
"\n",
159172
"You can even use different probability distributions, though it can be tricky. You have to pass a frozen distribution to the `dist` kwarg in `ax.set_[x|y]scale`.\n",
160173
"\n",
161-
"Here's a standard normal scale right next to a beta scale ($\\alpha = 1$ and $\\beta = 1$) for comparison"
174+
"Here's a standard normal scale right next to two different beta scales for comparison"
162175
]
163176
},
164177
{
@@ -171,9 +184,7 @@
171184
"outputs": [],
172185
"source": [
173186
"import paramnormal\n",
174-
"\n",
175-
"beta1 = paramnormal.beta(α=3, β=2)\n",
176-
"beta2 = paramnormal.beta(α=2, β=7)\n",
187+
"seaborn.set(style='ticks', context='notebook', rc=clear_bkgd)\n",
177188
"\n",
178189
"fig, (ax1, ax2, ax3, ax4) = pyplot.subplots(figsize=(8, 5), nrows=4)\n",
179190
"\n",
@@ -182,11 +193,13 @@
182193
"ax1.set_xlabel('Normal probability scale')\n",
183194
"ax1.set_yticks([])\n",
184195
"\n",
196+
"beta1 = paramnormal.beta(α=3, β=2)\n",
185197
"ax2.set_xscale('prob', dist=beta1)\n",
186198
"ax2.set_xlim(left=2, right=98)\n",
187199
"ax2.set_xlabel('Beta probability scale (α=3, β=2)')\n",
188200
"ax2.set_yticks([])\n",
189201
"\n",
202+
"beta2 = paramnormal.beta(α=2, β=7)\n",
190203
"ax3.set_xscale('prob', dist=beta2)\n",
191204
"ax3.set_xlim(left=2, right=98)\n",
192205
"ax3.set_xlabel('Beta probability scale (α=2, β=7)')\n",
@@ -197,7 +210,7 @@
197210
"ax4.set_xlabel('Linear scale (for reference)')\n",
198211
"ax4.set_yticks([])\n",
199212
"\n",
200-
"seaborn.despine(fig=fig, left=True)\n"
213+
"seaborn.despine(fig=fig, left=True)"
201214
]
202215
},
203216
{
@@ -292,10 +305,17 @@
292305
"metadata": {},
293306
"source": [
294307
"### Percentile and Quanitile plots\n",
295-
"For convenience, you can do percetile and quantile plots with the same function.\n",
296-
"\n",
308+
"For convenience, you can do percetile and quantile plots with the same function."
309+
]
310+
},
311+
{
312+
"cell_type": "raw",
313+
"metadata": {},
314+
"source": [
297315
".. note::\n",
298-
" The percentile and probability axes are plotted against the same values. The difference is only that \"percentiles\" are plotted on a linear scale."
316+
" The percentile and probability axes are plotted against the\n",
317+
" same values. The difference is only that \"percentiles\" \n",
318+
" are plotted on a linear scale."
299319
]
300320
},
301321
{
@@ -334,4 +354,4 @@
334354
},
335355
"nbformat": 4,
336356
"nbformat_minor": 0
337-
}
357+
}

probscale/probscale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
)
1212

1313

14-
def _mask_non_prop(a):
14+
def _mask_non_positives(a):
1515
"""
1616
Return a Numpy array where all values outside ]0, 1[ are
1717
replaced with NaNs. If all values are inside ]0, 1[, the original

probscale/viz.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ def probplot(data, ax=None, axtype='prob', probax='x',
136136

137137

138138
def _fit_line(x, y, xhat=None, fitprobs=None, fitlogs=None, dist=None):
139-
""" Fits a line to x-y data in various forms (raw, log, prob scales)
139+
"""
140+
Fits a line to x-y data in various forms (linear, log, prob scales).
140141
141142
Parameters
142143
----------

0 commit comments

Comments
 (0)