Skip to content

Commit

Permalink
removed all # noqa: F811 from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nfarabullini committed Feb 27, 2024
1 parent 952f52f commit 681a8d7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def defir_to_gtir():

def test_stencil_definition(
defir_to_gtir,
ijk_domain, # noqa: F811 [redefinition, reason: fixture]
ijk_domain, # [redefinition, reason: fixture]
):
stencil_definition = (
TDefinition(name="definition", domain=ijk_domain, fields=["a", "b"])
Expand Down
2 changes: 1 addition & 1 deletion tests/eve_tests/unit_tests/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


# -- Name tests --
def test_name(name_with_cases): # noqa: F811 # pytest fixture not detected
def test_name(name_with_cases):
name = codegen.Name(name_with_cases.pop("words"))
for case, cased_string in name_with_cases.items():
assert name.as_case(case) == cased_string
Expand Down
6 changes: 3 additions & 3 deletions tests/next_tests/integration_tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def verify_with_default_data(

@pytest.fixture
def cartesian_case(
exec_alloc_descriptor: test_definitions.ExecutionAndAllocatorDescriptor, # noqa: F811 # fixtures
exec_alloc_descriptor: test_definitions.ExecutionAndAllocatorDescriptor,
):
yield Case(
exec_alloc_descriptor.executor,
Expand All @@ -487,8 +487,8 @@ def cartesian_case(

@pytest.fixture
def unstructured_case(
mesh_descriptor, # noqa: F811 # fixtures
exec_alloc_descriptor: test_definitions.ExecutionAndAllocatorDescriptor, # noqa: F811 # fixtures
mesh_descriptor,
exec_alloc_descriptor: test_definitions.ExecutionAndAllocatorDescriptor,
):
yield Case(
exec_alloc_descriptor.executor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
)


def test_copy(cartesian_case): # noqa: F811 # fixtures
def test_copy(cartesian_case):
@gtx.field_operator
def testee(a: cases.IJKField) -> cases.IJKField:
field_tuple = (a, a)
Expand All @@ -69,7 +69,7 @@ def testee(a: cases.IJKField) -> cases.IJKField:


@pytest.mark.uses_tuple_returns
def test_multicopy(cartesian_case): # noqa: F811 # fixtures
def test_multicopy(cartesian_case):
@gtx.field_operator
def testee(a: cases.IJKField, b: cases.IJKField) -> tuple[cases.IJKField, cases.IJKField]:
return a, b
Expand All @@ -78,7 +78,7 @@ def testee(a: cases.IJKField, b: cases.IJKField) -> tuple[cases.IJKField, cases.


@pytest.mark.uses_cartesian_shift
def test_cartesian_shift(cartesian_case): # noqa: F811 # fixtures
def test_cartesian_shift(cartesian_case):
@gtx.field_operator
def testee(a: cases.IJKField) -> cases.IJKField:
return a(Ioff[1])
Expand All @@ -90,7 +90,7 @@ def testee(a: cases.IJKField) -> cases.IJKField:


@pytest.mark.uses_unstructured_shift
def test_unstructured_shift(unstructured_case): # noqa: F811 # fixtures
def test_unstructured_shift(unstructured_case):
@gtx.field_operator
def testee(a: cases.VField) -> cases.EField:
return a(E2V[0])
Expand Down Expand Up @@ -148,7 +148,7 @@ def composed_shift_unstructured(inp: cases.VField) -> cases.CField:


@pytest.mark.uses_cartesian_shift
def test_fold_shifts(cartesian_case): # noqa: F811 # fixtures
def test_fold_shifts(cartesian_case):
"""Shifting the result of an addition should work."""

@gtx.field_operator
Expand All @@ -163,7 +163,7 @@ def testee(a: cases.IJKField, b: cases.IJKField) -> cases.IJKField:
cases.verify(cartesian_case, testee, a, b, out=out, ref=a.ndarray[1:] + b.ndarray[2:])


def test_tuples(cartesian_case): # noqa: F811 # fixtures
def test_tuples(cartesian_case):
@gtx.field_operator
def testee(a: cases.IJKFloatField, b: cases.IJKFloatField) -> cases.IJKFloatField:
inps = a, b
Expand All @@ -175,7 +175,7 @@ def testee(a: cases.IJKFloatField, b: cases.IJKFloatField) -> cases.IJKFloatFiel
)


def test_scalar_arg(unstructured_case): # noqa: F811 # fixtures
def test_scalar_arg(unstructured_case):
"""Test scalar argument being turned into 0-dim field."""

@gtx.field_operator
Expand All @@ -194,7 +194,7 @@ def testee(a: int32) -> cases.VField:
)


def test_nested_scalar_arg(unstructured_case): # noqa: F811 # fixtures
def test_nested_scalar_arg(unstructured_case):
@gtx.field_operator
def testee_inner(a: int32) -> cases.VField:
return broadcast(a + 1, (Vertex,))
Expand All @@ -212,7 +212,7 @@ def testee(a: int32) -> cases.VField:

@pytest.mark.uses_index_fields
@pytest.mark.uses_cartesian_shift
def test_scalar_arg_with_field(cartesian_case): # noqa: F811 # fixtures
def test_scalar_arg_with_field(cartesian_case):
@gtx.field_operator
def testee(a: cases.IJKField, b: int32) -> cases.IJKField:
tmp = b * a
Expand All @@ -226,7 +226,7 @@ def testee(a: cases.IJKField, b: int32) -> cases.IJKField:
cases.verify(cartesian_case, testee, a, b, out=out, ref=ref)


def test_scalar_in_domain_spec_and_fo_call(cartesian_case): # noqa: F811 # fixtures
def test_scalar_in_domain_spec_and_fo_call(cartesian_case):
pytest.xfail(
"Scalar arguments not supported to be used in both domain specification "
"and as an argument to a field operator."
Expand All @@ -253,7 +253,7 @@ def testee(size: gtx.IndexType, out: gtx.Field[[IDim], gtx.IndexType]):


@pytest.mark.uses_scan
def test_scalar_scan(cartesian_case): # noqa: F811 # fixtures
def test_scalar_scan(cartesian_case):
@gtx.scan_operator(axis=KDim, forward=True, init=(0.0))
def testee_scan(state: float, qc_in: float, scalar: float) -> float:
qc = qc_in + state + scalar
Expand All @@ -273,7 +273,7 @@ def testee(qc: cases.IKFloatField, scalar: float):

@pytest.mark.uses_scan
@pytest.mark.uses_scan_in_field_operator
def test_tuple_scalar_scan(cartesian_case): # noqa: F811 # fixtures
def test_tuple_scalar_scan(cartesian_case):
@gtx.scan_operator(axis=KDim, forward=True, init=0.0)
def testee_scan(
state: float, qc_in: float, tuple_scalar: tuple[float, tuple[float, float]]
Expand All @@ -296,7 +296,7 @@ def testee_op(
@pytest.mark.uses_cartesian_shift
@pytest.mark.uses_scan
@pytest.mark.uses_index_fields
def test_scalar_scan_vertical_offset(cartesian_case): # noqa: F811 # fixtures
def test_scalar_scan_vertical_offset(cartesian_case):
@gtx.scan_operator(axis=KDim, forward=True, init=(0.0))
def testee_scan(state: float, inp: float) -> float:
return inp
Expand Down Expand Up @@ -336,7 +336,7 @@ def testee_prog(a: cases.IKField):
cases.verify(cartesian_case, testee_prog, a, inout=a[1, 3], ref=ref)


def test_astype_int(cartesian_case): # noqa: F811 # fixtures
def test_astype_int(cartesian_case):
@gtx.field_operator
def testee(a: cases.IFloatField) -> gtx.Field[[IDim], int64]:
b = astype(a, int64)
Expand All @@ -351,7 +351,7 @@ def testee(a: cases.IFloatField) -> gtx.Field[[IDim], int64]:


@pytest.mark.uses_tuple_returns
def test_astype_on_tuples(cartesian_case): # noqa: F811 # fixtures
def test_astype_on_tuples(cartesian_case):
@gtx.field_operator
def field_op_returning_a_tuple(
a: cases.IFloatField, b: cases.IFloatField
Expand Down Expand Up @@ -423,7 +423,7 @@ def cast_nested_tuple(
)


def test_astype_bool_field(cartesian_case): # noqa: F811 # fixtures
def test_astype_bool_field(cartesian_case):
@gtx.field_operator
def testee(a: cases.IFloatField) -> gtx.Field[[IDim], bool]:
b = astype(a, bool)
Expand All @@ -438,7 +438,7 @@ def testee(a: cases.IFloatField) -> gtx.Field[[IDim], bool]:


@pytest.mark.parametrize("inp", [0.0, 2.0])
def test_astype_bool_scalar(cartesian_case, inp): # noqa: F811 # fixtures
def test_astype_bool_scalar(cartesian_case, inp):
@gtx.field_operator
def testee(inp: float) -> gtx.Field[[IDim], bool]:
return broadcast(astype(inp, bool), (IDim,))
Expand All @@ -448,7 +448,7 @@ def testee(inp: float) -> gtx.Field[[IDim], bool]:
cases.verify(cartesian_case, testee, inp, out=out, ref=bool(inp))


def test_astype_float(cartesian_case): # noqa: F811 # fixtures
def test_astype_float(cartesian_case):
@gtx.field_operator
def testee(a: cases.IFloatField) -> gtx.Field[[IDim], np.float32]:
b = astype(a, float32)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def mixed_args(
return (a, (c, a))


def test_allocate_default_unique(cartesian_case): # noqa: F811 # fixtures
def test_allocate_default_unique(cartesian_case):
a = cases.allocate(cartesian_case, mixed_args, "a")()

assert np.min(a.asnumpy()) == 0
Expand All @@ -54,15 +54,15 @@ def test_allocate_default_unique(cartesian_case): # noqa: F811 # fixtures
assert np.max(c.asnumpy()) == np.prod(tuple(cartesian_case.default_sizes.values())) * 2


def test_allocate_return_default_zeros(cartesian_case): # noqa: F811 # fixtures
def test_allocate_return_default_zeros(cartesian_case):
a, (b, c) = cases.allocate(cartesian_case, mixed_args, cases.RETURN)()

assert np.all(a.asnumpy() == 0)
assert np.all(b.asnumpy() == 0)
assert np.all(c.asnumpy() == 0)


def test_allocate_const(cartesian_case): # noqa: F811 # fixtures
def test_allocate_const(cartesian_case):
a = cases.allocate(cartesian_case, mixed_args, "a").strategy(cases.ConstInitializer(42))()
assert np.all(a.asnumpy() == 42)

Expand All @@ -71,7 +71,7 @@ def test_allocate_const(cartesian_case): # noqa: F811 # fixtures


@pytest.mark.parametrize("exec_alloc_descriptor", [definitions.ProgramBackendId.ROUNDTRIP.load()])
def test_verify_fails_with_wrong_reference(cartesian_case): # noqa: F811 # fixtures
def test_verify_fails_with_wrong_reference(cartesian_case):
a = cases.allocate(cartesian_case, addition, "a")()
b = cases.allocate(cartesian_case, addition, "b")()
out = cases.allocate(cartesian_case, addition, cases.RETURN)()
Expand All @@ -82,7 +82,7 @@ def test_verify_fails_with_wrong_reference(cartesian_case): # noqa: F811 # fixt


@pytest.mark.parametrize("exec_alloc_descriptor", [definitions.ProgramBackendId.ROUNDTRIP.load()])
def test_verify_fails_with_wrong_type(cartesian_case): # noqa: F811 # fixtures
def test_verify_fails_with_wrong_type(cartesian_case):
a = cases.allocate(cartesian_case, addition, "a").dtype(np.float32)()
b = cases.allocate(cartesian_case, addition, "b")()
out = cases.allocate(cartesian_case, addition, cases.RETURN)()
Expand All @@ -93,7 +93,7 @@ def test_verify_fails_with_wrong_type(cartesian_case): # noqa: F811 # fixtures

@pytest.mark.parametrize("exec_alloc_descriptor", [definitions.ProgramBackendId.ROUNDTRIP.load()])
def test_verify_with_default_data_fails_with_wrong_reference(
cartesian_case, # noqa: F811 # fixtures
cartesian_case,
):
def wrong_ref(a, b):
return a - b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)


def test_default_backend_is_respected_field_operator(cartesian_case): # noqa: F811 # fixtures
def test_default_backend_is_respected_field_operator(cartesian_case):
"""Test that manually calling the field operator without setting the backend raises an error."""

# Important not to set the backend here!
Expand All @@ -43,7 +43,7 @@ def copy(a: IField) -> IField:
_ = copy(a, out=a, offset_provider={})


def test_default_backend_is_respected_scan_operator(cartesian_case): # noqa: F811 # fixtures
def test_default_backend_is_respected_scan_operator(cartesian_case):
"""Test that manually calling the scan operator without setting the backend raises an error."""

# Important not to set the backend here!
Expand All @@ -58,7 +58,7 @@ def sum(state: float, a: float) -> float:
_ = sum(a, out=a, offset_provider={})


def test_default_backend_is_respected_program(cartesian_case): # noqa: F811 # fixtures
def test_default_backend_is_respected_program(cartesian_case):
"""Test that manually calling the program without setting the backend raises an error."""

@gtx.field_operator
Expand All @@ -78,7 +78,7 @@ def copy_program(a: IField, b: IField) -> IField:
_ = copy_program(a, b, offset_provider={})


def test_missing_arg_field_operator(cartesian_case): # noqa: F811 # fixtures
def test_missing_arg_field_operator(cartesian_case):
"""Test that calling a field_operator without required args raises an error."""

@gtx.field_operator(backend=cartesian_case.executor)
Expand All @@ -94,7 +94,7 @@ def copy(a: IField) -> IField:
_ = copy(a, out=a)


def test_missing_arg_scan_operator(cartesian_case): # noqa: F811 # fixtures
def test_missing_arg_scan_operator(cartesian_case):
"""Test that calling a scan_operator without required args raises an error."""

@gtx.scan_operator(backend=cartesian_case.executor, axis=KDim, init=0.0, forward=True)
Expand All @@ -110,7 +110,7 @@ def sum(state: float, a: float) -> float:
_ = sum(a, out=a)


def test_missing_arg_program(cartesian_case): # noqa: F811 # fixtures
def test_missing_arg_program(cartesian_case):
"""Test that calling a program without required args raises an error."""

@gtx.field_operator
Expand Down

0 comments on commit 681a8d7

Please sign in to comment.