From 193540bb432babc3a71207d2044c074137a1ca39 Mon Sep 17 00:00:00 2001 From: Zoheb Shaikh Date: Tue, 6 Aug 2024 13:13:59 +0000 Subject: [PATCH] Ensure order of generated Schema --- schema.json | 620 ++++++++++++++++++++----------------------- src/scanspec/core.py | 4 +- 2 files changed, 291 insertions(+), 333 deletions(-) diff --git a/schema.json b/schema.json index d8aa5f62..c50fb0cf 100644 --- a/schema.json +++ b/schema.json @@ -16,17 +16,23 @@ "schema": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -38,12 +44,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Spec", @@ -69,16 +69,16 @@ "discriminator": { "propertyName": "type", "mapping": { - "Static": "#/components/schemas/Static", - "Line": "#/components/schemas/Line", "Concat": "#/components/schemas/Concat-Input", + "Line": "#/components/schemas/Line", + "Static": "#/components/schemas/Static", + "Spiral": "#/components/schemas/Spiral", "Product": "#/components/schemas/Product-Input", + "Repeat": "#/components/schemas/Repeat", "Zip": "#/components/schemas/Zip-Input", "Mask": "#/components/schemas/Mask-Input", "Snake": "#/components/schemas/Snake-Input", - "Squash": "#/components/schemas/Squash-Input", - "Repeat": "#/components/schemas/Repeat", - "Spiral": "#/components/schemas/Spiral" + "Squash": "#/components/schemas/Squash-Input" } } } @@ -255,17 +255,23 @@ "schema": { "anyOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -277,12 +283,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Spec", @@ -345,17 +345,23 @@ "schema": { "anyOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -367,12 +373,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Spec", @@ -548,34 +548,34 @@ "left": { "oneOf": [ { - "$ref": "#/components/schemas/CombinationOf-Input" + "$ref": "#/components/schemas/Range" }, { - "$ref": "#/components/schemas/Polygon" + "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/DifferenceOf" + "$ref": "#/components/schemas/Polygon" }, { - "$ref": "#/components/schemas/Range" + "$ref": "#/components/schemas/Circle" }, { - "$ref": "#/components/schemas/Rectangle" + "$ref": "#/components/schemas/Ellipse" }, { - "$ref": "#/components/schemas/UnionOf" + "$ref": "#/components/schemas/CombinationOf-Input" }, { - "$ref": "#/components/schemas/SymmetricDifferenceOf" + "$ref": "#/components/schemas/UnionOf" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/IntersectionOf" }, { - "$ref": "#/components/schemas/Circle" + "$ref": "#/components/schemas/DifferenceOf" }, { - "$ref": "#/components/schemas/IntersectionOf" + "$ref": "#/components/schemas/SymmetricDifferenceOf" } ], "title": "Left", @@ -599,34 +599,34 @@ "right": { "oneOf": [ { - "$ref": "#/components/schemas/CombinationOf-Input" + "$ref": "#/components/schemas/Range" }, { - "$ref": "#/components/schemas/Polygon" + "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/DifferenceOf" + "$ref": "#/components/schemas/Polygon" }, { - "$ref": "#/components/schemas/Range" + "$ref": "#/components/schemas/Circle" }, { - "$ref": "#/components/schemas/Rectangle" + "$ref": "#/components/schemas/Ellipse" }, { - "$ref": "#/components/schemas/UnionOf" + "$ref": "#/components/schemas/CombinationOf-Input" }, { - "$ref": "#/components/schemas/SymmetricDifferenceOf" + "$ref": "#/components/schemas/UnionOf" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/IntersectionOf" }, { - "$ref": "#/components/schemas/Circle" + "$ref": "#/components/schemas/DifferenceOf" }, { - "$ref": "#/components/schemas/IntersectionOf" + "$ref": "#/components/schemas/SymmetricDifferenceOf" } ], "title": "Right", @@ -671,34 +671,34 @@ "left": { "oneOf": [ { - "$ref": "#/components/schemas/CombinationOf-Output" + "$ref": "#/components/schemas/Range" }, { - "$ref": "#/components/schemas/Polygon" + "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/DifferenceOf" + "$ref": "#/components/schemas/Polygon" }, { - "$ref": "#/components/schemas/Range" + "$ref": "#/components/schemas/Circle" }, { - "$ref": "#/components/schemas/Rectangle" + "$ref": "#/components/schemas/Ellipse" }, { - "$ref": "#/components/schemas/UnionOf" + "$ref": "#/components/schemas/CombinationOf-Output" }, { - "$ref": "#/components/schemas/SymmetricDifferenceOf" + "$ref": "#/components/schemas/UnionOf" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/IntersectionOf" }, { - "$ref": "#/components/schemas/Circle" + "$ref": "#/components/schemas/DifferenceOf" }, { - "$ref": "#/components/schemas/IntersectionOf" + "$ref": "#/components/schemas/SymmetricDifferenceOf" } ], "title": "Left", @@ -722,34 +722,34 @@ "right": { "oneOf": [ { - "$ref": "#/components/schemas/CombinationOf-Output" + "$ref": "#/components/schemas/Range" }, { - "$ref": "#/components/schemas/Polygon" + "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/DifferenceOf" + "$ref": "#/components/schemas/Polygon" }, { - "$ref": "#/components/schemas/Range" + "$ref": "#/components/schemas/Circle" }, { - "$ref": "#/components/schemas/Rectangle" + "$ref": "#/components/schemas/Ellipse" }, { - "$ref": "#/components/schemas/UnionOf" + "$ref": "#/components/schemas/CombinationOf-Output" }, { - "$ref": "#/components/schemas/SymmetricDifferenceOf" + "$ref": "#/components/schemas/UnionOf" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/IntersectionOf" }, { - "$ref": "#/components/schemas/Circle" + "$ref": "#/components/schemas/DifferenceOf" }, { - "$ref": "#/components/schemas/IntersectionOf" + "$ref": "#/components/schemas/SymmetricDifferenceOf" } ], "title": "Right", @@ -794,17 +794,23 @@ "left": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -816,12 +822,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Left", @@ -845,17 +845,23 @@ "right": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -867,12 +873,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Right", @@ -929,17 +929,23 @@ "left": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -951,12 +957,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Left", @@ -980,17 +980,23 @@ "right": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -1002,12 +1008,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Right", @@ -1063,9 +1063,6 @@ "properties": { "left": { "oneOf": [ - { - "$ref": "#/components/schemas/Polygon" - }, { "$ref": "#/components/schemas/Range" }, @@ -1073,10 +1070,13 @@ "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/Polygon" }, { "$ref": "#/components/schemas/Circle" + }, + { + "$ref": "#/components/schemas/Ellipse" } ], "title": "Left", @@ -1094,9 +1094,6 @@ }, "right": { "oneOf": [ - { - "$ref": "#/components/schemas/Polygon" - }, { "$ref": "#/components/schemas/Range" }, @@ -1104,10 +1101,13 @@ "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/Polygon" }, { "$ref": "#/components/schemas/Circle" + }, + { + "$ref": "#/components/schemas/Ellipse" } ], "title": "Right", @@ -1238,9 +1238,6 @@ "properties": { "left": { "oneOf": [ - { - "$ref": "#/components/schemas/Polygon" - }, { "$ref": "#/components/schemas/Range" }, @@ -1248,10 +1245,13 @@ "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/Polygon" }, { "$ref": "#/components/schemas/Circle" + }, + { + "$ref": "#/components/schemas/Ellipse" } ], "title": "Left", @@ -1269,9 +1269,6 @@ }, "right": { "oneOf": [ - { - "$ref": "#/components/schemas/Polygon" - }, { "$ref": "#/components/schemas/Range" }, @@ -1279,10 +1276,13 @@ "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/Polygon" }, { "$ref": "#/components/schemas/Circle" + }, + { + "$ref": "#/components/schemas/Ellipse" } ], "title": "Right", @@ -1365,17 +1365,23 @@ "spec": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -1387,12 +1393,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Spec", @@ -1416,34 +1416,34 @@ "region": { "oneOf": [ { - "$ref": "#/components/schemas/CombinationOf-Input" + "$ref": "#/components/schemas/Range" }, { - "$ref": "#/components/schemas/Polygon" + "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/DifferenceOf" + "$ref": "#/components/schemas/Polygon" }, { - "$ref": "#/components/schemas/Range" + "$ref": "#/components/schemas/Circle" }, { - "$ref": "#/components/schemas/Rectangle" + "$ref": "#/components/schemas/Ellipse" }, { - "$ref": "#/components/schemas/UnionOf" + "$ref": "#/components/schemas/CombinationOf-Input" }, { - "$ref": "#/components/schemas/SymmetricDifferenceOf" + "$ref": "#/components/schemas/UnionOf" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/IntersectionOf" }, { - "$ref": "#/components/schemas/Circle" + "$ref": "#/components/schemas/DifferenceOf" }, { - "$ref": "#/components/schemas/IntersectionOf" + "$ref": "#/components/schemas/SymmetricDifferenceOf" } ], "title": "Region", @@ -1494,17 +1494,23 @@ "spec": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -1516,12 +1522,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Spec", @@ -1545,34 +1545,34 @@ "region": { "oneOf": [ { - "$ref": "#/components/schemas/CombinationOf-Output" + "$ref": "#/components/schemas/Range" }, { - "$ref": "#/components/schemas/Polygon" + "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/DifferenceOf" + "$ref": "#/components/schemas/Polygon" }, { - "$ref": "#/components/schemas/Range" + "$ref": "#/components/schemas/Circle" }, { - "$ref": "#/components/schemas/Rectangle" + "$ref": "#/components/schemas/Ellipse" }, { - "$ref": "#/components/schemas/UnionOf" + "$ref": "#/components/schemas/CombinationOf-Output" }, { - "$ref": "#/components/schemas/SymmetricDifferenceOf" + "$ref": "#/components/schemas/UnionOf" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/IntersectionOf" }, { - "$ref": "#/components/schemas/Circle" + "$ref": "#/components/schemas/DifferenceOf" }, { - "$ref": "#/components/schemas/IntersectionOf" + "$ref": "#/components/schemas/SymmetricDifferenceOf" } ], "title": "Region", @@ -1682,17 +1682,23 @@ "spec": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -1704,12 +1710,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Spec", @@ -1814,17 +1814,23 @@ "outer": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -1836,12 +1842,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Outer", @@ -1865,17 +1865,23 @@ "inner": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -1887,12 +1893,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Inner", @@ -1937,17 +1937,23 @@ "outer": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -1959,12 +1965,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Outer", @@ -1988,17 +1988,23 @@ "inner": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -2010,12 +2016,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Inner", @@ -2118,48 +2118,6 @@ }, "y_max": { "type": "number", - "title": "Y Max", - "description": "Maximum inclusive y value in the region" - }, - "angle": { - "type": "number", - "title": "Angle", - "description": "Clockwise rotation angle of the rectangle", - "default": 0.0 - }, - "type": { - "type": "string", - "enum": [ - "Rectangle" - ], - "const": "Rectangle", - "title": "Type", - "default": "Rectangle" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "x_axis", - "y_axis", - "x_min", - "y_min", - "x_max", - "y_max" - ], - "title": "Rectangle", - "description": "Mask contains points of axis within a rotated xy rectangle.\n\n.. example_spec::\n\n from scanspec.regions import Rectangle\n from scanspec.specs import Line\n\n grid = Line(\"y\", 1, 3, 10) * ~Line(\"x\", 0, 2, 10)\n spec = grid & Rectangle(\"x\", \"y\", 0, 1.1, 1.5, 2.1, 30)" - }, - "Repeat": { - "properties": { - "num": { - "type": "integer", - "minimum": 1.0, - "title": "Num", - "description": "Number of frames to produce" - }, - "gap": { - "type": "boolean", "title": "Gap", "description": "If False and the slowest of the stack of Frames is snaked then the end and start of consecutive iterations of Spec will have no gap", "default": true @@ -2211,17 +2169,23 @@ "spec": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -2233,12 +2197,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Spec", @@ -2282,17 +2240,23 @@ "spec": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -2304,12 +2268,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Spec", @@ -2419,17 +2377,23 @@ "spec": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -2441,12 +2405,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Spec", @@ -2496,17 +2454,23 @@ "spec": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -2518,12 +2482,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Spec", @@ -2609,9 +2567,6 @@ "properties": { "left": { "oneOf": [ - { - "$ref": "#/components/schemas/Polygon" - }, { "$ref": "#/components/schemas/Range" }, @@ -2619,10 +2574,13 @@ "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/Polygon" }, { "$ref": "#/components/schemas/Circle" + }, + { + "$ref": "#/components/schemas/Ellipse" } ], "title": "Left", @@ -2640,9 +2598,6 @@ }, "right": { "oneOf": [ - { - "$ref": "#/components/schemas/Polygon" - }, { "$ref": "#/components/schemas/Range" }, @@ -2650,10 +2605,13 @@ "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/Polygon" }, { "$ref": "#/components/schemas/Circle" + }, + { + "$ref": "#/components/schemas/Ellipse" } ], "title": "Right", @@ -2692,9 +2650,6 @@ "properties": { "left": { "oneOf": [ - { - "$ref": "#/components/schemas/Polygon" - }, { "$ref": "#/components/schemas/Range" }, @@ -2702,10 +2657,13 @@ "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/Polygon" }, { "$ref": "#/components/schemas/Circle" + }, + { + "$ref": "#/components/schemas/Ellipse" } ], "title": "Left", @@ -2723,9 +2681,6 @@ }, "right": { "oneOf": [ - { - "$ref": "#/components/schemas/Polygon" - }, { "$ref": "#/components/schemas/Range" }, @@ -2733,10 +2688,13 @@ "$ref": "#/components/schemas/Rectangle" }, { - "$ref": "#/components/schemas/Ellipse" + "$ref": "#/components/schemas/Polygon" }, { "$ref": "#/components/schemas/Circle" + }, + { + "$ref": "#/components/schemas/Ellipse" } ], "title": "Right", @@ -2776,17 +2734,23 @@ "input_spec": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -2798,12 +2762,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Input Spec", @@ -2827,17 +2785,23 @@ "valid_spec": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -2849,12 +2813,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Valid Spec", @@ -2922,17 +2880,23 @@ "left": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -2944,12 +2908,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Left", @@ -2973,17 +2931,23 @@ "right": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Input" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Input" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Input" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Input" }, @@ -2995,12 +2959,6 @@ }, { "$ref": "#/components/schemas/Squash-Input" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Right", @@ -3045,17 +3003,23 @@ "left": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -3067,12 +3031,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Left", @@ -3096,17 +3054,23 @@ "right": { "oneOf": [ { - "$ref": "#/components/schemas/Static" + "$ref": "#/components/schemas/Concat-Output" }, { "$ref": "#/components/schemas/Line" }, { - "$ref": "#/components/schemas/Concat-Output" + "$ref": "#/components/schemas/Static" + }, + { + "$ref": "#/components/schemas/Spiral" }, { "$ref": "#/components/schemas/Product-Output" }, + { + "$ref": "#/components/schemas/Repeat" + }, { "$ref": "#/components/schemas/Zip-Output" }, @@ -3118,12 +3082,6 @@ }, { "$ref": "#/components/schemas/Squash-Output" - }, - { - "$ref": "#/components/schemas/Repeat" - }, - { - "$ref": "#/components/schemas/Spiral" } ], "title": "Right", diff --git a/src/scanspec/core.py b/src/scanspec/core.py index 487ab9de..7e63732f 100644 --- a/src/scanspec/core.py +++ b/src/scanspec/core.py @@ -146,7 +146,7 @@ class _TaggedUnion: def __init__(self, base_class: type): self._base_class = base_class # The members of the tagged union, i.e. subclasses of the baseclasses - self._members: set[type] = set() + self._members: list[type] = list() # Classes and their field names that refer to this tagged union self._referrers: dict[type | Callable, set[str]] = {} self.type_adapter = TypeAdapter(None) @@ -175,7 +175,7 @@ def add_member(self, cls: type): return if cls is self._base_class: return - self._members.add(cls) + self._members.append(cls) union = self._make_union() if union: # There are more than 1 subclasses in the union, so set all the referrers