mfitzp / icoshift

A versatile tool for the rapid alignment of 1D NMR spectra
https://www.mfitzp.com/tools/icoshift/
Other
16 stars 10 forks source link

Update to Python3 and simple test file #3

Open mars20 opened 4 years ago

mars20 commented 4 years ago

Updated the code to make it compatible with Python3 test_wine.py is a simple test program

NichVC commented 3 years ago

I think I've encountered another bug with this Python3 version when using the 'average2' alignment. I got a:

“TypeError: object of type 'int' has no len()” from line 595 of icoshift.py:
if len(ref_w) == 0 or ref_w.shape[0] == 0:

The error was fixed by changing "len(ref_w)" to "ref_w".

I'm rather new to github, so not entirely sure how I branch/merge this fix.

acmoudleysa commented 11 months ago

Your code seems to work. The only bug I found was this (not sure if it's a bug tbh)

In line 678. Instead of

ind_blocks = numpy.array([0, numpy.cumsum(ind_blocks, 0)], dtype=ind_blocks.dtype).flatten()

Making 0 a numpy array works for me.

numpy.array([numpy.array([0]),numpy.cumsum(ind_blocks, 0)], dtype=ind_blocks.dtype).flatten()

I feel the variable names need to be changed throughout the script.