From f2e87c429d6ed164ff94e76d67ecc3147b264237 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas Date: Mon, 29 Dec 2025 10:35:09 -0500 Subject: [PATCH] Improve explicit imports hygiene MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove unused runtime dependencies (ModelingToolkit, NonlinearSolve, QuasiMonteCarlo, SparseArrays, Symbolics) - Make LinearAlgebra imports explicit (norm, I) - Remove broken/incomplete code from utils.jl - Clean up test dependencies, remove unused packages - Make test imports more explicit where possible - Add ExplicitImports.jl tests to verify import hygiene Files modified: - Project.toml: Reduced to only LinearAlgebra dependency - src/FastSolvers.jl: Explicit imports from LinearAlgebra - src/utils.jl: Removed broken sample_collocation_points function - test/Project.toml: Added ExplicitImports, removed unused deps - test/runtests.jl: Made imports more explicit - test/explicit_imports.jl: New file for CI import checks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- Project.toml | 12 +----------- src/FastSolvers.jl | 11 +---------- src/utils.jl | 38 +------------------------------------- test/Project.toml | 9 +-------- test/explicit_imports.jl | 8 ++++++++ test/runtests.jl | 10 ++++++---- 6 files changed, 18 insertions(+), 70 deletions(-) create mode 100644 test/explicit_imports.jl diff --git a/Project.toml b/Project.toml index 10d0d4e..fe19c4e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,21 +1,11 @@ name = "FastSolvers" uuid = "afc03370-3a10-4444-b401-158123c3c69f" -authors = ["Anant Thazhemadam "] version = "0.1.0" +authors = ["Anant Thazhemadam "] [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" -NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" -QuasiMonteCarlo = "8a4e6c94-4038-4cdc-81c3-7e6ffdb2a71b" -SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" [compat] LinearAlgebra = "1.10" -ModelingToolkit = "9.20.0" -NonlinearSolve = "3.13.1" -QuasiMonteCarlo = "0.3.3" -SparseArrays = "1.10" -Symbolics = "5.32.0" julia = "1.10" diff --git a/src/FastSolvers.jl b/src/FastSolvers.jl index 88bcd2d..e1269da 100644 --- a/src/FastSolvers.jl +++ b/src/FastSolvers.jl @@ -1,14 +1,5 @@ module FastSolvers -using SparseArrays -using NonlinearSolve -using LinearAlgebra -using QuasiMonteCarlo - -import QuasiMonteCarlo.SamplingAlgorithm -import QuasiMonteCarlo.sample - -import ModelingToolkit.PDESystem -import ModelingToolkit.Equation +using LinearAlgebra: norm, I include("utils.jl") diff --git a/src/utils.jl b/src/utils.jl index 78299b6..260f964 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1,37 +1 @@ -function sample_collocation_points( - domain::T, num_points::Tuple{Int, Int}, sampler::SamplingAlgorithm) where {T} - d = length(domain) - ni, nb = num_points - - # Sample interior points - lb = [] - ub = [] - for i in 1:d - push!(lb, domain[i].left) - push!(ub, domain[i].right) - end - interior_points = sample(ni, lb, ub, sampler) - - # Sample boundary points - nbcs = length(bcs) - nb_local = floor(Int, nb / nbcs) - boundary_points = [] - for j in 1:nbcs - mask = [] - bcs_local = bcs[j] - for i in 1:d - if typeof(bcs_local.lhs.arguments[i]) != SymbolicUtils.BasicSymbolic - push!(mask, i) - end - end - lb_local = lb[mask] - ub_local = ub[mask] - push!( - boundary_points, QuasiMonteCarlo.sample(nb_local, lb_local, ub_local, sampler)) - end - return interior_points, reduce(vcat, boundary_points) -end - -function LinearAlgebra.UpperTriangular(a::Float64) - return a -end +# Utility functions for FastSolvers diff --git a/test/Project.toml b/test/Project.toml index 91e89a5..5d2ba59 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,17 +1,10 @@ [deps] -BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" -LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" -OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" QuasiMonteCarlo = "8a4e6c94-4038-4cdc-81c3-7e6ffdb2a71b" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] -DomainSets = "0.7.14" -ModelingToolkit = "9.20.0" -OrdinaryDiffEq = "6.84.0" julia = "1.10" diff --git a/test/explicit_imports.jl b/test/explicit_imports.jl new file mode 100644 index 0000000..3fbd73a --- /dev/null +++ b/test/explicit_imports.jl @@ -0,0 +1,8 @@ +using ExplicitImports +using FastSolvers +using Test + +@testset "ExplicitImports" begin + @test check_no_implicit_imports(FastSolvers) === nothing + @test check_no_stale_explicit_imports(FastSolvers) === nothing +end diff --git a/test/runtests.jl b/test/runtests.jl index 807322a..6da1f94 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,10 +2,8 @@ using FastSolvers using Test using ForwardDiff using QuasiMonteCarlo -using SparseArrays -using LinearAlgebra -using NonlinearSolve -using BenchmarkTools +using SparseArrays: spzeros +using NonlinearSolve: NonlinearLeastSquaresProblem, solve @testset "RKHS kernels" begin include("kernels/interface.jl") @@ -24,3 +22,7 @@ end include("rfnn/derivatives.jl") include("rfnn/function_approx.jl") end + +@testset "Explicit Imports" begin + include("explicit_imports.jl") +end