mobiusklein / ms_deisotope

A library for deisotoping and charge state deconvolution of complex mass spectra
https://mobiusklein.github.io/ms_deisotope
Apache License 2.0
33 stars 14 forks source link

fixes py3-specific issues in deconvolution processing #1

Closed lukauskas closed 7 years ago

lukauskas commented 7 years ago

Fairly self explanatory, see the diff in the code. Py3 defaults to float division so n/2 would return a float which is later used in range function that throws an error cause it knows not what to do with it.

Similarly, in weighted average calculation, weights is a map object in py3. The implementation of weighted_average tries to traverse this object twice which means that the second time it traverses it (namely when computing the sum), the object is empty. Thus the sum is always 0 and we get a division-by-zero exception.

mobiusklein commented 7 years ago

Thank you for your contribution.

This change looks good. I've been working on Py3 compatibility in other areas as I prepare unit tests. I haven't quite gotten around to unit testing this component yet.