Skip to content

Commit

Permalink
Check dimension_names for all zarr.json
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Jul 4, 2024
1 parent e150aa9 commit 5e1ce06
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/JsonValidator/MultiscaleArrays/Multiscale.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
const permitDtypeMismatch = ["0.1", "0.2", "0.3", "0.4"].includes(version);
const checkDimSeparator = ["0.2", "0.3", "0.4"].includes(version);
const allowMissingDimNames = ["0.1", "0.2", "0.3", "0.4"].includes(version);
function allEqual(items) {
return items.every((value) => value == items[0]);
Expand All @@ -29,11 +30,12 @@
let dimCounts = [];
let shapes = [];
let dimSeparators = [];
let zarrayJsonList = [];
for (let i = 0; i < datasets.length; i++) {
let dataset = datasets[i];
let zarray = await getZarrArrayJson(source + "/" + dataset.path);
console.log('zarray', zarray);
zarrayJsonList.push(zarray);
// Need to handle Zarr v2 and Zarr v3:
dimCounts.push(zarray.shape.length);
dtypes.push(zarray.dtype || zarray.data_type);
Expand Down Expand Up @@ -74,6 +76,24 @@
});
}
});
if (!allowMissingDimNames) {
let axesNames = JSON.stringify(axes.map(axis => axis.name));
zarrayJsonList.forEach((arrData, i) => {
let msg;
if (!arrData.dimension_names) {
msg = `No dimension_names found for dataset ${i}`;
} else {
let dimNames = JSON.stringify(arrData.dimension_names);
if (dimNames != axesNames) {
msg = `dimension_names: ${dimNames} don't match axes names: ${axesNames}`;
}
}
if (msg) {
checks.push({msg});
}
});
}
}
if (checkDimSeparator) {
dimSeparators.forEach((sep) => {
Expand Down

0 comments on commit 5e1ce06

Please sign in to comment.