"""The plot helpers draw without error (Agg backend).""" import matplotlib matplotlib.use("Agg") import numpy as np # noqa: E402 from cymsim import Listener, Plate, Strike, compute_modes, make_grid, plot, presets, synthesize # noqa: E402 from conftest import STEEL_LOSSY # noqa: E402 def test_plots(): pl = Plate.uniform(make_grid(0.2, 0.15, 0.0125), STEEL_LOSSY, 1e-3) ms = compute_modes(pl, 4000) s = synthesize(ms, Strike(), Listener(), duration=0.1, movie=True) plot.plate(pl, strike=Strike(), listener=Listener()) plot.plate(presets.crash_bell_16().evaluate(0.02)) plot.mode(ms, 0) plot.frame(s, 3) plot.signal(s, tmax=0.05) plot.spectrogram(s, modes=ms, window=512, hop=128) plot.spectrogram(s.spectrogram(512, 128), log_freq=False) plot.decay_times(ms) plot.force(s) anim = plot.animate(s, stride=4) assert anim is not None assert np.isfinite(s.pressure).all()