Skip to content

Commit f6af25b

Browse files
committed
Fixed CI and mypy errors
1 parent c0353dd commit f6af25b

File tree

2 files changed

+43
-42
lines changed

2 files changed

+43
-42
lines changed

.github/workflows/python-lint-tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ name: Lint and Tests
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
- release/*
88
pull_request:
99
branches:
10-
- master
10+
- main
1111
- release/*
1212

1313
jobs:
@@ -32,6 +32,7 @@ jobs:
3232
- name: Install dependencies
3333
run: |
3434
python -m pip install --upgrade pip
35+
python -m pip install .
3536
python -m pip install mypy black isort
3637
- name: Python Code Quality and Lint
3738
uses: abey79/python-lint@master

vnoise/vnoise.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ def _lerp(t, a, b):
1212

1313

1414
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]:
1717
g = GRAD3[hash_value & 15]
1818
return x * g[..., 0]
1919

2020

2121
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]:
2626
g = GRAD3[:, 0:2][hash_value & 15]
2727
return x * g[..., 0] + y * g[..., 1]
2828

2929

3030
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]:
3636
g = GRAD3[hash_value & 15]
3737
return x * g[..., 0] + y * g[..., 1] + z * g[..., 2]
3838

@@ -45,17 +45,17 @@ def __init__(self, seed: Optional[int] = None):
4545
else:
4646
self._set_perm(PERM)
4747

48-
def seed(self, s: int):
48+
def seed(self, s: int) -> None:
4949
perm = list(PERM)
5050
random.Random(s).shuffle(perm)
5151
self._set_perm(perm)
5252

5353
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)
5555

5656
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]:
5959
i = np.floor(np.fmod(x, repeat)).astype(int)
6060
ii = np.fmod(i + 1, repeat)
6161
i = (i & 255) + base
@@ -71,13 +71,13 @@ def _noise1_impl(
7171

7272
def _noise2_impl(
7373
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],
7676
repeat_x: int,
7777
repeat_y: int,
7878
base: int,
7979
grid_mode: bool,
80-
) -> Union[float, np.array]:
80+
) -> Union[float, np.ndarray]:
8181
i = np.floor(np.fmod(x, repeat_x)).astype(int)
8282
j = np.floor(np.fmod(y, repeat_y)).astype(int)
8383
ii = np.fmod(i + 1, repeat_x)
@@ -118,15 +118,15 @@ def _noise2_impl(
118118

119119
def _noise3_impl(
120120
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],
124124
repeat_x: int,
125125
repeat_y: int,
126126
repeat_z: int,
127127
base: int,
128128
grid_mode: bool,
129-
) -> Union[float, np.array]:
129+
) -> Union[float, np.ndarray]:
130130
i = np.floor(np.fmod(x, repeat_x)).astype(int)
131131
j = np.floor(np.fmod(y, repeat_y)).astype(int)
132132
k = np.floor(np.fmod(z, repeat_z)).astype(int)
@@ -199,25 +199,25 @@ def _noise3_impl(
199199
@overload
200200
def noise1(
201201
self,
202-
x: np.array,
202+
x: float,
203203
octaves: int = 1,
204204
persistence: float = 0.5,
205205
lacunarity: float = 2.0,
206206
repeat: int = 1024,
207207
base: int = 0,
208-
) -> np.array:
208+
) -> float:
209209
...
210210

211211
@overload
212212
def noise1(
213213
self,
214-
x: float,
214+
x: np.ndarray,
215215
octaves: int = 1,
216216
persistence: float = 0.5,
217217
lacunarity: float = 2.0,
218218
repeat: int = 1024,
219219
base: int = 0,
220-
) -> float:
220+
) -> np.ndarray:
221221
...
222222

223223
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
247247
@overload
248248
def noise2(
249249
self,
250-
x: np.array,
251-
y: Union[float, np.array],
250+
x: float,
251+
y: float,
252252
octaves: int = 1,
253253
persistence: float = 0.5,
254254
lacunarity: float = 2.0,
255255
repeat_x: int = 1024,
256256
repeat_y: int = 1024,
257257
base: int = 0,
258258
grid_mode: bool = True,
259-
) -> np.array:
259+
) -> float:
260260
...
261261

262262
@overload
263263
def noise2(
264264
self,
265-
x: float,
266-
y: float,
265+
x: np.ndarray,
266+
y: Union[float, np.ndarray],
267267
octaves: int = 1,
268268
persistence: float = 0.5,
269269
lacunarity: float = 2.0,
270270
repeat_x: int = 1024,
271271
repeat_y: int = 1024,
272272
base: int = 0,
273273
grid_mode: bool = True,
274-
) -> float:
274+
) -> np.ndarray:
275275
...
276276

277277
def noise2(
@@ -332,9 +332,9 @@ def noise2(
332332
@overload
333333
def noise3(
334334
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,
338338
octaves: int = 1,
339339
persistence: float = 0.5,
340340
lacunarity: float = 2.0,
@@ -343,15 +343,15 @@ def noise3(
343343
repeat_z: int = 1024,
344344
base: int = 0,
345345
grid_mode: bool = True,
346-
) -> np.array:
346+
) -> float:
347347
...
348348

349349
@overload
350350
def noise3(
351351
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],
355355
octaves: int = 1,
356356
persistence: float = 0.5,
357357
lacunarity: float = 2.0,
@@ -360,7 +360,7 @@ def noise3(
360360
repeat_z: int = 1024,
361361
base: int = 0,
362362
grid_mode: bool = True,
363-
) -> float:
363+
) -> np.ndarray:
364364
...
365365

366366
def noise3(

0 commit comments

Comments
 (0)