Selecting parts of an array based on the conjunction of two conditions in v1

question
#1

I am updating some code from v0.6 to v1, and I have not been able to resolve one particular issue (except by workaround). In v0.6 my code included the construction

A[:,(A[1,:].==1) & (A[2,:].==10)]

for selecting the parts of the array A (of type Array{Int64,2}) based on the conjunction of two conditions. When I try to run this code in v1, I get the error message

MethodError: no method matching &(::BitArray{1}, ::BitArray{1})

followed by a suggestion for correcting the error, which I have been unable to implement. I would greatly appreciate assistance. Thanks.

#2

Welcome! You just need to make the & elementwise with a .&:

A[:,(A[1,:].==1) .& (A[2,:].==10)]

In general,you’ll want to fix deprecations warnings in 0.6 before upgrading it — those warnings are there for a reason, and they’ll tell you exactly how to fix things like this! The transition version 0.7 will similarly be helpful for some other issues you may encounter.

1 Like