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

test[next]: simplify boilerplate for fieldview single feature tests #1236

Merged
merged 44 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8c10f3b
[wip] field builder
Apr 11, 2023
7c81757
MVP cartesian_case fixture
Apr 12, 2023
354a4db
fix typo
Apr 13, 2023
015d4a5
Result of discussion
tehrengruber Apr 13, 2023
634b03e
add unstructured and automatic verify
Apr 17, 2023
fa053a5
include scalar input args
Apr 18, 2023
2872844
programs, scans, custom comparisons and more tests
Apr 19, 2023
f4b5247
cleanup
Apr 19, 2023
637a032
more cleanup
Apr 19, 2023
6e91ed5
do not exclude cases.py from mypy
Apr 19, 2023
13cd3de
Merge remote-tracking branch 'upstream/main' into c14-feature-test-setup
Apr 20, 2023
f8e87c7
more unique default data
Apr 24, 2023
b1ae6de
generic fieldview snippet names
Apr 24, 2023
da6c7cd
cleanup
Apr 24, 2023
46d33a8
cleanup
Apr 24, 2023
382875e
cleanup noqas
Apr 24, 2023
93c201d
Update tests/next_tests/integration_tests/feature_tests/cases.py
DropD Apr 24, 2023
e41c885
fix scalar value typing
Apr 24, 2023
77345cf
cleanup
Apr 24, 2023
98557c0
improve make_builder readability
Apr 24, 2023
e2dabe0
review fixes
Apr 24, 2023
115ddc9
Merge remote-tracking branch 'upstream/main' into c14-feature-test-setup
Apr 25, 2023
fbd7ab4
replace allocate wrapper with `make_builder` decorator
Apr 25, 2023
18e6eab
fix allocate and default verify scalar arg tests
Apr 25, 2023
0f523ab
extended docstrings for allocate and verify
Apr 26, 2023
41a104a
spellcheck the docstrings
Apr 26, 2023
dfaa775
use `get_type_hints` from eve.extended_typing
Apr 26, 2023
069a193
fix rst markup in docstrings
Apr 26, 2023
9e0ba4f
use `ScalarValue` type alias everywhere appropriate
Apr 26, 2023
641a004
unignore cases from mypy, fix typing, fix tests
Apr 27, 2023
fec2f50
explicitly import reduction_setup fixture in cases
Apr 27, 2023
b4409dd
Merge remote-tracking branch 'upstream/main' into c14-feature-test-setup
Apr 27, 2023
798ae73
re-exclude cartesian tests from mypy in pre-commit
Apr 27, 2023
60a43fe
Merge remote-tracking branch 'upstream/main' into c14-feature-test-setup
Apr 27, 2023
3ecb224
remove support for multidim scalars
Apr 27, 2023
818bfe2
cleanup superfluous type ignore
Apr 27, 2023
b88d646
tests cleanup
Apr 27, 2023
332a44f
match testee arg naming convention to ref lambdas
Apr 27, 2023
67608c9
fix tests
Apr 27, 2023
e595e3f
test and fix cases.py
Apr 27, 2023
2f60876
cleanup
Apr 27, 2023
2f92b0f
reorder cases module according to guidelines
Apr 28, 2023
b45241a
incorporating suggestions from review.
Apr 28, 2023
420086a
fix order in cases.py
Apr 28, 2023
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
19 changes: 18 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ repos:
tests/cartesian_tests/integration_tests/multi_feature_tests/utils.py |
tests/cartesian_tests/integration_tests/feature_tests/test_call_interface.py |
tests/cartesian_tests/unit_tests/frontend_tests/test_gtscript_frontend.py |
tests/next_tests/.*
tests/next_tests/unit_tests/.* |
tests/next_tests/integration_tests/multi_feature_tests/.* |
tests/next_tests/integration_tests/feature_tests/ffront_tests/.* |
tests/next_tests/integration_tests/feature_tests/iterator_tests/.* |
tests/next_tests/integration_tests/feature_tests/otf_tests/.* |
tests/next_tests/integration_tests/feature_tests/math_builtin_test_data.py |
tests/next_tests/past_common_fixtures.py |
tests/next_tests/toy_connectivity.py |
)$

