Skip to content

Commit fa66e08

Browse files
committed
Add tests
1 parent 45bbc00 commit fa66e08

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

src/diff.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ function differentiate(ps::AbstractArray{PT, N}, xs) where {N, PT<:ARPL}
3535
end
3636
qs
3737
end
38+
differentiate(ps::AbstractArray{<:ARPL}, v::AbstractVariable) = differentiate.(ps, v)
39+
3840
differentiate(p::ARPL, xs) = [differentiate(p, x) for x in xs]
3941

4042
# differentiate(p, [x, y]) with TypedPolynomials promote x to a Monomial

src/rational.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ function (-)(r::RationalPoly, s::RationalPoly)
4646
end
4747
_minus(p, s::RationalPoly) = (p * s.den - s.num) / s.den
4848
_minus(s::RationalPoly, p) = (s.num - p * s.den) / s.den
49-
(-)(p::APL, r::RationalPoly) = _minus(r, p)
49+
(-)(p::APL, r::RationalPoly) = _minus(p, r)
5050
(-)(r::RationalPoly, p::APL) = _minus(r, p)
5151
(-)(r::RationalPoly, α) = _minus(r, α)
52-
(-)(α, r::RationalPoly) = _minus(r, α)
52+
(-)(α, r::RationalPoly) = _minus(α, r)
5353
(-)(r::RationalPoly) = (-r.num) / r.den
5454

5555
(*)(r::RationalPoly, s::RationalPoly) = (r.num*s.num) / (r.den*s.den)

test/comp.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ MultivariatePolynomials.terms(p::CustomPoly) = terms(p.p)
7070
@test 3 != 4x / 2x
7171
@test 4x / 2x == 2
7272
@test 3 != 4x / 2x
73+
@test 1 - 1/x == (x - 1) / x
74+
@test 1 - 1/x != (1 - x) / x
7375
@test x + x/x == 1 + x^2/x
7476
@test x - x/x == -(1 - x^2/x)
7577
@test (1+x)/x - 1 == 1/x

test/diff.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@testset "Differentiation" begin
22
Mod.@polyvar x y
3+
@test differentiate(3, y) == 0
4+
@test differentiate([x, y], y) == [0, 1]
35
@test differentiate(true*x+true*x^2, y) == 0
46
@inferred differentiate(true*x+true*x^2, y)
57
@test differentiate(x*y + 3y^2 , [x, y]) == [y, x+6y]

test/mono.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,9 @@
8282
@test σ[2] in (1, 3)
8383
@test σ[3] in (2, 5)
8484
@test mergemonovec([[x*y, x, x*y], [x^2*y, x]]) == [x^2*y, x*y, x]
85+
@test_throws ArgumentError monovec([1, 2], [x^2])
86+
σ, X = sortmonovec((y, x))
87+
@test σ == [2, 1]
88+
@test X == [x, y]
8589
end
8690
end

0 commit comments

Comments
 (0)