It's pretty easy to know if a variable is different from another in Matlab. However, it's not so straight forward to see the reason.
This is a problem when dealing with new Parsers, for example. One seeks to check if the new parser produces the same structure after a modification. The canonical way is to just:
isequal(new,old)
However, this does not tell where and why the difference occurs. Also, it's useful not just to know where the content changes, but why. Hence, a useful tool is something like:
[isdiff,why] = compare_this(new,old)
Type, size, length, and content comparison is required to achieve that and inform correctly. For example, a given structure got an extra field not previously found (length/size wise comparison), the type at new.data.cell{3} can be char while in old.new.data{3} can be int16, etc.
Finally, the comparison needs also to walkthrough all nested levels, reporting exactly where/why the difference occurs (i.e. recursion).
The above requirements indicate that what we need is a schema validation tool.
Requirements:
[x] A schema validation toolbox that support both flat (str,array) and nested/tree-like variables (struct/cell).
[x] The tool should be recursive and extensible, so both schemas creation and schema validation can be performed.
[x] The function has to report correctly why and where the differences are found, in arbitrary and deeply nested trees (e.g. a.b{3}.c{3,3}.d(4,1,3).e{3}.f).
[x] Be extensible, so we can build schemas and/or evaluate different aspects.
It's pretty easy to know if a variable is different from another in Matlab. However, it's not so straight forward to see the reason.
This is a problem when dealing with new Parsers, for example. One seeks to check if the new parser produces the same structure after a modification. The canonical way is to just:
isequal(new,old)
However, this does not tell where and why the difference occurs. Also, it's useful not just to know where the content changes, but why. Hence, a useful tool is something like:
[isdiff,why] = compare_this(new,old)
Type, size, length, and content comparison is required to achieve that and inform correctly. For example, a given structure got an extra field not previously found (length/size wise comparison), the type at new.data.cell{3} can be
char
while in old.new.data{3} can beint16
, etc.Finally, the comparison needs also to walkthrough all nested levels, reporting exactly where/why the difference occurs (i.e. recursion).
The above requirements indicate that what we need is a schema validation tool.
Requirements:
a.b{3}.c{3,3}.d(4,1,3).e{3}.f
).