Skip to content

Commit 7f66cf7

Browse files
committed
Fix bad noise module __getattr__ function.
Add example for noise samples to uint8.
1 parent 174c684 commit 7f66cf7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tcod/noise.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@
2727
[0.24613297, 0.3678193 , 0.6222316 , 0.8195127 , 0.79614234],
2828
[0.17527187, 0.4373501 , 0.76734173, 0.9020113 , 0.76327705]],
2929
dtype=float32)
30-
31-
30+
>>> ((samples + 1.0) * (256 / 2)).astype(np.uint8) # Or as 8-bit unsigned bytes.
31+
array([[128, 57, 30, 37, 40],
32+
[ 92, 35, 33, 71, 90],
33+
[ 76, 54, 85, 144, 164],
34+
[ 63, 94, 159, 209, 203],
35+
[ 44, 111, 196, 230, 195]], dtype=uint8)
3236
""" # noqa: E501
3337
import enum
3438
import warnings
@@ -89,7 +93,7 @@ def __repr__(self) -> str:
8993

9094

9195
def __getattr__(name: str) -> Implementation:
92-
if hasattr(Implementation, name):
96+
if name in Implementation.__members__:
9397
warnings.warn(
9498
f"'tcod.noise.{name}' is deprecated,"
9599
f" use 'tcod.noise.Implementation.{name}' instead.",

0 commit comments

Comments
 (0)