MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / prepare_grid

Function prepare_grid

fractals/julia_sets.py:67–82  ·  view source on GitHub ↗

Create a grid of complex values of size nb_pixels*nb_pixels with real and imaginary parts ranging from -window_size to window_size (inclusive). Returns a numpy array. >>> prepare_grid(1,3) array([[-1.-1.j, -1.+0.j, -1.+1.j], [ 0.-1.j, 0.+0.j, 0.+1.j], [

(window_size: float, nb_pixels: int)

Source from the content-addressed store, hash-verified

65
66
67def prepare_grid(window_size: float, nb_pixels: int) -> np.ndarray:
68 """
69 Create a grid of complex values of size nb_pixels*nb_pixels with real and
70 imaginary parts ranging from -window_size to window_size (inclusive).
71 Returns a numpy array.
72
73 >>> prepare_grid(1,3)
74 array([[-1.-1.j, -1.+0.j, -1.+1.j],
75 [ 0.-1.j, 0.+0.j, 0.+1.j],
76 [ 1.-1.j, 1.+0.j, 1.+1.j]])
77 """
78 x = np.linspace(-window_size, window_size, nb_pixels)
79 x = x.reshape((nb_pixels, 1))
80 y = np.linspace(-window_size, window_size, nb_pixels)
81 y = y.reshape((1, nb_pixels))
82 return x + 1.0j * y
83
84
85def iterate_function(

Callers 1

julia_sets.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected