Skip to content

Commit

Permalink
Clean up using and import usage (HSU-ANT#71)
Browse files Browse the repository at this point in the history
* Clean up `using` statements

Collect in one place, sort alphabetically, and avoid `using` a whole
module (only bind specific names from the module).

* Use explicit quantification for extention instead of `import`
  • Loading branch information
martinholters authored Sep 7, 2021
1 parent 1c255a5 commit 7ab095d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
12 changes: 6 additions & 6 deletions src/ACME.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ module ACME
export DiscreteModel, run!, steadystate, steadystate!, linearize, ModelRunner

using Compat: evalpoly
using SparseArrays: SparseMatrixCSC, blockdiag, dropzeros!, findnz,
nonzeros, sparse, spzeros
using IterTools: subsets
using LinearAlgebra: BLAS, I, axpy!, lu, rmul!
using Markdown: @doc_str

using ProgressMeter
using IterTools
using OrderedCollections: OrderedDict
using StaticArrays
using ProgressMeter: @showprogress
using SparseArrays: SparseMatrixCSC, blockdiag, dropzeros!, findnz,
nonzeros, sparse, spzeros
using StaticArrays: @SMatrix, @SVector, SMatrix, SVector
using Statistics: mean, var

include("kdtree.jl")
include("solvers.jl")
Expand Down
4 changes: 1 addition & 3 deletions src/circuit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

export Circuit, add!, connect!, disconnect!, @circuit, composite_element

import Base: delete!

struct CircuitNLFunc{Fs}
fs::Fs
end
Expand Down Expand Up @@ -130,7 +128,7 @@ end
Deletes the element named `designator` from the circuit `c` (disconnecting all
its pins).
"""
function delete!(c::Circuit, designator::Symbol)
function Base.delete!(c::Circuit, designator::Symbol)
for net in c.nets
filter!(elempin -> elempin[1] != designator, net)
end
Expand Down
13 changes: 4 additions & 9 deletions src/kdtree.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Copyright 2016, 2017, 2018, 2019 Martin Holters
# Copyright 2016, 2017, 2018, 2019, 2021 Martin Holters
# See accompanying license file.

import Base.deleteat!
import Base.isless
import Base.isempty
using Statistics: mean, var

mutable struct KDTree{Tcv<:AbstractVector,Tp<:AbstractMatrix}
cut_dim::Vector{Int}
cut_val::Tcv
Expand Down Expand Up @@ -83,7 +78,7 @@ mutable struct AltEntry{T}
delta_norm::T
end

isless(e1::AltEntry, e2::AltEntry) = isless(e1.delta_norm, e2.delta_norm)
Base.isless(e1::AltEntry, e2::AltEntry) = isless(e1.delta_norm, e2.delta_norm)

mutable struct Alts{T}
entries::Vector{AltEntry{T}}
Expand Down Expand Up @@ -139,10 +134,10 @@ function siftdown!(alts::Alts, i)
end
end

isempty(alts::Alts) = alts.number_valid == 0
Base.isempty(alts::Alts) = alts.number_valid == 0
peek(alts::Alts) = alts.entries[1]

function deleteat!(alts::Alts, i::Integer)
function Base.deleteat!(alts::Alts, i::Integer)
alts.entries[i], alts.entries[alts.number_valid] = alts.entries[alts.number_valid], alts.entries[i]
alts.number_valid -= 1
if i alts.number_valid
Expand Down
5 changes: 2 additions & 3 deletions src/solvers.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright 2016, 2017, 2018, 2019 Martin Holters
# Copyright 2016, 2017, 2018, 2019, 2021 Martin Holters
# See accompanying license file.

export SimpleSolver, HomotopySolver, CachingSolver
import Base.copy!

struct ParametricNonLinEq{F_eval<:Function,F_setp<:Function,F_calcjp<:Function,Scratch}
func::F_eval
Expand Down Expand Up @@ -132,7 +131,7 @@ function solve!(solver::LinearSolver, x::Vector{Float64}, b::Vector{Float64})
return nothing
end

function copy!(dest::LinearSolver, src::LinearSolver)
function Base.copy!(dest::LinearSolver, src::LinearSolver)
copyto!(dest.factors, src.factors)
copyto!(dest.ipiv, src.ipiv)
end
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ include("checklic.jl")

using ACME
using Compat: evalpoly, only
using Test: @test, @test_broken, @test_logs, @test_throws, @testset
using FFTW: rfft
using ProgressMeter
using ProgressMeter: Progress, next!
using SparseArrays: sparse, spzeros
using Test: @test, @test_broken, @test_logs, @test_throws, @testset

@testset "topomat" begin
tv, ti = ACME.topomat(sparse([1 -1 1; -1 1 -1]))
Expand Down

0 comments on commit 7ab095d

Please sign in to comment.