function (==)(x::DDataset, y::Union{Dataset, DDataset})
y1 = distribute(y, length.(domainchunks(rows(x))))
res = delayed(==, get_result=true).(x.chunks, y1.chunks)
all(collect(delayed((xs...) -> [xs...])(res...)))
end
其中的(==)这是什么语法?
function (==)(x::DDataset, y::Union{Dataset, DDataset})
y1 = distribute(y, length.(domainchunks(rows(x))))
res = delayed(==, get_result=true).(x.chunks, y1.chunks)
all(collect(delayed((xs...) -> [xs...])(res...)))
end
其中的(==)这是什么语法?
那就是个 isequal ==
,其实不要括号也行。
这个函数的作用是为 DDataset
类型添加 与 DDataset
, Dataset
类型判断相等的操作。
这里要注意的是需要显式导入这个符号,不然没法添加对新类型的支持。
julia> ==
== (generic function with 155 methods)
julia> struct newTpye a end
julia> ==(a::newTpye, b::newTpye) = a.a==b.a
ERROR: error in method definition: function Base.== must be explicitly imported to be extended
Stacktrace:
[1] top-level scope at none:0
[2] top-level scope at REPL[5]:1
julia> function ==(a::newTpye, b::newTpye) a.a==b.b end
ERROR: error in method definition: function Base.== must be explicitly imported to be extended
Stacktrace:
[1] top-level scope at none:0
[2] top-level scope at REPL[6]:1
julia> import Base.==
julia> ==(a::newTpye, b::newTpye) = a.a==b.a
== (generic function with 156 methods)
julia> newTpye(1) == newTpye(1.0)
true
julia> ==
== (generic function with 156 methods)
julia>