Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Type hint for precision dependant Float, Int #111

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading