Skip to content

Commit 4deaa06

Browse files
committed
Suppressed spurious deprecation
Matplotlib emits deprecation when you copy rcParams, which is foolish, so I suppressed it.
1 parent 6181e6e commit 4deaa06

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

12-Particle-Filters.ipynb

Lines changed: 1 addition & 22 deletions
Large diffs are not rendered by default.

kf_book/pf_internal.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
unicode_literals)
1818

1919

20+
import warnings
21+
2022
from filterpy.monte_carlo import stratified_resample, residual_resample
2123
import matplotlib as mpl
2224
import matplotlib.pyplot as plt
@@ -112,13 +114,17 @@ def sigmoid(x, x0, alpha):
112114
.5*norm(x, .5, .08) +
113115
np.sqrt(norm(x, 0.8, 0.06)) +0.1 * (1 - sigmoid(x, 0.45, 0.15)))
114116

115-
# hack because of bug `with plt.xkcd()` doesn't return context correctly
116-
saved_state = mpl.rcParams.copy()
117-
plt.xkcd()
118-
plt.axes(xticks=[], yticks=[], frameon=False)
119-
plt.plot(x, y2)
120-
plt.ylim([0, max(y2)+.1])
121-
mpl.rcParams.update(saved_state)
117+
with warnings.catch_warnings():
118+
# matplotlib warns about deprecated rcParams when you copy. Oye.
119+
warnings.simplefilter("ignore", mpl.MatplotlibDeprecationWarning)
120+
121+
# hack because of bug `with plt.xkcd()` doesn't return context correctly
122+
saved_state = mpl.rcParams.copy()
123+
plt.xkcd()
124+
plt.axes(xticks=[], yticks=[], frameon=False)
125+
plt.plot(x, y2)
126+
plt.ylim([0, max(y2)+.1])
127+
mpl.rcParams.update(saved_state)
122128

123129

124130
def plot_monte_carlo_ukf():

0 commit comments

Comments
 (0)