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 flaky mixed precision failures in tests #386

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion model/common/src/icon4py/model/common/type_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
26 changes: 26 additions & 0 deletions tools/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
#
# 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)
6 changes: 0 additions & 6 deletions tools/tests/icon4pygen/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,11 +37,6 @@
OUTPATH = "."


@pytest.fixture
def cli():
return CliRunner()


def dycore_fencils() -> list[tuple[str, str]]:
return _fencils(dycore.__file__, DYCORE_PKG)

Expand Down
Loading