Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit 9842b91

Browse files
quinnjnalimilan
authored andcommitted
Full 0.5/0.4 compat + fix failing tests (#113)
* Updates for 0.5 and get tests passing * Do the 0.5 updates in a compat friendly way * Add 0.4 compat for the sum_pairwise_blocksize removal from Base * Quick update to constructors test
1 parent d0b94ae commit 9842b91

File tree

5 files changed

+41
-35
lines changed

5 files changed

+41
-35
lines changed

src/broadcast.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ using Base.Broadcast: check_broadcast_shape
44
function gen_nullcheck(narrays::Int, nd::Int)
55
e_nullcheck = macroexpand(:( @nref $nd isnull_1 d->j_d_1 ))
66
for k = 2:narrays
7-
isnull = symbol("isnull_$k")
8-
j_d_k = symbol("j_d_$k")
7+
isnull = Symbol("isnull_$k")
8+
j_d_k = Symbol("j_d_$k")
99
e_isnull_k = macroexpand(:( @nref $nd $(isnull) d->$(j_d_k) ))
1010
e_nullcheck = Expr(:||, e_nullcheck, e_isnull_k)
1111
end
@@ -43,7 +43,7 @@ function gen_broadcast_body(nd::Int, narrays::Int, f, lift::Bool)
4343
end
4444

4545
function gen_broadcast_function(nd::Int, narrays::Int, f, lift::Bool)
46-
As = [symbol("A_"*string(i)) for i = 1:narrays]
46+
As = [Symbol("A_"*string(i)) for i = 1:narrays]
4747
body = gen_broadcast_body(nd, narrays, f, lift)
4848
@eval let
4949
local _F_
@@ -104,12 +104,12 @@ end
104104

105105
# broadcasted ops
106106
for (op, scalar_op) in (
107-
(:(Base.(:(.==))), :(==)),
108-
(:(Base.(:.!=)), :!=),
109-
(:(Base.(:.<)), :<),
110-
(:(Base.(:.>)), :>),
111-
(:(Base.(:.<=)), :<=),
112-
(:(Base.(:.>=)), :>=)
107+
(:(@compat Base.:(.==)), :(==)),
108+
(:(@compat Base.:.!=), :!=),
109+
(:(@compat Base.:.<), :<),
110+
(:(@compat Base.:.>), :>),
111+
(:(@compat Base.:.<=), :<=),
112+
(:(@compat Base.:.>=), :>=)
113113
)
114114
@eval begin
115115
($op)(X::NullableArray, Y::NullableArray) = broadcast($scalar_op, X, Y)

src/map.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Base.Cartesian
22

33
function gen_nullcheck(narrays::Int)
4-
As = [symbol("A_"*string(i)) for i = 1:narrays]
4+
As = [Symbol("A_"*string(i)) for i = 1:narrays]
55
e_nullcheck = :($(As[1]).isnull[i])
66
for i = 2:narrays
77
e_nullcheck = Expr(:||, e_nullcheck, :($(As[i]).isnull[i]))
@@ -99,7 +99,7 @@ function gen_map_body{F}(_map_to!::Symbol, narrays::Int, f::F)
9999
end
100100

101101
function gen_map!_function{F}(narrays::Int, lift::Bool, f::F)
102-
As = [symbol("A_"*string(i)) for i = 1:narrays]
102+
As = [Symbol("A_"*string(i)) for i = 1:narrays]
103103
body = gen_map!_body(narrays, lift, f)
104104
@eval let
105105
local _F_
@@ -111,7 +111,7 @@ function gen_map!_function{F}(narrays::Int, lift::Bool, f::F)
111111
end
112112

113113
function gen_map_function{F}(_map_to!::Symbol, narrays::Int, f::F)
114-
As = [symbol("A_"*string(i)) for i = 1:narrays]
114+
As = [Symbol("A_"*string(i)) for i = 1:narrays]
115115
body_map_to! = gen_map_to!_body(_map_to!, narrays, f)
116116
body_map = gen_map_body(_map_to!, narrays, f)
117117

src/operators.jl

+20-21
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import Compat: @functorize
33
@noinline throw_error() = error()
44

55
for f in (
6-
:(Base.(:+)),
7-
:(Base.(:-)),
8-
:(Base.(:!)),
9-
:(Base.(:~)),
6+
:(@compat Base.:+),
7+
:(@compat Base.:-),
8+
:(@compat Base.:!),
9+
:(@compat Base.:~),
1010
)
1111
@eval begin
1212
@inline function $(f){S}(x::Nullable{S})
@@ -21,16 +21,16 @@ end
2121

2222
# Implement the binary operators: +, -, *, /, %, &, |, ^, <<, and >>
2323
for f in (
24-
:(Base.(:+)),
25-
:(Base.(:-)),
26-
:(Base.(:*)),
27-
:(Base.(:/)),
28-
:(Base.(:%)),
29-
:(Base.(:&)),
30-
:(Base.(:|)),
31-
:(Base.(:^)),
32-
:(Base.(:<<)),
33-
:(Base.(:>>)),
24+
:(@compat Base.:+),
25+
:(@compat Base.:-),
26+
:(@compat Base.:*),
27+
:(@compat Base.:/),
28+
:(@compat Base.:%),
29+
:(@compat Base.:&),
30+
:(@compat Base.:|),
31+
:(@compat Base.:^),
32+
:(@compat Base.:<<),
33+
:(@compat Base.:>>),
3434
)
3535
@eval begin
3636
@inline function $(f){S1, S2}(x::Nullable{S1}, y::Nullable{S2})
@@ -45,8 +45,8 @@ end
4545

4646
# Implement the binary operators: == and !=
4747
for f in (
48-
:(Base.(:(==))),
49-
:(Base.(:!=)),
48+
:(@compat Base.:(==)),
49+
:(@compat Base.:!=),
5050
)
5151
@eval begin
5252
function $(f){S1, S2}(x::Nullable{S1}, y::Nullable{S2})
@@ -61,10 +61,10 @@ end
6161

6262
# Implement the binary operators: <, >, <=, and >=
6363
for f in (
64-
:(Base.(:<)),
65-
:(Base.(:>)),
66-
:(Base.(:<=)),
67-
:(Base.(:>=)),
64+
:(@compat Base.:<),
65+
:(@compat Base.:>),
66+
:(@compat Base.:<=),
67+
:(@compat Base.:>=),
6868
)
6969
@eval begin
7070
function $(f){S1, S2}(x::Nullable{S1}, y::Nullable{S2})
@@ -119,4 +119,3 @@ end
119119
error()
120120
end
121121
end
122-

src/reduce.jl

+8-1
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,18 @@ function mapreduce_pairwise_impl_skipnull{T}(f, op, X::NullableArray{T},
5555
end
5656
end
5757

58+
# from comment: https://github.com/JuliaLang/julia/pull/16217#issuecomment-223768129
59+
if VERSION < v"0.5.0-dev+4441"
60+
sum_pairwise_blocksize = Base.sum_pairwise_blocksize
61+
else
62+
sum_pairwise_blocksize(T) = Base.pairwise_blocksize(T, +)
63+
end
64+
5865
mapreduce_impl_skipnull{T}(f, op, X::NullableArray{T}) =
5966
mapreduce_seq_impl_skipnull(f, op, X, 1, length(X.values))
6067
mapreduce_impl_skipnull(f, op::typeof(@functorize(+)), X::NullableArray) =
6168
mapreduce_pairwise_impl_skipnull(f, op, X, 1, length(X.values),
62-
max(128, Base.sum_pairwise_blocksize(f)))
69+
max(128, sum_pairwise_blocksize(f)))
6370

6471
# general mapreduce interface
6572

test/constructors.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module TestConstructors
6060
@test isa(Z, NullableVector{Int})
6161
@test Z.isnull == [false, true, false, false, false, false, true]
6262

63-
Y = NullableArray([1, "na", 2, 3, 4, 5, "na"], Int, ASCIIString)
63+
Y = NullableArray([1, nothing, 2, 3, 4, 5, nothing], Int, Void)
6464
@test isequal(Y, Z)
6565

6666
# test parameterized type constructor with no arguments

0 commit comments

Comments
 (0)