Skip to content
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

chop! no longer produces empty coefficients #479

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dstahlke
Copy link

Test case:
using ApproxFun
x,y = Fun(identity, Chebyshev() * Chebyshev())
ApproxFun.norm(0*x)
ApproxFun.norm(zero(x))

I didn't create a unit test because I couldn't find a way to reproduce with ApproxFunBase only.

Test case:
    using ApproxFun
    x,y = Fun(identity, Chebyshev() * Chebyshev())
    ApproxFun.norm(0*x)
    ApproxFun.norm(zero(x))
@dstahlke
Copy link
Author

Without this patch, norm(zero(x)) gives the following error in ApproxFunBase/src/Multivariate/ProductFun.jl:177:

ERROR: LoadError: BoundsError: attempt to access 0×0 Matrix{Float64} at index [1:1, 1:1]

Fixing ProductFun to handle empty coefficients just leads to a similar error later on. So it seems this package generally assumes that the coefficients vector is not empty. Thus I modified chop! to never return an empty coefficients vector.

dstahlke added a commit to dstahlke/ApproxFun.jl that referenced this pull request Jun 12, 2023
Test case (requires also JuliaApproximation/ApproxFunBase.jl#479):
    using ApproxFun

    xdom = Chebyshev(-1..1)
    ydom = Chebyshev(-1..1)
    domain = xdom * ydom
    x,y = Fun(identity, domain)
    Dx = Derivative(Chebyshev()^2, [1,0])
    Dy = Derivative(Chebyshev()^2, [0,1])

    N(u, v) = [
        2*u - x;
        3*v + y
    ]

    u0 = one(x) * one(y)
    v0 = one(x) * one(y)
    u, v = newton(N, [u0, v0])

Bug report:
JuliaApproximation#887
@jishnub
Copy link
Member

jishnub commented Jun 12, 2023

Thanks! ideally the empty ProductFun and LowRankFun should be made to work, but that requires fixing a lot of code, so I think this should be fine

@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Patch coverage: 19.90% and project coverage change: -44.84 ⚠️

Comparison is base (2f401fa) 71.22% compared to head (20867a2) 26.38%.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #479       +/-   ##
===========================================
- Coverage   71.22%   26.38%   -44.84%     
===========================================
  Files          80       81        +1     
  Lines        8331     8443      +112     
===========================================
- Hits         5934     2228     -3706     
- Misses       2397     6215     +3818     
Impacted Files Coverage Δ
src/ApproxFunBase.jl 44.00% <ø> (-39.34%) ⬇️
src/Fun.jl 36.14% <0.00%> (-33.01%) ⬇️
src/LinearAlgebra/blas.jl 77.77% <ø> (ø)
src/Operators/banded/Conversion.jl 24.13% <0.00%> (-53.83%) ⬇️
src/Operators/functionals/CalculusFunctional.jl 10.81% <0.00%> (-61.61%) ⬇️
src/Spaces/Spaces.jl 2.40% <ø> (-64.65%) ⬇️
src/Spaces/SumSpace.jl 32.38% <0.00%> (-37.29%) ⬇️
src/eigen.jl 0.00% <0.00%> (ø)
src/Operators/banded/CalculusOperator.jl 17.35% <19.35%> (-57.21%) ⬇️
src/show.jl 66.37% <41.46%> (-16.46%) ⬇️
... and 4 more

... and 59 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants