103 # just in case the sum isn't exactly 1 — sometimes the API returns
104 # e.g. 0.499999 due to floating point error
--> 105 weights /= weights.sum()
106 rand_values = rand.choice(outcomes, shots, p=weights)
107
TypeError: No loop matching the specified signature and casting was found for ufunc true_divide
which I believe is numpy freaking out about dividing ints (specifically 1).
What is the expected behavior?
no errors!
Suggested solutions
casting the output array to floats before normalizing should fix this.
Information
What is the current behavior?
Steps to reproduce the problem
minimal repro program:
produces
which I believe is numpy freaking out about dividing ints (specifically 1).
What is the expected behavior?
no errors!
Suggested solutions
casting the output array to floats before normalizing should fix this.