-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update for julia 1.x #5
base: master
Are you sure you want to change the base?
Changes from all commits
5b480d2
a4b1537
ee1eec8
88b3b44
f31beae
a070e68
fb3bcc6
fafe806
45b82a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: "master" | ||
tags: ['*'] | ||
pull_request: | ||
concurrency: | ||
# Skip intermediate builds: always. | ||
# Cancel intermediate builds: only if it is a pull request build. | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | ||
jobs: | ||
test: | ||
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
version: | ||
- '1.6' | ||
- '1' | ||
- 'nightly' | ||
os: | ||
- ubuntu-latest | ||
arch: | ||
- x64 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: ${{ matrix.version }} | ||
arch: ${{ matrix.arch }} | ||
- uses: julia-actions/cache@v1 | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
- uses: julia-actions/julia-runtest@v1 | ||
- uses: julia-actions/julia-processcoverage@v1 | ||
- uses: codecov/codecov-action@v2 | ||
with: | ||
files: lcov.info |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: CompatHelper | ||
on: | ||
schedule: | ||
- cron: 0 0 * * * | ||
workflow_dispatch: | ||
jobs: | ||
CompatHelper: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Pkg.add("CompatHelper") | ||
run: julia -e 'using Pkg; Pkg.add("CompatHelper")' | ||
- name: CompatHelper.main() | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} | ||
run: julia -e 'using CompatHelper; CompatHelper.main()' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
name: TagBot | ||
on: | ||
schedule: | ||
- cron: 0 * * * * | ||
issue_comment: | ||
types: | ||
- created | ||
workflow_dispatch: | ||
jobs: | ||
TagBot: | ||
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: JuliaRegistries/TagBot@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
ssh: ${{ secrets.DOCUMENTER_KEY }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above, I guess we’ll see whether this works or not. TagBot would be really good to have. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
*.jl.cov | ||
*.jl.*.cov | ||
*.jl.mem | ||
Manifest.toml | ||
.vscode |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||
name = "UnitfulIntegration" | ||||
uuid = "6043864f-155a-5464-b5be-64e090a46784" | ||||
authors = ["contributors"] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
IMO, just writing "contributors" doesn’t add much value. I would just remove the line (the |
||||
version = "0.2.0" | ||||
|
||||
[deps] | ||||
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" | ||||
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" | ||||
|
||||
[compat] | ||||
julia = "1" | ||||
QuadGK = "2.6" | ||||
Unitful = "1.12" | ||||
|
||||
[extras] | ||||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||||
|
||||
[targets] | ||||
test = ["Test"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
# UnitfulIntegration | ||
|
||
[![Build Status](https://travis-ci.org/ajkeller34/UnitfulIntegration.jl.svg?branch=master)](https://travis-ci.org/ajkeller34/UnitfulIntegration.jl) | ||
[![Coverage Status](https://coveralls.io/repos/ajkeller34/UnitfulIntegration.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/ajkeller34/UnitfulIntegration.jl?branch=master) | ||
[![codecov.io](http://codecov.io/github/ajkeller34/UnitfulIntegration.jl/coverage.svg?branch=master)](http://codecov.io/github/ajkeller34/UnitfulIntegration.jl?branch=master) | ||
[![CI](https://github.com/PainterQubits/UnitfulIntegration.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/PainterQubits/UnitfulIntegration.jl/actions/workflows/CI.yml) | ||
[![codecov.io](https://codecov.io/github/PainterQubits/UnitfulIntegration.jl/coverage.svg?branch=master)](https://codecov.io/github/PainterQubits/UnitfulIntegration.jl?branch=master) | ||
|
||
This package enables integration of physical quantity-valued functions, using | ||
the Quantity types implemented in [Unitful.jl](https://github.com/ajkeller34/Unitful.jl). | ||
|
||
This package currently supports [QuadGK.jl](https://github.com/JuliaMath/QuadGK.jl), | ||
which was originally in Julia Base. We do not support QuadGK as implemented in Julia 0.5. | ||
To use this package with Julia 0.5, you need to install the QuadGK package and | ||
qualify all invocations of QuadGK functions with the module name (e.g. | ||
`import QuadGK; QuadGK.quadgk(...)`). | ||
This package currently supports [QuadGK.jl](https://github.com/JuliaMath/QuadGK.jl) v2.6 or newer. | ||
|
||
|
||
|
||
PRs for other integration packages are welcome. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove this? Do you think that they shouldn’t be welcome any more? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was my mistake, I intended to remove the part concearning the old julia version and ended up removing the PR part too |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,16 @@ | ||
__precompile__(true) | ||
module UnitfulIntegration | ||
|
||
using Unitful | ||
import Unitful: DimensionError | ||
import QuadGK | ||
import LinearAlgebra | ||
import Unitful: AbstractQuantity | ||
import QuadGK: cachedrule, rulecache | ||
|
||
function QuadGK.quadgk(f, a::Quantity, b::Quantity, c::Quantity...; kws...) | ||
d = dimension(a) | ||
d != dimension(b) && throw(DimensionError(a,b)) | ||
for x in c | ||
d != dimension(x) && throw(DimensionError(a,x)) | ||
end | ||
QuadGK.quadgk(f, promote(a,b,c...)...; kws...) | ||
end | ||
|
||
function QuadGK.quadgk(f, a::Quantity{T,D,U}, b::Quantity{T,D,U}, c::Quantity{T,D,U}...; | ||
atol=missing, rtol=sqrt(eps(T)), maxevals=10^7, order=7, norm=LinearAlgebra.norm) where | ||
{T<:AbstractFloat,D,U} | ||
if ismissing(atol) | ||
error("must provide an explicit atol keyword argument, e.g. ", | ||
"`zero(f(a)*a)` supposing f is defined at a.") | ||
end | ||
_do_quadgk(f, [a, b, c...], order, T, atol, rtol, maxevals, norm) | ||
end | ||
|
||
function QuadGK.quadgk(f, a::Quantity{Complex{T},D,U}, b::Quantity{Complex{T},D,U}, | ||
c::Quantity{Complex{T},D,U}...; atol=missing, rtol=sqrt(eps(T)), maxevals=10^7, | ||
order=7, norm=LinearAlgebra.norm) where {T<:AbstractFloat,D,U} | ||
if ismissing(atol) | ||
error("must provide an explicit atol keyword argument, e.g. ", | ||
"`zero(f(a)*a)` supposing f is defined at a.") | ||
end | ||
_do_quadgk(f, [a, b, c...], order, T, atol, rtol, maxevals, norm) | ||
end | ||
|
||
# Necessary with infinite or semi-infinite intervals since quantities !<: Real | ||
function _do_quadgk(f, s::Array{Quantity{T,D,U},1}, n, ::Type{Tw}, atol, rtol, | ||
maxevals, nrm) where {Tw,T<:Real,D,U} | ||
# fix `cachedrule` until it is possible to extend Unitful with package extension https://github.com/JuliaLang/julia/pull/47695 (julia >= 1.10) | ||
|
||
s_no_u = reinterpret(T, s) | ||
s1 = s_no_u[1]; s2 = s_no_u[end]; inf1 = isinf(s1); inf2 = isinf(s2) | ||
if inf1 || inf2 | ||
if inf1 && inf2 # x = t/(1-t^2) coordinate transformation | ||
return QuadGK.do_quadgk(t -> begin t2 = t*t; den = 1 / (1 - t2); | ||
f(t*den*U())*U() * (1+t2)*den*den; end, | ||
map(x -> isinf(x) ? copysign(one(x), x) : | ||
2x / (1+hypot(1,2x)), s_no_u), | ||
n, T, atol, rtol, maxevals, nrm) | ||
end | ||
s0,si = inf1 ? (s2,s1) : (s1,s2) | ||
if si < 0 # x = s0 - t/(1-t) | ||
return QuadGK.do_quadgk(t -> begin den = 1 / (1 - t); | ||
f((s0 - t*den)*U())*U() * den*den; end, | ||
reverse!(map(x -> 1 / (1 + 1 / (s0 - x)), s_no_u)), | ||
n, T, atol, rtol, maxevals, nrm) | ||
else # x = s0 + t/(1-t) | ||
return QuadGK.do_quadgk(t -> begin den = 1 / (1 - t); | ||
f((s0 + t*den)*U())*U() * den*den; end, | ||
map(x -> 1 / (1 + 1 / (x - s0)), s_no_u), | ||
n, T, atol, rtol, maxevals, nrm) | ||
end | ||
end | ||
QuadGK.do_quadgk(f, s, n, Tw, atol, rtol, maxevals, nrm) | ||
@generated function cachedrule(::Type{T}, n::Integer) where {T<:AbstractQuantity} | ||
TF = typeof(float(real(one(T)))) | ||
cache = haskey(rulecache, TF) ? rulecache[TF] : (rulecache[TF] = Dict{Int,NTuple{3,Vector{TF}}}()) | ||
:(haskey($cache, n) ? $cache[n] : ($cache[n] = kronrod($T, n))) | ||
end | ||
|
||
_do_quadgk(f, s, n, ::Type{Tw}, atol, rtol, maxevals, nrm) where {Tw} = | ||
QuadGK.do_quadgk(f, s, n, Tw, atol, rtol, maxevals, nrm) | ||
|
||
end # module |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,9 @@ | ||
using UnitfulIntegration | ||
using Test | ||
using UnitfulIntegration, Test, QuadGK, Unitful | ||
|
||
import QuadGK | ||
using Unitful | ||
import Unitful: m, s, DimensionError | ||
|
||
# Test physical quantity-valued functions | ||
@test QuadGK.quadgk(x->x*m, 0.0, 1.0, atol=0.0m)[1] ≈ 0.5m | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove this test? |
||
@testset "quad" begin | ||
f(x) = x^2 | ||
res = quadgk(f, 1u"m", 2u"m")[1] | ||
@test isapprox(res, 7//3 *u"m^3") | ||
end | ||
|
||
# Test integration over an axis with units | ||
@test QuadGK.quadgk(ustrip, 0.0m, 1.0m, atol=0.0m)[1] ≈ 0.5m | ||
|
||
# Test integration where the unitful domain is infinite or semi-infinite | ||
@test QuadGK.quadgk(x->exp(-x/(1.0m)), 0.0m, Inf*m, atol=0.0m)[1] ≈ 1.0m | ||
@test QuadGK.quadgk(x->exp(x/(1.0m)), -Inf*m, 0.0m, atol=0.0m)[1] ≈ 1.0m | ||
@test QuadGK.quadgk(x->exp(-abs(x/(1.0m))), | ||
-Inf*m, Inf*m, atol=0.0m)[1] ≈ 2.0m | ||
|
||
# Test mixed case (physical quantity-valued f and unitful domain) | ||
@test QuadGK.quadgk(t->ustrip(t)*m/s, 0.0s, 2.0s, atol=0.0m)[1] ≈ 2.0m | ||
|
||
# Test that errors are thrown when dimensionally unsound | ||
@test_throws DimensionError QuadGK.quadgk(ustrip, 0.0m, 1.0s)[1] | ||
@test_throws DimensionError QuadGK.quadgk(ustrip, 0.0, 1.0m)[1] | ||
|
||
# Test that we throw an error when atol is not specified (at present | ||
# I believe it is only possible to check when the domain is unitful) | ||
@test_throws ErrorException QuadGK.quadgk(ustrip, 0.0m, 1.0m) | ||
Comment on lines
-11
to
-29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove these tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Concerning the test, are they all still relevant? I don't have any particular reason against more tests, I'm just not sure if all the old test are necessary. I guess it's better to have more tests than lesser though, I'll amend my commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Edit: it seems they were, as there are issues with the infinites handling (more broken stuff), I'm working on it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure this package has a
DOCUMENTER_KEY
, since it doesn’t have any documentation. I guess we’ll see what this does in that case. In my opinion, we don’t really need CompatHelper.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok