Skip to content

Commit a4a6b9e

Browse files
MilesCranmergithub-actions[bot]
authored andcommitted
Format .jl files
1 parent afc6938 commit a4a6b9e

File tree

10 files changed

+77
-72
lines changed

10 files changed

+77
-72
lines changed

benchmark/benchmarks.jl

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ function create_utils_benchmark()
8888
suite["best_of_sample"] = @benchmarkable(
8989
best_of_sample(pop, rss, $options),
9090
setup = (
91-
nfeatures=1;
92-
dataset=Dataset(randn(nfeatures, 32), randn(32));
93-
pop=Population(dataset; npop=100, nlength=20, options=($options), nfeatures);
94-
rss=RunningSearchStatistics(; options=($options))
91+
nfeatures = 1;
92+
dataset = Dataset(randn(nfeatures, 32), randn(32));
93+
pop = Population(dataset; npop=100, nlength=20, options=($options), nfeatures);
94+
rss = RunningSearchStatistics(; options=($options))
9595
)
9696
)
9797

@@ -110,9 +110,9 @@ function create_utils_benchmark()
110110
end
111111
end,
112112
setup = (
113-
nfeatures=1;
114-
dataset=Dataset(randn(nfeatures, 32), randn(32));
115-
mutation_weights=MutationWeights(;
113+
nfeatures = 1;
114+
dataset = Dataset(randn(nfeatures, 32), randn(32));
115+
mutation_weights = MutationWeights(;
116116
mutate_constant=1.0,
117117
mutate_operator=1.0,
118118
swap_operands=1.0,
@@ -125,23 +125,21 @@ function create_utils_benchmark()
125125
form_connection=0.0,
126126
break_connection=0.0,
127127
);
128-
options=Options(;
129-
unary_operators=[sin, cos],
130-
binary_operators=[+, -, *, /],
131-
mutation_weights,
128+
options = Options(;
129+
unary_operators=[sin, cos], binary_operators=[+, -, *, /], mutation_weights
132130
);
133-
recorder=RecordType();
134-
temperature=1.0;
135-
curmaxsize=20;
136-
rss=RunningSearchStatistics(; options);
137-
trees=[
131+
recorder = RecordType();
132+
temperature = 1.0;
133+
curmaxsize = 20;
134+
rss = RunningSearchStatistics(; options);
135+
trees = [
138136
gen_random_tree_fixed_size(15, options, nfeatures, Float64) for _ in 1:100
139137
];
140-
expressions=[
138+
expressions = [
141139
Expression(tree; operators=options.operators, variable_names=["x1"]) for
142140
tree in trees
143141
];
144-
members=[
142+
members = [
145143
PopMember(dataset, expression, options; deterministic=false) for
146144
expression in expressions
147145
]
@@ -155,14 +153,14 @@ function create_utils_benchmark()
155153
end,
156154
seconds = 20,
157155
setup = (
158-
nfeatures=1;
159-
T=Float64;
160-
dataset=Dataset(randn(nfeatures, 512), randn(512));
161-
ntrees=($ntrees);
162-
trees=[
156+
nfeatures = 1;
157+
T = Float64;
158+
dataset = Dataset(randn(nfeatures, 512), randn(512));
159+
ntrees = ($ntrees);
160+
trees = [
163161
gen_random_tree_fixed_size(20, $options, nfeatures, T) for i in 1:ntrees
164162
];
165-
members=[
163+
members = [
166164
PopMember(dataset, tree, $options; deterministic=false) for tree in trees
167165
]
168166
)
@@ -181,9 +179,9 @@ function create_utils_benchmark()
181179
compute_complexity(tree, $options)
182180
end,
183181
setup = (
184-
T=Float64;
185-
nfeatures=3;
186-
trees=[
182+
T = Float64;
183+
nfeatures = 3;
184+
trees = [
187185
gen_random_tree_fixed_size(20, $options, nfeatures, T) for
188186
i in 1:($ntrees)
189187
]
@@ -199,9 +197,9 @@ function create_utils_benchmark()
199197
SymbolicRegression.MutationFunctionsModule.randomly_rotate_tree!(tree)
200198
end,
201199
setup = (
202-
T=Float64;
203-
nfeatures=3;
204-
trees=[
200+
T = Float64;
201+
nfeatures = 3;
202+
trees = [
205203
gen_random_tree_fixed_size(20, $options, nfeatures, T) for
206204
i in 1:($ntrees)
207205
]
@@ -216,9 +214,9 @@ function create_utils_benchmark()
216214
)
217215
end,
218216
setup = (
219-
T=Float64;
220-
nfeatures=3;
221-
trees=[
217+
T = Float64;
218+
nfeatures = 3;
219+
trees = [
222220
gen_random_tree_fixed_size(20, $options, nfeatures, T) for i in 1:($ntrees)
223221
]
224222
)
@@ -242,9 +240,9 @@ function create_utils_benchmark()
242240
check_constraints(tree, $options, $options.maxsize)
243241
end,
244242
setup = (
245-
T=Float64;
246-
nfeatures=3;
247-
trees=[
243+
T = Float64;
244+
nfeatures = 3;
245+
trees = [
248246
gen_random_tree_fixed_size(20, $options, nfeatures, T) for i in 1:($ntrees)
249247
]
250248
)

src/CheckConstraints.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ function check_constraints(
9191
return true
9292
end
9393

94-
check_constraints(ex::Union{AbstractExpression,AbstractExpressionNode}, options::AbstractOptions)::Bool = check_constraints(
95-
ex, options, options.maxsize
96-
)
94+
check_constraints(
95+
ex::Union{AbstractExpression,AbstractExpressionNode}, options::AbstractOptions
96+
)::Bool = check_constraints(ex, options, options.maxsize)
9797

9898
end

src/ComposableExpression.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,8 @@ function apply_operator(op::F, x::Vararg{Any,N}) where {F<:Function,N}
271271
if all(_is_valid, x)
272272
return _apply_operator(op, x...)
273273
else
274-
example_vector = something(
275-
map(xi -> xi isa ValidVector ? xi : nothing, x)...
276-
)::ValidVector
274+
example_vector =
275+
something(map(xi -> xi isa ValidVector ? xi : nothing, x)...)::ValidVector
277276
expected_return_type = Base.promote_op(
278277
_apply_operator, typeof(op), map(typeof, x)...
279278
)

src/Configure.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,12 @@ function activate_env_on_workers(
243243
)
244244
verbosity > 0 && @info "Activating environment on workers."
245245
@everywhere procs begin
246-
Base.MainInclude.eval(quote
247-
using Pkg
248-
Pkg.activate($$project_path)
249-
end)
246+
Base.MainInclude.eval(
247+
quote
248+
using Pkg
249+
Pkg.activate($$project_path)
250+
end,
251+
)
250252
end
251253
end
252254

@@ -289,9 +291,12 @@ function import_module_on_workers(
289291
all_extensions = vcat(relevant_extensions, @something(worker_imports, Symbol[]))
290292

291293
for ext in all_extensions
292-
push!(expr.args, quote
293-
using $ext: $ext
294-
end)
294+
push!(
295+
expr.args,
296+
quote
297+
using $ext: $ext
298+
end,
299+
)
295300
end
296301

297302
verbosity > 0 && if isempty(relevant_extensions)

src/MLJInterface.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,9 @@ end
595595
function get_equation_strings_for(
596596
::AbstractSingletargetSRRegressor, trees, options, variable_names
597597
)
598-
return (t -> string_tree(t, options; variable_names=variable_names, pretty=false)).(
599-
trees
600-
)
598+
return (
599+
t -> string_tree(t, options; variable_names=variable_names, pretty=false)
600+
).(trees)
601601
end
602602
function get_equation_strings_for(
603603
::AbstractMultitargetSRRegressor, trees, options, variable_names

src/Options.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ end
150150
break
151151
end
152152
end
153-
found_degree == 0 &&
154-
error("Operator $(op) is not in the operator set.")
153+
found_degree == 0 && error("Operator $(op) is not in the operator set.")
155154
(found_degree, found_idx)
156155
end,
157156
new_max_nesting_dict = [
@@ -167,7 +166,7 @@ end
167166
end
168167
end
169168
found_degree == 0 &&
170-
error("Operator $(nested_op) is not in the operator set.")
169+
error("Operator $(nested_op) is not in the operator set.")
171170
(found_degree, found_idx)
172171
end
173172
(nested_degree, nested_idx, max_nesting)

src/SearchUtils.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,18 @@ to avoid spam when worker processes exit normally.
3737
macro filtered_async(expr)
3838
return esc(
3939
quote
40-
$(Base).errormonitor(@async begin
41-
try
42-
$expr
43-
catch ex
44-
if !(ex isa $(Distributed).ProcessExitedException)
45-
rethrow(ex)
40+
$(Base).errormonitor(
41+
@async begin
42+
try
43+
$expr
44+
catch ex
45+
if !(ex isa $(Distributed).ProcessExitedException)
46+
rethrow(ex)
47+
end
4648
end
4749
end
48-
end)
49-
end
50+
)
51+
end,
5052
)
5153
end
5254

test/manual_distributed.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ procs = addprocs(2)
55
using Test, Pkg
66
project_path = splitdir(Pkg.project().path)[1]
77
@everywhere procs begin
8-
Base.MainInclude.eval(quote
9-
using Pkg
10-
Pkg.activate($$project_path)
11-
end)
8+
Base.MainInclude.eval(
9+
quote
10+
using Pkg
11+
Pkg.activate($$project_path)
12+
end,
13+
)
1214
end
1315
@everywhere using SymbolicRegression
1416
@everywhere _inv(x::Float32)::Float32 = 1.0f0 / x

test/test_units.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ end
137137
!has_cos(member.tree) || any(
138138
t ->
139139
t.degree == 1 &&
140-
options.operators.unaops[t.op] == cos &&
141-
Node(Float64; feature=1) in t &&
142-
compute_complexity(t, options) > 1,
140+
options.operators.unaops[t.op] == cos &&
141+
Node(Float64; feature=1) in t &&
142+
compute_complexity(t, options) > 1,
143143
get_tree(member.tree),
144144
) for member in dominating
145145
]

test/test_utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function simple_bottomk(x, k)
99
end
1010

1111
array_options = [
12-
(n=n, seed=seed, T=T) for
13-
n in (1, 5, 20, 50, 100, 1000), seed in 1:10, T in (Float32, Float64, Int)
12+
(n=n, seed=seed, T=T) for n in (1, 5, 20, 50, 100, 1000), seed in 1:10,
13+
T in (Float32, Float64, Int)
1414
]
1515

1616
@testset "argmin_fast" begin

0 commit comments

Comments
 (0)