boofun.visualization.animation

Animation utilities for Boolean function visualization.

This module provides tools for creating animations showing how properties of Boolean functions change as n increases.

Supports: - Matplotlib animations (GIF, MP4) - Plotly animations (HTML)

Functions

animate_fourier_spectrum(family[, n_range, ...])

Animate Fourier spectrum (spectral weight by degree) as n grows.

animate_growth(family[, property_name, n_range])

Convenience function to create a growth animation.

animate_influences(family[, n_range])

Convenience function to animate influence distribution.

create_growth_animation(family[, ...])

Create multi-panel animation showing multiple properties.

Classes

GrowthAnimator(family)

Create animations showing function properties as n grows.

boofun.visualization.animation.animate_growth(family: FunctionFamily, property_name: str = 'total_influence', n_range: Tuple[int, int, int] = (3, 15, 2), **kwargs) animation.FuncAnimation[source]

Convenience function to create a growth animation.

Parameters:
  • family – BooleanFamily to animate

  • property_name – Property to track

  • n_range – (start, stop, step) for n values

  • **kwargs – Additional arguments to GrowthAnimator.animate()

Returns:

Matplotlib animation object

boofun.visualization.animation.animate_influences(family: FunctionFamily, n_range: Tuple[int, int, int] = (3, 15, 2), **kwargs) animation.FuncAnimation[source]

Convenience function to animate influence distribution.

Parameters:
  • family – BooleanFamily to animate

  • n_range – (start, stop, step) for n values

  • **kwargs – Additional arguments

Returns:

Matplotlib animation object

boofun.visualization.animation.animate_fourier_spectrum(family: FunctionFamily, n_range: Tuple[int, int, int] = (3, 9, 2), figsize: Tuple[int, int] = (12, 6), interval: int = 800) animation.FuncAnimation[source]

Animate Fourier spectrum (spectral weight by degree) as n grows.

Parameters:
  • family – BooleanFamily to animate

  • n_range – (start, stop, step) for n values

  • figsize – Figure size

  • interval – Milliseconds between frames

Returns:

Matplotlib animation object

boofun.visualization.animation.create_growth_animation(family: FunctionFamily, properties: List[str] = None, n_range: Tuple[int, int, int] = (3, 15, 2), figsize: Tuple[int, int] = (14, 8), interval: int = 600) animation.FuncAnimation[source]

Create multi-panel animation showing multiple properties.

Parameters:
  • family – BooleanFamily to animate

  • properties – List of properties to show (default: influence, degree, variance)

  • n_range – (start, stop, step) for n values

  • figsize – Figure size

  • interval – Milliseconds between frames

Returns:

Matplotlib animation object

class boofun.visualization.animation.GrowthAnimator(family: FunctionFamily)[source]

Create animations showing function properties as n grows.

Example

>>> animator = GrowthAnimator(MajorityFamily())
>>> animator.animate("total_influence", n_range=(3, 15, 2))
>>> animator.save("majority_growth.gif")
__init__(family: FunctionFamily)[source]

Initialize animator with a function family.

Parameters:

family – BooleanFamily to animate

animate(property_name: str, n_range: Tuple[int, int, int] = (3, 15, 2), figsize: Tuple[int, int] = (10, 6), interval: int = 500, property_func: Callable | None = None) animation.FuncAnimation[source]

Create animation of property growth.

Parameters:
  • property_name – Name of property to animate

  • n_range – (start, stop, step) for n values

  • figsize – Figure size

  • interval – Milliseconds between frames

  • property_func – Custom function to compute property (default uses builtin)

Returns:

Matplotlib animation object

animate_influences(n_range: Tuple[int, int, int] = (3, 15, 2), figsize: Tuple[int, int] = (12, 6), interval: int = 700) animation.FuncAnimation[source]

Animate influence distribution as n grows.

Shows bar chart of influences with bars growing/shrinking.

Parameters:
  • n_range – (start, stop, step) for n values

  • figsize – Figure size

  • interval – Milliseconds between frames

Returns:

Matplotlib animation object

save(filename: str, fps: int = 2, **kwargs)[source]

Save animation to file.

Parameters:
  • filename – Output filename (supports .gif, .mp4)

  • fps – Frames per second

  • **kwargs – Additional arguments to animation.save()

show()[source]

Display the animation.