Skip to content

Commit 2690923

Browse files
committed
add tests, setindex! parallel
1 parent d25b095 commit 2690923

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Polynomials.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ function setindex!(p::Poly, v, i)
203203
p.a[i+1] = v
204204
v
205205
end
206+
function setindex!(p::Poly, vs, idx::AbstractArray)
207+
[setindex!(p, v, i) for (i,v) in zip(idx, vs)]
208+
p
209+
end
206210

207211
copy(p::Poly) = Poly(copy(p.a), p.var)
208212

test/runtests.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ p1[5] = 1
163163
@test p1 == Poly([1,2,1,0,0,1])
164164

165165

166-
## elementwise operations
166+
## elementwise operations #52
167167
println("Test for element-wise operations")
168168
p1 = Poly([1, 2])
169169
p2 = Poly([3, 1.])
@@ -177,3 +177,9 @@ pmin = p-3
177177
@test isa(pprod,Vector{Poly{Float64}})
178178
@test isa(pmin, Vector{Poly{Float64}})
179179

180+
## getindex with ranges #43
181+
p1 = Poly([4,5,6])
182+
@test all(p1[0:1] .== [4,5])
183+
@test all(p1[0:end] .== [4,5,6])
184+
p1[0:1] = [7,8]
185+
@test all(p1[0:end] .== [7,8,6])

0 commit comments

Comments
 (0)