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

Clean up Angle's operators

    Details

    • Type: Improvement
    • Status: To Do
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: afw
    • Story Points:
      3
    • Team:
      Alert Production

      Description

      Angle's API has a number of inconsistencies:

      • It supports * and *= for Angle, double, and int in any combination (though Angle only through implicit conversion in Python).
      • It supports += and -= for Angle, double and int, but + and - only for Angle in C++.
      • It supports += and -= only for Angle in Python.
      • It supports * for Angle directly, but *=, +=, and -= only through implicit conversion to double.
      • It supports / for double and int directly in C++, but supports int only through implicit conversion in Python.
      • It supports comparison operators between Angle and Angle, double, or int in Python, but only with other Angle objects in C++.
      • AngleUnit can be tested for inequality in Python but not C++.
      • Expressions like degrees * 42.0 are allowed in Python but not C++.

      The API should be reviewed with other DM programmers for which of these operations are desirable, and the code updated with more coherent handling.

        Attachments

          Issue Links

            Activity

            Hide
            krzys Krzysztof Findeisen added a comment -

            Russell Owen suggested that Angle's implicit conversion to double be removed. IMO the main application is expressions like sin(angle), which can be done by dedicated methods.

            Show
            krzys Krzysztof Findeisen added a comment - Russell Owen suggested that Angle 's implicit conversion to double be removed. IMO the main application is expressions like sin(angle) , which can be done by dedicated methods.
            Hide
            rowen Russell Owen added a comment - - edited

            sin(angle) could also be handled using free functions in the same scope as Angle. That might be a bit easier for users.

            Jim Bosch had an interesting suggestion that is clearly out of scope for this ticket, but I am recording it for posterity): have pybind11 wrap Angle as astropy.coordinates.Angle. DM-9221

            Show
            rowen Russell Owen added a comment - - edited sin(angle) could also be handled using free functions in the same scope as Angle . That might be a bit easier for users. Jim Bosch had an interesting suggestion that is clearly out of scope for this ticket, but I am recording it for posterity): have pybind11 wrap Angle as astropy.coordinates.Angle . DM-9221
            Hide
            krzys Krzysztof Findeisen added a comment -

            Yes, I meant "function", not "method".

            How would that work? If I try to construct a SpherePoint from Python, will pybind11 convert my constructor arguments from astropy.coordinates.Angle to afw.geom.Angle?

            Show
            krzys Krzysztof Findeisen added a comment - Yes, I meant "function", not "method". How would that work? If I try to construct a SpherePoint from Python, will pybind11 convert my constructor arguments from astropy.coordinates.Angle to afw.geom.Angle ?

              People

              • Assignee:
                krzys Krzysztof Findeisen
                Reporter:
                krzys Krzysztof Findeisen
                Watchers:
                Krzysztof Findeisen, Russell Owen
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Summary Panel