Open
Description
this is the code i write by C#
var ndarrya = np.array(new double[] { 10, 20, 30, 40, 50, 60,70,80,90,100 });
var conditions = new NDarray<bool>[2];
conditions[0] = ndarrya <= 30;
conditions[1] = (ndarrya > 50)&(ndarrya <= 100);
var choiselist = new NDarray<float>[2];
choiselist[0] = np.array(new float[] { 10 });
choiselist[1] = np.array(new float[] { 20 });
var des = np.select(conditions, choiselist, 0);
there is an error in the following line
conditions[1] = (ndarrya > 50)&(ndarrya <= 100);
Visual studio warn that 'the operation & can not be userd between NDarray[bool]
I just want to know how to write the Multiple Conditions
wish for you reply
Activity
henon commentedon Aug 30, 2024
Can you provide the equivalent python snippet for comparison?
xiaozhu1988 commentedon Sep 1, 2024
the result is below
[66 66 66 0 77 77 77 77 77 88 88 88]
sorry for reply so late,
Fix boolean operators & | and ^ between NDarrays (#129)
henon commentedon Sep 1, 2024
The operators were only defined for scalars, now I added overloads for arrays and it works:
xiaozhu1988 commentedon Sep 1, 2024
henon commentedon Sep 1, 2024
Fixed in https://www.nuget.org/packages/Numpy/3.11.1.34