You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## How do I handle `if` statements in my symbolic forms?
26
+
27
+
For statements that are in the `if then else` form, use `IfElse.ifelse` from the
28
+
[IfElse.jl](https://github.com/SciML/IfElse.jl) package to represent the code in a
29
+
functional form. For handling direct `if` statements, you can use equivalent boolean
30
+
mathematical expressions. For example `if x > 0 ...` can be implementated as just
31
+
`(x > 0) * `, where if `x <= 0` then the boolean will evaluate to `0` and thus the
32
+
term will be excluded from the model.
33
+
34
+
## ERROR: TypeError: non-boolean (Num) used in boolean context?
35
+
36
+
If you see the error:
37
+
38
+
```julia
39
+
ERROR: TypeError: non-boolean (Num) used in boolean context
40
+
```
41
+
42
+
then it's likely you are trying to trace through a function which cannot be
43
+
directly represented in Julia symbols. The techniques to handle this problem,
44
+
such as `@register`, are described in detail
45
+
[in the Symbolics.jl documentation](https://symbolics.juliasymbolics.org/dev/manual/faq/#Transforming-my-function-to-a-symbolic-equation-has-failed.-What-do-I-do?-1).
0 commit comments