Skip to content

Commit

Permalink
Add tests for array_apply, more NaN tests for comparisons, add requir…
Browse files Browse the repository at this point in the history
…ed flag for sub-processes
  • Loading branch information
m-mohr committed Dec 11, 2023
1 parent 4375df0 commit ad402ce
Show file tree
Hide file tree
Showing 8 changed files with 432 additions and 5 deletions.
11 changes: 10 additions & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This folder contains test cases for the openEO processes.
- [x] arctan
- [x] arctan2
- [x] array_append
- [ ] array_apply
- [x] array_apply
- [x] array_concat
- [x] array_contains
- [x] array_create
Expand Down Expand Up @@ -226,6 +226,15 @@ properties:
description: An argument, can be of any type
returns:
description: The return value, can be of any type
required:
description: >-
A list of processes that is required for this test (except for the process provided in `id`).
This is usually required for processes that run a sub-process (callback) so that the test suite can skip tests for processes that are not supported.
type: array
items:
type: string
description: The identifier for the sub-process.
pattern: '^\w+$'
delta:
description: If set to a positive number the equality of the actual return value and the expected return value is checked against a delta value to circumvent problems with floating-point inaccuracy.
type: number
Expand Down
338 changes: 336 additions & 2 deletions tests/array_apply.json5
Original file line number Diff line number Diff line change
@@ -1,4 +1,338 @@
{
"id": "array_apply",
"tests": []
}
"tests": [
{
// empty array
"required": [
"absolute"
],
"arguments": {
"data": [],
"process": {
"process_graph": {
"absolute": {
"process_id": "absolute",
"arguments": {
"x": {
"from_argument": "x"
}
},
"result": true
}
}
}
},
"returns": []
},
{
// single math process applied to a normal array
"required": [
"absolute"
],
"arguments": {
"data": [
1,
-2,
3.5,
-4.725,
NaN
],
"process": {
"process_graph": {
"absolute": {
"process_id": "absolute",
"arguments": {
"x": {
"from_argument": "x"
}
},
"result": true
}
}
}
},
"returns": [
1,
2,
3.5,
4.725,
NaN
]
},
{
// single math process applied to a normal array, with context parameter
"required": [
"multiply"
],
"arguments": {
"data": [
1,
2.5
],
"process": {
"process_graph": {
"absolute": {
"process_id": "multiply",
"arguments": {
"x": {
"from_argument": "x"
},
"y": {
"from_argument": "context"
}
},
"result": true
}
}
},
"context": 2.5
},
"returns": [
2.5,
6.25
]
},
{
// single comparison process with datatype change applied to a normal array
"required": [
"gt"
],
"arguments": {
"data": [
1,
-2,
3.5,
-4.725,
NaN
],
"process": {
"process_graph": {
"gt": {
"process_id": "gt",
"arguments": {
"x": {
"from_argument": "x"
},
"y": 3
},
"result": true
}
}
}
},
"returns": [
false,
false,
true,
true,
false
]
},
{
// handle index from a normal array
"required": [
"constant"
],
"arguments": {
"data": [
1,
2,
3,
4
],
"process": {
"process_graph": {
"const": {
"process_id": "constant",
"arguments": {
"x": {
"from_argument": "index"
}
},
"result": true
}
}
}
},
"returns": [
0,
1,
2,
3
]
},
{
// handle label from a labeled array
"required": [
"constant"
],
"arguments": {
"data": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 1.23
},
{
"key": "B02",
"value": 0.98
}
]
},
"process": {
"process_graph": {
"const": {
"process_id": "constant",
"arguments": {
"x": {
"from_argument": "label"
}
},
"result": true
}
}
}
},
"returns": [
"B01",
"B02"
]
},
{
// handle index and value from a labeled array
"required": [
"add"
],
"arguments": {
"data": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 1.23
},
{
"key": "B02",
"value": 0.98
}
]
},
"process": {
"process_graph": {
"const": {
"process_id": "add",
"arguments": {
"x": {
"from_argument": "index"
},
"y": {
"from_argument": "x"
}
},
"result": true
}
}
}
},
"returns": [
1.23,
1.98
]
},
{
// single math process applied to a labeled array
"required": [
"subtract"
],
"arguments": {
"data": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 1.23
},
{
"key": "B02",
"value": 0.98
}
]
},
"process": {
"process_graph": {
"const": {
"process_id": "subtract",
"arguments": {
"x": {
"from_argument": "x"
},
"y": 1
},
"result": true
}
}
}
},
"returns": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 0.23
},
{
"key": "B02",
"value": -0.02
}
]
}
},
{
// apply multiple math process to a labeled array
"required": [
"add",
"multiply"
],
"arguments": {
"data": [
1,
-2,
3.5,
-4.725,
NaN
],
"process": {
"process_graph": {
"add": {
"process_id": "add",
"arguments": {
"x": {
"from_argument": "x"
},
"y": 1.5
}
},
"mulitply": {
"process_id": "mulitply",
"arguments": {
"x": {
"from_node": "add"
},
"y": 2
},
"result": true
}
}
}
},
"returns": [
5,
-1,
10,
6.45,
NaN
]
}
]
}
16 changes: 15 additions & 1 deletion tests/eq.json5
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@
},
"returns": null
},
{
"arguments": {
"x": 5,
"y": NaN
},
"returns": false
},
{
"arguments": {
"x": NaN,
"y": 5
},
"returns": false
},
{
"arguments": {
"x": NaN,
Expand All @@ -119,4 +133,4 @@
"returns": false
}
]
}
}
Loading

0 comments on commit ad402ce

Please sign in to comment.