fractalpy.fractals package
Submodules
fractalpy.fractals.fractal_base module
This module provides the base fractal class for this package.
- class fractalpy.fractals.fractal_base.FractalBase(limits: tuple[float, float, float, float], n_pts: int = 1000, threshold: int = 1000, color_map: str = 'hsv', c_set: str = 'black', pallet_len: int = 250, color_map_shift: int = 0)
Bases:
ABCAn abstract class to represent a base class for fractals.
Initialises Fractal with either the Mandelbrot set or Julia set along with default attributes.
- Parameters
limits (tuple, optional) – Tuple of minimum and maximum values along x-axis and y-axis.
n_pts (int, optional) – Number of points along y-axis. Defaults to 1000.
threshold (int, optional) – Number of iterations before point determined to be in the set. Defaults to 1000.
color_map (str, optional) – Color map for plots. Defaults to ‘hsv’.
pallet_len (int, optional) – Length of periodicity for color pallet. Defaults to 250.
color_map_shift (int, optional) – Length to shift color pallet. Defaults to 0.
- abstract property color_chart
The color chart of the calculated set
- property color_map
- get_target_ranges(m: float, target: tuple[float, float])
Gets the x range and y range for the target point at corresponding zoom magnitude
- abstract plot(fig_size: float = 5, axis: Union[str, bool, tuple[float, float, float, float]] = 'off', title: str = '', n_ticks: int = 5)
Plots the calculated set.
- Parameters
fig_size (int, optional) – Size of figure in inches of x-axis for plot. Defaults to 4.
axis (tuple[float, float, float, float] or bool or string, optional) – Axis parameters for plot. Defaults to ‘off’.
title (str, optional) – title of plot. Defaults to ‘’.
n_ticks (int, optional) – Number of ticks for axes. Defaults to 5.
- property ratio
A property for the aspect ratio
- abstract save(filename: str = '', extension: str = 'png')
Saves an image of the calculated set in the ‘images’ directory.
- Parameters
filename (_type_) – The filename of the saved image. Defaults to None.
frame_iter (#) – The frame iteration number. Defaults to ‘’.
extension (str, optional) – The extension to save the image as. Defaults to ‘png’.
- property x_y_ranges
A property for the ranges of the x-points and the y-points
- abstract zoom(m: float, target: tuple[float, float], filename: str = '', extension: str = 'gif', frame_subdir: str = 'frames', n_frames: int = 120, fps: int = 60, n_jobs: int = 2)
Compiles a video after generating a sequence of images, beginning with the object’s current co-ordinate frame and finishing at the target location frame.
- Parameters
filename (str, optional) – Name of output file. Defaults to None.
extension (str, optional) – Extension of the output file format. Defaults to ‘gif’.
frame_subdir (str, optional) – Directory to save image frames. Defaults to ‘frames’.
m (float, optional) – the zoom magnitude.
target (tuple[float, float], optional) – Target location for the end of zoom. The first tuple entry is location with x, y coordinates. Defaults to (6e+4, -1.186592e+0, -1.901211e-1). # TODO fix the defaults here. it depends on which class
n_frames (int, optional) – Number of total frames compiled. n_frames-2 frames are compiled intermediately between the initial frame and target frame. Defaults to 120.
fps (int, optional) – Number of frames per second for output video. This determines the smoothness between frames and affects the length of the output video. Defaults to 60.
n_jobs (int, optional) – Number of workers for parallel processing. Defaults to os.cpu_count().
fractalpy.fractals.fractals module
This module provides the usage classes for this package.
- class fractalpy.fractals.fractals.Julia(c: complex = -0.79 + 0.15j, limits: tuple[float, float, float, float] = (-1.5, 1.5, -1.5, 1.5), **kwargs)
Bases:
FractalBaseA class to represent the Julia set.
Initialises Fractal with either the Mandelbrot set or Julia set along with default attributes.
- Parameters
limits (tuple, optional) – Tuple of minimum and maximum values along x-axis and y-axis.
n_pts (int, optional) – Number of points along y-axis. Defaults to 1000.
threshold (int, optional) – Number of iterations before point determined to be in the set. Defaults to 1000.
color_map (str, optional) – Color map for plots. Defaults to ‘hsv’.
pallet_len (int, optional) – Length of periodicity for color pallet. Defaults to 250.
color_map_shift (int, optional) – Length to shift color pallet. Defaults to 0.
- property color_chart
The color chart of the calculated set
- plot(**kwargs)
Plots the calculated set.
- Parameters
fig_size (int, optional) – Size of figure in inches of x-axis for plot. Defaults to 4.
axis (tuple[float, float, float, float] or bool or string, optional) – Axis parameters for plot. Defaults to ‘off’.
title (str, optional) – title of plot. Defaults to ‘’.
n_ticks (int, optional) – Number of ticks for axes. Defaults to 5.
- save(filename='', **kwargs)
Saves an image of the calculated set in the ‘images’ directory.
- Parameters
filename (_type_) – The filename of the saved image. Defaults to None.
frame_iter (#) – The frame iteration number. Defaults to ‘’.
extension (str, optional) – The extension to save the image as. Defaults to ‘png’.
- spin(filename: Optional[str] = None, extension: str = 'gif', n_frames: int = 60, fps: int = 60, n_jobs: int = 2)
- Creates a sequence of images beginning with the objects current co-ordinate frame and finishing at the target
location.
- Parameters
filename (_type_, optional) – _description_. Defaults to None.
extension (str, optional) – _description_. Defaults to ‘gif’.
n_frames (int, optional) – _description_. Defaults to 60.
fps (int, optional) – _description_. Defaults to 60.
n_jobs (_type_, optional) – _description_. Defaults to os.cpu_count().
- zoom(m=5, target=(0.5, 0.5), **kwargs)
Compiles a video after generating a sequence of images, beginning with the object’s current co-ordinate frame and finishing at the target location frame.
- Parameters
filename (str, optional) – Name of output file. Defaults to None.
extension (str, optional) – Extension of the output file format. Defaults to ‘gif’.
frame_subdir (str, optional) – Directory to save image frames. Defaults to ‘frames’.
m (float, optional) – the zoom magnitude.
target (tuple[float, float], optional) – Target location for the end of zoom. The first tuple entry is location with x, y coordinates. Defaults to (6e+4, -1.186592e+0, -1.901211e-1). # TODO fix the defaults here. it depends on which class
n_frames (int, optional) – Number of total frames compiled. n_frames-2 frames are compiled intermediately between the initial frame and target frame. Defaults to 120.
fps (int, optional) – Number of frames per second for output video. This determines the smoothness between frames and affects the length of the output video. Defaults to 60.
n_jobs (int, optional) – Number of workers for parallel processing. Defaults to os.cpu_count().
- class fractalpy.fractals.fractals.Mandelbrot(limits: tuple[float, float, float, float] = (-2, 1, -1.5, 1.5), **kwargs)
Bases:
FractalBaseA class to represent the Mandelbrot set.
Initialises Fractal with either the Mandelbrot set or Julia set along with default attributes.
- Parameters
limits (tuple, optional) – Tuple of minimum and maximum values along x-axis and y-axis.
n_pts (int, optional) – Number of points along y-axis. Defaults to 1000.
threshold (int, optional) – Number of iterations before point determined to be in the set. Defaults to 1000.
color_map (str, optional) – Color map for plots. Defaults to ‘hsv’.
pallet_len (int, optional) – Length of periodicity for color pallet. Defaults to 250.
color_map_shift (int, optional) – Length to shift color pallet. Defaults to 0.
- property color_chart
The color chart of the calculated set
- plot(**kwargs)
Plots the calculated set.
- Parameters
fig_size (int, optional) – Size of figure in inches of x-axis for plot. Defaults to 4.
axis (tuple[float, float, float, float] or bool or string, optional) – Axis parameters for plot. Defaults to ‘off’.
title (str, optional) – title of plot. Defaults to ‘’.
n_ticks (int, optional) – Number of ticks for axes. Defaults to 5.
- save(filename='', **kwargs)
Saves an image of the calculated set in the ‘images’ directory.
- Parameters
filename (_type_) – The filename of the saved image. Defaults to None.
frame_iter (#) – The frame iteration number. Defaults to ‘’.
extension (str, optional) – The extension to save the image as. Defaults to ‘png’.
- zoom(m=60000.0, target=(-1.186592, -0.1901211), **kwargs)
Compiles a video after generating a sequence of images, beginning with the object’s current co-ordinate frame and finishing at the target location frame.
- Parameters
filename (str, optional) – Name of output file. Defaults to None.
extension (str, optional) – Extension of the output file format. Defaults to ‘gif’.
frame_subdir (str, optional) – Directory to save image frames. Defaults to ‘frames’.
m (float, optional) – the zoom magnitude.
target (tuple[float, float], optional) – Target location for the end of zoom. The first tuple entry is location with x, y coordinates. Defaults to (6e+4, -1.186592e+0, -1.901211e-1). # TODO fix the defaults here. it depends on which class
n_frames (int, optional) – Number of total frames compiled. n_frames-2 frames are compiled intermediately between the initial frame and target frame. Defaults to 120.
fps (int, optional) – Number of frames per second for output video. This determines the smoothness between frames and affects the length of the output video. Defaults to 60.
n_jobs (int, optional) – Number of workers for parallel processing. Defaults to os.cpu_count().