Skip to content

Commit

Permalink
code reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosanjose committed Nov 21, 2024
1 parent 070c081 commit 752c677
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
20 changes: 20 additions & 0 deletions src/specialmatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,26 @@ Base.view(a::CompressedOrbitalMatrix{C}, i::AnyCellSites, j::AnyCellSites = i) w
return dec(parent(a)[i, j])
end

## checkbounds

# checkbounds axis
checkbounds_axis_or_orbaxis(a::AbstractOrbitalMatrix, i, axis) =
checkbounds(Bool, axes(a, axis), i)

# checkbounds orbaxis
checkbounds_axis_or_orbaxis(a::AbstractOrbitalMatrix, i::CellIndices, axis) =
checkbounds_axis_or_orbaxis(orbaxes(a, axis), i)

function checkbounds_axis_or_orbaxis(a::AbstractOrbitalMatrix, i::CellIndices)
dict = cellsdict(a)
c = cell(i, a)
if haskey(dict, c)
return siteindex(i) in keys(orbgroups(dict[c]))
else
return false
end
end

## broadcasting

# following the manual: https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-array
Expand Down
18 changes: 0 additions & 18 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -546,24 +546,6 @@ boundingbox(l::LatticeSlice) = boundingbox(keys(cellsdict(l)))
pos(s::CellSitePos) = s.type.r
ind(s::CellSitePos) = s.inds

# checkbounds axis
checkbounds_axis_or_orbaxis(a::AbstractOrbitalMatrix, i, axis) =
checkbounds(Bool, axes(a, axis), i)

# checkbounds orbaxis
checkbounds_axis_or_orbaxis(a::AbstractOrbitalMatrix, i::CellIndices, axis) =
checkbounds_axis_or_orbaxis(orbaxes(a, axis), i)

function checkbounds_axis_or_orbaxis(a::OrbitalSliceGrouped, i::CellIndices)
dict = cellsdict(a)
c = cell(i, a)
if haskey(dict, c)
return siteindex(i) in keys(orbgroups(dict[c]))
else
return false
end
end

# iterators

sites(l::LatticeSlice) =
Expand Down

0 comments on commit 752c677

Please sign in to comment.