Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findall(f .== f[1]), TypeError: non-boolean (Num) used in boolean context #1000

Closed
xiang-yu opened this issue Oct 13, 2023 · 4 comments
Closed

Comments

@xiang-yu
Copy link

xiang-yu commented Oct 13, 2023

Hi everyone,

Any thoughts on the following error?
Note that SymPy in Julia works.

f = Symbolics.variables(:f, 1:Q)

3-element Vector{Num}:
f₁
f₂
f₃

findall(f .== f[1])

TypeError: non-boolean (Num) used in boolean context
Stacktrace:
[1] iterate
@ ./iterators.jl:514 [inlined]
[2] iterate
@ ./generator.jl:44 [inlined]
[3] grow_to!
@ ./array.jl:855 [inlined]
[4] collect
@ ./array.jl:779 [inlined]
[5] findall(A::Vector{Num})
@ Base ./array.jl:2402
[6] top-level scope
@ REPL[126]:1

@ChrisRackauckas
Copy link
Member

== on symbolics is not a boolean, so it cannot be used in boolean comparisons. Did you instead mean findall(isequal.(f,f[1]))?

@xiang-yu
Copy link
Author

xiang-yu commented Oct 14, 2023

isequal works like a charm! Thanks a lot, @ChrisRackauckas . Any chance this can be added to the instruction of Symbolics?

@ChrisRackauckas
Copy link
Member

It's already in the docs https://symbolics.juliasymbolics.org/stable/manual/faq/. I extended it as well: https://github.com/JuliaSymbolics/Symbolics.jl/blob/master/docs/src/manual/faq.md#equality-and-set-membership-tests. Let me know if anything else would clear up the confusion.

@ChrisRackauckas
Copy link
Member

x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants