@@ -12,27 +12,27 @@ def _lerp(t, a, b):
12
12
13
13
14
14
def _grad1 (
15
- hash_value : Union [int , np .array ], x : Union [float , np .array ]
16
- ) -> Union [float , np .array ]:
15
+ hash_value : Union [int , np .ndarray ], x : Union [float , np .ndarray ]
16
+ ) -> Union [float , np .ndarray ]:
17
17
g = GRAD3 [hash_value & 15 ]
18
18
return x * g [..., 0 ]
19
19
20
20
21
21
def _grad2 (
22
- hash_value : Union [int , np .array ],
23
- x : Union [float , np .array ],
24
- y : Union [float , np .array ],
25
- ) -> Union [float , np .array ]:
22
+ hash_value : Union [int , np .ndarray ],
23
+ x : Union [float , np .ndarray ],
24
+ y : Union [float , np .ndarray ],
25
+ ) -> Union [float , np .ndarray ]:
26
26
g = GRAD3 [:, 0 :2 ][hash_value & 15 ]
27
27
return x * g [..., 0 ] + y * g [..., 1 ]
28
28
29
29
30
30
def _grad3 (
31
- hash_value : Union [int , np .array ],
32
- x : Union [float , np .array ],
33
- y : Union [float , np .array ],
34
- z : Union [float , np .array ],
35
- ) -> Union [float , np .array ]:
31
+ hash_value : Union [int , np .ndarray ],
32
+ x : Union [float , np .ndarray ],
33
+ y : Union [float , np .ndarray ],
34
+ z : Union [float , np .ndarray ],
35
+ ) -> Union [float , np .ndarray ]:
36
36
g = GRAD3 [hash_value & 15 ]
37
37
return x * g [..., 0 ] + y * g [..., 1 ] + z * g [..., 2 ]
38
38
@@ -45,17 +45,17 @@ def __init__(self, seed: Optional[int] = None):
45
45
else :
46
46
self ._set_perm (PERM )
47
47
48
- def seed (self , s : int ):
48
+ def seed (self , s : int ) -> None :
49
49
perm = list (PERM )
50
50
random .Random (s ).shuffle (perm )
51
51
self ._set_perm (perm )
52
52
53
53
def _set_perm (self , perm : Sequence [int ]) -> None :
54
- self ._perm = np .array (perm * 2 , dtype = np .uint8 )
54
+ self ._perm = np .array (list ( perm ) * 2 , dtype = np .uint8 )
55
55
56
56
def _noise1_impl (
57
- self , x : Union [float , np .array ], repeat : int , base : int
58
- ) -> Union [float , np .array ]:
57
+ self , x : Union [float , np .ndarray ], repeat : int , base : int
58
+ ) -> Union [float , np .ndarray ]:
59
59
i = np .floor (np .fmod (x , repeat )).astype (int )
60
60
ii = np .fmod (i + 1 , repeat )
61
61
i = (i & 255 ) + base
@@ -71,13 +71,13 @@ def _noise1_impl(
71
71
72
72
def _noise2_impl (
73
73
self ,
74
- x : Union [float , np .array ],
75
- y : Union [float , np .array ],
74
+ x : Union [float , np .ndarray ],
75
+ y : Union [float , np .ndarray ],
76
76
repeat_x : int ,
77
77
repeat_y : int ,
78
78
base : int ,
79
79
grid_mode : bool ,
80
- ) -> Union [float , np .array ]:
80
+ ) -> Union [float , np .ndarray ]:
81
81
i = np .floor (np .fmod (x , repeat_x )).astype (int )
82
82
j = np .floor (np .fmod (y , repeat_y )).astype (int )
83
83
ii = np .fmod (i + 1 , repeat_x )
@@ -118,15 +118,15 @@ def _noise2_impl(
118
118
119
119
def _noise3_impl (
120
120
self ,
121
- x : Union [float , np .array ],
122
- y : Union [float , np .array ],
123
- z : Union [float , np .array ],
121
+ x : Union [float , np .ndarray ],
122
+ y : Union [float , np .ndarray ],
123
+ z : Union [float , np .ndarray ],
124
124
repeat_x : int ,
125
125
repeat_y : int ,
126
126
repeat_z : int ,
127
127
base : int ,
128
128
grid_mode : bool ,
129
- ) -> Union [float , np .array ]:
129
+ ) -> Union [float , np .ndarray ]:
130
130
i = np .floor (np .fmod (x , repeat_x )).astype (int )
131
131
j = np .floor (np .fmod (y , repeat_y )).astype (int )
132
132
k = np .floor (np .fmod (z , repeat_z )).astype (int )
@@ -199,25 +199,25 @@ def _noise3_impl(
199
199
@overload
200
200
def noise1 (
201
201
self ,
202
- x : np . array ,
202
+ x : float ,
203
203
octaves : int = 1 ,
204
204
persistence : float = 0.5 ,
205
205
lacunarity : float = 2.0 ,
206
206
repeat : int = 1024 ,
207
207
base : int = 0 ,
208
- ) -> np . array :
208
+ ) -> float :
209
209
...
210
210
211
211
@overload
212
212
def noise1 (
213
213
self ,
214
- x : float ,
214
+ x : np . ndarray ,
215
215
octaves : int = 1 ,
216
216
persistence : float = 0.5 ,
217
217
lacunarity : float = 2.0 ,
218
218
repeat : int = 1024 ,
219
219
base : int = 0 ,
220
- ) -> float :
220
+ ) -> np . ndarray :
221
221
...
222
222
223
223
def noise1 (self , x , octaves = 1 , persistence = 0.5 , lacunarity = 2.0 , repeat = 1024 , base = 0 ):
@@ -247,31 +247,31 @@ def noise1(self, x, octaves=1, persistence=0.5, lacunarity=2.0, repeat=1024, bas
247
247
@overload
248
248
def noise2 (
249
249
self ,
250
- x : np . array ,
251
- y : Union [ float , np . array ] ,
250
+ x : float ,
251
+ y : float ,
252
252
octaves : int = 1 ,
253
253
persistence : float = 0.5 ,
254
254
lacunarity : float = 2.0 ,
255
255
repeat_x : int = 1024 ,
256
256
repeat_y : int = 1024 ,
257
257
base : int = 0 ,
258
258
grid_mode : bool = True ,
259
- ) -> np . array :
259
+ ) -> float :
260
260
...
261
261
262
262
@overload
263
263
def noise2 (
264
264
self ,
265
- x : float ,
266
- y : float ,
265
+ x : np . ndarray ,
266
+ y : Union [ float , np . ndarray ] ,
267
267
octaves : int = 1 ,
268
268
persistence : float = 0.5 ,
269
269
lacunarity : float = 2.0 ,
270
270
repeat_x : int = 1024 ,
271
271
repeat_y : int = 1024 ,
272
272
base : int = 0 ,
273
273
grid_mode : bool = True ,
274
- ) -> float :
274
+ ) -> np . ndarray :
275
275
...
276
276
277
277
def noise2 (
@@ -332,9 +332,9 @@ def noise2(
332
332
@overload
333
333
def noise3 (
334
334
self ,
335
- x : np . array ,
336
- y : Union [ float , np . array ] ,
337
- z : Union [ float , np . array ] ,
335
+ x : float ,
336
+ y : float ,
337
+ z : float ,
338
338
octaves : int = 1 ,
339
339
persistence : float = 0.5 ,
340
340
lacunarity : float = 2.0 ,
@@ -343,15 +343,15 @@ def noise3(
343
343
repeat_z : int = 1024 ,
344
344
base : int = 0 ,
345
345
grid_mode : bool = True ,
346
- ) -> np . array :
346
+ ) -> float :
347
347
...
348
348
349
349
@overload
350
350
def noise3 (
351
351
self ,
352
- x : float ,
353
- y : float ,
354
- z : float ,
352
+ x : np . ndarray ,
353
+ y : Union [ float , np . ndarray ] ,
354
+ z : Union [ float , np . ndarray ] ,
355
355
octaves : int = 1 ,
356
356
persistence : float = 0.5 ,
357
357
lacunarity : float = 2.0 ,
@@ -360,7 +360,7 @@ def noise3(
360
360
repeat_z : int = 1024 ,
361
361
base : int = 0 ,
362
362
grid_mode : bool = True ,
363
- ) -> float :
363
+ ) -> np . ndarray :
364
364
...
365
365
366
366
def noise3 (
0 commit comments