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

Improve "unsupported operand types" error for afwImage arithmetic

    Details

    • Type: Improvement
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: afw
    • Story Points:
      1
    • Team:
      External

      Description

      If a user tries to add two images, or multiply an image by a constant, or do any kind of not-in-place image arithmetic, they get an unfriendly TypeError: unspotted operand type(s).

      This ticket is to clarify the error message and suggest an alternative, for example, "afwImages must be modified in place, e.g., if you want image1 + image2, try image1 += image2."

        Attachments

          Activity

          Hide
          price Paul Price added a comment -

          Please let me know what you think about this solution, Meredith Rawls.

          Show
          price Paul Price added a comment - Please let me know what you think about this solution, Meredith Rawls .
          Hide
          mrawls Meredith Rawls added a comment -

          This is great, thank you for doing it so comprehensively and adding the nice set of tests. Wow do we have a lot of flavors of image and exposure  

          Show
          mrawls Meredith Rawls added a comment - This is great, thank you for doing it so comprehensively and adding the nice set of tests. Wow do we have a lot of flavors of image and exposure  
          Hide
          price Paul Price added a comment -

          Meredith Rawls, I had to change the implementation because arithmetic operations are defined if the operand is an lsst.afw.image.ImageSlice. That's something I had no idea existed, and I don't think is actually used anywhere, but I don't want to usher through an RFC removing it, so I had to make things a bit more complicated to deal with it. Would you mind having another look, please?

          Show
          price Paul Price added a comment - Meredith Rawls , I had to change the implementation because arithmetic operations are defined if the operand is an lsst.afw.image.ImageSlice . That's something I had no idea existed, and I don't think is actually used anywhere, but I don't want to usher through an RFC removing it, so I had to make things a bit more complicated to deal with it. Would you mind having another look, please?
          Hide
          mrawls Meredith Rawls added a comment -

          Ah, I wondered if there might be a weird edge case like that. I've never heard of ImageSlice either. I liked the simplicity of the first implementation, but this will do, short of removing ImageSlice via RFC as you say. Please verify the warning prints when intended and Jenkins is happy with it all, of course. Thanks!

          Show
          mrawls Meredith Rawls added a comment - Ah, I wondered if there might be a weird edge case like that. I've never heard of ImageSlice either. I liked the simplicity of the first implementation, but this will do, short of removing ImageSlice via RFC as you say. Please verify the warning prints when intended and Jenkins is happy with it all, of course. Thanks!
          Hide
          price Paul Price added a comment -

          Jenkins is green.

          Merged to master.

          Thanks Meredith Rawls!

          Show
          price Paul Price added a comment - Jenkins is green. Merged to master. Thanks Meredith Rawls !

            People

            • Assignee:
              price Paul Price
              Reporter:
              mrawls Meredith Rawls
              Reviewers:
              Meredith Rawls
              Watchers:
              Meredith Rawls, Paul Price
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel