Skip to content

Commit

Permalink
Finished main work in icon4py.testing
Browse files Browse the repository at this point in the history
  • Loading branch information
egparedes committed Dec 5, 2024
1 parent 74ea99c commit fb8fe5f
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 16 deletions.
3 changes: 2 additions & 1 deletion model/common/src/icon4py/model/common/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from __future__ import annotations

from . import fields
from ._common import (
DoubleBuffering,
Pair,
Expand All @@ -17,6 +16,7 @@
chainable,
named_property,
)
from . import fields, serialbox


__all__ = [
Expand All @@ -30,4 +30,5 @@
"chainable",
# Modules
"fields",
"serialbox",
]
28 changes: 16 additions & 12 deletions model/common/src/icon4py/model/common/utils/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@
#
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause

from __future__ import annotations

import logging as log
from typing import Optional, TypeAlias, Union
from typing import Optional, TypeAlias, Union, TYPE_CHECKING

import gt4py._core.definitions as gt_core_defs
import gt4py.next as gtx
from gt4py.next import backend
import numpy as np
import numpy.typing as npt

from icon4py.model.common import dimension, type_alias as ta
from icon4py.model.common.grid.base import BaseGrid
from icon4py.model.common import type_alias as ta

if TYPE_CHECKING:
from icon4py.model.common import dimension
from icon4py.model.common.grid import base as grid_base

""" Enum values from Enum values taken from DLPack reference implementation at:
https://github.com/dmlc/dlpack/blob/main/include/dlpack/dlpack.h
via GT4Py
"""

#: Enum values from Enum values taken from DLPack reference implementation at:
#: https://github.com/dmlc/dlpack/blob/main/include/dlpack/dlpack.h
#: via GT4Py
CUDA_DEVICE_TYPES = (
gt_core_defs.DeviceType.CUDA,
gt_core_defs.DeviceType.CUDA_MANAGED,
Expand Down Expand Up @@ -129,7 +135,7 @@ def random_field(
return as_field(dims, arr)

def zero_field(
grid: BaseGrid,
grid: grid_base.BaseGrid,
*dims: gtx.Dimension,
dtype=ta.wpfloat,
extend: Optional[dict[gtx.Dimension, int]] = None,
Expand All @@ -138,7 +144,7 @@ def zero_field(


def constant_field(
grid: BaseGrid, value: float, *dims: gtx.Dimension, dtype=ta.wpfloat
grid: grid_base.BaseGrid, value: float, *dims: gtx.Dimension, dtype=ta.wpfloat
) -> gtx.Field:
return as_field(
dims,
Expand All @@ -157,7 +163,7 @@ def _shape(


def random_mask(
grid: BaseGrid,
grid: grid_base.BaseGrid,
*dims: gtx.Dimension,
dtype: Optional[npt.DTypeLike] = None,
extend: Optional[dict[gtx.Dimension, int]] = None,
Expand Down Expand Up @@ -196,5 +202,3 @@ def allocate_indices(
xp = import_array_ns(backend)
shapex = _size(grid, dim, is_halfdim)
return gtx.as_field((dim,), xp.arange(shapex, dtype=dtype), allocator=backend)


2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import nox

nox.options.default_venv_backend = "uv"
nox.options.sessions = ["lint", "test"]
#nox.options.sessions = ["lint", "test"]


def session_install(
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ docs = [
]
lint = ["pre-commit>=4.0.1", "ruff>=0.8.0", "tach>=0.16.0"]
test = [
# workspace members
"icon4py-testing>=0.0.6",
# external dependencies
"coverage[toml]>=7.5.0",
"nox @ git+https://github.com/wntrblm/nox.git@aa09595437608dfe21eb776d8a4bcc0bd5f9916b", # TODO: remove once next version is released
"pytest>=8.0.1",
Expand Down
10 changes: 10 additions & 0 deletions tach.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
exact = true
exclude = []
forbid_circular_dependencies = true
interfaces = []
source_roots = [
"model/atmosphere/advection/src",
"model/atmosphere/diffusion/src",
"model/atmosphere/dycore/src",
"model/atmosphere/subgrid_scale_physics/microphysics/src",
"model/common/src",
"model/driver/src",
"model/testing/src",
"tools/src",
]

Expand Down Expand Up @@ -45,6 +49,12 @@ depends_on = [
{ path = "icon4py.model.common" },
]

[[modules]]
path = "icon4py.model.testing"
depends_on = [
{ path = "icon4py.model.common" },
]

[[modules]]
path = "icon4pytools"
depends_on = []
Expand Down
2 changes: 0 additions & 2 deletions tools/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ parallel = true
source_pkgs = ['icon4pytools']

# -- pytest --
[tool.pytest]

[tool.pytest.ini_options]
addopts = ['-p icon4py.model.testing.pytest_config']
markers = [
Expand Down
28 changes: 28 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fb8fe5f

Please sign in to comment.