Skip to content

Commit aaa4de3

Browse files
authored
Add utility isfinite(::AbstractLattice) (#31)
1 parent 7efc444 commit aaa4de3

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/lattices/chains.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct InfiniteChain <: AbstractLattice{1}
1010
end
1111
end
1212
Base.axes(::InfiniteChain) = ((-typemax(Int)):typemax(Int),)
13+
Base.isfinite(::Type{InfiniteChain}) = false
1314

1415
"""
1516
FiniteChain(length::Integer=1)
@@ -23,6 +24,7 @@ struct FiniteChain <: AbstractLattice{1}
2324
end
2425
end
2526
Base.axes(chain::FiniteChain) = (1:(chain.L),)
27+
Base.isfinite(::Type{FiniteChain}) = true
2628

2729
const Chain = Union{InfiniteChain,FiniteChain}
2830

src/lattices/squarelattice.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct InfiniteStrip <: AbstractLattice{2}
1515
end
1616
InfiniteLadder(N::Integer) = InfiniteStrip(2, N)
1717
Base.axes(strip::InfiniteStrip) = (1:(strip.L), (-typemax(Int)):typemax(Int))
18+
Base.isfinite(::Type{InfiniteStrip}) = false
1819

1920
"""
2021
InfiniteCylinder(L::Int, N::Int)
@@ -33,6 +34,7 @@ struct InfiniteCylinder <: AbstractLattice{2}
3334
end
3435

3536
Base.axes(::InfiniteCylinder) = ((-typemax(Int)):typemax(Int), (-typemax(Int)):typemax(Int))
37+
Base.isfinite(::Type{InfiniteCylinder}) = false
3638

3739
"""
3840
InfiniteHelix(L::Integer, N::Integer)
@@ -51,6 +53,7 @@ end
5153
function Base.axes(::InfiniteHelix)
5254
return ((-typemax(Int)):typemax(Int), (-typemax(Int)):typemax(Int))
5355
end
56+
Base.isfinite(::Type{InfiniteHelix}) = false
5457

5558
############################################################################################
5659

src/lattices/triangularlattice.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ struct HoneycombYC <: AbstractLattice{2}
1717
end
1818
end
1919

20+
Base.isfinite(::Type{HoneycombYC}) = false
21+
2022
# TODO: do proper boundscheck
2123
function Base.checkbounds(::Type{Bool}, lattice::HoneycombYC, inds::Vararg{Int,2})
2224
return true

0 commit comments

Comments
 (0)