From afd1f66095095cf0a71b1386a7042d727ef99f79 Mon Sep 17 00:00:00 2001 From: Jutho Date: Fri, 5 Jan 2024 22:15:55 +0100 Subject: [PATCH] fix more ambiguity warnings in julia 1.6 --- src/spaces/cartesianspace.jl | 7 +++++-- src/spaces/complexspace.jl | 7 +++++-- src/spaces/generalspace.jl | 7 +++++-- src/spaces/vectorspaces.jl | 6 ++---- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/spaces/cartesianspace.jl b/src/spaces/cartesianspace.jl index 834688a4..87822d59 100644 --- a/src/spaces/cartesianspace.jl +++ b/src/spaces/cartesianspace.jl @@ -40,8 +40,11 @@ Base.:^(::RealNumbers, d::Int) = CartesianSpace(d) # Corresponding methods: #------------------------ -dim(V::CartesianSpace, s::Trivial = Trivial()) = V.d -Base.axes(V::CartesianSpace) = Base.OneTo(dim(V)) +dim(V::CartesianSpace, ::Trivial=Trivial()) = V.d +Base.axes(V::CartesianSpace, ::Trivial=Trivial()) = Base.OneTo(dim(V)) +hassector(V::CartesianSpace, ::Trivial) = dim(V) != 0 +sectors(V::CartesianSpace) = OneOrNoneIterator(dim(V) != 0, Trivial()) +sectortype(::Type{CartesianSpace}) = Trivial Base.oneunit(::Type{CartesianSpace}) = CartesianSpace(1) ⊕(V₁::CartesianSpace, V₂::CartesianSpace) = CartesianSpace(V₁.d + V₂.d) diff --git a/src/spaces/complexspace.jl b/src/spaces/complexspace.jl index 72314352..a9929f9a 100644 --- a/src/spaces/complexspace.jl +++ b/src/spaces/complexspace.jl @@ -38,9 +38,12 @@ Base.:^(::ComplexNumbers, d::Int) = ComplexSpace(d) # Corresponding methods: #------------------------ -dim(V::ComplexSpace, s::Trivial = Trivial()) = V.d +dim(V::ComplexSpace, s::Trivial=Trivial()) = V.d isdual(V::ComplexSpace) = V.dual -Base.axes(V::ComplexSpace) = Base.OneTo(dim(V)) +Base.axes(V::ComplexSpace, ::Trivial=Trivial()) = Base.OneTo(dim(V)) +hassector(V::ComplexSpace, ::Trivial) = dim(V) != 0 +sectors(V::ComplexSpace) = OneOrNoneIterator(dim(V) != 0, Trivial()) +sectortype(::Type{ComplexSpace}) = Trivial Base.conj(V::ComplexSpace) = ComplexSpace(dim(V), !isdual(V)) diff --git a/src/spaces/generalspace.jl b/src/spaces/generalspace.jl index efef1b57..d75727a8 100644 --- a/src/spaces/generalspace.jl +++ b/src/spaces/generalspace.jl @@ -23,11 +23,14 @@ function GeneralSpace{𝕜}(d::Int=0; dual::Bool=false, conj::Bool=false) where return GeneralSpace{𝕜}(d, dual, conj) end -dim(V::GeneralSpace, s::Trivial = Trivial()) = V.d +dim(V::GeneralSpace, s::Trivial=Trivial()) = V.d isdual(V::GeneralSpace) = V.dual isconj(V::GeneralSpace) = V.conj -Base.axes(V::GeneralSpace) = Base.OneTo(dim(V)) +Base.axes(V::GeneralSpace, ::Trivial=Trivial()) = Base.OneTo(dim(V)) +hassector(V::GeneralSpace, ::Trivial) = dim(V) != 0 +sectors(V::GeneralSpace) = OneOrNoneIterator(dim(V) != 0, Trivial()) +sectortype(::Type{GeneralSpace}) = Trivial field(::Type{GeneralSpace{𝕜}}) where {𝕜} = 𝕜 InnerProductStyle(::Type{<:GeneralSpace}) = NoInnerProduct() diff --git a/src/spaces/vectorspaces.jl b/src/spaces/vectorspaces.jl index 8ad0bb36..14595580 100644 --- a/src/spaces/vectorspaces.jl +++ b/src/spaces/vectorspaces.jl @@ -212,7 +212,6 @@ Return the type of sector over which object `a` (e.g. a representation space or defined. Also works in type domain. """ sectortype(V::VectorSpace) = sectortype(typeof(V)) -sectortype(::Type{<:ElementarySpace}) = Trivial """ hassector(V::VectorSpace, a::Sector) -> Bool @@ -220,15 +219,14 @@ sectortype(::Type{<:ElementarySpace}) = Trivial Return whether a vector space `V` has a subspace corresponding to sector `a` with non-zero dimension, i.e. `dim(V, a) > 0`. """ -hassector(V::ElementarySpace, ::Trivial) = dim(V) != 0 -Base.axes(V::ElementarySpace, ::Trivial) = axes(V) +function hassector end """ sectors(V::ElementarySpace) Return an iterator over the different sectors of `V`. """ -sectors(V::ElementarySpace) = OneOrNoneIterator(dim(V) != 0, Trivial()) +function sectors end # Composite vector spaces #-------------------------