From 7d329713ca4bba202176b82a60841e9d537c906a Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Thu, 12 May 2022 22:28:23 +0100 Subject: [PATCH] Refactor 0.4 schema validation tests Ports changes made against the latest version of the specification to consolidate the JSON test using the JSON schema test suite format --- 0.4/examples/invalid/duplicate_axes.json | 33 - 0.4/examples/invalid/duplicate_scale.json | 40 - .../invalid/empty_transformations.json | 25 - 0.4/examples/invalid/invalid_axes_count.json | 28 - 0.4/examples/invalid/invalid_axis_type.json | 33 - .../invalid/invalid_channels_color.json | 48 - .../invalid/invalid_channels_window.json | 50 - .../invalid_multiscales_transformations.json | 39 - 0.4/examples/invalid/invalid_path.json | 33 - .../invalid/invalid_transformation_type.json | 33 - 0.4/examples/invalid/invalid_version.json | 33 - 0.4/examples/invalid/missing_axes.json | 21 - 0.4/examples/invalid/missing_axes_name.json | 31 - 0.4/examples/invalid/missing_datasets.json | 20 - 0.4/examples/invalid/missing_path.json | 32 - 0.4/examples/invalid/missing_scale.json | 30 - 0.4/examples/invalid/missing_space_axes.json | 31 - .../invalid/missing_transformations.json | 24 - 0.4/examples/invalid/no_axes.json | 23 - 0.4/examples/invalid/no_datasets.json | 20 - 0.4/examples/invalid/no_multiscales.json | 4 - 0.4/examples/invalid/one_space_axes.json | 36 - 0.4/examples/invalid/too_many_axes.json | 51 - 0.4/examples/invalid/too_many_space_axes.json | 41 - .../duplicate_axes_name.json | 33 - 0.4/examples/multiscales_strict/.config.json | 3 + .../multiscales_example.json | 0 .../multiscales_transformations.json | 0 0.4/examples/valid/custom_type_axes.json | 34 - 0.4/examples/valid/invalid_axis_units.json | 33 - 0.4/examples/valid/mismatch_axes_units.json | 38 - 0.4/examples/valid/missing_name.json | 43 - 0.4/examples/valid/missing_version.json | 31 - 0.4/examples/valid/untyped_axes.json | 33 - 0.4/examples/valid_strict/image.json | 35 - 0.4/examples/valid_strict/image_metadata.json | 46 - 0.4/examples/valid_strict/image_omero.json | 118 -- 0.4/index.bs | 2 +- 0.4/tests/image_suite.json | 1148 +++++++++++++++++ 0.4/tests/strict_image_suite.json | 388 ++++++ 0.4/tests/test_validation.py | 142 +- 41 files changed, 1617 insertions(+), 1269 deletions(-) delete mode 100644 0.4/examples/invalid/duplicate_axes.json delete mode 100644 0.4/examples/invalid/duplicate_scale.json delete mode 100644 0.4/examples/invalid/empty_transformations.json delete mode 100644 0.4/examples/invalid/invalid_axes_count.json delete mode 100644 0.4/examples/invalid/invalid_axis_type.json delete mode 100644 0.4/examples/invalid/invalid_channels_color.json delete mode 100644 0.4/examples/invalid/invalid_channels_window.json delete mode 100644 0.4/examples/invalid/invalid_multiscales_transformations.json delete mode 100644 0.4/examples/invalid/invalid_path.json delete mode 100644 0.4/examples/invalid/invalid_transformation_type.json delete mode 100644 0.4/examples/invalid/invalid_version.json delete mode 100644 0.4/examples/invalid/missing_axes.json delete mode 100644 0.4/examples/invalid/missing_axes_name.json delete mode 100644 0.4/examples/invalid/missing_datasets.json delete mode 100644 0.4/examples/invalid/missing_path.json delete mode 100644 0.4/examples/invalid/missing_scale.json delete mode 100644 0.4/examples/invalid/missing_space_axes.json delete mode 100644 0.4/examples/invalid/missing_transformations.json delete mode 100644 0.4/examples/invalid/no_axes.json delete mode 100644 0.4/examples/invalid/no_datasets.json delete mode 100644 0.4/examples/invalid/no_multiscales.json delete mode 100644 0.4/examples/invalid/one_space_axes.json delete mode 100644 0.4/examples/invalid/too_many_axes.json delete mode 100644 0.4/examples/invalid/too_many_space_axes.json delete mode 100644 0.4/examples/invalid_but_dont_fail/duplicate_axes_name.json create mode 100644 0.4/examples/multiscales_strict/.config.json rename 0.4/examples/{valid_strict => multiscales_strict}/multiscales_example.json (100%) rename 0.4/examples/{valid_strict => multiscales_strict}/multiscales_transformations.json (100%) delete mode 100644 0.4/examples/valid/custom_type_axes.json delete mode 100644 0.4/examples/valid/invalid_axis_units.json delete mode 100644 0.4/examples/valid/mismatch_axes_units.json delete mode 100644 0.4/examples/valid/missing_name.json delete mode 100644 0.4/examples/valid/missing_version.json delete mode 100644 0.4/examples/valid/untyped_axes.json delete mode 100644 0.4/examples/valid_strict/image.json delete mode 100644 0.4/examples/valid_strict/image_metadata.json delete mode 100644 0.4/examples/valid_strict/image_omero.json create mode 100644 0.4/tests/image_suite.json create mode 100644 0.4/tests/strict_image_suite.json diff --git a/0.4/examples/invalid/duplicate_axes.json b/0.4/examples/invalid/duplicate_axes.json deleted file mode 100644 index ede5e00e..00000000 --- a/0.4/examples/invalid/duplicate_axes.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "x", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} \ No newline at end of file diff --git a/0.4/examples/invalid/duplicate_scale.json b/0.4/examples/invalid/duplicate_scale.json deleted file mode 100644 index f5413ce1..00000000 --- a/0.4/examples/invalid/duplicate_scale.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - }, - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/empty_transformations.json b/0.4/examples/invalid/empty_transformations.json deleted file mode 100644 index 0445961f..00000000 --- a/0.4/examples/invalid/empty_transformations.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/invalid_axes_count.json b/0.4/examples/invalid/invalid_axes_count.json deleted file mode 100644 index 8f14f68b..00000000 --- a/0.4/examples/invalid/invalid_axes_count.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/invalid_axis_type.json b/0.4/examples/invalid/invalid_axis_type.json deleted file mode 100644 index 33509a6b..00000000 --- a/0.4/examples/invalid/invalid_axis_type.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "invalid", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/invalid_channels_color.json b/0.4/examples/invalid/invalid_channels_color.json deleted file mode 100644 index 89d02d5c..00000000 --- a/0.4/examples/invalid/invalid_channels_color.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [1, 1], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ], - "omero": { - "channels": [ - { - "active": true, - "coefficient": 1.0, - "color": 255, - "family": "linear", - "label": "1234", - "window": { - "end": 1765.0, - "max": 2555.0, - "min": 5.0, - "start": 0.0 - } - } - ] - } -} - diff --git a/0.4/examples/invalid/invalid_channels_window.json b/0.4/examples/invalid/invalid_channels_window.json deleted file mode 100644 index 0ce38243..00000000 --- a/0.4/examples/invalid/invalid_channels_window.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ], - "omero": { - "channels": [ - { - "active": true, - "coefficient": 1.0, - "color": "ff0000", - "family": "linear", - "label": "1234", - "window": { - "end": "100", - "max": 2555.0, - "min": 5.0, - "start": 0.0 - } - } - ] - } -} diff --git a/0.4/examples/invalid/invalid_multiscales_transformations.json b/0.4/examples/invalid/invalid_multiscales_transformations.json deleted file mode 100644 index b93f37e6..00000000 --- a/0.4/examples/invalid/invalid_multiscales_transformations.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "coordinateTransformations": [ - { - "scale": ["invalid"], - "type": "scale" - } - ], - "version": "0.4" - } - ] -} \ No newline at end of file diff --git a/0.4/examples/invalid/invalid_path.json b/0.4/examples/invalid/invalid_path.json deleted file mode 100644 index ef82f0bb..00000000 --- a/0.4/examples/invalid/invalid_path.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": 0, - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/invalid_transformation_type.json b/0.4/examples/invalid/invalid_transformation_type.json deleted file mode 100644 index fbd8e497..00000000 --- a/0.4/examples/invalid/invalid_transformation_type.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "translation" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/invalid_version.json b/0.4/examples/invalid/invalid_version.json deleted file mode 100644 index cab8991b..00000000 --- a/0.4/examples/invalid/invalid_version.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.3" - } - ] -} diff --git a/0.4/examples/invalid/missing_axes.json b/0.4/examples/invalid/missing_axes.json deleted file mode 100644 index e3c2da19..00000000 --- a/0.4/examples/invalid/missing_axes.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "multiscales": [ - { - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/missing_axes_name.json b/0.4/examples/invalid/missing_axes_name.json deleted file mode 100644 index 99ce120f..00000000 --- a/0.4/examples/invalid/missing_axes_name.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "type": "space", - "units": "micron" - }, - { - "type": "space", - "units": "micron" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 0.13, - 0.13 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/missing_datasets.json b/0.4/examples/invalid/missing_datasets.json deleted file mode 100644 index 21b81ba9..00000000 --- a/0.4/examples/invalid/missing_datasets.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "version": "0.4" - } - ] -} - diff --git a/0.4/examples/invalid/missing_path.json b/0.4/examples/invalid/missing_path.json deleted file mode 100644 index 587390fe..00000000 --- a/0.4/examples/invalid/missing_path.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/missing_scale.json b/0.4/examples/invalid/missing_scale.json deleted file mode 100644 index ed863677..00000000 --- a/0.4/examples/invalid/missing_scale.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "translation": [1, 1], - "type": "translation" - } - ] - } - ], - "version": "0.4" - } - ] -} \ No newline at end of file diff --git a/0.4/examples/invalid/missing_space_axes.json b/0.4/examples/invalid/missing_space_axes.json deleted file mode 100644 index 75a84711..00000000 --- a/0.4/examples/invalid/missing_space_axes.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "t", - "type": "time" - }, - { - "name": "c", - "type": "channel" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/missing_transformations.json b/0.4/examples/invalid/missing_transformations.json deleted file mode 100644 index 85fbdc1c..00000000 --- a/0.4/examples/invalid/missing_transformations.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0" - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/no_axes.json b/0.4/examples/invalid/no_axes.json deleted file mode 100644 index 94570af2..00000000 --- a/0.4/examples/invalid/no_axes.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "multiscales": [ - { - "axes": [], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} - diff --git a/0.4/examples/invalid/no_datasets.json b/0.4/examples/invalid/no_datasets.json deleted file mode 100644 index add3f0eb..00000000 --- a/0.4/examples/invalid/no_datasets.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/no_multiscales.json b/0.4/examples/invalid/no_multiscales.json deleted file mode 100644 index d6dbfb33..00000000 --- a/0.4/examples/invalid/no_multiscales.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "@type": "ngff:Image", - "multiscales": [] -} diff --git a/0.4/examples/invalid/one_space_axes.json b/0.4/examples/invalid/one_space_axes.json deleted file mode 100644 index 9fd96a1f..00000000 --- a/0.4/examples/invalid/one_space_axes.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "t", - "type": "time" - }, - { - "name": "c", - "type": "channel" - }, - { - "name": "x", - "type": "space" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/too_many_axes.json b/0.4/examples/invalid/too_many_axes.json deleted file mode 100644 index 3eba4cfc..00000000 --- a/0.4/examples/invalid/too_many_axes.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "angle", - "type": "custom" - }, - { - "name": "t", - "type": "time" - }, - { - "name": "c", - "type": "channel" - }, - { - "name": "z", - "type": "space" - }, - { - "name": "y", - "type": "space" - }, - { - "name": "x", - "type": "space" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1, - 1, - 1, - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid/too_many_space_axes.json b/0.4/examples/invalid/too_many_space_axes.json deleted file mode 100644 index 5d185260..00000000 --- a/0.4/examples/invalid/too_many_space_axes.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "X", - "type": "space" - }, - { - "name": "z", - "type": "space" - }, - { - "name": "y", - "type": "space" - }, - { - "name": "x", - "type": "space" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1, - 1, - 1 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/invalid_but_dont_fail/duplicate_axes_name.json b/0.4/examples/invalid_but_dont_fail/duplicate_axes_name.json deleted file mode 100644 index a811f9a3..00000000 --- a/0.4/examples/invalid_but_dont_fail/duplicate_axes_name.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "x", - "type": "space", - "units": "meter" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 0.13, - 0.13 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/multiscales_strict/.config.json b/0.4/examples/multiscales_strict/.config.json new file mode 100644 index 00000000..b0469538 --- /dev/null +++ b/0.4/examples/multiscales_strict/.config.json @@ -0,0 +1,3 @@ +{ + "schema": "schemas/strict_image.schema" +} diff --git a/0.4/examples/valid_strict/multiscales_example.json b/0.4/examples/multiscales_strict/multiscales_example.json similarity index 100% rename from 0.4/examples/valid_strict/multiscales_example.json rename to 0.4/examples/multiscales_strict/multiscales_example.json diff --git a/0.4/examples/valid_strict/multiscales_transformations.json b/0.4/examples/multiscales_strict/multiscales_transformations.json similarity index 100% rename from 0.4/examples/valid_strict/multiscales_transformations.json rename to 0.4/examples/multiscales_strict/multiscales_transformations.json diff --git a/0.4/examples/valid/custom_type_axes.json b/0.4/examples/valid/custom_type_axes.json deleted file mode 100644 index 557be833..00000000 --- a/0.4/examples/valid/custom_type_axes.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "angle", - "type": "custom" - }, - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [1, 1, 1], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} \ No newline at end of file diff --git a/0.4/examples/valid/invalid_axis_units.json b/0.4/examples/valid/invalid_axis_units.json deleted file mode 100644 index 078da224..00000000 --- a/0.4/examples/valid/invalid_axis_units.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micron" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 0.13, - 0.13 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/valid/mismatch_axes_units.json b/0.4/examples/valid/mismatch_axes_units.json deleted file mode 100644 index 3c10c4ff..00000000 --- a/0.4/examples/valid/mismatch_axes_units.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "t", - "type": "time", - "units": "micrometer" - }, - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 0.13, - 0.13 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} diff --git a/0.4/examples/valid/missing_name.json b/0.4/examples/valid/missing_name.json deleted file mode 100644 index f333aaa9..00000000 --- a/0.4/examples/valid/missing_name.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "@type": "ngff:Image", - "multiscales": [ - { - "version": "0.4", - "datasets": [ - { - "path": "path/to/0", - "coordinateTransformations": [ - { - "type": "scale", - "scale": [1, 1] - } - ] - } - ], - "type": "gaussian", - "metadata": { - "method": "skimage.transform.pyramid_gaussian", - "version": "0.16.1", - "args": [ - "true", - "false" - ], - "kwargs": { - "multichannel": true - } - }, - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ] - } - ] -} diff --git a/0.4/examples/valid/missing_version.json b/0.4/examples/valid/missing_version.json deleted file mode 100644 index 0e1e6b7f..00000000 --- a/0.4/examples/valid/missing_version.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "@type": "ngff:Image", - "multiscales": [ - { - "name": "example", - "datasets": [ - { - "path": "path/to/0", - "coordinateTransformations": [ - { - "type": "scale", - "scale": [1, 1] - } - ] - } - ], - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ] - } - ] -} diff --git a/0.4/examples/valid/untyped_axes.json b/0.4/examples/valid/untyped_axes.json deleted file mode 100644 index af65e409..00000000 --- a/0.4/examples/valid/untyped_axes.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "angle" - }, - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [1, 1, 1], - "type": "scale" - } - ] - } - ], - "version": "0.4" - } - ] -} \ No newline at end of file diff --git a/0.4/examples/valid_strict/image.json b/0.4/examples/valid_strict/image.json deleted file mode 100644 index e6affa00..00000000 --- a/0.4/examples/valid_strict/image.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [1, 1], - "type": "scale" - } - ] - } - ], - "version": "0.4", - "name": "simple_image", - "type": "foo", - "metadata": { - "key": "value" - } - } - ] -} \ No newline at end of file diff --git a/0.4/examples/valid_strict/image_metadata.json b/0.4/examples/valid_strict/image_metadata.json deleted file mode 100644 index 8a438ed8..00000000 --- a/0.4/examples/valid_strict/image_metadata.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "@id": "top", - "@type": "ngff:Image", - "multiscales": [ - { - "@id": "inner", - "version": "0.4", - "name": "example", - "datasets": [ - { - "path": "path/to/0", - "coordinateTransformations": [ - { - "type": "scale", - "scale": [1, 1] - } - ] - } - ], - "type": "gaussian", - "metadata": { - "method": "skimage.transform.pyramid_gaussian", - "version": "0.16.1", - "args": [ - "true", - "false" - ], - "kwargs": { - "multichannel": true - } - }, - "axes": [ - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ] - } - ] -} diff --git a/0.4/examples/valid_strict/image_omero.json b/0.4/examples/valid_strict/image_omero.json deleted file mode 100644 index 6bf2070b..00000000 --- a/0.4/examples/valid_strict/image_omero.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "multiscales": [ - { - "axes": [ - { - "name": "t", - "type": "time" - }, - { - "name": "c", - "type": "channel" - }, - { - "name": "z", - "type": "space", - "units": "micrometer" - }, - { - "name": "y", - "type": "space", - "units": "micrometer" - }, - { - "name": "x", - "type": "space", - "units": "micrometer" - } - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1, - 0.5, - 0.13, - 0.13 - ], - "type": "scale" - }, - { - "translation": [ - 0, - 9, - 0.5, - 25.74, - 21.58 - ], - "type": "translation" - } - ] - }, - { - "path": "1", - "coordinateTransformations": [ - { - "scale": [ - 1, - 1, - 1, - 0.26, - 0.26 - ], - "type": "scale" - } - ] - } - ], - "version": "0.4", - "name": "image_with_omero_metadata", - "type": "foo", - "metadata": { - "key": "value" - } - } - ], - "omero": { - "channels": [ - { - "active": true, - "coefficient": 1.0, - "color": "00FF00", - "family": "linear", - "inverted": false, - "label": "FITC", - "window": { - "end": 813.0, - "max": 870.0, - "min": 102.0, - "start": 82.0 - } - }, - { - "active": true, - "coefficient": 1.0, - "color": "FF0000", - "family": "linear", - "inverted": false, - "label": "RD-TR-PE", - "window": { - "end": 815.0, - "max": 441.0, - "min": 129.0, - "start": 78.0 - } - } - ], - "id": 1, - "rdefs": { - "defaultT": 0, - "defaultZ": 2, - "model": "color" - }, - "version": "0.4" - } -} diff --git a/0.4/index.bs b/0.4/index.bs index e531ff07..8dcb5cc2 100644 --- a/0.4/index.bs +++ b/0.4/index.bs @@ -296,7 +296,7 @@ Each "multiscales" dictionary SHOULD contain the field "type", which gives the t It SHOULD contain the field "metadata", which contains a dictionary with additional information about the downscaling method.
-path: examples/valid_strict/multiscales_example.json
+path: examples/multiscales_strict/multiscales_example.json
 highlight: json
 
