Updated to use absolute imports
I used to add .\code to the path, which was an absurd hack. Now all code is imported with import code.foo.
This commit is contained in:
parent
fa62edccc4
commit
6f1fd2f16f
File diff suppressed because one or more lines are too long
@ -1174,8 +1174,8 @@
|
||||
],
|
||||
"source": [
|
||||
"from book_format import figsize, set_figsize\n",
|
||||
"import book_plots as bp\n",
|
||||
"from book_plots import interactive_plot\n",
|
||||
"import code.book_plots as bp\n",
|
||||
"from code.book_plots import interactive_plot\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"\n",
|
||||
"belief = np.array([1/3, 1/3, 0, 0, 0, 0, 0, 0, 1/3, 0])\n",
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -50,7 +50,7 @@
|
||||
" font-family: 'Source Code Pro', Consolas, monocco, monospace;\n",
|
||||
"}\n",
|
||||
" div.cell{\n",
|
||||
" width: 850px;\n",
|
||||
" //width: 950px;\n",
|
||||
" margin-left: 0% !important;\n",
|
||||
" margin-right: auto;\n",
|
||||
" }\n",
|
||||
@ -64,7 +64,7 @@
|
||||
" //font-family: 'Chivo',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Cardo',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Arvo',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Poppins',verdana,arial,sans-serif; \n",
|
||||
" //font-family: 'Poppins',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Ubuntu',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Fontin',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Raleway',verdana,arial,sans-serif;\n",
|
||||
@ -88,10 +88,10 @@
|
||||
" h1 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
"\t}\n",
|
||||
"\t\n",
|
||||
"\n",
|
||||
" div.input_area {\n",
|
||||
" background: #F6F6F9;\n",
|
||||
" border: 1px solid #586e75; \n",
|
||||
" border: 1px solid #586e75;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .text_cell_render h1 {\n",
|
||||
@ -104,7 +104,7 @@
|
||||
" display: block;\n",
|
||||
" white-space: wrap;\n",
|
||||
" text-align: left;\n",
|
||||
" } \n",
|
||||
" }\n",
|
||||
" h2 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" text-align: left;\n",
|
||||
@ -120,7 +120,7 @@
|
||||
" display: block;\n",
|
||||
" white-space: wrap;\n",
|
||||
" text-align: left;\n",
|
||||
" } \n",
|
||||
" }\n",
|
||||
" h3 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
@ -187,42 +187,38 @@
|
||||
" margin: 2em;\n",
|
||||
" }\n",
|
||||
" ul li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.5em; \n",
|
||||
" padding-left: 0.5em;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.5em;\n",
|
||||
" }\n",
|
||||
" ul li li{\n",
|
||||
" padding-left: 0.2em; \n",
|
||||
" margin-bottom: 0.2em; \n",
|
||||
" margin-top: 0.2em; \n",
|
||||
" padding-left: 0.2em;\n",
|
||||
" margin-bottom: 0.2em;\n",
|
||||
" margin-top: 0.2em;\n",
|
||||
" }\n",
|
||||
" ol{\n",
|
||||
" margin: 2em;\n",
|
||||
" }\n",
|
||||
" ol li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.5em; \n",
|
||||
" padding-left: 0.5em;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.5em;\n",
|
||||
" }\n",
|
||||
" ul li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.2em; \n",
|
||||
" padding-left: 0.5em;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.2em;\n",
|
||||
" }\n",
|
||||
" a:link{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" a:visited{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" }\n",
|
||||
" a:hover{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" }\n",
|
||||
" a:focus{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" a:active{\n",
|
||||
@ -230,10 +226,10 @@
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" .rendered_html :link {\n",
|
||||
" text-decoration: underline; \n",
|
||||
" text-decoration: underline;\n",
|
||||
" }\n",
|
||||
" .rendered_html :hover {\n",
|
||||
" text-decoration: none; \n",
|
||||
" text-decoration: none;\n",
|
||||
" }\n",
|
||||
" .rendered_html :visited {\n",
|
||||
" text-decoration: none;\n",
|
||||
@ -246,7 +242,7 @@
|
||||
" }\n",
|
||||
" .warning{\n",
|
||||
" color: rgb( 240, 20, 20 )\n",
|
||||
" } \n",
|
||||
" }\n",
|
||||
" hr {\n",
|
||||
" color: #f3f3f3;\n",
|
||||
" background-color: #f3f3f3;\n",
|
||||
|
@ -40,7 +40,6 @@ if matplotlib.__version__ == '1.4.3':
|
||||
warnings.simplefilter(action="ignore", category=FutureWarning)
|
||||
|
||||
np.set_printoptions(precision=3)
|
||||
sys.path.insert(0, './code') # allow us to import code
|
||||
|
||||
def test_filterpy_version():
|
||||
|
||||
|
@ -16,7 +16,7 @@ for more information.
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
import book_plots as bp
|
||||
import code.book_plots as bp
|
||||
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow, FancyArrow
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function,
|
||||
|
||||
from book_format import figsize
|
||||
from contextlib import contextmanager
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import sys
|
||||
@ -30,24 +31,42 @@ try:
|
||||
except:
|
||||
pass
|
||||
|
||||
sys.path.insert(0, '..')
|
||||
""" If the plot is inline (%matplotlib inline) we need to
|
||||
do special processing for the interactive_plot context manager,
|
||||
otherwise it outputs a lot of extra <matplotlib.figure.figure
|
||||
type output into the notebook."""
|
||||
|
||||
IS_INLINE = mpl.get_backend().find('backend_inline') != -1
|
||||
|
||||
|
||||
def end_interactive(fig):
|
||||
""" end interaction in a plot created with %matplotlib notebook """
|
||||
plt.gcf().canvas.draw()
|
||||
|
||||
if IS_INLINE:
|
||||
return
|
||||
|
||||
fig.canvas.draw()
|
||||
time.sleep(1.)
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
|
||||
@contextmanager
|
||||
def interactive_plot(close=True, fig=None):
|
||||
if fig is None:
|
||||
if fig is None and not IS_INLINE:
|
||||
fig = plt.figure()
|
||||
|
||||
yield
|
||||
plt.tight_layout()
|
||||
if close:
|
||||
try:
|
||||
# if the figure only uses annotations tight_output
|
||||
# throws an exception
|
||||
if not IS_INLINE: plt.tight_layout()
|
||||
except:
|
||||
pass
|
||||
|
||||
if not IS_INLINE:
|
||||
plt.show()
|
||||
|
||||
if close and not IS_INLINE:
|
||||
end_interactive(fig)
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ for more information.
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
import book_plots as bp
|
||||
import code.book_plots as bp
|
||||
import filterpy.kalman as kf
|
||||
from math import radians, sin, cos, sqrt, exp
|
||||
import matplotlib.pyplot as plt
|
||||
|
@ -16,18 +16,14 @@ for more information.
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
import book_plots
|
||||
|
||||
import code.book_plots as book_plots
|
||||
import numpy as np
|
||||
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow, FancyArrow
|
||||
import pylab as plt
|
||||
import time
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def plot_gh_results(weights, estimates, predictions, time_step=0):
|
||||
|
||||
n = len(weights)
|
||||
|
@ -16,7 +16,7 @@ for more information.
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
import book_plots as bp
|
||||
import code.book_plots as bp
|
||||
import filterpy.stats as stats
|
||||
from math import sqrt
|
||||
import matplotlib.pyplot as plt
|
||||
|
@ -16,7 +16,8 @@ for more information.
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
import book_plots as bp
|
||||
import code.book_plots as bp
|
||||
from code.book_plots import interactive_plot
|
||||
import filterpy.stats as stats
|
||||
from filterpy.stats import plot_covariance_ellipse
|
||||
from matplotlib.patches import Ellipse
|
||||
@ -417,7 +418,6 @@ def plot_correlation_covariance():
|
||||
plt.title('|4.0 3.9|\n|3.9 4.0|')
|
||||
plt.show()
|
||||
|
||||
from book_plots import interactive_plot
|
||||
|
||||
def plot_track(ps, actual, zs, cov, std_scale=1,
|
||||
plot_P=True, y_lim=None, dt=1.,
|
||||
|
@ -17,7 +17,7 @@ from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
|
||||
from book_plots import figsize, end_interactive
|
||||
from code.book_plots import figsize, end_interactive
|
||||
from filterpy.monte_carlo import stratified_resample, residual_resample
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pyplot as plt
|
||||
|
Loading…
Reference in New Issue
Block a user