Skip to content

Commit

Permalink
findmin/findmax -> argmin/argmax
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosanjose committed Jul 1, 2021
1 parent a366bb9 commit 7a868b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Quantica.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Quantica

# Use README as the docstring of the module:
using Base.Threads: Iterators
@doc read(joinpath(dirname(@__DIR__), "README.md"), String) Quantica

using Requires
Expand All @@ -19,7 +20,7 @@ using SparseArrays: getcolptr, AbstractSparseMatrix, AbstractSparseMatrixCSC

using Statistics: mean

using Compat # for use of findmin/findmax in bandstructure.jl
using Compat # for use of argmin/argmax in bandstructure.jl

export sublat, bravais, lattice, dims, supercell, unitcell,
hopping, onsite, @onsite!, @hopping!, @block!, parameters, siteselector, hopselector, nrange,
Expand Down
6 changes: 3 additions & 3 deletions src/bandstructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ function refine_bisection(found, neighs, steps, criterion, diag)
end

select_closest(εs, criterion, ε0, εi...) =
last(findmin(ε -> ifelse(criterion(ε, ε0, εi...), abs- ε0), Inf), εs))
argmin(ε -> ifelse(criterion(ε, ε0, εi...), abs- ε0), Inf), εs)

"""
gapedge(b::Bandstructure{1}, ε₀; refinesteps = 0)
Expand All @@ -1057,15 +1057,15 @@ function gapedge(b::Bandstructure{1,<:Any,T}, ε0, ::typeof(+); kw...) where {T}
isinband(b, ε0) && return (missing, zero(T))
minbands = Iterators.flatten(filter!.(φε -> last(φε) > ε0, minima(b; kw...)))
isempty(minbands) && return (missing, T(Inf))
(φ₊, ε₊) = findmin(last, minbands) |> last
(φ₊, ε₊) = argmin(last, minbands)
return (φ₊, ε₊)
end

function gapedge(b::Bandstructure{1,<:Any,T}, ε0, ::typeof(-); kw...) where {T}
isinband(b, ε0) && return (missing, zero(T))
maxbands = Iterators.flatten(filter!.(φε -> last(φε) < ε0, maxima(b; kw...)))
isempty(maxbands) && return (missing, T(-Inf))
(φ₋, ε₋) = findmax(last, maxbands) |> last
(φ₋, ε₋) = argmax(last, maxbands)
return (φ₋, ε₋)
end

Expand Down

0 comments on commit 7a868b8

Please sign in to comment.