RFC/WIP: coercion "cascades" for MvNormal #1823
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This redesigns the constructors of
MvNormal
to:MvNormal{Float32}(μ, Σ)
will enforce that the result has eltype
Float32
The benefits of this design are subtle but significant, as it
allows the user to specify intent, allows the constructors to
accept input arguments that are not (yet) consistent with
the desired output types (e.g.,
MvNormal{Float64}(Any[1,2], I)
),and makes it easy for developers to "propagate" consistent
types across the code base (e.g., fixes #1544).
Among things this fixes, it's currently possible to construct an
MvNormal
with inconsistent dimensions:This is possible because the consistency check is not in the inner constructor.