Skip to content

Commit

Permalink
test[next]: fix obsolete asarray (#1436)
Browse files Browse the repository at this point in the history
  • Loading branch information
havogt authored Jan 31, 2024
1 parent 3fb512d commit 6262708
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def testee(
for name in ("out1", "out2", "out3", "out4")
)

ref = np.asarray(a) + 2 * np.asarray(b) + 3 * np.asarray(c)
ref = a + 2 * b + 3 * c

cases.verify(
cartesian_case,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def testee(a: cases.IKField, offset_field: cases.IKField) -> gtx.Field[[IDim, KD
offset_field,
out=out,
offset_provider={"Ioff": IDim, "Koff": KDim},
ref=np.full_like(offset_field, True, dtype=bool),
ref=np.full_like(offset_field.asnumpy(), True, dtype=bool),
comparison=lambda out, ref: np.all(out == ref),
)

Expand Down Expand Up @@ -665,7 +665,7 @@ def testee(a: cases.IField, b: cases.IField, left: int32, right: int32) -> cases
def testee(left: int32, right: int32) -> cases.IField:
return broadcast(3, (IDim,)) if left > right else broadcast(4, (IDim,))

e = np.asarray(a) if left < right else np.asarray(b)
e = a if left < right else b
cases.verify(
cartesian_case,
testee,
Expand Down Expand Up @@ -764,9 +764,9 @@ def testee(out: tuple[cases.KField, tuple[cases.KField, cases.KField]]):
cartesian_case,
testee,
ref=lambda: (expected + 1.0, (expected + 2.0, expected + 3.0)),
comparison=lambda ref, out: np.all(np.asarray(out[0]) == ref[0])
and np.all(np.asarray(out[1][0]) == ref[1][0])
and np.all(np.asarray(out[1][1]) == ref[1][1]),
comparison=lambda ref, out: np.all(out[0] == ref[0])
and np.all(out[1][0] == ref[1][0])
and np.all(out[1][1] == ref[1][1]),
)


Expand Down Expand Up @@ -1195,5 +1195,7 @@ def consume_constants(input: cases.IFloatField) -> cases.IFloatField:
return constants.PI * constants.E * input

cases.verify_with_default_data(
cartesian_case, consume_constants, ref=lambda input: constants.PI * constants.E * input
cartesian_case,
consume_constants,
ref=lambda input: constants.PI * constants.E * input,
)
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ def nested_if_conditional_return(
out = cases.allocate(cartesian_case, nested_if_conditional_return, cases.RETURN)()

ref = {
(True, True): np.asarray(inp) + 1,
(True, False): np.asarray(inp) + 2,
(False, True): np.asarray(inp) + 3,
(False, False): np.asarray(inp) + 3,
(True, True): inp.asnumpy() + 1,
(True, False): inp.asnumpy() + 2,
(False, True): inp.asnumpy() + 3,
(False, False): inp.asnumpy() + 3,
}

cases.verify(
Expand Down Expand Up @@ -289,7 +289,7 @@ def nested_if(a: cases.IField, b: cases.IField, condition: bool) -> cases.IField
b,
condition,
out=out,
ref=np.asarray(a) + 1 if condition else np.asarray(b) + 5,
ref=a.asnumpy() + 1 if condition else b.asnumpy() + 5,
)


Expand Down

0 comments on commit 6262708

Please sign in to comment.