JuliaApproximation / ApproxFunBase.jl

Core functionality of ApproxFun
MIT License
12 stars 13 forks source link

chop! no longer produces empty coefficients #479

Open dstahlke opened 1 year ago

dstahlke commented 1 year ago

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

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

dstahlke commented 1 year ago

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.

jishnub commented 1 year ago

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[bot] commented 1 year ago

Codecov Report

Patch coverage: 19.90% and project coverage change: -44.84 :warning:

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

Additional details and impacted files ```diff @@ 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](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation) | Coverage Δ | | |---|---|---| | [src/ApproxFunBase.jl](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL0FwcHJveEZ1bkJhc2Uuamw=) | `44.00% <ø> (-39.34%)` | :arrow_down: | | [src/Fun.jl](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL0Z1bi5qbA==) | `36.14% <0.00%> (-33.01%)` | :arrow_down: | | [src/LinearAlgebra/blas.jl](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL0xpbmVhckFsZ2VicmEvYmxhcy5qbA==) | `77.77% <ø> (ø)` | | | [src/Operators/banded/Conversion.jl](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL09wZXJhdG9ycy9iYW5kZWQvQ29udmVyc2lvbi5qbA==) | `24.13% <0.00%> (-53.83%)` | :arrow_down: | | [src/Operators/functionals/CalculusFunctional.jl](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL09wZXJhdG9ycy9mdW5jdGlvbmFscy9DYWxjdWx1c0Z1bmN0aW9uYWwuamw=) | `10.81% <0.00%> (-61.61%)` | :arrow_down: | | [src/Spaces/Spaces.jl](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL1NwYWNlcy9TcGFjZXMuamw=) | `2.40% <ø> (-64.65%)` | :arrow_down: | | [src/Spaces/SumSpace.jl](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL1NwYWNlcy9TdW1TcGFjZS5qbA==) | `32.38% <0.00%> (-37.29%)` | :arrow_down: | | [src/eigen.jl](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL2VpZ2VuLmps) | `0.00% <0.00%> (ø)` | | | [src/Operators/banded/CalculusOperator.jl](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL09wZXJhdG9ycy9iYW5kZWQvQ2FsY3VsdXNPcGVyYXRvci5qbA==) | `17.35% <19.35%> (-57.21%)` | :arrow_down: | | [src/show.jl](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL3Nob3cuamw=) | `66.37% <41.46%> (-16.46%)` | :arrow_down: | | ... and [4 more](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation) | | ... and [59 files with indirect coverage changes](https://app.codecov.io/gh/JuliaApproximation/ApproxFunBase.jl/pull/479/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation)

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