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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user