Nov-09-2020, 09:58 PM
If the only objection is writing out the triplets, you could do the following. It runs the same commands, just does it in a loop.
However, this doesn't change the fundamental calls made. Perhaps someone else can see if there's a better way to have numpy do the sum more directly.
from itertool import product triplets = tuple(product((0, 1), repeat = 3)) sums = {} for triple in triplets: sums[triple] = sum(np.all((results-np.array(triple))==0, axis=1))The sums will be in a dict
sums
rather than as separate variables. But you can pull them out, or you could change how the keys are named.However, this doesn't change the fundamental calls made. Perhaps someone else can see if there's a better way to have numpy do the sum more directly.