-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tricky interface for AffineMap(::LinearMap, ::Vector)
#90
Comments
Hmm, I see. It probably makes sense to rename the linear approximation to something more explicit. Add a deprecation for that, and allow Are there any consumers of this method with an opinion? (Actually - is the linear approximation "wrong" w.r.t. the offset component anyway? If we want a linear approximation around a point wouldn't we want a LinearMap?) @RomeoV would you be willing to contribute a PR? |
Happy to make a PR after a little more discussion on the interface. Another interface possibility just occurred to me: AffineMap(::LinearTransformation, ::Any)
AffineMap(::AbstractMatrix, ::Translation)
AffineMap(::AbstractMatrix, ::Vector) and a bunch of other combinations. CoordinateTransformations.jl/src/affine.jl Lines 104 to 109 in b97c74a
I propose we instead change the definition of struct AffineMap{M<:LinearMap, V<:Translation} <: AbstractAffineMap
linear::M
translation::V
end (note the restriction in the template paramters) AffineMap(M, V) = AffineMap(LinearMap(M), Translation(V)) and then simply (map::AffineMap)(x) = (map.translation \circ map.linear)(x) Would that be fine? |
Also, is there any reason we don't restrict the inner type of CoordinateTransformations.jl/src/affine.jl Lines 37 to 43 in b97c74a
i.e. it refers to "a matrix-like object", i.e. an |
I just encountered a very tricky silent bug while slinging around
AffineMap
,LinearMap
,Transformation
etc.In summary, I have some 3D rotation matrices stored as
LinearMap
and tried to combine it with a translation stored asVector
. Spot the error in this code:It turns out that
AffineMap(::LinearMap, ::Vector)
actually calls an overloaded functionAffineMap(::Transformation, ::Any)
and returns an AffineMap just fine, but withAffineMap.v == zeros(3)
!CoordinateTransformations.jl/src/affine.jl
Lines 121 to 125 in b97c74a
I.e.
This is a super tricky bug, as it's completely silent, and occurs from a "misuse" of the interface that is very subtle.
Perhaps it would make sense to rename the function
to something like
AffineMapApprox
(or something similar), although I realize that would be a breaking change.Alternatively, we could overload
AffineMap(::LinearTransformation, ::Any)
, e.g. giving a warning likeThe text was updated successfully, but these errors were encountered: