Skip to content

Commit 2cf6c1c

Browse files
authored
Make all/any more consistent with other programming languages #494 (#550)
1 parent 92b5f40 commit 2cf6c1c

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Added a [section about character encodings to the implementation guide](meta/implementation.md#character-encoding).
2929
Removed any character encoding related wording from the process specifications itself.
3030
- Added a uniqueness contraint to various array-typed parameters (e.g. lists of dimension names or labels)
31+
- `all`: For empty arrays, returns `true` instead of no-data. [#494](https://github.com/Open-EO/openeo-processes/issues/494)
32+
- `any`: For empty arrays, returns `false` instead of no-data. [#494](https://github.com/Open-EO/openeo-processes/issues/494)
3133
- `apply_polygon`: Renamed `polygons` parameter to `geometries` for better alignment with other geometry handling processes. [#511](https://github.com/Open-EO/openeo-processes/issues/511)
3234
- `clip`: Throw an exception if min > max [#472](https://github.com/Open-EO/openeo-processes/issues/472)
3335
- `is_nan`: Return `false` instead of `true` for non-numerical data types. [#486](https://github.com/Open-EO/openeo-processes/issues/486)

all.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "all",
33
"summary": "Are all of the values true?",
4-
"description": "Checks if **all** of the values in `data` are true. If no value is given (i.e. the array is empty) the process returns the no-data value (or `null`).\n\nBy default all no-data values are ignored so that the process returns the no-data value (or `null`) if all values are no-data, `true` if all values are true and `false` otherwise. Setting the `ignore_nodata` flag to `false` takes no-data values into account and the array values are reduced pairwise according to the following truth table:\n\n```\n || no-data | false | true\n------- || ------- | ----- | -------\nno-data || no-data | false | no-data\nfalse || false | false | false\ntrue || no-data | false | true\n```\n\n**Remark:** The process evaluates all values from the first to the last element and stops once the outcome is unambiguous. A result is ambiguous unless a value is `false` or all values have been taken into account.",
4+
"description": "Checks if **all** of the values in `data` are true. If no value is given (i.e. the array is empty) the process returns `true`.\n\nBy default, all no-data values are ignored so that the process returns `true` if all values are no-data or true, and `false` otherwise. Setting the `ignore_nodata` flag to `false` takes no-data values into account and the array values are reduced pairwise according to the following truth table:\n\n```\n || no-data | false | true\n------- || ------- | ----- | -------\nno-data || no-data | false | no-data\nfalse || false | false | false\ntrue || no-data | false | true\n```\n\n**Remark:** The process evaluates all values in an arbitrary order and stops once the outcome is unambiguous, i.e. when either a `false` value is encountered, or when all values have been taken into account.",
55
"categories": [
66
"logic",
77
"reducer"
@@ -124,11 +124,19 @@
124124
},
125125
"returns": null
126126
},
127+
{
128+
"arguments": {
129+
"data": [
130+
null
131+
]
132+
},
133+
"returns": true
134+
},
127135
{
128136
"arguments": {
129137
"data": []
130138
},
131-
"returns": null
139+
"returns": true
132140
}
133141
]
134142
}

any.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "any",
33
"summary": "Is at least one value true?",
4-
"description": "Checks if **any** (i.e. at least one) value in `data` is `true`. If no value is given (i.e. the array is empty) the process returns the no-data value (or `null`).\n\nBy default all no-data values are ignored so that the process returns the no-data value (or `null`) if all values are no-data, `true` if at least one value is true and `false` otherwise. Setting the `ignore_nodata` flag to `false` takes no-data values into account and the array values are reduced pairwise according to the following truth table:\n\n```\n || no-data | false | true\n------- || ------- | ------- | ----\nno-data || no-data | no-data | true\nfalse || no-data | false | true\ntrue || true | true | true\n```\n\n**Remark:** The process evaluates all values from the first to the last element and stops once the outcome is unambiguous. A result is ambiguous unless a value is `true`.",
4+
"description": "Checks if **any** (i.e. at least one) value in `data` is `true`. If no value is given (i.e. the array is empty) the process returns `false`.\n\nBy default all no-data values are ignored so that the process returns `true` if at least one value is true and `false` otherwise. Setting the `ignore_nodata` flag to `false` takes no-data values into account and the array values are reduced pairwise according to the following truth table:\n\n```\n || no-data | false | true\n------- || ------- | ------- | ----\nno-data || no-data | no-data | true\nfalse || no-data | false | true\ntrue || true | true | true\n```\n\n**Remark:** The process evaluates all values in an arbitrary order and stops once the outcome is unambiguous, i.e. when either a `true` value is encountered, or when all values have been taken into account.",
55
"categories": [
66
"logic",
77
"reducer"
@@ -124,11 +124,19 @@
124124
},
125125
"returns": null
126126
},
127+
{
128+
"arguments": {
129+
"data": [
130+
null
131+
]
132+
},
133+
"returns": false
134+
},
127135
{
128136
"arguments": {
129137
"data": []
130138
},
131-
"returns": null
139+
"returns": false
132140
}
133141
]
134142
}

tests/all.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@
8484
],
8585
"ignore_nodata": false
8686
},
87-
"returns": {"type": "nodata"}
87+
"returns": true
8888
},
8989
{
9090
"arguments": {
9191
"data": []
9292
},
93-
"returns": {"type": "nodata"}
93+
"returns": true
9494
}
9595
]
9696
}

tests/any.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@
8484
],
8585
"ignore_nodata": false
8686
},
87-
"returns": {"type": "nodata"}
87+
"returns": false
8888
},
8989
{
9090
"arguments": {
9191
"data": []
9292
},
93-
"returns": {"type": "nodata"}
93+
"returns": false
9494
}
9595
]
9696
}

0 commit comments

Comments
 (0)