jjhelmus / nmrglue

A module for working with NMR data in Python
BSD 3-Clause "New" or "Revised" License
209 stars 86 forks source link

np.round after cast to int? #94

Closed smsaladi closed 5 years ago

smsaladi commented 5 years ago

I think this ought to be np.round(np.array(centers)).astype('int')

https://github.com/jjhelmus/nmrglue/blob/a27b0bf796d427144d52d71403276ab0b6225047/nmrglue/analysis/linesh.py#L132

[4] seems to be as intended. [5] does not

In [3]: centers = np.linspace(0, 1, 10)

In [4]: np.round(np.array(centers)).astype('int')
Out[4]: array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1])

In [5]: np.round(np.array(centers).astype('int'))
Out[5]: array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
jjhelmus commented 5 years ago

Yes the round should be applied prior to the cast to int. Thanks for reporting this and the quick fix.

closes via #95