Skip to content

Commit c8a2e69

Browse files
committed
Move to new-style parametric method syntax with where
1 parent 018c25f commit c8a2e69

File tree

7 files changed

+119
-124
lines changed

7 files changed

+119
-124
lines changed

src/categoricalvector.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ checkaxis(::CategoricalVector) = nothing
6262
## Add some special indexing for CategoricalVector{Tuple}'s to achieve something like
6363
## Panda's hierarchical indexing
6464

65-
axisindexes{T<:Tuple,S,A}(ax::Axis{S,CategoricalVector{T,A}}, idx) = axisindexes(ax, (idx,))
65+
axisindexes(ax::Axis{S,CategoricalVector{T,A}}, idx) where {T<:Tuple,S,A} = axisindexes(ax, (idx,))
6666

67-
function axisindexes{T<:Tuple,S,A}(ax::Axis{S,CategoricalVector{T,A}}, idx::Tuple)
67+
function axisindexes(ax::Axis{S,CategoricalVector{T,A}}, idx::Tuple) where {T<:Tuple,S,A}
6868
collect(filter(ax_idx->_tuple_matches(ax.val[ax_idx], idx), indices(ax.val)...))
6969
end
7070

@@ -78,5 +78,5 @@ function _tuple_matches(element::Tuple, idx::Tuple)
7878
return true
7979
end
8080

81-
axisindexes{T<:Tuple,S,A}(ax::Axis{S,CategoricalVector{T,A}}, idx::AbstractArray) =
81+
axisindexes(ax::Axis{S,CategoricalVector{T,A}}, idx::AbstractArray) where {T<:Tuple,S,A} =
8282
vcat([axisindexes(ax, i) for i in idx]...)

src/combine.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ function equalvalued(X::NTuple)
99
return allequal
1010
end #equalvalued
1111

12-
sizes{T<:AxisArray}(As::T...) = tuple(zip(map(a -> map(length, indices(a)), As)...)...)
13-
matchingdims{N,T<:AxisArray}(As::NTuple{N,T}) = all(equalvalued, sizes(As...))
14-
matchingdimsexcept{N,T<:AxisArray}(As::NTuple{N,T}, n::Int) = all(equalvalued, sizes(As...)[[1:n-1; n+1:end]])
12+
sizes(As::T...) where {T<:AxisArray} = tuple(zip(map(a -> map(length, indices(a)), As)...)...)
13+
matchingdims(As::NTuple{N,T}) where {N,T<:AxisArray} = all(equalvalued, sizes(As...))
14+
matchingdimsexcept(As::NTuple{N,T}, n::Int) where {N,T<:AxisArray} = all(equalvalued, sizes(As...)[[1:n-1; n+1:end]])
1515

16-
function Base.cat{T}(n::Integer, As::AxisArray{T}...)
16+
function Base.cat(n::Integer, As::AxisArray{T}...) where T
1717
if n <= ndims(As[1])
1818
matchingdimsexcept(As, n) || error("All non-concatenated axes must be identically-valued")
1919
newaxis = Axis{axisnames(As[1])[n]}(vcat(map(A -> A.axes[n].val, As)...))
@@ -25,7 +25,7 @@ function Base.cat{T}(n::Integer, As::AxisArray{T}...)
2525
end #if
2626
end #Base.cat
2727

28-
function axismerge{name,T}(method::Symbol, axes::Axis{name,T}...)
28+
function axismerge(method::Symbol, axes::Axis{name,T}...) where {name,T}
2929

3030
axisvals = if method == :inner
3131
intersect(axisvalues(axes...)...)
@@ -45,7 +45,7 @@ function axismerge{name,T}(method::Symbol, axes::Axis{name,T}...)
4545

4646
end
4747

