diff --git a/model/common/src/icon4py/model/common/type_alias.py b/model/common/src/icon4py/model/common/type_alias.py index 9fbdbd576e..4ca01a06ed 100644 --- a/model/common/src/icon4py/model/common/type_alias.py +++ b/model/common/src/icon4py/model/common/type_alias.py @@ -16,9 +16,11 @@ from gt4py.next.ffront.fbuiltins import float32, float64 +DEFAULT_PRECISION = "double" + wpfloat: TypeAlias = float64 -precision = os.environ.get("FLOAT_PRECISION", "double").lower() +precision = os.environ.get("FLOAT_PRECISION", DEFAULT_PRECISION).lower() if precision == "double": vpfloat = wpfloat elif precision == "mixed": diff --git a/tools/tests/conftest.py b/tools/tests/conftest.py new file mode 100644 index 0000000000..d9a0c2ac4c --- /dev/null +++ b/tools/tests/conftest.py @@ -0,0 +1,26 @@ +# ICON4Py - ICON inspired code in Python and GT4Py +# +# Copyright (c) 2022, ETH Zurich and MeteoSwiss +# All rights reserved. +# +# This file is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or any later +# version. See the LICENSE.txt file at the top-level directory of this +# distribution for a copy of the license or check . +# +# SPDX-License-Identifier: GPL-3.0-or-later + +import os +from importlib import reload + +import icon4py.model.common.type_alias as type_alias +import pytest +from click.testing import CliRunner + + +@pytest.fixture +def cli(): + yield CliRunner() + os.environ["FLOAT_PRECISION"] = type_alias.DEFAULT_PRECISION + reload(type_alias) diff --git a/tools/tests/icon4pygen/test_codegen.py b/tools/tests/icon4pygen/test_codegen.py index 35d09c6a41..8f9fae6746 100644 --- a/tools/tests/icon4pygen/test_codegen.py +++ b/tools/tests/icon4pygen/test_codegen.py @@ -21,7 +21,6 @@ import icon4py.model.common.interpolation.stencils as intp import icon4py.model.common.type_alias as type_alias import pytest -from click.testing import CliRunner from gt4py.next.ffront.fbuiltins import float32, float64 from icon4pytools.icon4pygen.cli import main @@ -38,11 +37,6 @@ OUTPATH = "." -@pytest.fixture -def cli(): - return CliRunner() - - def dycore_fencils() -> list[tuple[str, str]]: return _fencils(dycore.__file__, DYCORE_PKG)