1

Let's say I have a "Truth" array: a = [1,2,3]

and I want to compare it to b for equality with

b = [1,2,3]

awkward.all(a == b)

Easy enough. Now we want this to be a general code which works for all of our data. But for one of these cases, have a truth of let's say:

c =[x>0, 2, 3]

so the first entry can be anything. Now we could of course say ak.all(a[1:] == c[1:]) but then we cannot use this requirement on the first case anymore. So is there a way to keep the general behavior of comparing two arrays with each other but one array entry can be anything bigger than zero?

I also know we can go the long way and compare every entry by itself, but we would like to avoid that if possible.

I would be happy for any suggestions

rollerstop
  • 11
  • 2
  • Is your `c[0]` element a condition like `x > 0` or an actual value? – Avinash May 23 '22 at 11:02
  • Array-oriented computations are "SIMD" in the sense that they apply the same instructions to all elements of the array. In that model, you wouldn't be comparing one element with `>` and all other elements with `==`. If it's just one element, then perhaps this first element should be pulled out of the array, since you want to apply different instructions to it, so it doesn't belong in the same array. If you have lots of `>` and lots of `==`, then perhaps you want two arrays, one with lower bounds and the other with upper bounds? (Also could be relevant: `ak.where`.) – Jim Pivarski May 23 '22 at 13:07
  • @Avinash It's an actuall value, that in this case is allowed to be everything bigger than 0 – rollerstop May 23 '22 at 13:12
  • @JimPivarski That would be an option, it is just supposed to be a general function which is supposed to be as simple as possible. So for two samples I can pull it out, since they do not have requirements for the first element, but every other sample actually has a fixed value for that. So I was hoping that I don't need to change the function, but only the truth array. But it seems like for those, I need to introduce an if statement to pull the 0th element out – rollerstop May 23 '22 at 13:14

0 Answers0