Spaces:
Running
Running
MilesCranmer
commited on
Commit
·
7c303e1
1
Parent(s):
5b1c837
Compare address to nothing; rather than value
Browse files- julia/sr.jl +6 -6
julia/sr.jl
CHANGED
@@ -281,7 +281,7 @@ function evalTreeArray(tree::Node, cX::Array{Float32, 2})::Union{Array{Float32,
|
|
281 |
end
|
282 |
elseif tree.degree == 1
|
283 |
cumulator = evalTreeArray(tree.l, cX)
|
284 |
-
if cumulator
|
285 |
return nothing
|
286 |
end
|
287 |
op_idx = tree.op
|
@@ -296,11 +296,11 @@ function evalTreeArray(tree::Node, cX::Array{Float32, 2})::Union{Array{Float32,
|
|
296 |
return cumulator
|
297 |
else
|
298 |
cumulator = evalTreeArray(tree.l, cX)
|
299 |
-
if cumulator
|
300 |
return nothing
|
301 |
end
|
302 |
array2 = evalTreeArray(tree.r, cX)
|
303 |
-
if array2
|
304 |
return nothing
|
305 |
end
|
306 |
|
@@ -321,7 +321,7 @@ end
|
|
321 |
# Score an equation
|
322 |
function scoreFunc(tree::Node)::Float32
|
323 |
prediction = evalTreeArray(tree)
|
324 |
-
if prediction
|
325 |
return 1f9
|
326 |
end
|
327 |
if weighted
|
@@ -338,7 +338,7 @@ function scoreFuncBatch(tree::Node)::Float32
|
|
338 |
batch_idx = randperm(len)[1:batchSize]
|
339 |
batch_X = X[batch_idx, :]
|
340 |
prediction = evalTreeArray(tree, batch_X)
|
341 |
-
if prediction
|
342 |
return 1f9
|
343 |
end
|
344 |
size_adjustment = 1f0
|
@@ -491,7 +491,7 @@ end
|
|
491 |
# with a variable or constant
|
492 |
function deleteRandomOp(tree::Node)::Node
|
493 |
node, parent = randomNodeAndParent(tree, nothing)
|
494 |
-
isroot = (parent
|
495 |
|
496 |
if node.degree == 0
|
497 |
# Replace with new constant
|
|
|
281 |
end
|
282 |
elseif tree.degree == 1
|
283 |
cumulator = evalTreeArray(tree.l, cX)
|
284 |
+
if cumulator === nothing
|
285 |
return nothing
|
286 |
end
|
287 |
op_idx = tree.op
|
|
|
296 |
return cumulator
|
297 |
else
|
298 |
cumulator = evalTreeArray(tree.l, cX)
|
299 |
+
if cumulator === nothing
|
300 |
return nothing
|
301 |
end
|
302 |
array2 = evalTreeArray(tree.r, cX)
|
303 |
+
if array2 === nothing
|
304 |
return nothing
|
305 |
end
|
306 |
|
|
|
321 |
# Score an equation
|
322 |
function scoreFunc(tree::Node)::Float32
|
323 |
prediction = evalTreeArray(tree)
|
324 |
+
if prediction === nothing
|
325 |
return 1f9
|
326 |
end
|
327 |
if weighted
|
|
|
338 |
batch_idx = randperm(len)[1:batchSize]
|
339 |
batch_X = X[batch_idx, :]
|
340 |
prediction = evalTreeArray(tree, batch_X)
|
341 |
+
if prediction === nothing
|
342 |
return 1f9
|
343 |
end
|
344 |
size_adjustment = 1f0
|
|
|
491 |
# with a variable or constant
|
492 |
function deleteRandomOp(tree::Node)::Node
|
493 |
node, parent = randomNodeAndParent(tree, nothing)
|
494 |
+
isroot = (parent === nothing)
|
495 |
|
496 |
if node.degree == 0
|
497 |
# Replace with new constant
|