Skip to content

Commit 20e5c16

Browse files
committed
Add indexing parameter to tcod.noise.grid.
1 parent 7f66cf7 commit 20e5c16

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tcod/noise.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from typing import Any, Optional, Sequence, Tuple, Union
4040

4141
import numpy as np
42+
from typing_extensions import Literal
4243

4344
import tcod.constants
4445
import tcod.random
@@ -441,6 +442,7 @@ def grid(
441442
shape: Tuple[int, ...],
442443
scale: Union[Tuple[float, ...], float],
443444
origin: Optional[Tuple[int, ...]] = None,
445+
indexing: Union[Literal["ij"], Literal["xy"]] = "xy",
444446
) -> Tuple[np.ndarray, ...]:
445447
"""A helper function for generating a grid of noise samples.
446448
@@ -456,6 +458,8 @@ def grid(
456458
If `None` then the `origin` will be zero on each axis.
457459
`origin` is not scaled by the `scale` parameter.
458460
461+
`indexing` is passed to :any:`numpy.meshgrid`.
462+
459463
Example::
460464
461465
>>> noise = tcod.noise.Noise(dimensions=2, seed=42)
@@ -486,4 +490,6 @@ def grid(
486490
np.arange(i_shape) * i_scale + i_origin
487491
for i_shape, i_scale, i_origin in zip(shape, scale, origin)
488492
)
489-
return tuple(np.meshgrid(*indexes, copy=False, sparse=True, indexing="xy"))
493+
return tuple(
494+
np.meshgrid(*indexes, copy=False, sparse=True, indexing=indexing)
495+
)

0 commit comments

Comments
 (0)