Skip to content

Commit

Permalink
[FIX] Type hint for precision dependant Float, Int (#111)
Browse files Browse the repository at this point in the history
* Fix the type hint of Float, Int

* Attempt using TypeAlias
  • Loading branch information
FlorianDeconinck authored Feb 14, 2025
1 parent b5c06c2 commit 597d1d4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ndsl/dsl/typing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import Tuple, Union, cast
from typing import Tuple, TypeAlias, Union, cast

import gt4py.cartesian.gtscript as gtscript
import numpy as np
Expand Down Expand Up @@ -34,13 +34,13 @@ def get_precision() -> int:
# We redefine the type as a way to distinguish
# the model definition of a float to other usage of the
# common numpy type in the rest of the code.
NDSL_32BIT_FLOAT_TYPE = np.float32
NDSL_64BIT_FLOAT_TYPE = np.float64
NDSL_32BIT_INT_TYPE = np.int32
NDSL_64BIT_INT_TYPE = np.int64
NDSL_32BIT_FLOAT_TYPE: TypeAlias = np.float32
NDSL_64BIT_FLOAT_TYPE: TypeAlias = np.float64
NDSL_32BIT_INT_TYPE: TypeAlias = np.int32
NDSL_64BIT_INT_TYPE: TypeAlias = np.int64


def global_set_precision() -> type:
def global_set_precision() -> Tuple[TypeAlias, TypeAlias]:
"""Set the global precision for all references of
Float and Int in the codebase. Defaults to 64 bit."""
global Float, Int
Expand Down

0 comments on commit 597d1d4

Please sign in to comment.