3939from typing import Any , Optional , Sequence , Tuple , Union
4040
4141import numpy as np
42+ from typing_extensions import Literal
4243
4344import tcod .constants
4445import 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