@@ -28,36 +28,39 @@ Ps = (ImmutablePolynomial, Polynomial, SparsePolynomial, LaurentPolynomial, Fact
28
28
isimmutable (p:: P ) where {P} = P <: ImmutablePolynomial
29
29
isimmutable (:: Type{<:ImmutablePolynomial} ) = true
30
30
31
- @testset " Construction" for coeff in [
32
- Int64[1 , 1 , 1 , 1 ],
33
- Float32[1 , - 4 , 2 ],
34
- ComplexF64[1 - 1im , 2 + 3im ],
35
- [3 // 4 , - 2 // 1 , 1 // 1 ]
36
- ]
31
+ @testset " Construction" begin
32
+ @testset for coeff in Any[
33
+ Int64[1 , 1 , 1 , 1 ],
34
+ Float32[1 , - 4 , 2 ],
35
+ ComplexF64[1 - 1im , 2 + 3im ],
36
+ [3 // 4 , - 2 // 1 , 1 // 1 ]
37
+ ]
38
+
39
+ @testset for P in Ps
40
+ p = P (coeff)
41
+ @test coeffs (p) == ᵗ⁰ coeff
42
+ @test degree (p) == length (coeff) - 1
43
+ @test indeterminate (p) == :x
44
+ P == Polynomial && @test length (p) == length (coeff)
45
+ P == Polynomial && @test size (p) == size (coeff)
46
+ P == Polynomial && @test size (p, 1 ) == size (coeff, 1 )
47
+ P == Polynomial && @test typeof (p). parameters[1 ] == eltype (coeff)
48
+ if P != FactoredPolynomial
49
+ @test eltype (p) == eltype (coeff)
50
+ end
51
+ @test all ([- 200 , - 0.3 , 1 , 48.2 ] .∈ Polynomials. domain (p))
37
52
38
- for P in Ps
39
- p = P (coeff)
40
- @test coeffs (p) == ᵗ⁰ coeff
41
- @test degree (p) == length (coeff) - 1
42
- @test indeterminate (p) == :x
43
- P == Polynomial && @test length (p) == length (coeff)
44
- P == Polynomial && @test size (p) == size (coeff)
45
- P == Polynomial && @test size (p, 1 ) == size (coeff, 1 )
46
- P == Polynomial && @test typeof (p). parameters[1 ] == eltype (coeff)
47
- @test eltype (p) == eltype (coeff)
48
- @test all ([- 200 , - 0.3 , 1 , 48.2 ] .∈ Polynomials. domain (p))
49
-
50
- # # issue #316
51
- @test_throws InexactError P {Int,:x} ([1 + im, 1 ])
52
- @test_throws InexactError P {Int} ([1 + im, 1 ], :x )
53
- @test_throws InexactError P {Int,:x} (1 + im)
54
- @test_throws InexactError P {Int} (1 + im)
55
-
56
- # # issue #395
57
- v = [1 ,2 ,3 ]
58
- @test P (v) == P (v,:x ) == P (v,' x' ) == P (v," x" ) == P (v, Polynomials. Var (:x ))
59
- end
53
+ # # issue #316
54
+ @test_throws InexactError P {Int,:x} ([1 + im, 1 ])
55
+ @test_throws InexactError P {Int} ([1 + im, 1 ], :x )
56
+ @test_throws InexactError P {Int,:x} (1 + im)
57
+ @test_throws InexactError P {Int} (1 + im)
60
58
59
+ # # issue #395
60
+ v = [1 ,2 ,3 ]
61
+ @test P (v) == P (v,:x ) == P (v,' x' ) == P (v," x" ) == P (v, Polynomials. Var (:x ))
62
+ end
63
+ end
61
64
end
62
65
63
66
@testset " Mapdomain" begin
@@ -1493,3 +1496,13 @@ end
1493
1496
@test c == MA. operate (* , A, b)
1494
1497
@test 0 == @allocated MA. buffered_operate! (buffer, MA. add_mul, c, A, b)
1495
1498
end
1499
+
1500
+ @testset " empty SparsePolynomial" begin
1501
+ p = SparsePolynomial (Float64[0 ])
1502
+ @test eltype (p) == Float64
1503
+ @test eltype (keys (p)) == Int
1504
+ @test eltype (values (p)) == Float64
1505
+ @test collect (p) == Float64[]
1506
+ @test collect (keys (p)) == Int[]
1507
+ @test collect (values (p)) == Float64[]
1508
+ end
0 commit comments