diff --git a/0.4/tests/image_suite.json b/0.4/tests/image_suite.json new file mode 100644 index 00000000..f22fa67f --- /dev/null +++ b/0.4/tests/image_suite.json @@ -0,0 +1,1148 @@ +{ + "description": "TBD", + "schema": { + "id": "schemas/image.schema" + }, + "tests": [ + { + "formerly": "valid/mismatch_axes_units.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "t", + "type": "time", + "units": "micrometer" + }, + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 0.13, + 0.13 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": true + }, + { + "formerly": "valid/untyped_axes.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "angle" + }, + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": true + }, + { + "formerly": "valid/missing_version.json", + "description": "TBD", + "data": { + "@type": "ngff:Image", + "multiscales": [ + { + "name": "example", + "datasets": [ + { + "path": "path/to/0", + "coordinateTransformations": [ + { + "type": "scale", + "scale": [ + 1, + 1 + ] + } + ] + } + ], + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ] + } + ] + }, + "valid": true + }, + { + "formerly": "valid/invalid_axis_units.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micron" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 0.13, + 0.13 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": true + }, + { + "formerly": "valid/missing_name.json", + "description": "TBD", + "data": { + "@type": "ngff:Image", + "multiscales": [ + { + "version": "0.4", + "datasets": [ + { + "path": "path/to/0", + "coordinateTransformations": [ + { + "type": "scale", + "scale": [ + 1, + 1 + ] + } + ] + } + ], + "type": "gaussian", + "metadata": { + "method": "skimage.transform.pyramid_gaussian", + "version": "0.16.1", + "args": [ + "true", + "false" + ], + "kwargs": { + "multichannel": true + } + }, + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ] + } + ] + }, + "valid": true + }, + { + "formerly": "valid/custom_type_axes.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "angle", + "type": "custom" + }, + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": true + }, + { + "formerly": "invalid/duplicate_axes.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "x", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/missing_space_axes.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "t", + "type": "time" + }, + { + "name": "c", + "type": "channel" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/invalid_transformation_type.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "translation" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/missing_scale.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "translation": [ + 1, + 1 + ], + "type": "translation" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/too_many_axes.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "angle", + "type": "custom" + }, + { + "name": "t", + "type": "time" + }, + { + "name": "c", + "type": "channel" + }, + { + "name": "z", + "type": "space" + }, + { + "name": "y", + "type": "space" + }, + { + "name": "x", + "type": "space" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1, + 1, + 1, + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/invalid_channels_color.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ], + "omero": { + "channels": [ + { + "active": true, + "coefficient": 1.0, + "color": 255, + "family": "linear", + "label": "1234", + "window": { + "end": 1765.0, + "max": 2555.0, + "min": 5.0, + "start": 0.0 + } + } + ] + } + }, + "valid": false + }, + { + "formerly": "invalid/missing_axes_name.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "type": "space", + "units": "micron" + }, + { + "type": "space", + "units": "micron" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 0.13, + 0.13 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/invalid_axes_count.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/one_space_axes.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "t", + "type": "time" + }, + { + "name": "c", + "type": "channel" + }, + { + "name": "x", + "type": "space" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/invalid_path.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": 0, + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/invalid_multiscales_transformations.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "coordinateTransformations": [ + { + "scale": [ + "invalid" + ], + "type": "scale" + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/missing_transformations.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0" + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/no_datasets.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/missing_datasets.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/missing_axes.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/invalid_version.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.3" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/invalid_axis_type.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "invalid", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/duplicate_scale.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + }, + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/no_axes.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/too_many_space_axes.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "X", + "type": "space" + }, + { + "name": "z", + "type": "space" + }, + { + "name": "y", + "type": "space" + }, + { + "name": "x", + "type": "space" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1, + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/no_multiscales.json", + "description": "TBD", + "data": { + "@type": "ngff:Image", + "multiscales": [] + }, + "valid": false + }, + { + "formerly": "invalid/invalid_channels_window.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ], + "omero": { + "channels": [ + { + "active": true, + "coefficient": 1.0, + "color": "ff0000", + "family": "linear", + "label": "1234", + "window": { + "end": "100", + "max": 2555.0, + "min": 5.0, + "start": 0.0 + } + } + ] + } + }, + "valid": false + }, + { + "formerly": "invalid/empty_transformations.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + }, + { + "formerly": "invalid/missing_path.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4" + } + ] + }, + "valid": false + } + ] +} diff --git a/0.4/tests/strict_image_suite.json b/0.4/tests/strict_image_suite.json new file mode 100644 index 00000000..22b34c5e --- /dev/null +++ b/0.4/tests/strict_image_suite.json @@ -0,0 +1,388 @@ +{ + "description": "TBD", + "schema": { + "id": "schemas/strict_image.schema" + }, + "tests": [ + { + "formerly": "valid_strict/multiscales_example.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "version": "0.4", + "name": "example", + "axes": [ + { + "name": "t", + "type": "time", + "unit": "millisecond" + }, + { + "name": "c", + "type": "channel" + }, + { + "name": "z", + "type": "space", + "unit": "micrometer" + }, + { + "name": "y", + "type": "space", + "unit": "micrometer" + }, + { + "name": "x", + "type": "space", + "unit": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "type": "scale", + "scale": [ + 1.0, + 1.0, + 0.5, + 0.5, + 0.5 + ] + } + ] + }, + { + "path": "1", + "coordinateTransformations": [ + { + "type": "scale", + "scale": [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0 + ] + } + ] + }, + { + "path": "2", + "coordinateTransformations": [ + { + "type": "scale", + "scale": [ + 1.0, + 1.0, + 2.0, + 2.0, + 2.0 + ] + } + ] + } + ], + "coordinateTransformations": [ + { + "type": "scale", + "scale": [ + 0.1, + 1.0, + 1.0, + 1.0, + 1.0 + ] + } + ], + "type": "gaussian", + "metadata": { + "description": "the fields in metadata depend on the downscaling implementation. Here, the parameters passed to the skimage function are given", + "method": "skimage.transform.pyramid_gaussian", + "version": "0.16.1", + "args": "[true]", + "kwargs": { + "multichannel": true + } + } + } + ] + }, + "valid": true + }, + { + "formerly": "valid_strict/multiscales_transformations.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "coordinateTransformations": [ + { + "scale": [ + 10, + 10 + ], + "type": "scale" + } + ], + "version": "0.4", + "name": "image_with_coordinateTransformations", + "type": "foo", + "metadata": { + "key": "value" + } + } + ] + }, + "valid": true + }, + { + "formerly": "valid_strict/image_metadata.json", + "description": "TBD", + "data": { + "@id": "top", + "@type": "ngff:Image", + "multiscales": [ + { + "@id": "inner", + "version": "0.4", + "name": "example", + "datasets": [ + { + "path": "path/to/0", + "coordinateTransformations": [ + { + "type": "scale", + "scale": [ + 1, + 1 + ] + } + ] + } + ], + "type": "gaussian", + "metadata": { + "method": "skimage.transform.pyramid_gaussian", + "version": "0.16.1", + "args": [ + "true", + "false" + ], + "kwargs": { + "multichannel": true + } + }, + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ] + } + ] + }, + "valid": true + }, + { + "formerly": "valid_strict/image.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4", + "name": "simple_image", + "type": "foo", + "metadata": { + "key": "value" + } + } + ] + }, + "valid": true + }, + { + "formerly": "valid_strict/image_omero.json", + "description": "TBD", + "data": { + "multiscales": [ + { + "axes": [ + { + "name": "t", + "type": "time" + }, + { + "name": "c", + "type": "channel" + }, + { + "name": "z", + "type": "space", + "units": "micrometer" + }, + { + "name": "y", + "type": "space", + "units": "micrometer" + }, + { + "name": "x", + "type": "space", + "units": "micrometer" + } + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1, + 0.5, + 0.13, + 0.13 + ], + "type": "scale" + }, + { + "translation": [ + 0, + 9, + 0.5, + 25.74, + 21.58 + ], + "type": "translation" + } + ] + }, + { + "path": "1", + "coordinateTransformations": [ + { + "scale": [ + 1, + 1, + 1, + 0.26, + 0.26 + ], + "type": "scale" + } + ] + } + ], + "version": "0.4", + "name": "image_with_omero_metadata", + "type": "foo", + "metadata": { + "key": "value" + } + } + ], + "omero": { + "channels": [ + { + "active": true, + "coefficient": 1.0, + "color": "00FF00", + "family": "linear", + "inverted": false, + "label": "FITC", + "window": { + "end": 813.0, + "max": 870.0, + "min": 102.0, + "start": 82.0 + } + }, + { + "active": true, + "coefficient": 1.0, + "color": "FF0000", + "family": "linear", + "inverted": false, + "label": "RD-TR-PE", + "window": { + "end": 815.0, + "max": 441.0, + "min": 129.0, + "start": 78.0 + } + } + ], + "id": 1, + "rdefs": { + "defaultT": 0, + "defaultZ": 2, + "model": "color" + }, + "version": "0.4" + } + }, + "valid": true + } + ] +} diff --git a/0.4/tests/test_validation.py b/0.4/tests/test_validation.py index 3a6a5761..83f49911 100644 --- a/0.4/tests/test_validation.py +++ b/0.4/tests/test_validation.py @@ -1,73 +1,85 @@ import json import glob +from dataclasses import dataclass +from typing import List + import pytest -from jsonschema import RefResolver, Draft202012Validator +from jsonschema import RefResolver, Draft202012Validator as Validator from jsonschema.exceptions import ValidationError -with open('schemas/image.schema') as f: - image_schema = json.load(f) -with open('schemas/strict_image.schema') as f: - strict_image_schema = json.load(f) -schema_store = { - image_schema['$id']: image_schema, - strict_image_schema['$id']: strict_image_schema, -} - -resolver = RefResolver.from_schema(image_schema, store=schema_store) -validator = Draft202012Validator(image_schema, resolver=resolver) -strict_validator = Draft202012Validator(strict_image_schema, resolver=resolver) - -valid_strict_files = list(glob.glob("examples/valid_strict/*.json")) -valid_files = list(glob.glob("examples/valid/*.json")) -invalid_files = list(glob.glob("examples/invalid/*.json")) -invalid_but_dont_fail_files = list( - glob.glob("examples/invalid_but_dont_fail/*.json")) - - -def ids(files): - return [str(x).split("/")[-1][0:-5] for x in files] - - -@pytest.mark.parametrize( - "testfile", valid_strict_files, ids=ids(valid_strict_files)) -def test_valid_strict(testfile): - with open(testfile) as f: - data = ''.join(line for line in f if not line.lstrip().startswith('//')) - jsondata = json.loads(data) - validator.validate(jsondata) - strict_validator.validate(jsondata) - - -@pytest.mark.parametrize("testfile", valid_files, ids=ids(valid_files)) -def test_valid_files(testfile): - with open(testfile) as f: - json_file = json.load(f) - validator.validate(json_file) - with pytest.raises(ValidationError): - strict_validator.validate(json_file) - - -@pytest.mark.parametrize("testfile", invalid_files, ids=ids(invalid_files)) -def test_invalid(testfile): - with open(testfile) as f: - json_file = json.load(f) - with pytest.raises(ValidationError): - validator.validate(json_file) - with pytest.raises(ValidationError): - strict_validator.validate(json_file) - - -@pytest.mark.xfail -@pytest.mark.parametrize( - "testfile", invalid_but_dont_fail_files, - ids=ids(invalid_but_dont_fail_files)) -def test_invalid_but_dontfail(testfile): - with open(testfile) as f: - json_file = json.load(f) - with pytest.raises(ValidationError): - validator.validate(json_file) - with pytest.raises(ValidationError): - strict_validator.validate(json_file) +@dataclass +class Suite: + schema: dict + schema_store: dict + data: dict + valid: bool = True + + def validate(self, validator) -> None: + if not self.valid: + with pytest.raises(ValidationError): + validator.validate(self.data) + else: + validator.validate(self.data) + + +def pytest_generate_tests(metafunc): + """ + Generates tests for the examples/ as well as tests/ subdirectories. + + Examples: + These tests evalute all of the files under the examples/ directory + using the configuration in the provided config file in order detect + what should be run. It is assumed that all files are valid and complete + so that they can be wholly included into the specification. The + .config.json file in each directory defines which schema will be used. + + Validation: + These test consumes https://github.com/json-schema-org/JSON-Schema-Test-Suite#structure-of-a-test + styled JSON tests. Metadata in each test defines which schema is used + and whether or not the block is considered valid. + """ + if "suite" in metafunc.fixturenames: + suites: List[Schema] = [] + ids: List[str] = [] + + # Validation + for filename in glob.glob("tests/*.json"): + with open(filename) as o: + suite = json.load(o) + schema = suite["schema"] + with open(schema["id"]) as f: + schema = json.load(f) + for test in suite["tests"]: + ids.append("validate_" + str(test["formerly"]).split("/")[-1][0:-5]) + suites.append(Suite(schema, {schema["$id"]: schema}, test["data"], test["valid"])) + + # Examples + for config_filename in glob.glob("examples/*/.config.json"): + with open(config_filename) as o: + data = json.load(o) + schema = data["schema"] + with open(schema) as f: + schema = json.load(f) + for filename in glob.glob("examples/*/*.json"): + with open(filename) as f: + # Strip comments + data = ''.join(line for line in f if not line.lstrip().startswith('//')) + data = json.loads(data) + ids.append("example_" + str(filename).split("/")[-1][0:-5]) + suites.append(Suite(schema, {schema["$id"]: schema}, data, True)) # Assume true + + metafunc.parametrize("suite", suites, ids=ids, indirect=True) + + +@pytest.fixture +def suite(request): + return request.param + + +def test_run(suite): + resolver = RefResolver.from_schema(suite.schema, store=suite.schema_store) + validator = Validator(suite.schema, resolver=resolver) + suite.validate(validator)