diff --git a/lib/CanonicalMoments/Project.toml b/lib/CanonicalMoments/Project.toml index 18c8db1..17b96ab 100644 --- a/lib/CanonicalMoments/Project.toml +++ b/lib/CanonicalMoments/Project.toml @@ -9,6 +9,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" RecurrenceRelationships = "807425ed-42ea-44d6-a357-6771516d7b2c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" +SciMLPublic = "431bcebd-1456-4ced-9d72-93c2757fff0b" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [weakdeps] @@ -38,6 +39,7 @@ Random = "1.10" RecurrenceRelationships = "0.2" Reexport = "1.2.2" SafeTestsets = "0.1" +SciMLPublic = "1" SpecialFunctions = "2" StaticArrays = "1" Statistics = "1.10" diff --git a/lib/CanonicalMoments/src/CanonicalMoments.jl b/lib/CanonicalMoments/src/CanonicalMoments.jl index a178929..273ce51 100644 --- a/lib/CanonicalMoments/src/CanonicalMoments.jl +++ b/lib/CanonicalMoments/src/CanonicalMoments.jl @@ -1,14 +1,17 @@ module CanonicalMoments -using Polynomials, LinearAlgebra, RecurrenceRelationships, Reexport +using Polynomials: Polynomials, AbstractPolynomial, Polynomial, coeffs +using LinearAlgebra: LinearAlgebra, SymTridiagonal +using RecurrenceRelationships: forwardrecurrence +using Reexport: @reexport +using SciMLPublic: @public @reexport using DiscreteMeasures -import Base: isapprox, inv, denominator, numerator +import Base: isapprox, denominator, numerator import Statistics: mean import LinearAlgebra: issymmetric import DiscreteMeasures: support, weights -import Polynomials: denominator, numerator function DEFAULT_ROOT_SOLVER(C, args...; kwargs...) return if length(C) == 3 # 2nd order @@ -47,6 +50,9 @@ export StieltjesTransform, denominator, numerator include("measure_transform_algs.jl") export PolyRootsSupportAlg, EigvalSupportAlg export LinearSolveWeightAlg, PolyWeightAlg, EigvecWeightAlg +# Documented supertypes of the support/weight algorithms; part of the public API +# (used as the `support_alg`/`weight_alg` field types downstream) but not exported. +@public AbstractSupportAlg, AbstractWeightAlg include("measure_transforms.jl") export DiscreteMeasureTransform1 diff --git a/lib/CanonicalMoments/test/qa/Project.toml b/lib/CanonicalMoments/test/qa/Project.toml index 50503eb..ea5c2eb 100644 --- a/lib/CanonicalMoments/test/qa/Project.toml +++ b/lib/CanonicalMoments/test/qa/Project.toml @@ -3,6 +3,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" CanonicalMoments = "58d2c334-1a3c-4862-bb37-9012b9e58a38" DiscreteMeasures = "7766d772-2108-41ee-a4bd-11c51440a39b" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [sources] @@ -14,5 +15,6 @@ Aqua = "0.8" CanonicalMoments = "0.1" DiscreteMeasures = "0.1" JET = "0.9, 0.10, 0.11" +SciMLTesting = "1.7" Test = "1" julia = "1.10" diff --git a/lib/CanonicalMoments/test/qa/qa.jl b/lib/CanonicalMoments/test/qa/qa.jl index b4a326e..c24bb90 100644 --- a/lib/CanonicalMoments/test/qa/qa.jl +++ b/lib/CanonicalMoments/test/qa/qa.jl @@ -1,12 +1,12 @@ -using CanonicalMoments -using Aqua -using JET -using Test +using SciMLTesting, CanonicalMoments, JET, Test -@testset "Aqua" begin - Aqua.test_all(CanonicalMoments) -end - -@testset "JET" begin - JET.test_package(CanonicalMoments; target_defined_modules = true) -end +run_qa( + CanonicalMoments; + explicit_imports = true, + ei_kwargs = (; + # `@reexport using DiscreteMeasures` necessarily brings the `DiscreteMeasures` + # module name (and its `DiscreteMeasure` export, used here) implicitly; the + # re-export is intentional, so these are not implicit-imports to clean up. + no_implicit_imports = (; ignore = (:DiscreteMeasures, :DiscreteMeasure)), + ), +) diff --git a/lib/DiscreteMeasures/test/qa/Project.toml b/lib/DiscreteMeasures/test/qa/Project.toml index 4f3c930..9c9a138 100644 --- a/lib/DiscreteMeasures/test/qa/Project.toml +++ b/lib/DiscreteMeasures/test/qa/Project.toml @@ -2,6 +2,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" DiscreteMeasures = "7766d772-2108-41ee-a4bd-11c51440a39b" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [sources] @@ -11,5 +12,6 @@ DiscreteMeasures = {path = "../.."} Aqua = "0.8" DiscreteMeasures = "0.1" JET = "0.9, 0.10, 0.11" +SciMLTesting = "1.7" Test = "1" julia = "1.10" diff --git a/lib/DiscreteMeasures/test/qa/qa.jl b/lib/DiscreteMeasures/test/qa/qa.jl index c76ecaa..a188dd6 100644 --- a/lib/DiscreteMeasures/test/qa/qa.jl +++ b/lib/DiscreteMeasures/test/qa/qa.jl @@ -1,12 +1,3 @@ -using DiscreteMeasures -using Aqua -using JET -using Test +using SciMLTesting, DiscreteMeasures, JET, Test -@testset "Aqua" begin - Aqua.test_all(DiscreteMeasures) -end - -@testset "JET" begin - JET.test_package(DiscreteMeasures; target_defined_modules = true) -end +run_qa(DiscreteMeasures; explicit_imports = true) diff --git a/lib/OUQBase/Project.toml b/lib/OUQBase/Project.toml index 3b3a53e..05c9225 100644 --- a/lib/OUQBase/Project.toml +++ b/lib/OUQBase/Project.toml @@ -4,6 +4,7 @@ authors = ["Avinash Subramanian (JuliaHub), Benjamin Chung (JuliaHub), Adam Gerl version = "0.1.0" [deps] +ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" CanonicalMoments = "58d2c334-1a3c-4862-bb37-9012b9e58a38" DiscreteMeasures = "7766d772-2108-41ee-a4bd-11c51440a39b" DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf" @@ -12,15 +13,16 @@ ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -PolynomialRoots = "3a141323-8675-5d76-9d11-e1df1406c778" Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b" Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" +TermInterface = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c" [compat] julia = "1.10" +ADTypes = "1" CanonicalMoments = "0.1" DiscreteMeasures = "0.1" DomainSets = "0.7.15" @@ -31,13 +33,13 @@ Optimization = "5" OptimizationBBO = "0.4" OrderedCollections = "1.7.0" Pkg = "1.10" -PolynomialRoots = "1" Polynomials = "4.0.13" Reexport = "1.2.2" SciMLBase = "2.153" SafeTestsets = "0.1" SymbolicUtils = "3" Symbolics = "6.39.1" +TermInterface = "2" Test = "1.10" [sources] diff --git a/lib/OUQBase/src/OUQBase.jl b/lib/OUQBase/src/OUQBase.jl index 4316c74..89bc13c 100644 --- a/lib/OUQBase/src/OUQBase.jl +++ b/lib/OUQBase/src/OUQBase.jl @@ -1,15 +1,25 @@ module OUQBase -using ModelingToolkit, Symbolics -using OrderedCollections -using DiscreteMeasures -using Optimization, JuMP -using SymbolicUtils - -import Symbolics: BasicSymbolic -using CanonicalMoments +using ModelingToolkit: ModelingToolkit, @named, OptimizationSystem, get_variables, + getbounds, parameters, structural_simplify, unknowns +using Symbolics: Symbolics, Equation, Inequality, Num, wrap +using SymbolicUtils: SymbolicUtils, BasicSymbolic, @rule, substitute +using SymbolicUtils.Rewriters: Chain +using TermInterface: arguments +using OrderedCollections: OrderedCollections, OrderedDict +using DiscreteMeasures: DiscreteMeasures, DiscreteMeasure, ProductDiscreteMeasure, + expectation, support, weights +# `Optimization` is kept loaded (it provides the solver machinery used downstream); +# only its module binding is needed at this layer. +using Optimization: Optimization +using JuMP: JuMP, @constraint, @objective, @variable, set_lower_bound, set_name, + set_upper_bound +using SciMLBase: SciMLBase, OptimizationFunction, OptimizationProblem +using ADTypes: AbstractADType + +using CanonicalMoments: CanonicalMoments, DiscreteMeasureTransform1 import CanonicalMoments: RawMomentSequence -using Reexport +using Reexport: @reexport # User should not have to depend on CanonicalMoments to use OUQBase. @reexport using CanonicalMoments: PolyRootsSupportAlg, PolyWeightAlg, EigvalSupportAlg, EigvecWeightAlg diff --git a/lib/OUQBase/src/interface.jl b/lib/OUQBase/src/interface.jl index c8c36db..fe2bc50 100644 --- a/lib/OUQBase/src/interface.jl +++ b/lib/OUQBase/src/interface.jl @@ -1,5 +1,3 @@ -using SciMLBase - macro random_variables(block) lines = block isa Expr && block.head === :block ? block.args : [block] Base.remove_linenums!(block) diff --git a/lib/OUQBase/src/operators.jl b/lib/OUQBase/src/operators.jl index ebbf6c0..adb9562 100644 --- a/lib/OUQBase/src/operators.jl +++ b/lib/OUQBase/src/operators.jl @@ -1,5 +1,5 @@ -import Symbolics: Operator, Term, Num, symtype, value -using SymbolicUtils +import Symbolics: Operator, value +import SymbolicUtils: Term, symtype struct 𝔼_ <: Operator end diff --git a/lib/OUQBase/src/reduction_transformations/canonical_moments.jl b/lib/OUQBase/src/reduction_transformations/canonical_moments.jl index cd5d4b8..b1dee6f 100644 --- a/lib/OUQBase/src/reduction_transformations/canonical_moments.jl +++ b/lib/OUQBase/src/reduction_transformations/canonical_moments.jl @@ -1,14 +1,3 @@ -using CanonicalMoments -using OrderedCollections -using ModelingToolkit - -import SymbolicUtils.Rewriters: Chain -import Symbolics: wrap -import CanonicalMoments: RawMomentSequence - -using SciMLBase - - function get_raw_moment_order(equation::Union{Equation, Inequality}, random_var::Num) remove_expectation_rule = @rule 𝔼(~f) => ~f extract_moment_rule = @rule ^(~base, ~exponent) => ~exponent @@ -271,7 +260,7 @@ function construct_optimization_problem( (rand_var_vec) -> substitute(~f, Dict(constituent_random_variables .=> rand_var_vec)) # QN: Will variables always be passed in right order? Should be correct since this order is preserved in getting the induced_discrete_measure. - ouq_obj_f = simplify(obj_expression; rewriter = extract_f_rule) + ouq_obj_f = Symbolics.simplify(obj_expression; rewriter = extract_f_rule) else error("Objective is not a ProbabilityObjective or ExpectationObjective") end diff --git a/lib/OUQBase/src/reduction_transformations/winkler_extremal_measures.jl b/lib/OUQBase/src/reduction_transformations/winkler_extremal_measures.jl index ee9673a..8e499bf 100644 --- a/lib/OUQBase/src/reduction_transformations/winkler_extremal_measures.jl +++ b/lib/OUQBase/src/reduction_transformations/winkler_extremal_measures.jl @@ -370,8 +370,8 @@ function construct_optimization_problem( oracle_or_symbolic::Symbolic; kwargs..., ) - @debug "Objective: $objective.objective" objective = ouq_sys.objective + @debug "Objective: $(objective._obj)" extract_condition_rule = @rule ℙ(~condition) => ~condition condition = Symbolics.simplify(objective._obj; rewriter = extract_condition_rule) _discrete_measure_map = diff --git a/lib/OUQBase/test/qa/Project.toml b/lib/OUQBase/test/qa/Project.toml index 98aba77..31a3ed2 100644 --- a/lib/OUQBase/test/qa/Project.toml +++ b/lib/OUQBase/test/qa/Project.toml @@ -4,6 +4,7 @@ CanonicalMoments = "58d2c334-1a3c-4862-bb37-9012b9e58a38" DiscreteMeasures = "7766d772-2108-41ee-a4bd-11c51440a39b" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" OUQBase = "01930cae-99d2-7439-8f4f-ace2ece9f1b9" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [sources] @@ -17,5 +18,6 @@ CanonicalMoments = "0.1" DiscreteMeasures = "0.1" JET = "0.9, 0.10, 0.11" OUQBase = "0.1" +SciMLTesting = "1.7" Test = "1" julia = "1.10" diff --git a/lib/OUQBase/test/qa/qa.jl b/lib/OUQBase/test/qa/qa.jl index 1bbf9ff..3a096b7 100644 --- a/lib/OUQBase/test/qa/qa.jl +++ b/lib/OUQBase/test/qa/qa.jl @@ -1,12 +1,34 @@ -using OUQBase -using Aqua -using JET -using Test +using SciMLTesting, OUQBase, JET, Test -@testset "Aqua" begin - Aqua.test_all(OUQBase) -end - -@testset "JET" begin - JET.test_package(OUQBase; target_defined_modules = true) -end +run_qa( + OUQBase; + explicit_imports = true, + # piracies: OUQBase defines `CanonicalMoments.RawMomentSequence(::Symbolics.Num, ...)`, + # owning neither the type nor the arg types; resolving it is a design change. + aqua_broken = (:piracies,), # SciML/OptimalUncertaintyQuantification.jl#33 + ei_kwargs = (; + # Explicit imports of names that are non-public in the upstream majors OUQBase + # actually resolves. OUQBase's [compat] caps SciMLBase 2.x / Symbolics 6.x / + # SymbolicUtils 3.x / ModelingToolkit 9.x, where these are not `public`-declared + # (the public declarations only landed in later majors that [compat] excludes; + # verified against the registered releases on Julia 1.12: Symbolics 6.58.0 / + # SymbolicUtils 3.32.0). + # :BasicSymbolic/:Term/:symtype - SymbolicUtils + # :Operator/:value - Symbolics + all_explicit_imports_are_public = (; + ignore = (:BasicSymbolic, :Operator, :Term, :symtype, :value), + ), + # Non-public qualified accesses into upstream packages; still non-public in the + # resolved upstream majors: + # :BasicSymbolic/:isbinop/:promote_symtype - SymbolicUtils + # :evaluate/:geq/:leq - Symbolics + # :getdefault - ModelingToolkit + # :NoAD/:NullParameters - SciMLBase + all_qualified_accesses_are_public = (; + ignore = ( + :BasicSymbolic, :NoAD, :NullParameters, :evaluate, :geq, :getdefault, + :isbinop, :leq, :promote_symtype, + ), + ), + ), +) diff --git a/src/OptimalUncertaintyQuantification.jl b/src/OptimalUncertaintyQuantification.jl index 6468157..faf717f 100644 --- a/src/OptimalUncertaintyQuantification.jl +++ b/src/OptimalUncertaintyQuantification.jl @@ -1,6 +1,6 @@ module OptimalUncertaintyQuantification -using Reexport +using Reexport: @reexport @reexport using OUQBase end # module diff --git a/test/qa/Project.toml b/test/qa/Project.toml index d7d9df5..f8599fb 100644 --- a/test/qa/Project.toml +++ b/test/qa/Project.toml @@ -5,6 +5,7 @@ DiscreteMeasures = "7766d772-2108-41ee-a4bd-11c51440a39b" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" OUQBase = "01930cae-99d2-7439-8f4f-ace2ece9f1b9" OptimalUncertaintyQuantification = "91ab1271-1799-4997-981e-07ad84422b0d" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [sources] @@ -20,5 +21,6 @@ DiscreteMeasures = "0.1" JET = "0.9, 0.10, 0.11" OUQBase = "0.1" OptimalUncertaintyQuantification = "0.1" +SciMLTesting = "1.7" Test = "1" julia = "1.10" diff --git a/test/qa/qa.jl b/test/qa/qa.jl index 701b77c..69c139f 100644 --- a/test/qa/qa.jl +++ b/test/qa/qa.jl @@ -1,12 +1,12 @@ -using OptimalUncertaintyQuantification -using Aqua -using JET -using Test +using SciMLTesting, OptimalUncertaintyQuantification, JET, Test -@testset "Aqua" begin - Aqua.test_all(OptimalUncertaintyQuantification) -end - -@testset "JET" begin - JET.test_package(OptimalUncertaintyQuantification; target_defined_modules = true) -end +run_qa( + OptimalUncertaintyQuantification; + explicit_imports = true, + ei_kwargs = (; + # `@reexport using OUQBase` necessarily brings the `OUQBase` module name into + # scope; that re-export is the umbrella package's whole purpose, so the module + # name is not a genuine implicit-import to clean up. + no_implicit_imports = (; ignore = (:OUQBase,)), + ), +)