Skip to content

Commit 993c1c3

Browse files
author
Arda Aytekin
committed
Minor changes preparing for v0.6
Minor changes introduced in order to prepare the package for v0.6: - [x] `VERSION < v"0.6"` added, since the previous implementation was failing in juliabox.com with the `v0.6-dev` kernel, - [x] Relaxed the build matrix in `.travis.yml` file, - [x] Changed from `Array(T, n)` to `Vector{T}(n)` to get rid of the deprecation warnings, and, - [x] Fixed `convert` rules in two ways: (1) added `map` version to the `AbstractArray` case to cover for everything, (2) removed the `promote_type` section from conversions. As for the last item above, `convert{T,S}(::Type{Poly{T}}, n::S)` should ALWAYS convert to `Poly{T}`, not to `Poly{promote_type(T,S)}`. Closes #100.
1 parent ccc54d2 commit 993c1c3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ julia:
88
- nightly
99
notifications:
1010
email: false
11-
sudo: required
12-
dist: trusty
11+
12+
# Allow for failures when it comes to `nightly` builds not to block the patches
13+
# that pass in supported versions.
14+
matrix:
15+
fast_finish: true
16+
allow_failures:
17+
- julia: nightly

src/Polynomials.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ include("show.jl") # display polynomials.
109109

110110
convert{T}(::Type{Poly{T}}, p::Poly{T}) = p
111111
convert{T}(::Type{Poly{T}}, p::Poly) = Poly(convert(Vector{T}, p.a), p.var)
112-
convert{T, S<:Number}(::Type{Poly{T}}, x::S, var::SymbolLike=:x) = Poly(promote_type(T, S)[x], var)
113-
convert{T, S<:Number}(::Type{Poly{T}}, x::Vector{S}, var::SymbolLike=:x) = (R = promote_type(T,S); Poly(convert(Vector{R},x), var))
114-
convert{T, S<:Number,n}(::Type{Poly{T}}, x::Array{S,n}, var::SymbolLike=:x) = map(el->convert(Poly{promote_type(T,S)},el,var),x)
112+
convert{T, S<:Number}(::Type{Poly{T}}, x::S, var::SymbolLike=:x) = Poly(T[x], var)
113+
convert{T, S<:Number}(::Type{Poly{T}}, x::AbstractArray{S}, var::SymbolLike=:x) = map(el->Poly(T[el],var), x)
115114
promote_rule{T, S}(::Type{Poly{T}}, ::Type{Poly{S}}) = Poly{promote_type(T, S)}
116115
promote_rule{T, S<:Number}(::Type{Poly{T}}, ::Type{S}) = Poly{promote_type(T, S)}
117116
eltype{T}(::Poly{T}) = T
@@ -306,7 +305,7 @@ dot_operators = quote
306305
@compat Base.:.*{T<:Number,S}(c::T, p::Poly{S}) = Poly(c * p.a, p.var)
307306
@compat Base.:.*{T<:Number,S}(p::Poly{S}, c::T) = Poly(p.a * c, p.var)
308307
end
309-
VERSION < v"0.6.0-dev" && eval(dot_operators)
308+
VERSION < v"0.6.0" && eval(dot_operators)
310309

311310

312311
# are any values NaN
@@ -434,7 +433,7 @@ polyint{T,S<:Number}(p::Poly{T}, k::S) = _polyint(p, k)
434433
function _polyint{T,S<:Number}(p::Poly{T}, k::S)
435434
n = length(p)
436435
R = promote_type(typeof(one(T)/1), S)
437-
a2 = Array(R, n+1)
436+
a2 = Vector{R}(n+1)
438437
a2[1] = k
439438
for i = 1:n
440439
a2[i+1] = p[i-1] / i
@@ -474,7 +473,7 @@ end
474473

475474
function _polyder{T}(p::Poly{T}, order::Int=1)
476475
n = length(p)
477-
a2 = Array(T, n-order)
476+
a2 = Vector{T}(n-order)
478477
for i = order:n-1
479478
a2[i-order+1] = p[i] * prod((i-order+1):i)
480479
end

0 commit comments

Comments
 (0)