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

Unexpected result of boolean operation between vectors #33

Closed
gnilrets opened this issue Nov 19, 2015 · 2 comments
Closed

Unexpected result of boolean operation between vectors #33

gnilrets opened this issue Nov 19, 2015 · 2 comments

Comments

@gnilrets
Copy link
Contributor

vtrue = Daru::Vector.new([true]*2)
vfalse = Daru::Vector.new([false]*2)

bool = (vfalse and vtrue)

The result is a vector where all of the elements are true, where I would expect all of them to be false.

@v0dro
Copy link
Member

v0dro commented Nov 21, 2015

The and clause you're using is Ruby boolean and, which cannot be modified. Moreover such piecewise boolean operations aren't currently supported on Vector. Use a Daru::Core::Query::BoolArray for that.

Or alternatively:

vtrue = Daru::Vector.new([true]*2)
vfalse = Daru::Vector.new([false]*2)

bool = (vfalse.eq(false).and(vtrue.eq(true)))
# OR
bool = (vfalse.eq(false) & vtrue.eq(true))

This operation will return a BoolArray.

@v0dro v0dro closed this as completed Nov 21, 2015
@gnilrets
Copy link
Contributor Author

Thanks, this works

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