Skip to content

Commit 7aacc85

Browse files
authored
feat: remove data nesting (#155)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 58ed1ab commit 7aacc85

File tree

2 files changed

+36
-90
lines changed

2 files changed

+36
-90
lines changed

src/uhi/resources/histogram.schema.json

Lines changed: 34 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@
4141
}
4242
},
4343
"$defs": {
44+
"data_array": {
45+
"oneOf": [
46+
{
47+
"type": "string",
48+
"description": "A path (URI?) to the floating point bin data; outer dimension is [∑weights, ∑weights², value, variance]"
49+
},
50+
{
51+
"type": "array",
52+
"items": { "type": "number" }
53+
}
54+
]
55+
},
4456
"regular_axis": {
4557
"type": "object",
4658
"description": "An evenly spaced set of continuous bins.",
@@ -169,129 +181,63 @@
169181
"int_storage": {
170182
"type": "object",
171183
"description": "A storage holding integer counts.",
172-
"required": ["type", "data"],
184+
"required": ["type", "values"],
173185
"additionalProperties": false,
174186
"properties": {
175187
"type": { "type": "string", "const": "int" },
176-
"data": {
177-
"oneOf": [
178-
{
179-
"type": "string",
180-
"description": "A path (URI?) to the integer bin data."
181-
},
182-
{ "type": "array", "items": { "type": "integer" } }
183-
]
184-
}
188+
"values": { "$ref": "#/$defs/data_array" }
185189
}
186190
},
187191
"double_storage": {
188192
"type": "object",
189193
"description": "A storage holding floating point counts.",
190-
"required": ["type", "data"],
194+
"required": ["type", "values"],
191195
"additionalProperties": false,
192196
"properties": {
193197
"type": { "type": "string", "const": "double" },
194-
"data": {
195-
"oneOf": [
196-
{
197-
"type": "string",
198-
"description": "A path (URI?) to the floating point bin data."
199-
},
200-
{ "type": "array", "items": { "type": "number" } }
201-
]
202-
}
198+
"values": { "$ref": "#/$defs/data_array" }
203199
}
204200
},
205201
"weighted_storage": {
206202
"type": "object",
207203
"description": "A storage holding floating point counts and variances.",
208-
"required": ["type", "data"],
204+
"required": ["type", "values", "variances"],
209205
"additionalProperties": false,
210206
"properties": {
211207
"type": { "type": "string", "const": "weighted" },
212-
"data": {
213-
"oneOf": [
214-
{
215-
"type": "string",
216-
"description": "A path (URI?) to the floating point bin data; outer dimension is [value, variance]"
217-
},
218-
{
219-
"type": "object",
220-
"required": ["values", "variances"],
221-
"additionalProperties": false,
222-
"properties": {
223-
"values": { "type": "array", "items": { "type": "number" } },
224-
"variances": { "type": "array", "items": { "type": "number" } }
225-
}
226-
}
227-
]
228-
}
208+
"values": { "$ref": "#/$defs/data_array" },
209+
"variances": { "$ref": "#/$defs/data_array" }
229210
}
230211
},
231212
"mean_storage": {
232213
"type": "object",
233214
"description": "A storage holding 'profile'-style floating point counts, values, and variances.",
234-
"required": ["type", "data"],
215+
"required": ["type", "counts", "values", "variances"],
235216
"additionalProperties": false,
236217
"properties": {
237218
"type": { "type": "string", "const": "mean" },
238-
"data": {
239-
"oneOf": [
240-
{
241-
"type": "string",
242-
"description": "A path (URI?) to the floating point bin data; outer dimension is [counts, value, variance]"
243-
},
244-
{
245-
"type": "object",
246-
"required": ["counts", "values", "variances"],
247-
"additionalProperties": false,
248-
"properties": {
249-
"counts": { "type": "array", "items": { "type": "number" } },
250-
"values": { "type": "array", "items": { "type": "number" } },
251-
"variances": { "type": "array", "items": { "type": "number" } }
252-
}
253-
}
254-
]
255-
}
219+
"counts": { "$ref": "#/$defs/data_array" },
220+
"values": { "$ref": "#/$defs/data_array" },
221+
"variances": { "$ref": "#/$defs/data_array" }
256222
}
257223
},
258224
"weighted_mean_storage": {
259225
"type": "object",
260226
"description": "A storage holding 'profile'-style floating point ∑weights, ∑weights², values, and variances.",
261-
"required": ["type", "data"],
227+
"required": [
228+
"type",
229+
"sum_of_weights",
230+
"sum_of_weights_squared",
231+
"values",
232+
"variances"
233+
],
262234
"additionalProperties": false,
263235
"properties": {
264236
"type": { "type": "string", "const": "weighted_mean" },
265-
"data": {
266-
"oneOf": [
267-
{
268-
"type": "string",
269-
"description": "A path (URI?) to the floating point bin data; outer dimension is [∑weights, ∑weights², value, variance]"
270-
},
271-
{
272-
"type": "object",
273-
"required": [
274-
"sum_of_weights",
275-
"sum_of_weights_squared",
276-
"values",
277-
"variances"
278-
],
279-
"additionalProperties": false,
280-
"properties": {
281-
"sum_of_weights": {
282-
"type": "array",
283-
"items": { "type": "number" }
284-
},
285-
"sum_of_weights_squared": {
286-
"type": "array",
287-
"items": { "type": "number" }
288-
},
289-
"values": { "type": "array", "items": { "type": "number" } },
290-
"variances": { "type": "array", "items": { "type": "number" } }
291-
}
292-
}
293-
]
294-
}
237+
"sum_of_weights": { "$ref": "#/$defs/data_array" },
238+
"sum_of_weights_squared": { "$ref": "#/$defs/data_array" },
239+
"values": { "$ref": "#/$defs/data_array" },
240+
"variances": { "$ref": "#/$defs/data_array" }
295241
}
296242
}
297243
}

tests/resources/reg.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"circular": false
1313
}
1414
],
15-
"storage": { "type": "int", "data": [1, 2, 3, 4, 5] }
15+
"storage": { "type": "int", "values": [1, 2, 3, 4, 5] }
1616
},
1717
"two": {
1818
"axes": [
@@ -26,6 +26,6 @@
2626
"circular": false
2727
}
2828
],
29-
"storage": { "type": "double", "data": "some/path/depends/on/format" }
29+
"storage": { "type": "double", "values": "some/path/depends/on/format" }
3030
}
3131
}

0 commit comments

Comments
 (0)