Skip to content

Commit d044afd

Browse files
authored
Merge pull request #879 from kordejong/gh841
lue.pcraster max and min differ when testing for non_spatial_to_spatial
2 parents 486dcf6 + 35a745f commit d044afd

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

source/framework/python/pcraster/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ def min(*args):
951951
# TODO Support non-spatial condition(?)
952952
condition = expression1 <= expression2
953953

954-
if is_non_spatial(condition) or lue_is_value(condition):
954+
if is_non_spatial(condition):
955955
condition = non_spatial_to_spatial(condition)
956956

957957
return lfr.where(condition, expression1, expression2)

source/framework/python/test/pcraster/local_operation_test.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .operation_test import OperationTest, setUpModule, tearDownModule
77

88

9-
# TODO Add tests for overload accepting value instead of non_spatial
9+
# TODO Add remaining tests for overload accepting value instead of non_spatial, similar to max/min.
1010

1111

1212
class LocalOperationTest(OperationTest):
@@ -26,28 +26,40 @@ def test_add(self):
2626
@lue_test.framework_test_case
2727
def test_max(self):
2828
for expression_type in [np.uint8, np.int32, np.float32]:
29-
spatial, non_spatial = (
29+
spatial, non_spatial, value = (
3030
self.spatial[expression_type],
3131
self.non_spatial[expression_type],
32+
self.value[expression_type],
3233
)
3334

3435
_ = lpr.max(spatial, spatial)
3536
_ = lpr.max(spatial, non_spatial)
37+
_ = lpr.max(spatial, value)
3638
_ = lpr.max(non_spatial, spatial)
3739
_ = lpr.max(non_spatial, non_spatial)
40+
_ = lpr.max(non_spatial, value)
41+
_ = lpr.max(value, spatial)
42+
_ = lpr.max(value, non_spatial)
43+
_ = lpr.max(value, value)
3844

3945
@lue_test.framework_test_case
4046
def test_min(self):
4147
for expression_type in [np.uint8, np.int32, np.float32]:
42-
spatial, non_spatial = (
48+
spatial, non_spatial, value = (
4349
self.spatial[expression_type],
4450
self.non_spatial[expression_type],
51+
self.value[expression_type],
4552
)
4653

4754
_ = lpr.min(spatial, spatial)
4855
_ = lpr.min(spatial, non_spatial)
56+
_ = lpr.min(spatial, value)
4957
_ = lpr.min(non_spatial, spatial)
5058
_ = lpr.min(non_spatial, non_spatial)
59+
_ = lpr.min(non_spatial, value)
60+
_ = lpr.min(value, spatial)
61+
_ = lpr.min(value, non_spatial)
62+
_ = lpr.min(value, value)
5163

5264
@lue_test.framework_test_case
5365
def test_subtract(self):

0 commit comments

Comments
 (0)