I find that when writing tests with datashape I have a hard time figuring out which part of the dshape is not equal which leads to a slower debug process.
This adds an assert_dshape_equal function which aims to provide much better errors. One of the nice pieces path: %s part of the message that shows you the exact path to the parts that are not equal, here are some examples:
In [2]: assert_dshape_equal(dshape('var * int32'), dshape('var * float64'))
AssertionError: ctype names do not match: 'int32' != 'float64'
path: _.measure.name
In [3]: assert_dshape_equal(dshape('2 * int32'), dshape('var * int32'))
AssertionError: dimensions do not match: 2 != var
path: _.shape[0]
In [4]: assert_dshape_equal(dshape('var * 2 * int32'), dshape('var * 3 * int32'))
AssertionError: dimensions do not match: 2 != 3
var * 2 != var * 3
path: _.shape[1]
In [6]: assert_dshape_equal(dshape('var * {a: 3 * {b: int32}}'), dshape('var * {a: 3 * {b: float32}}'))
AssertionError: ctype names do not match: 'int32' != 'float32'
path: _.measure['a'].measure['b'].name
I do not want to refactor the current tests to use this because I don't want to break anything (there are no tests for the tests); however, it would be nice to use something like this going forward.
I find that when writing tests with datashape I have a hard time figuring out which part of the dshape is not equal which leads to a slower debug process. This adds an
assert_dshape_equal
function which aims to provide much better errors. One of the nice piecespath: %s
part of the message that shows you the exact path to the parts that are not equal, here are some examples:I do not want to refactor the current tests to use this because I don't want to break anything (there are no tests for the tests); however, it would be nice to use something like this going forward.