-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b769ffb
commit df5a417
Showing
5 changed files
with
58 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
julia 0.5 | ||
Unitful 0.1.5 | ||
QuadGK 0.1.1 | ||
julia 0.7 | ||
Unitful 0.11.0 | ||
QuadGK 2.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
using UnitfulIntegration | ||
using Base.Test | ||
using Test | ||
|
||
import QuadGK | ||
using Unitful | ||
import Unitful: m, s, DimensionError | ||
|
||
# Test physical quantity-valued functions | ||
@test QuadGK.quadgk(x->x*m, 0.0, 1.0, abstol=0.0m)[1] ≈ 0.5m | ||
@test QuadGK.quadgk(x->x*m, 0.0, 1.0, atol=0.0m)[1] ≈ 0.5m | ||
|
||
# Test integration over an axis with units | ||
@test QuadGK.quadgk(ustrip, 0.0m, 1.0m, abstol=0.0m)[1] ≈ 0.5m | ||
@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, abstol=0.0m)[1] ≈ 1.0m | ||
@test QuadGK.quadgk(x->exp(x/(1.0m)), -Inf*m, 0.0m, abstol=0.0m)[1] ≈ 1.0m | ||
@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, abstol=0.0m)[1] ≈ 2.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, abstol=0.0m)[1] ≈ 2.0m | ||
@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 abstol is not specified (at present | ||
# 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) |