Exporting

It’s easy.

save

Setting save will save the animation to disk and show it inline.

[1]:
import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], save='exporting_tutorial.gif').render()
[########################################] | 100% Completed |  5.7s
gifsicle: warning: trivial adaptive palette (only 206 colors in source)
[1]:

fmt

fmt does not have to be explicitly set; if save is suffixed with a file format, it will use that, else if save is not suffixed with any file format, it will default to gif.

import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], save='exporting_tutorial').render()

However, fmt can be explicitly set as well. For example, to save as a video, set fmt as mp4, but note imageio-ffmpeg is required, e.g. pip install imageio-ffmpeg.

import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], save='exporting_tutorial', fmt='mp4').render()

show

To disable showing inline, set show to False. If save is set, will still save to disk.

import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], show=False).render()

pygifsicle

Reduce file size of an output GIF by setting pygifiscle to True. If save is not set, will write a temporary file in the current working directory.

For this to work, pip install pygifsicle and conda install gifsicle.

import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], pygifsicle=True).render()

workers

By default, ahlive uses a single thread to output each frame, but supports multiple processors through workers.

import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], workers=1).render()

scheduler

Sometimes, scheduler='single-threaded' is more efficient than scheduler=processors if your dataset is large.

import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], scheduler='single-threaded').render()