11"""pnoise library"""
22"""
33Ported from the Processing project - http://processing.org
4- Copyright (c) 2021 Antoine Beyeler
4+ Copyright (c) 2021-2022 Antoine Beyeler
55Copyright (c) 2012-15 The Processing Foundation
66Copyright (c) 2004-12 Ben Fry and Casey Reas
77Copyright (c) 2001-04 Massachusetts Institute of Technology
@@ -51,7 +51,7 @@ def perlin(
5151 y : Union [Number , Sequence [Number ]],
5252 z : Union [Number , Sequence [Number ]],
5353 grid_mode : bool = True ,
54- ) -> np .ndarray :
54+ ) -> Union [ np .ndarray , float ] :
5555 """Compute perlin noise for a range of values.
5656
5757 Each of the x, y, and z argument may be 1D sequence of float. Perlin noise will be
@@ -65,7 +65,10 @@ def perlin(
6565 if not grid_mode or single :
6666 grid = np .array ([x , y , z ], dtype = float )
6767 else :
68- grid = np .array (np .meshgrid (x , y , z , indexing = "ij" , copy = False ), dtype = float )
68+ grid = np .array (
69+ np .meshgrid (np .array (x ), np .array (y ), np .array (z ), indexing = "ij" , copy = False ),
70+ dtype = float ,
71+ )
6972
7073 np .abs (grid , out = grid )
7174 grid_i = grid .astype (int )
@@ -109,7 +112,7 @@ def perlin(
109112 grid [idx ] -= 1.0
110113
111114 if single :
112- return np . asscalar ( r )
115+ return float ( r . item () )
113116 elif not grid_mode :
114117 return r
115118 else :
0 commit comments