Skip to content

Commit

Permalink
use BlockLasts as argument name
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe committed Nov 5, 2024
1 parent 0c6f7e5 commit 20009e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
end
@test axes(a') == dual.(reverse(axes(a)))

@test isdual(axes(a', 1)) isdual(axes(a, 2))
@test isdual(axes(a', 2)) isdual(axes(a, 1))
@test isdual(axes(a', 1)) isdual(axes(a, 2))
@test isdual(axes(a', 2)) isdual(axes(a, 1))
@test isnothing(show(devnull, MIME("text/plain"), a))

# Check preserving dual in tensor algebra.
Expand Down
11 changes: 6 additions & 5 deletions NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ using ..LabelledNumbers:
labelled_isequal,
unlabel

abstract type AbstractGradedUnitRange{T,CS} <: AbstractBlockedUnitRange{T,CS} end
abstract type AbstractGradedUnitRange{T,BlockLasts} <:
AbstractBlockedUnitRange{T,BlockLasts} end

struct GradedUnitRange{T,BlockLasts<:Vector{T}} <: AbstractGradedUnitRange{T,BlockLasts}
first::T
Expand All @@ -42,14 +43,14 @@ struct GradedOneTo{T,BlockLasts<:Vector{T}} <: AbstractGradedUnitRange{T,BlockLa
lasts::BlockLasts

# assume that lasts is sorted, no checks carried out here
function GradedOneTo(lasts::CS) where {T<:Integer,CS<:AbstractVector{T}}
function GradedOneTo(lasts::BlockLasts) where {T<:Integer,BlockLasts<:AbstractVector{T}}
Base.require_one_based_indexing(lasts)
isempty(lasts) || first(lasts) >= 0 || throw(ArgumentError("blocklasts must be >= 0"))
return new{T,CS}(lasts)
return new{T,BlockLasts}(lasts)
end
function GradedOneTo(lasts::CS) where {T<:Integer,CS<:Tuple{T,Vararg{T}}}
function GradedOneTo(lasts::BlockLasts) where {T<:Integer,BlockLasts<:Tuple{T,Vararg{T}}}
first(lasts) >= 0 || throw(ArgumentError("blocklasts must be >= 0"))
return new{T,CS}(lasts)
return new{T,BlockLasts}(lasts)
end
end

Expand Down
5 changes: 3 additions & 2 deletions NDTensors/src/lib/GradedAxes/src/gradedunitrangedual.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
struct GradedUnitRangeDual{T,CS,NondualUnitRange<:AbstractGradedUnitRange{T,CS}} <:
AbstractGradedUnitRange{T,CS}
struct GradedUnitRangeDual{
T,BlockLasts,NondualUnitRange<:AbstractGradedUnitRange{T,BlockLasts}
} <: AbstractGradedUnitRange{T,BlockLasts}
nondual_unitrange::NondualUnitRange
end

Expand Down

0 comments on commit 20009e1

Please sign in to comment.