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

Copy! in interpolation does not take into account scalars #903

Closed
bertini97 opened this issue Jan 10, 2025 · 5 comments
Closed

Copy! in interpolation does not take into account scalars #903

bertini97 opened this issue Jan 10, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@bertini97
Copy link

Describe the bug 🐞

> a = LinearInterpolation([1.0, 2.0], [1.0, 2.0])
LinearInterpolation{Vector{Float64}, Vector{Float64}}([1.0, 2.0], [1.0, 2.0], false)

> b = [1.0]
1-element Vector{Float64}:
 1.0

> a(b, 1.1)
1-element Vector{Float64}:
 1.1

> a(b, 1.0)
ERROR: MethodError: no method matching copy!(::Vector{Float64}, ::Float64)

This is because of the copy! when the tval is the first one:

copy!(out, u[k])

Expected behavior
Expected behavior is that it should be interpolated properly. I don't know if this is intended. It doesn't look like it to me. Cheers.

@bertini97 bertini97 added the bug Something isn't working label Jan 10, 2025
@bertini97
Copy link
Author

bertini97 commented Jan 10, 2025

A solution that works is doing what is done below for all other values:

out .= u[k]

@ChrisRackauckas
Copy link
Member

Is this a DataInterpolations.jl issue? This is for DataInterpolations.LinearInterpolation?

@bertini97
Copy link
Author

I would say no, I don't have it installed. I imported SciMLBase's interpolations.jl

@ChrisRackauckas
Copy link
Member

Oh I see what you're saying. The inplace form of interpolation just cannot support scalars. That is just a fundamental Julia thing and cannot be solved by a package (nor does it really make sense? There is no preallocating for a scalar)

@bertini97
Copy link
Author

Sorry, I improperly called them scalars. But they are in fact a 1D array with one element. The interpolation should work. And it does if you do not select a boundary value. If you select a boundary value it will use copy instead of broadcast, for reasons I can't tell right now. But this looks like a bug, I urge you to consider reopening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants