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

[WIP] Compatibility with QuadGK.jl #41

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ julia = "1.6"
[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Ratios = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SaferIntegers = "88634af6-177f-5301-88b8-7819386cfa38"
Expand All @@ -43,4 +44,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["Test", "Aqua", "LinearAlgebra", "Ratios", "SaferIntegers", "SafeTestsets", "ScientificTypes", "ScientificTypesBase", "StaticArrays", "Unitful"]
test = ["Test", "Aqua", "LinearAlgebra", "QuadGK", "Ratios", "SaferIntegers", "SafeTestsets", "ScientificTypes", "ScientificTypesBase", "StaticArrays", "Unitful"]
3 changes: 2 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ for f in (:one, :typemin, :typemax)
Base.$f(::Type{Q}) where {Q<:AbstractQuantity} = $f(Q{DEFAULT_VALUE_TYPE, DEFAULT_DIM_TYPE})
end
if f == :one # Return empty dimensions, as should be multiplicative identity.
@eval Base.$f(q::Q) where {Q<:AbstractQuantity} = new_quantity(Q, $f(ustrip(q)), one(dimension(q)))
# Special behavior as packages use `one` to get an element of the value type:
@eval Base.$f(q::Q) where {Q<:AbstractQuantity} = $f(ustrip(q))
else
@eval Base.$f(q::Q) where {Q<:AbstractQuantity} = new_quantity(Q, $f(ustrip(q)), dimension(q))
end
Expand Down
23 changes: 2 additions & 21 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
using SafeTestsets
import Ratios: SimpleRatio

@static if !hasmethod(round, Tuple{Int, SimpleRatio{Int}})
@eval Base.round(T, x::SimpleRatio) = round(T, x.num // x.den)
end

if parse(Bool, get(ENV, "DQ_TEST_UPREFERRED", "false"))
@safetestset "Test upreferred disallowed" begin
include("test_ban_upreferred.jl")
end
else
@safetestset "Unitful.jl integration tests" begin
include("test_unitful.jl")
end
@safetestset "ScientificTypes.jl integration tests" begin
include("test_scitypes.jl")
end
@safetestset "Unit tests" begin
include("unittests.jl")
end
@safetestset "Aqua tests" begin
include("test_aqua.jl")
end
@safetestset "QuadGK integration tests" begin
include("test_quadgk.jl")
end
7 changes: 7 additions & 0 deletions test/test_quadgk.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using DynamicQuantities
using Test
using QuadGK

integral = quadgk(t -> 5u"m/s^2" * t, 0u"s", 10u"s")

@test integral == 5u"m/s^2" * (10u"s")^2 / 2
Loading