I'm trying to compare floating numbers that are stored in numpy arrays. I would like them to be compared with a tolerance and every number of the array should be compared with every number of the other array. My attempt is shown underneath, I used two simple arrays as examples but it has the problem that it only compares numbers with the same indices.
b_y_ion_mass = np.array([1.000, 2.1300, 3.4320, 6.0000])
observed_mass_array = np.array([0.7310, 2.2300, 5.999, 8.000, 9.000])
abs_tol = 0.2
for (fragment, mass) in zip(b_y_ion_mass, observed_mass_array):
if (fragment+abs_tol)> mass and (fragment-abs_tol)< mass:
print(mass)
It would be great if anyone could help me.
Thank you.