Define values for ArraySpace - #688
Merged
Merged
Conversation
`values(f)` errored for an array-valued `Fun`, which broke `iszero` since it started consulting `values` in #635. Three separate causes: * `itransform` was only defined for `VectorSpace`, so a `MatrixSpace` fell through to the generic `Space` method and hit `checkcanonicalspace`, which errors as an `ArraySpace` of canonical spaces is its own canonical space. Widen the method to `ArraySpace` and reshape the values to the shape of the space. * The component coefficients may be views, so `pad!` may not resize them. Use `pad` instead. * `_values` asserted a `Vector{float(T)}` return for any space over a numeric domain, which includes array-valued ones. Restrict the assertion to spaces with a scalar range type. Also fix `points(f::Fun{<:ArraySpace})`, which passed the total number of interlaced coefficients where a per-component count is expected, so that `values(f) == f.(points(f))`. Fixes #647 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #647.
values(f)errored for an array-valuedFun, soiszerobroke for theseafter #635 started consulting
values:There were three separate causes:
itransformwas only defined for aVectorSpace, so aMatrixSpacefellthrough to the generic
Spacemethod and reachedcheckcanonicalspace,which errors because
canonicalspaceis applied component-wise and anArraySpaceof canonical spaces is therefore its own canonical space. Themethod is now defined for an
ArraySpace, and reshapes the values to theshape of the space.
The component coefficients are views if the interlacer is trivial, in which
case
pad!can't resize them. This brokevaluesfor aVectorSpaceaswell, e.g.
Fun(x->[exp(x),sin(x)], -1..1).padis used instead._valuesasserted aVector{float(T)}return type for every space over anumeric domain.
UnivariateSpaceonly constrains the domain type, so anArraySpaceover one matched, and the assertion rejected the array-valuedresult. The assertion is now restricted to spaces with a scalar range type.
Additionally,
points(f::Fun{<:ArraySpace})passedncoefficients(f), thetotal number of interlaced coefficients, where
points(::ArraySpace, n)expects a per-component count. This was silently wrong for
Fourier, and anerror for a finite-dimensional component space such as
PointSpace. It nowmatches the padding used in
itransform, sovalues(f) == f.(points(f)).Tests cover
PointSpaceandHeavisideSpacecomponents at vector and matrixshapes; the latter is over a numeric domain and has a trivial interlacer, so
it exercises the second and third points above.
Downstream
ApproxFuntests pass against this branch.🤖 Generated with Claude Code