Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-10147

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: ndarray
    • Labels:
      None

      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.

        Attachments

          Activity

          Hide
          krzys 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
          krzys 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:
            jbosch Jim Bosch
            Reporter:
            Parejkoj John Parejko
            Watchers:
            Jim Bosch, John Parejko, Krzysztof Findeisen, Russell Owen, Simon Krughoff
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:

                Jenkins Builds

                No builds found.