From a4a6b9e0f0c9e6dce9d9b39decba99d855f4ce85 Mon Sep 17 00:00:00 2001 From: MilesCranmer <7593028+MilesCranmer@users.noreply.github.com> Date: Mon, 13 Oct 2025 00:28:27 +0000 Subject: [PATCH] Format .jl files --- benchmark/benchmarks.jl | 70 ++++++++++++++++++------------------- src/CheckConstraints.jl | 6 ++-- src/ComposableExpression.jl | 5 ++- src/Configure.jl | 19 ++++++---- src/MLJInterface.jl | 6 ++-- src/Options.jl | 5 ++- src/SearchUtils.jl | 18 +++++----- test/manual_distributed.jl | 10 +++--- test/test_units.jl | 6 ++-- test/test_utils.jl | 4 +-- 10 files changed, 77 insertions(+), 72 deletions(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index e92149614..3412242b5 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -88,10 +88,10 @@ function create_utils_benchmark() suite["best_of_sample"] = @benchmarkable( best_of_sample(pop, rss, $options), setup = ( - nfeatures=1; - dataset=Dataset(randn(nfeatures, 32), randn(32)); - pop=Population(dataset; npop=100, nlength=20, options=($options), nfeatures); - rss=RunningSearchStatistics(; options=($options)) + nfeatures = 1; + dataset = Dataset(randn(nfeatures, 32), randn(32)); + pop = Population(dataset; npop=100, nlength=20, options=($options), nfeatures); + rss = RunningSearchStatistics(; options=($options)) ) ) @@ -110,9 +110,9 @@ function create_utils_benchmark() end end, setup = ( - nfeatures=1; - dataset=Dataset(randn(nfeatures, 32), randn(32)); - mutation_weights=MutationWeights(; + nfeatures = 1; + dataset = Dataset(randn(nfeatures, 32), randn(32)); + mutation_weights = MutationWeights(; mutate_constant=1.0, mutate_operator=1.0, swap_operands=1.0, @@ -125,23 +125,21 @@ function create_utils_benchmark() form_connection=0.0, break_connection=0.0, ); - options=Options(; - unary_operators=[sin, cos], - binary_operators=[+, -, *, /], - mutation_weights, + options = Options(; + unary_operators=[sin, cos], binary_operators=[+, -, *, /], mutation_weights ); - recorder=RecordType(); - temperature=1.0; - curmaxsize=20; - rss=RunningSearchStatistics(; options); - trees=[ + recorder = RecordType(); + temperature = 1.0; + curmaxsize = 20; + rss = RunningSearchStatistics(; options); + trees = [ gen_random_tree_fixed_size(15, options, nfeatures, Float64) for _ in 1:100 ]; - expressions=[ + expressions = [ Expression(tree; operators=options.operators, variable_names=["x1"]) for tree in trees ]; - members=[ + members = [ PopMember(dataset, expression, options; deterministic=false) for expression in expressions ] @@ -155,14 +153,14 @@ function create_utils_benchmark() end, seconds = 20, setup = ( - nfeatures=1; - T=Float64; - dataset=Dataset(randn(nfeatures, 512), randn(512)); - ntrees=($ntrees); - trees=[ + nfeatures = 1; + T = Float64; + dataset = Dataset(randn(nfeatures, 512), randn(512)); + ntrees = ($ntrees); + trees = [ gen_random_tree_fixed_size(20, $options, nfeatures, T) for i in 1:ntrees ]; - members=[ + members = [ PopMember(dataset, tree, $options; deterministic=false) for tree in trees ] ) @@ -181,9 +179,9 @@ function create_utils_benchmark() compute_complexity(tree, $options) end, setup = ( - T=Float64; - nfeatures=3; - trees=[ + T = Float64; + nfeatures = 3; + trees = [ gen_random_tree_fixed_size(20, $options, nfeatures, T) for i in 1:($ntrees) ] @@ -199,9 +197,9 @@ function create_utils_benchmark() SymbolicRegression.MutationFunctionsModule.randomly_rotate_tree!(tree) end, setup = ( - T=Float64; - nfeatures=3; - trees=[ + T = Float64; + nfeatures = 3; + trees = [ gen_random_tree_fixed_size(20, $options, nfeatures, T) for i in 1:($ntrees) ] @@ -216,9 +214,9 @@ function create_utils_benchmark() ) end, setup = ( - T=Float64; - nfeatures=3; - trees=[ + T = Float64; + nfeatures = 3; + trees = [ gen_random_tree_fixed_size(20, $options, nfeatures, T) for i in 1:($ntrees) ] ) @@ -242,9 +240,9 @@ function create_utils_benchmark() check_constraints(tree, $options, $options.maxsize) end, setup = ( - T=Float64; - nfeatures=3; - trees=[ + T = Float64; + nfeatures = 3; + trees = [ gen_random_tree_fixed_size(20, $options, nfeatures, T) for i in 1:($ntrees) ] ) diff --git a/src/CheckConstraints.jl b/src/CheckConstraints.jl index 72669983c..b612e6766 100644 --- a/src/CheckConstraints.jl +++ b/src/CheckConstraints.jl @@ -91,8 +91,8 @@ function check_constraints( return true end -check_constraints(ex::Union{AbstractExpression,AbstractExpressionNode}, options::AbstractOptions)::Bool = check_constraints( - ex, options, options.maxsize -) +check_constraints( + ex::Union{AbstractExpression,AbstractExpressionNode}, options::AbstractOptions +)::Bool = check_constraints(ex, options, options.maxsize) end diff --git a/src/ComposableExpression.jl b/src/ComposableExpression.jl index 0666e1bb5..7e3ee3dd0 100644 --- a/src/ComposableExpression.jl +++ b/src/ComposableExpression.jl @@ -271,9 +271,8 @@ function apply_operator(op::F, x::Vararg{Any,N}) where {F<:Function,N} if all(_is_valid, x) return _apply_operator(op, x...) else - example_vector = something( - map(xi -> xi isa ValidVector ? xi : nothing, x)... - )::ValidVector + example_vector = + something(map(xi -> xi isa ValidVector ? xi : nothing, x)...)::ValidVector expected_return_type = Base.promote_op( _apply_operator, typeof(op), map(typeof, x)... ) diff --git a/src/Configure.jl b/src/Configure.jl index e637c24c6..e1c04c7e5 100644 --- a/src/Configure.jl +++ b/src/Configure.jl @@ -243,10 +243,12 @@ function activate_env_on_workers( ) verbosity > 0 && @info "Activating environment on workers." @everywhere procs begin - Base.MainInclude.eval(quote - using Pkg - Pkg.activate($$project_path) - end) + Base.MainInclude.eval( + quote + using Pkg + Pkg.activate($$project_path) + end, + ) end end @@ -289,9 +291,12 @@ function import_module_on_workers( all_extensions = vcat(relevant_extensions, @something(worker_imports, Symbol[])) for ext in all_extensions - push!(expr.args, quote - using $ext: $ext - end) + push!( + expr.args, + quote + using $ext: $ext + end, + ) end verbosity > 0 && if isempty(relevant_extensions) diff --git a/src/MLJInterface.jl b/src/MLJInterface.jl index bb2fddfb0..2f6e441fc 100644 --- a/src/MLJInterface.jl +++ b/src/MLJInterface.jl @@ -595,9 +595,9 @@ end function get_equation_strings_for( ::AbstractSingletargetSRRegressor, trees, options, variable_names ) - return (t -> string_tree(t, options; variable_names=variable_names, pretty=false)).( - trees - ) + return ( + t -> string_tree(t, options; variable_names=variable_names, pretty=false) + ).(trees) end function get_equation_strings_for( ::AbstractMultitargetSRRegressor, trees, options, variable_names diff --git a/src/Options.jl b/src/Options.jl index cb8d3bbf3..cde0d5a31 100644 --- a/src/Options.jl +++ b/src/Options.jl @@ -150,8 +150,7 @@ end break end end - found_degree == 0 && - error("Operator $(op) is not in the operator set.") + found_degree == 0 && error("Operator $(op) is not in the operator set.") (found_degree, found_idx) end, new_max_nesting_dict = [ @@ -167,7 +166,7 @@ end end end found_degree == 0 && - error("Operator $(nested_op) is not in the operator set.") + error("Operator $(nested_op) is not in the operator set.") (found_degree, found_idx) end (nested_degree, nested_idx, max_nesting) diff --git a/src/SearchUtils.jl b/src/SearchUtils.jl index 58d492e8a..89eaa8cbf 100644 --- a/src/SearchUtils.jl +++ b/src/SearchUtils.jl @@ -37,16 +37,18 @@ to avoid spam when worker processes exit normally. macro filtered_async(expr) return esc( quote - $(Base).errormonitor(@async begin - try - $expr - catch ex - if !(ex isa $(Distributed).ProcessExitedException) - rethrow(ex) + $(Base).errormonitor( + @async begin + try + $expr + catch ex + if !(ex isa $(Distributed).ProcessExitedException) + rethrow(ex) + end end end - end) - end + ) + end, ) end diff --git a/test/manual_distributed.jl b/test/manual_distributed.jl index e005155fd..ae3c52bb7 100644 --- a/test/manual_distributed.jl +++ b/test/manual_distributed.jl @@ -5,10 +5,12 @@ procs = addprocs(2) using Test, Pkg project_path = splitdir(Pkg.project().path)[1] @everywhere procs begin - Base.MainInclude.eval(quote - using Pkg - Pkg.activate($$project_path) - end) + Base.MainInclude.eval( + quote + using Pkg + Pkg.activate($$project_path) + end, + ) end @everywhere using SymbolicRegression @everywhere _inv(x::Float32)::Float32 = 1.0f0 / x diff --git a/test/test_units.jl b/test/test_units.jl index dd36ca6c9..9a9d0338b 100644 --- a/test/test_units.jl +++ b/test/test_units.jl @@ -137,9 +137,9 @@ end !has_cos(member.tree) || any( t -> t.degree == 1 && - options.operators.unaops[t.op] == cos && - Node(Float64; feature=1) in t && - compute_complexity(t, options) > 1, + options.operators.unaops[t.op] == cos && + Node(Float64; feature=1) in t && + compute_complexity(t, options) > 1, get_tree(member.tree), ) for member in dominating ] diff --git a/test/test_utils.jl b/test/test_utils.jl index 2433476a1..67ceb0dcc 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -9,8 +9,8 @@ function simple_bottomk(x, k) end array_options = [ - (n=n, seed=seed, T=T) for - n in (1, 5, 20, 50, 100, 1000), seed in 1:10, T in (Float32, Float64, Int) + (n=n, seed=seed, T=T) for n in (1, 5, 20, 50, 100, 1000), seed in 1:10, + T in (Float32, Float64, Int) ] @testset "argmin_fast" begin