Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility issues with v1.7+ #181

Merged
merged 3 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ jobs:
strategy:
matrix:
version:
- '1.5'
- '1'
- '1.6'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
Expand Down
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
6 changes: 5 additions & 1 deletion src/tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ end
pinverse(::SMatrix{E,0,T}) where {E,T} = SMatrix{0,E,T}() # BUG: workaround StaticArrays bug SMatrix{E,0,T}()'

function pinverse(m::SMatrix)
qrm = qr(m)
@static if VERSION >= v"1.7.0-beta2"
qrm = qr(m, NoPivot())
else
qrm = qr(m)
end
return inv(qrm.R) * qrm.Q'
end

Expand Down