Skip to content

Commit

Permalink
reduce ambiguities
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Mar 5, 2024
1 parent eef0d27 commit 43d4fbe
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/groupby.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function Base.similar(bc::Broadcasted{GroupedVariableStyle}, ::Type{ElType}) wh
return A
end

function Base.broadcasted(f,A::GroupedVariable{TV,TF,TGM,TM,TG}) where {TV,TF,TGM,TM,TG}
function Base.broadcasted(f::Function,A::GroupedVariable{TV,TF,TGM,TM,TG}) where {TV,TF,TGM,TM,TG}
# TODO change output TG

map_fun = (f,A.map_fun)
Expand Down Expand Up @@ -425,8 +425,8 @@ The function `f` will be called as `f(x,dims=d)` where `x` array (an element
of `gv`) and `d` is an integer of the dimension overwhich one need to reduce
`x`.
"""
Base.reduce(f,gv::GroupedVariable) = ReducedGroupedVariable(gv,f)
Base.reduce(f,gds::GroupedDataset) = ReducedGroupedDataset(gds,f)
Base.reduce(f::Function,gv::GroupedVariable) = ReducedGroupedVariable(gv,f)
Base.reduce(f::Function,gds::GroupedDataset) = ReducedGroupedDataset(gds,f)

for fun in (:maximum, :mean, :median, :minimum, :std, :sum, :var)
@eval $fun(gv::GroupedVariable) = reduce($fun,gv)
Expand Down Expand Up @@ -500,8 +500,10 @@ function broadcasted_gvr!(C,f,A,B)
end


Base.broadcasted(f,A,B::ReducedGroupedVariable) = broadcasted_gvr!(similar(A),f,A,B)
Base.broadcasted(f,A::ReducedGroupedVariable,B) = broadcasted_gvr!(similar(B),f,A,B)
Base.broadcasted(f::Function,A,B::ReducedGroupedVariable) =
broadcasted_gvr!(similar(A),f,A,B)
Base.broadcasted(f::Function,A::ReducedGroupedVariable,B) =
broadcasted_gvr!(similar(B),f,A,B)


function Base.Array(gr::ReducedGroupedVariable)
Expand Down
4 changes: 2 additions & 2 deletions src/multifile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ function Base.keys(mfds::MFDataset)
end
end

Base.getindex(v::MFVariable,indexes::Union{Int,Colon,AbstractRange{<:Integer}}...) = getindex(v.var,indexes...)
Base.setindex!(v::MFVariable,data,indexes::Union{Int,Colon,AbstractRange{<:Integer}}...) = setindex!(v.var,data,indexes...)
Base.getindex(v::MFVariable,indexes::Union{Integer,Colon,AbstractRange{<:Integer}}...) = getindex(v.var,indexes...)
Base.setindex!(v::MFVariable,data,indexes::Union{Integer,Colon,AbstractRange{<:Integer}}...) = setindex!(v.var,data,indexes...)


load!(v::MFVariable,buffer,indexes...) = CatArrays.load!(v.var,buffer,indexes...)
Expand Down
2 changes: 1 addition & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ struct MemoryVariable{T,N,TP,TA <: AbstractArray{T,N}} <: AbstractVariable{T,N}
_attrib::OrderedDict{String,Any}
end

struct MemoryDataset{TP,Tmasingvalue} <: AbstractDataset
struct MemoryDataset{TP <: Union{Nothing,AbstractDataset},Tmasingvalue} <: AbstractDataset
parent_dataset::TP
name::String # "/" for root group
dimensions::OrderedDict{String,Int}
Expand Down
4 changes: 4 additions & 0 deletions test/test_aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using Aqua
using CommonDataModel

Aqua.test_ambiguities(CommonDataModel)
1 change: 1 addition & 0 deletions test/test_multifile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import CommonDataModel:
checksum,
chunking,
dataset,
defVar,
defGroup,
deflate,
dimnames,
Expand Down

0 comments on commit 43d4fbe

Please sign in to comment.