Skip to content

Commit

Permalink
Updated for Python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
rlabbe committed Oct 13, 2020
1 parent e27f5b4 commit 91ea4c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
9 changes: 4 additions & 5 deletions 00-Preface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"metadata": {},
"outputs": [],
"source": [
"from __future__ import division, print_function\n",
"%matplotlib inline"
]
},
Expand All @@ -43,7 +42,7 @@
" <style>\n",
" .output_wrapper, .output {\n",
" height:auto !important;\n",
" max-height:100000px; \n",
" max-height:100000px;\n",
" }\n",
" .output_scroll {\n",
" box-shadow:none !important;\n",
Expand Down Expand Up @@ -576,7 +575,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This will only work if you are using Python 3.5+. This book requires 3.5 or later, so I will use it whenever I can. Note that the operator requires that both values are arrays. Hence, `x @ 3.` raises a ValueError whereas `np.dot(X, 3.)` works fine."
"This will only work if you are using Python 3.5+. This book requires 3.6 or later, so I will use it whenever I can. Note that the operator requires that both values are arrays. Hence, `x @ 3.` raises a ValueError whereas `np.dot(X, 3.)` works fine."
]
},
{
Expand Down Expand Up @@ -722,7 +721,7 @@
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x1f04c819fc8>]"
"[<matplotlib.lines.Line2D at 0x1d880f89dc8>]"
]
},
"execution_count": 18,
Expand Down Expand Up @@ -974,7 +973,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.4"
},
"nbdime-conflicts": {
"local_diff": [
Expand Down
27 changes: 6 additions & 21 deletions book_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
for more information.
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)

from contextlib import contextmanager
from IPython.core.display import HTML
import json
Expand Down Expand Up @@ -62,23 +59,16 @@ def test_installation():


v = matplotlib.__version__
min_version = "1.5.0" # this is really old!!!
min_version = "3.0" # this is really old!!!
if LooseVersion(v) < LooseVersion(min_version):
print("Minimum Matplotlib version supported is {}. "
"Please install a more recent version.".format(min_version))

# require Python 2.7, or 3.5+

# require Python 3.6+
import sys
v = sys.version_info
if v.major > 3:
# I guess if we are this far in the future it'll work? Who knows.
# I just don't want to start getting issue reports when Python goes
# to 4.0
return

if (v.major == 2 and v.minor != 7) or (v.major == 3 and v.minor < 5):
print('You must use Python version 2.7 or 3.5+ for the notebooks to work correctly')
if v.major < 3 or (v.major == 3 and v.minor < 6):
print('You must use Python version 3.6 or later for the notebooks to work correctly')


# need to add test for IPython. I think I want to be at 6, which also implies
Expand All @@ -97,11 +87,6 @@ def test_installation():
import matplotlib.pyplot as plt
import numpy as np

# version 1.4.3 of matplotlib has a bug that makes
# it issue a spurious warning on every plot that
# clutters the notebook output
if matplotlib.__version__ == '1.4.3':
warnings.simplefilter(action="ignore", category=FutureWarning)

try:
matplotlib.style.use('default')
Expand Down Expand Up @@ -169,7 +154,7 @@ def set_style():
plt.rcParams.update(style)
except:
pass
np.set_printoptions(suppress=True, precision=3,
np.set_printoptions(suppress=True, precision=3,
threshold=10000., linewidth=70,
formatter={'float':lambda x:' {:.3}'.format(x)})

Expand All @@ -183,7 +168,7 @@ def set_style():
<style>
.output_wrapper, .output {
height:auto !important;
max-height:100000px;
max-height:100000px;
}
.output_scroll {
box-shadow:none !important;
Expand Down

0 comments on commit 91ea4c1

Please sign in to comment.