48-
function indexmappings{N}(oldaxes::NTuple{N,Axis}, newaxes::NTuple{N,Axis})
48+
function indexmappings(oldaxes::NTuple{N,Axis}, newaxes::NTuple{N,Axis}) where N
4949
oldvals = axisvalues(oldaxes...)
5050
newvals = axisvalues(newaxes...)
5151
return collect(zip(indexmapping.(oldvals, newvals)...))
@@ -94,7 +94,7 @@ end
9494
9595
Combines AxisArrays with matching axis names into a single AxisArray spanning all of the axis values of the inputs. If a coordinate is defined in more than ones of the inputs, it takes its value from last input in which it appears. If a coordinate in the output array is not defined in any of the input arrays, it takes the value of the optional `fillvalue` keyword argument (default zero).
9696
"""
97-
function Base.merge{T,N,D,Ax}(As::AxisArray{T,N,D,Ax}...; fillvalue::T=zero(T))
97+
function Base.merge(As::AxisArray{T,N,D,Ax}...; fillvalue::T=zero(T)) where {T,N,D,Ax}
9898

9999
resultaxes = map(as -> axismerge(:outer, as...), map(tuple, axes.(As)...))
100100
resultdata = fill(fillvalue, length.(resultaxes)...)
@@ -121,9 +121,9 @@ Combines AxisArrays with matching axis names into a single AxisArray. Unlike `me
121121
122122
If an array value in the output array is not defined in any of the input arrays (i.e. in the case of a left, right, or outer join), it takes the value of the optional `fillvalue` keyword argument (default zero).
123123
"""
124-
function Base.join{T,N,D,Ax}(As::AxisArray{T,N,D,Ax}...; fillvalue::T=zero(T),
125-
newaxis::Axis=_nextaxistype(As[1].axes)(1:length(As)),
126-
method::Symbol=:outer)
124+
function Base.join(As::AxisArray{T,N,D,Ax}...; fillvalue::T=zero(T),
125+
newaxis::Axis=_nextaxistype(As[1].axes)(1:length(As)),
126+
method::Symbol=:outer) where {T,N,D,Ax}
127127

128128
prejoin_resultaxes = map(as -> axismerge(method, as...), map(tuple, axes.(As)...))
129129

@@ -150,11 +150,11 @@ function _collapse_axes(array_names, array_axes)
150150
end))
151151
end
152152

153-
function _splitall{N}(::Type{Val{N}}, As...)
153+
function _splitall(::Type{Val{N}}, As...) where N
154154
tuple((Base.IteratorsMD.split(A, Val{N}) for A in As)...)
155155
end
156156

157-
function _reshapeall{N}(::Type{Val{N}}, As...)
157+
function _reshapeall(::Type{Val{N}}, As...) where N
158158
tuple((reshape(A, Val{N}) for A in As)...)
159159
end
160160

@@ -174,15 +174,15 @@ function _collapsed_axis_eltype(LType, trailing_axes)
174174
return typejoin(eltypes...)
175175
end
176176

177-
function collapse{N, AN}(::Type{Val{N}}, As::Vararg{AxisArray, AN})
177+
function collapse(::Type{Val{N}}, As::Vararg{AxisArray, AN}) where {N, AN}
178178
collapse(Val{N}, ntuple(identity, Val{AN}), As...)
179179
end
180180

181-
function collapse{N, AN, NewArrayType<:AbstractArray}(::Type{Val{N}}, ::Type{NewArrayType}, As::Vararg{AxisArray, AN})
181+
function collapse(::Type{Val{N}}, ::Type{NewArrayType}, As::Vararg{AxisArray, AN}) where {N, AN, NewArrayType<:AbstractArray}
182182
collapse(Val{N}, NewArrayType, ntuple(identity, Val{AN}), As...)
183183
end
184184

185-
@generated function collapse{N, AN, LType}(::Type{Val{N}}, labels::NTuple{AN, LType}, As::Vararg{AxisArray, AN})
185+
@generated function collapse(::Type{Val{N}}, labels::NTuple{AN, LType}, As::Vararg{AxisArray, AN}) where {N, AN, LType}
186186
collapsed_dim_int = Int(N) + 1
187187
new_eltype = Base.promote_eltype(As...)
188188

0 commit comments

Comments
 (0)