-
Notifications
You must be signed in to change notification settings - Fork 113
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
Compatibility with QuadGK #597
Comments
There is already a package that is supposed to handle compatibility between Unitful and QuadGK. It is called UnitfulIntegration. However, it hasn’t been updated in a while and is not compatible with Unitful 1.x. My suggestion would be to bring UnitfulIntegration up to date to support the current versions of QuadGK and Unitful. For Julia ≥ |
Alright! I'm working on updating the package and I will issue a pull request as soon as possible! |
I have submitted a pull request on UnitfulIntegration |
Can you give a specific test case? I just tried it with the latest versions (QuadGK 2.6.0 and Unitful v1.12.2) in Julia 1.8.2, and it works fine for me: julia> using Unitful, QuadGK
julia> f(t) = 1.0u"J"
f (generic function with 1 method)
julia> quadgk(f, 0.0u"s", 10.0u"s")
(10.0 J s, 0.0 J s) |
It seems like there is a bug in Julia where if you do |
there are a couple things here that are forbidden to generated functions.
For addressing 1, the solution is simply to move that code outside of the generated function, so that the argument to the generated function is |
Infinite bounds do not work, even with julia> using Unitful, QuadGK
julia> quadgk(x->exp(-x/(1.0u"m")), 0.0u"m", Inf*u"m", atol=0.0u"m")
ERROR: DomainError with Inf m:
integrand produced NaN m in the interval (0.0 m, Inf m)
Stacktrace:
[...] |
Update: this turned out to be a bug in the use of |
Closed by JuliaRegistries/General#75775 |
Infinite bounds still don’t work: (jl_s3h7TF) pkg> st
Status `/tmp/jl_s3h7TF/Project.toml`
[1fd47b50] QuadGK v2.7.0 `https://github.com/JuliaMath/QuadGK.jl#master`
[1986cc42] Unitful v1.12.2
julia> using Unitful, QuadGK
julia> quadgk(x->exp(-x/(1.0u"m")), 0.0u"m", Inf*u"m")
ERROR: DomainError with Inf m:
integrand produced NaN m in the interval (0.0 m, Inf m)
Stacktrace:
[...] |
The problem with infinite bounds is a completely unrelated problem. I would suggest closing this issue in favor of a more specialized issue JuliaMath/QuadGK.jl#64 |
Should be fixed now, in any case. On
|
Great, thanks! |
Hello, the update of QuadGK (a popular library for numerical integration) from v2.5 to v2.6 broke compatibility with Unitful.
To restore compatibility, one would have to extend the QuadGK function
cachedrule
to also work with quantities with something likeUnitful and QuadGK don't have each other as dependencies, so it would not be possible to extend either without adding more dependencies.
Do you think it would be beneficial to create a new julia package (like UnitfulQuad or something similar) to make Unitful talk nicely with QuadGK, or do you have any suggestions on how to proceed? I think out of the box numerical integration with units is a strong selling point for Julia!
The text was updated successfully, but these errors were encountered: