# Document (and/or fix) how to test deep equality of ndarrays

XMLWordPrintable

#### Details

• Type: Story
• Status: To Do
• Resolution: Unresolved
• Fix Version/s: None
• Component/s:
• Labels:
None
• Story Points:
1
• Team:
Data Release Production

#### Description

The tutorial for ndarray mentions "Comparison" at the bottom, but does not describe how to test equality. We learned (while implementing operator== for BoundedField) that you have to first test the shape, otherwise you may segfault if the shapes are different. The following should work for a "deep" comparison of two ndarrays:

 return lhs.getShape() == rhs.getShape() && all(equal(lhs, rhs)); 

It would be useful for the tutorial doc to describe this, and/or for equal() to check the shapes first.

#### Activity

Hide
Krzysztof Findeisen added a comment -

I agree with Jim Bosch's remark on #dm that if the shapes don't match, about the only thing equal can do is throw an exception. So to get C++-style (scalar boolean) equality you still need to first check the shapes.

Show
Krzysztof Findeisen added a comment - I agree with Jim Bosch 's remark on #dm that if the shapes don't match, about the only thing equal can do is throw an exception. So to get C++-style (scalar boolean) equality you still need to first check the shapes.

#### People

Assignee:
Jim Bosch
Reporter:
John Parejko
Watchers:
Jim Bosch, John Parejko, Krzysztof Findeisen, Russell Owen, Simon Krughoff