Skip to content

Commit 8771ee0

Browse files
committed
Resolve remaining VSCode/MyPy issues and fix more warnings.
1 parent 916bfbb commit 8771ee0

File tree

3 files changed

+52
-15
lines changed

3 files changed

+52
-15
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"python.linting.flake8Enabled": true,
1212
"python.linting.mypyEnabled": true,
1313
"python.linting.mypyArgs": [
14-
"--ignore-missing-imports",
14+
"--python-version 3.8", // Python 3.8 supported by examples.
1515
"--follow-imports=silent",
1616
"--show-column-numbers"
1717
],

examples/cavegen.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
command line.
88
"""
99
import numpy as np
10-
import scipy.signal
10+
import scipy.signal # type: ignore
1111

1212

1313
def convolve(tiles: np.ndarray, wall_rule: int = 5) -> np.ndarray:
@@ -19,10 +19,11 @@ def convolve(tiles: np.ndarray, wall_rule: int = 5) -> np.ndarray:
1919
walls then the tile will become a wall.
2020
"""
2121
# Use convolve2d, the 2nd input is a 3x3 ones array.
22-
neighbors = scipy.signal.convolve2d(
22+
neighbors: np.ndarray = scipy.signal.convolve2d(
2323
tiles == 0, [[1, 1, 1], [1, 1, 1], [1, 1, 1]], "same"
2424
)
25-
return neighbors < wall_rule # Apply the wall rule.
25+
next_tiles: np.ndarray = neighbors < wall_rule # Apply the wall rule.
26+
return next_tiles
2627

2728

2829
def show(tiles: np.ndarray) -> None:

examples/samples_tcod.py

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,51 @@ def on_draw(self) -> None:
348348

349349
class NoiseSample(Sample):
350350
NOISE_OPTIONS = [ # (name, algorithm, implementation)
351-
("perlin noise", tcod.NOISE_PERLIN, tcod.noise.SIMPLE),
352-
("simplex noise", tcod.NOISE_SIMPLEX, tcod.noise.SIMPLE),
353-
("wavelet noise", tcod.NOISE_WAVELET, tcod.noise.SIMPLE),
354-
("perlin fbm", tcod.NOISE_PERLIN, tcod.noise.FBM),
355-
("perlin turbulence", tcod.NOISE_PERLIN, tcod.noise.TURBULENCE),
356-
("simplex fbm", tcod.NOISE_SIMPLEX, tcod.noise.FBM),
357-
("simplex turbulence", tcod.NOISE_SIMPLEX, tcod.noise.TURBULENCE),
358-
("wavelet fbm", tcod.NOISE_WAVELET, tcod.noise.FBM),
359-
("wavelet turbulence", tcod.NOISE_WAVELET, tcod.noise.TURBULENCE),
351+
(
352+
"perlin noise",
353+
tcod.noise.Algorithm.PERLIN,
354+
tcod.noise.Implementation.SIMPLE,
355+
),
356+
(
357+
"simplex noise",
358+
tcod.noise.Algorithm.SIMPLEX,
359+
tcod.noise.Implementation.SIMPLE,
360+
),
361+
(
362+
"wavelet noise",
363+
tcod.noise.Algorithm.WAVELET,
364+
tcod.noise.Implementation.SIMPLE,
365+
),
366+
(
367+
"perlin fbm",
368+
tcod.noise.Algorithm.PERLIN,
369+
tcod.noise.Implementation.FBM,
370+
),
371+
(
372+
"perlin turbulence",
373+
tcod.noise.Algorithm.PERLIN,
374+
tcod.noise.Implementation.TURBULENCE,
375+
),
376+
(
377+
"simplex fbm",
378+
tcod.noise.Algorithm.SIMPLEX,
379+
tcod.noise.Implementation.FBM,
380+
),
381+
(
382+
"simplex turbulence",
383+
tcod.noise.Algorithm.SIMPLEX,
384+
tcod.noise.Implementation.TURBULENCE,
385+
),
386+
(
387+
"wavelet fbm",
388+
tcod.noise.Algorithm.WAVELET,
389+
tcod.noise.Implementation.FBM,
390+
),
391+
(
392+
"wavelet turbulence",
393+
tcod.noise.Algorithm.WAVELET,
394+
tcod.noise.Implementation.TURBULENCE,
395+
),
360396
]
361397

362398
def __init__(self) -> None:
@@ -407,7 +443,7 @@ def on_draw(self) -> None:
407443
self.img.put_pixel(x, y, (c // 2, c // 2, c))
408444
rectw = 24
409445
recth = 13
410-
if self.implementation == tcod.noise.SIMPLE:
446+
if self.implementation == tcod.noise.Implementation.SIMPLE:
411447
recth = 10
412448
sample_console.draw_semigraphics(self.img)
413449
sample_console.draw_rect(
@@ -435,7 +471,7 @@ def on_draw(self) -> None:
435471
sample_console.print(
436472
2, 11, "Y/H : zoom (%2.1f)" % self.zoom, fg=WHITE, bg=None
437473
)
438-
if self.implementation != tcod.noise.SIMPLE:
474+
if self.implementation != tcod.noise.Implementation.SIMPLE:
439475
sample_console.print(
440476
2,
441477
12,

0 commit comments

Comments
 (0)