From 2cb3a61b46ebb9b9c956bedcc9eeec3529626149 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Wed, 13 Dec 2023 13:53:57 +0100 Subject: [PATCH] Add more tests --- tests/README.md | 22 +- tests/add_dimension.json5 | 179 ++++++++++++++- tests/apply.json5 | 158 ++++++++++++- tests/apply_dimension.json5 | 70 +++++- tests/array_create_labeled.json5 | 87 +++++++- tests/array_element.json5 | 24 ++ tests/array_find_label.json5 | 97 +++++++- tests/assets/xyb-enumerated-bands.json5 | 42 ++++ tests/assets/xyb-minimal-int.json5 | 42 ++++ tests/assets/xyb-one-band.json5 | 31 +++ ...-minimal.json5 => xyt-minimal-float.json5} | 0 tests/create_data_cube.json5 | 11 +- tests/dimension_labels.json5 | 57 ++++- tests/drop_dimension.json5 | 53 ++++- tests/reduce_dimension.json5 | 78 ++++++- tests/rename_dimension.json5 | 159 ++++++++++++- tests/rename_labels.json5 | 210 +++++++++++++++++- 17 files changed, 1295 insertions(+), 25 deletions(-) create mode 100644 tests/assets/xyb-enumerated-bands.json5 create mode 100644 tests/assets/xyb-minimal-int.json5 create mode 100644 tests/assets/xyb-one-band.json5 rename tests/assets/{xyt-minimal.json5 => xyt-minimal-float.json5} (100%) diff --git a/tests/README.md b/tests/README.md index e8cab80b..384d18b0 100644 --- a/tests/README.md +++ b/tests/README.md @@ -6,7 +6,7 @@ This folder contains test cases for the openEO processes. - [x] absolute - [x] add -- [ ] add_dimension +- [x] add_dimension - [ ] aggregate_spatial - [ ] aggregate_spatial_window (experimental) - [ ] aggregate_temporal @@ -15,8 +15,8 @@ This folder contains test cases for the openEO processes. - [x] and - [ ] anomaly - [x] any -- [ ] apply -- [ ] apply_dimension +- [x] apply* +- [x] apply_dimension* - [ ] apply_kernel - [ ] apply_neighborhood - [ ] apply_polygon (experimental) @@ -30,11 +30,11 @@ This folder contains test cases for the openEO processes. - [x] array_concat - [x] array_contains - [x] array_create -- [ ] array_create_labeled (experimental) +- [x] array_create_labeled (experimental) - [x] array_element - [x] array_filter - [x] array_find -- [ ] array_find_label (experimental) +- [x] array_find_label (experimental) - [x] array_interpolate_linear - [x] array_labels - [x] array_modify* (experimental) @@ -52,13 +52,13 @@ This folder contains test cases for the openEO processes. - [x] cummin* (experimental) - [x] cumproduct* (experimental) - [x] cumsum* (experimental) -- [ ] create_data_cube +- [x] create_data_cube - [x] date_between* (experimental) - [x] date_difference* (experimental) - [x] date_shift* (experimental) -- [ ] dimension_labels +- [x] dimension_labels - [x] divide -- [ ] drop_dimension +- [x] drop_dimension* - [x] e - [x] eq - [x] exp @@ -107,10 +107,10 @@ This folder contains test cases for the openEO processes. - [x] product - [x] quantiles - [x] rearrange* -- [ ] reduce_dimension +- [x] reduce_dimension* - [ ] reduce_spatial (experimental) -- [ ] rename_dimension -- [ ] rename_labels +- [x] rename_dimension +- [x] rename_labels - [ ] resample_cube_spatial - [ ] resample_cube_temporal - [ ] resample_spatial diff --git a/tests/add_dimension.json5 b/tests/add_dimension.json5 index 1be0c876..534bb139 100644 --- a/tests/add_dimension.json5 +++ b/tests/add_dimension.json5 @@ -1,5 +1,182 @@ { "id": "add_dimension", "level": "L2", - "tests": [] + "tests": [ + { + // add bands dimension + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "name": "b", + "label": "B1", + "type": "bands" + }, + "returns": { + "type": "datacube", + "dimensions": [ + { + "name": "b", + "type": "bands", + "values": ["B1"] + }, + { + "name": "t", + "type": "temporal", + "values": ["2020-06-01T00:00:00Z", "2020-06-03T00:00:00Z"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + }, + { + // add temporal dimension + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "name": "t", + "label": "2020-01-01T00:00:00Z", + "type": "temporal" + }, + "returns": { + "type": "datacube", + "dimensions": [ + { + "name": "t", + "type": "temporal", + "values": ["2020-01-01T00:00:00Z"] + }, + { + "name": "bands", + "type": "bands", + "values": ["red", "green", "blue"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + }, + { + // add second temporal dimension + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "name": "t2", + "label": "2010-01-01T00:00:00.0Z", + "type": "temporal" + }, + "returns": { + "type": "datacube", + "dimensions": [ + { + "name": "t2", + "type": "temporal", + "values": ["2010-01-01T00:00:00.0Z"] + }, + { + "name": "t", + "type": "temporal", + "values": ["2020-06-01T00:00:00Z", "2020-06-03T00:00:00Z"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + }, + { + // add other dimension + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "name": "var", + "label": 1, + "type": "other" + }, + "returns": { + "type": "datacube", + "dimensions": [ + { + "name": "var", + "type": "other", + "values": [1] + }, + { + "name": "t", + "type": "temporal", + "values": ["2020-06-01T00:00:00Z", "2020-06-03T00:00:00Z"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + }, + { + // throw for existing dimension + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "name": "t", + "label": "2020-01-01", + "type": "temporal" + }, + "throws": "DimensionExists" + } + ] } diff --git a/tests/apply.json5 b/tests/apply.json5 index 488e8eaa..3b5913f6 100644 --- a/tests/apply.json5 +++ b/tests/apply.json5 @@ -3,12 +3,13 @@ "level": "L1", "tests": [ { + // single math process "required": [ "add" ], "arguments": { "data": { - "$ref": "assets/xyt-minimal.json5" + "$ref": "assets/xyt-minimal-float.json5" }, "process": { "process_graph": { @@ -62,6 +63,161 @@ ] ] } + }, + { + // multiple processes with a data type change + "required": [ + "lt", + "gt", + "or" + ], + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "process": { + "process_graph": { + "lt": { + "process_id": "lt", + "arguments": { + "x": { + "from_argument": "x" + }, + "y": -50 + } + }, + "gt": { + "process_id": "gt", + "arguments": { + "x": { + "from_argument": "x" + }, + "y": 50 + } + }, + "or": { + "process_id": "or", + "arguments": { + "x": { + "from_node": "lt" + }, + "y": { + "from_node": "gt" + } + }, + "result": true + } + } + } + }, + "returns": { + "type": "datacube", + "nodata": NaN, + "dimensions": [ + { + "name": "t", + "type": "temporal", + "values": ["2020-06-01T00:00:00Z", "2020-06-03T00:00:00Z"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": [ + [ + [false, true, false, true], + [false, false, false, false], + [true, false, false, true] + ], + [ + [true, false, true, false], + [false, true, true, true], + [false, false, NaN, false] + ] + ] + } + }, + { + // math on integers with context parameter + "level": "L3", + "required": [ + "multiply" + ], + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "process": { + "process_graph": { + "add": { + "process_id": "multiply", + "arguments": { + "x": { + "from_parameter": "x" + }, + "y": { + "from_parameter": "context" + } + }, + "result": true + } + } + }, + "context": 10 + }, + "returns": { + "type": "datacube", + "nodata": 0, + "dimensions": [ + { + "name": "bands", + "type": "bands", + "values": ["red", "green", "blue"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": [ + [ + [1720, 470, 1170, 1920], + [670, 2510, 1950, 1030], + [90, 2110, 0, 2420] + ], + [ + [360, 870, 700, 2160], + [880, 1400, 580, 1930], + [2300, 390, 0, 870] + ], + [ + [1740, 880, 810, 1650], + [250, 770, 720, 90], + [1480, 1150, 0, 2080] + ] + ] + } } ] } diff --git a/tests/apply_dimension.json5 b/tests/apply_dimension.json5 index a981d77f..7e733083 100644 --- a/tests/apply_dimension.json5 +++ b/tests/apply_dimension.json5 @@ -8,7 +8,7 @@ ], "arguments": { "data": { - "$ref": "assets/xyt-minimal.json5" + "$ref": "assets/xyt-minimal-float.json5" }, "process": { "process_graph": { @@ -62,6 +62,74 @@ ] ] } + }, + { + "required": [ + "quantiles" + ], + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "process": { + "process_graph": { + "quantiles": { + "process_id": "quantiles", + "arguments": { + "data": { + "from_parameter": "data" + }, + "probabilities": [0.5, 0.75, 0.9] + }, + "result": true + } + } + }, + "dimension": "bands", + "target_dimension": "quantiles", + }, + "returns": { + "type": "datacube", + "nodata": NaN, + "dimensions": [ + { + "name": "quantiles", + "type": "other", + "values": [0, 1, 2] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": [ + [ + [172.0, 87.0, 81.0, 192.0], + [67.0, 140.0, 72.0, 103.0], + [148.0, 115.0, NaN, 208.0] + ], + [ + [173.0, 87.5, 99.0, 204.0], + [77.5, 195.5, 133.5, 148.0], + [189.0, 163.0, NaN, 225.0] + ], + [ + [173.6, 87.8, 109.8, 211.2], + [83.8, 228.8, 170.4, 175.0], + [213.6, 191.8, NaN, 235.2] + ] + ] + } } ] } diff --git a/tests/array_create_labeled.json5 b/tests/array_create_labeled.json5 index 71e62b09..3376e90f 100644 --- a/tests/array_create_labeled.json5 +++ b/tests/array_create_labeled.json5 @@ -1,5 +1,90 @@ { "id": "array_create_labeled", "level": "L3", - "tests": [] + "tests": [ + // empty array + { + "arguments": { + "data": [], + "labels": [] + }, + "returns": { + "type": "labeled-array", + "data": [] + } + }, + { + "arguments": { + "data": [1.23, 0.98], + "labels": ["B01", "B02"] + }, + "returns": { + "type": "labeled-array", + "data": [ + { + "key": "B01", + "value": 1.23 + }, + { + "key": "B02", + "value": 0.98 + } + ] + } + }, + { + "arguments": { + "data": [5,6,7,NaN], + "labels": [8,7,5,4] + }, + "returns": { + "type": "labeled-array", + "data": [ + { + "key": 8, + "value": 5 + }, + { + "key": 7, + "value": 6 + }, + { + "key": 5, + "value": 7 + }, + { + "key": 4, + "value": NaN + }, + ] + } + }, + { + "arguments": { + "data": [true, false], + "labels": [1, "2"] + }, + "returns": { + "type": "labeled-array", + "data": [ + { + "key": 1, + "value": true + }, + { + "key": "2", + "value": false + } + ] + } + }, + { + // mismatch of array lengths + "arguments": { + "data": [1], + "labels": [1,2], + }, + "throws": "ArrayLengthMismatch" + } + ] } diff --git a/tests/array_element.json5 b/tests/array_element.json5 index 2eab8dfb..e2b30985 100644 --- a/tests/array_element.json5 +++ b/tests/array_element.json5 @@ -157,5 +157,29 @@ }, "returns": null }, + { + "level": "L2", + "arguments": { + "data": { + "type": "labeled-array", + "data": [ + { + "key": 1, + "value": 4 + }, + { + "key": 2, + "value": 5 + }, + { + "key": 3, + "value": 6 + } + ] + }, + "label": 1 + }, + "returns": 4 + } ] } diff --git a/tests/array_find_label.json5 b/tests/array_find_label.json5 index ba3bc422..c5487add 100644 --- a/tests/array_find_label.json5 +++ b/tests/array_find_label.json5 @@ -1,5 +1,100 @@ { "id": "array_find_label", "level": "L3", - "tests": [] + "tests": [ + { + "arguments": { + "data": [ + 1, + 2 + ], + "label": 1 + }, + "returns": null + }, + { + "arguments": { + "data": { + "type": "labeled-array", + "data": [ + { + "key": "B01", + "value": 1.23 + }, + { + "key": "B02", + "value": 0.98 + } + ] + }, + "label": "B01" + }, + "returns": 0 + }, + { + "arguments": { + "data": { + "type": "labeled-array", + "data": [ + { + "key": "B01", + "value": 1.23 + }, + { + "key": "B02", + "value": 0.98 + } + ] + }, + "label": "B02" + }, + "returns": 1 + }, + { + "arguments": { + "data": { + "type": "labeled-array", + "data": [ + { + "key": 2, + "value": 1.23 + }, + { + "key": 3, + "value": 0.98 + }, + { + "key": 4, + "value": 2.75 + } + ] + }, + "label": 4 + }, + "returns": 2 + }, + { + "arguments": { + "data": { + "type": "labeled-array", + "data": [ + { + "key": 2, + "value": 1.23 + }, + { + "key": 3, + "value": 0.98 + }, + { + "key": 4, + "value": 2.75 + } + ] + }, + "label": 1 + }, + "returns": null + } + ] } diff --git a/tests/assets/xyb-enumerated-bands.json5 b/tests/assets/xyb-enumerated-bands.json5 new file mode 100644 index 00000000..db6e9ec4 --- /dev/null +++ b/tests/assets/xyb-enumerated-bands.json5 @@ -0,0 +1,42 @@ +{ + "type": "datacube", + "nodata": 0, + "dimensions": [ + { + "name": "bands", + "type": "bands", + "values": [0, 1, 2] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": [ + [ + [172, 47, 117, 192], + [67, 251, 195, 103], + [9, 211, 0, 242] + ], + [ + [36, 87, 70, 216], + [88, 140, 58, 193], + [230, 39, 0, 87] + ], + [ + [174, 88, 81, 165], + [25, 77, 72, 9], + [148, 115, 0, 208] + ] + ] +} diff --git a/tests/assets/xyb-minimal-int.json5 b/tests/assets/xyb-minimal-int.json5 new file mode 100644 index 00000000..6ed0d6f5 --- /dev/null +++ b/tests/assets/xyb-minimal-int.json5 @@ -0,0 +1,42 @@ +{ + "type": "datacube", + "nodata": 0, + "dimensions": [ + { + "name": "bands", + "type": "bands", + "values": ["red", "green", "blue"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": [ + [ + [172, 47, 117, 192], + [67, 251, 195, 103], + [9, 211, 0, 242] + ], + [ + [36, 87, 70, 216], + [88, 140, 58, 193], + [230, 39, 0, 87] + ], + [ + [174, 88, 81, 165], + [25, 77, 72, 9], + [148, 115, 0, 208] + ] + ] +} diff --git a/tests/assets/xyb-one-band.json5 b/tests/assets/xyb-one-band.json5 new file mode 100644 index 00000000..159c747f --- /dev/null +++ b/tests/assets/xyb-one-band.json5 @@ -0,0 +1,31 @@ +{ + "type": "datacube", + "dimensions": [ + { + "name": "bands", + "type": "bands", + "values": ["red"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": [ + [ + [172, 47, 117, 192], + [67, 251, 195, 103], + [9, 211, 0, 242] + ] + ] +} diff --git a/tests/assets/xyt-minimal.json5 b/tests/assets/xyt-minimal-float.json5 similarity index 100% rename from tests/assets/xyt-minimal.json5 rename to tests/assets/xyt-minimal-float.json5 diff --git a/tests/create_data_cube.json5 b/tests/create_data_cube.json5 index 8e35f191..01cff983 100644 --- a/tests/create_data_cube.json5 +++ b/tests/create_data_cube.json5 @@ -1,5 +1,14 @@ { "id": "create_data_cube", "level": "L3", - "tests": [] + "tests": [ + { + "arguments": {}, + "returns": { + "type": "datacube", + "dimensions": [], + "data": [] + } + } + ] } diff --git a/tests/dimension_labels.json5 b/tests/dimension_labels.json5 index 2908c443..ccb48ab4 100644 --- a/tests/dimension_labels.json5 +++ b/tests/dimension_labels.json5 @@ -1,5 +1,60 @@ { "id": "dimension_labels", "level": "L2", - "tests": [] + "tests": [ + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "dimension": "foo" + }, + "throws": "DimensionNotAvailable" + }, + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "dimension": "x" + }, + "returns": [404835.0, 404845.0, 404855.0, 404865.0] + }, + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "dimension": "x" + }, + "returns": [404835.0, 404845.0, 404855.0, 404865.0] + }, + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "dimension": "y" + }, + "returns": [5757495.0, 5757485.0, 5757475.0] + }, + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "dimension": "t" + }, + "returns": ["2020-06-01T00:00:00Z", "2020-06-03T00:00:00Z"] + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "dimension": "bands" + }, + "returns": ["red", "green", "blue"] + } + ] } diff --git a/tests/drop_dimension.json5 b/tests/drop_dimension.json5 index 36eb81c6..435d13d1 100644 --- a/tests/drop_dimension.json5 +++ b/tests/drop_dimension.json5 @@ -1,5 +1,56 @@ { "id": "drop_dimension", "level": "L2", - "tests": [] + "tests": [ + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "name": "t" + }, + "throws": "DimensionLabelCountMismatch" + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-one-band.json5" + }, + "name": "foo" + }, + "throws": "DimensionNotAvailable" + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-one-band.json5" + }, + "name": "bands" + }, + "returns": { + "type": "datacube", + "dimensions": [ + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": [ + [172, 47, 117, 192], + [67, 251, 195, 103], + [9, 211, 0, 242] + ] + } + }, + ] } diff --git a/tests/reduce_dimension.json5 b/tests/reduce_dimension.json5 index 896add44..705442a4 100644 --- a/tests/reduce_dimension.json5 +++ b/tests/reduce_dimension.json5 @@ -3,12 +3,13 @@ "level": "L1", "tests": [ { + // single process "required": [ "sum" ], "arguments": { "data": { - "$ref": "assets/xyt-minimal.json5" + "$ref": "assets/xyt-minimal-float.json5" }, "reducer": { "process_graph": { @@ -50,6 +51,81 @@ [ 98.26, 27.94, 25.16, -35.45] ] } + }, + { + // multiple processes with labels + "level": "L2", + "required": [ + "array_element", + "divide" + ], + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "reducer": { + "process_graph": { + "red": { + "process_id": "array_element", + "arguments": { + "data": { + "from_parameter": "data" + }, + "label": "red" + }, + "result": true + }, + "blue": { + "process_id": "array_element", + "arguments": { + "data": { + "from_parameter": "data" + }, + "label": "blue" + }, + "result": true + }, + "divide": { + "process_id": "divide", + "arguments": { + "x": { + "from_argument": "red" + }, + "y": { + "from_argument": "blue" + } + }, + "result": true + } + } + }, + "dimension": "bands" + }, + "returns": { + "type": "datacube", + "nodata": NaN, + "dimensions": [ + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": [ + [0.98850574712, 0.53409090909, 1.44444444444, 1.16363636363], + [2.68, 3.2597402597, 2.708333333333, 11.44444444444], + [0.06081081081081, 1.834782608695, NaN, 1.163461538461] + ] + } } ] } diff --git a/tests/rename_dimension.json5 b/tests/rename_dimension.json5 index 402cd245..9879bdf2 100644 --- a/tests/rename_dimension.json5 +++ b/tests/rename_dimension.json5 @@ -1,5 +1,162 @@ { "id": "rename_dimension", "level": "L2", - "tests": [] + "tests": [ + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "source": "foo", + "target": "bar" + }, + "throws": "DimensionNotAvailable" + }, + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "source": "t", + "target": "x" + }, + "throws": "DimensionExists" + }, + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "source": "t", + "target": "time" + }, + "returns": { + "type": "datacube", + "dimensions": [ + { + "name": "time", + "type": "temporal", + "values": ["2020-06-01T00:00:00Z", "2020-06-03T00:00:00Z"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + }, + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "source": "x", + "target": "lon" + }, + "returns": { + "type": "datacube", + "dimensions": [ + { + "name": "t", + "type": "temporal", + "values": ["2020-06-01T00:00:00Z", "2020-06-03T00:00:00Z"] + }, + { + "name": "lon", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + }, + { + "arguments": { + "data": { + "$ref": "assets/xyt-minimal-float.json5" + }, + "source": "y", + "target": "lat" + }, + "returns": { + "type": "datacube", + "dimensions": [ + { + "name": "t", + "type": "temporal", + "values": ["2020-06-01T00:00:00Z", "2020-06-03T00:00:00Z"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "lat", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "source": "bands", + "target": "b" + }, + "returns": { + "type": "datacube", + "dimensions": [ + { + "name": "b", + "type": "bands", + "values": ["red", "green", "blue"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + } + ] } diff --git a/tests/rename_labels.json5 b/tests/rename_labels.json5 index 82deb687..1adfe31f 100644 --- a/tests/rename_labels.json5 +++ b/tests/rename_labels.json5 @@ -3,23 +3,225 @@ "level": "L2", "tests": [ { - // Rename named labels: - // Rename the bands from `B1` to `red`, from `B2` to `green` and from `B3` to `blue`. "arguments": { "data": { - "from_parameter": "data" + "$ref": "assets/xyb-minimal-int.json5" }, "dimension": "bands", - "source": [ + "target": [ "B1", "B2", "B3" + ] + }, + "throws": "LabelsNotEnumerated" + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "dimension": "bands", + "target": [ + "B1" + ], + "source": [ + "red", + "green" + ] + }, + "throws": "LabelMismatch" + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "dimension": "bands", + "target": [ + "bar" + ], + "source": [ + "foo" + ] + }, + "throws": "LabelNotAvailable" + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "dimension": "bands", + "target": [ + "blue" + ], + "source": [ + "green" + ] + }, + "throws": "LabelExists" + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "dimension": "bands", + "source": [ + "red", + "green", + "blue" ], "target": [ + "B1", + "B2", + "B3" + ] + }, + "returns": { + "type": "datacube", + "nodata": 0, + "dimensions": [ + { + "name": "bands", + "type": "bands", + "values": ["B1", "B2", "B3"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-enumerated-bands.json5" + }, + "dimension": "bands", + "source": [ "red", "green", "blue" ] + }, + "returns": { + "type": "datacube", + "nodata": 0, + "dimensions": [ + { + "name": "bands", + "type": "bands", + "values": ["red", "green", "blue"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-minimal-int.json5" + }, + "dimension": "bands", + "source": [ + "blue", + "green" + ], + "target": [ + "B3", + "B2" + ] + }, + "returns": { + "type": "datacube", + "nodata": 0, + "dimensions": [ + { + "name": "bands", + "type": "bands", + "values": ["red", "B2", "B3"] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null + } + }, + { + "arguments": { + "data": { + "$ref": "assets/xyb-enumerated-bands.json5" + }, + "dimension": "bands", + "source": [ + "red" + ] + }, + "returns": { + "type": "datacube", + "nodata": 0, + "dimensions": [ + { + "name": "bands", + "type": "bands", + "values": ["red", 1, 2] + }, + { + "name": "y", + "type": "spatial", + "axis": "y", + "values": [5757495.0, 5757485.0, 5757475.0], + "reference_system": "EPSG:25832" + }, + { + "name": "x", + "type": "spatial", + "axis": "x", + "values": [404835.0, 404845.0, 404855.0, 404865.0], + "reference_system": "EPSG:25832" + } + ], + "data": null } } ]