Skip to content

Commit

Permalink
fix: copying complexity function to worker
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Nov 7, 2024
1 parent e7e2e0b commit 8288720
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Configure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function move_functions_to_workers(
ops = (options.loss_function,)
example_inputs = (Node(T; val=zero(T)), dataset, options)
elseif function_set == :complexity_mapping
if options.complexity_mapping isa Union{ComplexityMapping,Function}
if !(options.complexity_mapping isa Function)
continue
end
ops = (options.complexity_mapping,)
Expand Down
4 changes: 1 addition & 3 deletions test/test_custom_operators_multiprocessing.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using SymbolicRegression

const used_complexity = Ref(false)

defs = quote
_plus(x, y) = x + y
_mult(x, y) = x * y
Expand All @@ -11,7 +9,7 @@ defs = quote
_exp(x) = exp(x)
early_stop(loss, c) = ((loss <= 1e-10) && (c <= 10))
my_loss(x, y, w) = abs(x - y)^2 * w
my_complexity(ex) = (used_complexity[] = true; length(get_tree(ex)))
my_complexity(ex) = length(get_tree(ex))
end

# This is needed as workers are initialized in `Core.Main`!
Expand Down

0 comments on commit 8288720

Please sign in to comment.