- repo: https://github.com/pre-commit/mirrors-mypy
Expand Down Expand Up @@ -187,5 +194,15 @@ repos:
build/.* |
ci/.* |
docs/.* |
tests/conftest.py |
tests/cartesian_tests/.* |
tests/next_tests/unit_tests/.* |
tests/next_tests/integration_tests/multi_feature_tests/.* |
tests/next_tests/integration_tests/feature_tests/ffront_tests/.* |
tests/next_tests/integration_tests/feature_tests/iterator_tests/.* |
tests/next_tests/integration_tests/feature_tests/otf_tests/.* |
tests/next_tests/integration_tests/feature_tests/math_builtin_test_data.py |
tests/next_tests/past_common_fixtures.py |
tests/next_tests/toy_connectivity.py |
tests/.*
)$
2 changes: 2 additions & 0 deletions CODING_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Each test suite should follow the following structure:

Temporarily it may be allowed to split unit tests for a module into multiple `test_<module>_<feature>.py` test modules. This should be taken as a reason to think about splitting the source module though.

Temporarily, tests for testing utilities can be placed next to the module containing them, with the name `test_util_<module>.py`. This should be taken as a hint that the tested utils should be moved into the library.

TODO: add missing test conventions.

<!--
Expand Down
17 changes: 16 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,22 @@ skip_glob = ['*.venv/**', '_local/**']
# -- mypy --
[tool.mypy]
disallow_incomplete_defs = true
exclude = ['^setup\.py$', '^build/.*py$', '^ci/*.py$', '^tests/*.py$']
exclude = [
'^setup\.py$',
'^build/.*py$',
'^ci/*.py$',
'^tests/cartesian_tests/*.py$',
'^tests/storage_tests/*.py$',
'^tests/eve_tests/*.py$',
'^tests/next_tests/unit_tests/*.py$',
'^tests/next_tests/integration_tests/multi_feature_tests/*.py$',
'^tests/next_tests/integration_tests/feature_tests/ffront_tests/*.py$',
'^tests/next_tests/integration_tests/feature_tests/iterator_tests/*.py$',
'^tests/next_tests/integration_tests/feature_tests/otf_tests/*.py$',
'^tests/next_tests/integration_tests/feature_tests/math_builtin_test_data.py$',
'^tests/next_tests/past_common_fixtures.py$',
'^tests/next_tests/toy_connectivity.py$'
]
ignore_missing_imports = true
install_types = true
namespace_packages = false
Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/next/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

DimT = TypeVar("DimT", bound="Dimension")
DimsT = TypeVar("DimsT", bound=Sequence["Dimension"])
DT = TypeVar("DT", bound="DType")
DT = TypeVar("DT", bound="Scalar")

Scalar: TypeAlias = SupportsInt | SupportsFloat | np.int32 | np.int64 | np.float32 | np.float64

Expand Down
11 changes: 10 additions & 1 deletion src/gt4py/next/ffront/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,23 @@ def __post_init__(self):
f"The following closure variables are undefined: {', '.join(undefined_symbols)}"
)

def with_backend(self, backend: ppi.ProgramExecutor) -> "Program":
def with_backend(self, backend: ppi.ProgramExecutor) -> Program:
return Program(
past_node=self.past_node,
closure_vars=self.closure_vars,
backend=backend,
definition=self.definition, # type: ignore[arg-type] # mypy wrongly deduces definition as method here
)

def with_grid_type(self, grid_type: GridType) -> Program:
return Program(
past_node=self.past_node,
closure_vars=self.closure_vars,
backend=self.backend,
definition=self.definition,
grid_type=grid_type,
)

@functools.cached_property
def _all_closure_vars(self) -> dict[str, Any]:
return _get_closure_vars_recursively(self.closure_vars)
Expand Down
Loading