Skip to content

Commit

Permalink
array_find: Added parameter reverse. #269 #291
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Nov 4, 2021
1 parent c17e7e9 commit 6b666e6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `fit_curve`
- `predict_curve`
- `ard_normalized_radar_backscatter` and `sar_backscatter`: Added `options` parameter
- `run_udf`: Exception `InvalidRuntime` added
- `array_find`: Added parameter `reverse`. [#269](https://github.com/Open-EO/openeo-processes/issues/269)
- `run_udf`: Exception `InvalidRuntime` added. [#273](https://github.com/Open-EO/openeo-processes/issues/273)
- A new category "math > statistics" has been added [#277](https://github.com/Open-EO/openeo-processes/issues/277)

### Changed
Expand Down
27 changes: 26 additions & 1 deletion array_find.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "array_find",
"summary": "Get the index for a value in an array",
"description": "Checks whether the array specified for `data` contains the value specified in `value` and returns the zero-based index for the first match. If there's no match, `null` is returned.\n\n**Remarks:**\n\n* To get a boolean value returned use ``array_contains()``.\n* All definitions for the process ``eq()`` regarding the comparison of values apply here as well. A `null` return value from ``eq()`` is handled exactly as `false` (no match).\n* Data types MUST be checked strictly. For example, a string with the content *1* is not equal to the number *1*.\n* An integer *1* is equal to a floating-point number *1.0* as `integer` is a sub-type of `number`. Still, this process may return unexpectedly `false` when comparing floating-point numbers due to floating-point inaccuracy in machine-based computation.\n* Temporal strings are treated as normal strings and MUST NOT be interpreted.\n* If the specified value is an array, object or null, the process always returns `null`. See the examples for one to find `null` values.",
"description": "Returns the zero-based index of the first (or last) occurrence of the value specified by `value` in the array specified by `data` or `null` if there is no match. Use the parameter `reverse` to switch from the first to the last match.\n\n**Remarks:**\n\n* Use ``array_contains()`` to check if an array contains a value regardless of the position.\n* Use ``array_find_label()`` to find the index for a label.\n* All definitions for the process ``eq()`` regarding the comparison of values apply here as well. A `null` return value from ``eq()`` is handled exactly as `false` (no match).\n* Data types MUST be checked strictly. For example, a string with the content *1* is not equal to the number *1*.\n* An integer *1* is equal to a floating-point number *1.0* as `integer` is a sub-type of `number`. Still, this process may return unexpectedly `false` when comparing floating-point numbers due to floating-point inaccuracy in machine-based computation.\n* Temporal strings are treated as normal strings and MUST NOT be interpreted.\n* If the specified value is an array, object or null, the process always returns `null`. See the examples for one to find `null` values.",
"categories": [
"arrays",
"reducer"
Expand All @@ -23,6 +23,15 @@
"schema": {
"description": "Any data type is allowed."
}
},
{
"name": "reverse",
"description": "By default, this process finds the index of the first match. To return the index of the last match instead, set this flag to `true`.",
"schema": {
"type": "boolean"
},
"default": false,
"optional": true
}
],
"returns": {
Expand All @@ -43,12 +52,28 @@
"data": [
1,
2,
3,
2,
3
],
"value": 2
},
"returns": 1
},
{
"arguments": {
"data": [
1,
2,
3,
2,
3
],
"value": 2,
"reverse": true
},
"returns": 3
},
{
"arguments": {
"data": [
Expand Down
2 changes: 1 addition & 1 deletion proposals/array_find_label.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "array_find_label",
"summary": "Get the index for a label in a labeled array",
"description": "Checks whether the labeled array specified for `data` has the label specified in `label` and returns the zero-based index for it. If there's no match as either the label doesn't exist or the array is not labeled, `null` is returned.",
"description": "Checks whether the labeled array specified for `data` has the label specified in `label` and returns the zero-based index for it. If there's no match as either the label doesn't exist or the array is not labeled, `null` is returned.\n\nUse ``array_find()`` to find the index for a given value in the array.",
"categories": [
"arrays",
"reducer"
Expand Down

0 comments on commit 6b666e6

Please sign in to comment.