jfkcooper/HOGBEN

`angle.ipynb` runs a long calculation twice to animate a curve

Opened this issue · 1 comments

angle_range = np.linspace(0.2, 2.3, 50)
time_range = np.linspace(0, time*7, 20)
anim = angle_choice_with_time(sample, angle_1, angle_range, time_range, points, time, save_path)
HTML(anim.to_jshtml(default_mode='reflect')) # Converting to JavaScript HTML requires recalculation.

This should not have to run twice, as it is an expensive calculation

I've done some investigation here, and the problem is simply that the animation is actually only calculated when it is accessed/saved. So in this case that is on anim.save(save_path, writer=writergif) and then once again on anim.to_jshtml(default_mode='reflect').

I don't think we need to save any gifs when working with the Jupyter notebook so the solution is very simply to skip that part of the code in the notebook. So there's a few things we can do, but my instinct goes towards making this a bit more modular. In other words, splitting the saving of the animation to a gif from the code that saves said animation as an animation.

Another way is a bit more ugly imo, but but we can just put an argument in the function. "save_gif=True", which we can set as conditional to save the gif.