Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

No more ambiguity warnings.

Also renamed svd.jl to linalg.jl in preparation for DataMatrix type.
  • Loading branch information...
commit 5effea5a426b2793adcd3d474b412b8b7ac89c8b 1 parent f8282e8
@johnmyleswhite johnmyleswhite authored
View
6 src/datavec.jl
@@ -195,10 +195,6 @@ end
length(x::NAtype) = 1
size(x::NAtype) = ()
-==(na::NAtype, na2::NAtype) = NA
-==(na::NAtype, b) = NA
-==(a, na::NAtype) = NA
-
# constructor from type
function _dv_most_generic_type(vals)
# iterate over vals tuple to find the most generic non-NA type
@@ -505,6 +501,7 @@ assign{T}(x::PooledDataVec{T}, n::NAtype, rng::Range1) = begin (x.refs[rng] = 0)
# TODO: replace!(x::PooledDataVec{T}, from::T, to::T)
# and similar to and from NA
+replace!{R}(x::PooledDataVec{R}, fromval::NAtype, toval::NAtype) = NA # no-op to deal with warning
function replace!{R, S, T}(x::PooledDataVec{R}, fromval::S, toval::T)
# throw error if fromval isn't in the pool
fromidx = findfirst(x.pool, fromval)
@@ -649,6 +646,7 @@ function done(x::AbstractDataVec, state::Int)
end
# can promote in theory based on data type
+promote_rule{T, T}(::Type{AbstractDataVec{T}}, ::Type{T}) = promote_rule(T, T)
promote_rule{S, T}(::Type{AbstractDataVec{S}}, ::Type{T}) = promote_rule(S, T)
promote_rule{T}(::Type{AbstractDataVec{T}}, ::Type{T}) = T
# TODO: Abstract? Pooled?
View
0  src/svd.jl → src/linalg.jl
File renamed without changes
View
35 src/operators.jl
@@ -20,18 +20,26 @@ scalar_comparison_operators = [:(==), :(!=), :isless, :(>), :(>=),
array_comparison_operators = [:(.==), :(.!=), :(.>), :(.>=), :(.<), :(.<=)]
binary_operators = [:(+), :(.+), :(-), :(.-), :(*), :(.*), :(/), :(./),
- :(^), :(.^), :(div), :(mod), :(fld), :(rem),
+ :(div), :(mod), :(fld), :(rem),
:(&), :(|), :($)]
+induced_binary_operators = [:(^), :(.^)]
+
arithmetic_operators = [:(+), :(.+), :(-), :(.-), :(*), :(.*), :(/), :(./),
- :(^), :(.^), :(div), :(mod), :(fld), :(rem)]
+ :(div), :(mod), :(fld), :(rem)]
+
+induced_arithmetic_operators = [:(^), :(.^)]
biscalar_operators = [:(max), :(min)]
-scalar_arithmetic_operators = [:(+), :(-), :(*), :(/), :(^),
+scalar_arithmetic_operators = [:(+), :(-), :(*), :(/),
:(div), :(mod), :(fld), :(rem)]
-array_arithmetic_operators = [:(+), :(.+), :(-), :(.-), :(.*), :(./), :(.^)]
+induced_scalar_arithmetic_operators = [:(^)]
+
+array_arithmetic_operators = [:(+), :(.+), :(-), :(.-), :(.*), :(./)]
+
+induced_array_arithmetic_operators = [:(.^)]
bit_operators = [:(&), :(|), :($)]
@@ -53,7 +61,7 @@ columnar_operators = [:colmins, :colmaxs, :colprods, :colsums,
boolean_operators = [:any, :all]
-# ^ is a special case as it's defined in terms of *
+# TODO :(^) is a special case as it's defined in terms of :(*)
for f in unary_operators
@eval begin
@@ -310,6 +318,23 @@ for f in binary_operators
function ($f){T <: Union(String, Number)}(x::T, d::NAtype)
return NA
end
+ function ($f){T,N}(a::AbstractArray{T,N}, d::NAtype)
+ return NA
+ end
+ function ($f){T,N}(d::NAtype, a::AbstractArray{T,N})
+ return NA
+ end
+ end
+end
+
+for f in induced_binary_operators
+ @eval begin
+ function ($f)(d::NAtype, e::NAtype)
+ return NA
+ end
+ function ($f)(d::Union(String, Number), e::NAtype)
+ return NA
+ end
end
end
View
21 test/operators.jl
@@ -22,15 +22,27 @@ scalar_comparison_operators = [:(==), :(!=), :isless, :(>), :(>=),
array_comparison_operators = [:(.==), :(.!=), :(.>), :(.>=), :(.<), :(.<=)]
+binary_operators = [:(+), :(.+), :(-), :(.-), :(*), :(.*), :(/), :(./),
+ :(div), :(mod), :(fld), :(rem),
+ :(&), :(|), :($)]
+
+induced_binary_operators = [:(^), :(.^)]
+
arithmetic_operators = [:(+), :(.+), :(-), :(.-), :(*), :(.*), :(/), :(./),
- :(^), :(.^), :(div), :(mod), :(fld), :(rem)]
+ :(div), :(mod), :(fld), :(rem)]
+
+induced_arithmetic_operators = [:(^), :(.^)]
biscalar_operators = [:(max), :(min)]
-scalar_arithmetic_operators = [:(+), :(-), :(*), :(/), :(^),
+scalar_arithmetic_operators = [:(+), :(-), :(*), :(/),
:(div), :(mod), :(fld), :(rem)]
-array_arithmetic_operators = [:(+), :(.+), :(-), :(.-), :(.*), :(./), :(.^)]
+induced_scalar_arithmetic_operators = [:(^)]
+
+array_arithmetic_operators = [:(+), :(.+), :(-), :(.-), :(.*), :(./)]
+
+induced_array_arithmetic_operators = [:(.^)]
bit_operators = [:(&), :(|), :($)]
@@ -413,3 +425,6 @@ df = DataFrame(quote
df[1, 1] = NA
@assert isna(any(dv))
@assert isna(all(dv))
+
+# TODO: Confirm that this is not true any longer:
+# no method .^(NAtype,Int64)
Please sign in to comment.
Something went wrong with that request. Please try again.