smeerten / ssnake

A program for the analysis of NMR data.
Other
19 stars 15 forks source link

Extract part fails for single point (ValueError) #134

Closed Famlam closed 1 year ago

Famlam commented 1 year ago
  1. Have an arrayed spectrum (for example a spectrum where the CP contact time is varied), i.e. a semi-2D. In my case, the number of FID's was 3 (so a 3x2200 dataset)
  2. Want to extract only the second FID for further processing, so:
  3. Switch to the 'indirect dimension'
  4. Matrix -> Extract part
  5. Fill in Start index = 1, End index = 1, Step size = 1 (note: index = 1 refers tot the second spectrum) (Alternatively, use the mouse to click left and right of the second data point; you'll also get 1 in every input box)
  6. Get the error below
Traceback (most recent call last): 
File "C:\Users\x\AppData\Local\ssNake_install\src\widgetClasses.py", line 407, in applyAndClose self.applyFunc() 
File "C:\Users\x\AppData\Local\ssNake_install\src\ssNake.py", line 4900, in applyFunc self.apply(self.startVal, self.endVal, self.newSpec.isChecked(), self.stepVal) 
File "C:\Users\x\AppData\Local\ssNake_install\src\ssNake.py", line 4918, in apply self.father.current.extract(minimum, maximum, newSpec, step) 
File "C:\Users\x\AppData\Local\ssNake_install\src\views.py", line 1985, in extract self.plotReset() 
File "C:\Users\x\AppData\Local\ssNake_install\src\views.py", line 2485, in plotReset miny = np.min(self.line_ydata) 
File "", line 180, in amin 
File "C:\Program Files\Python310\lib\site-packages\numpy\core\fromnumeric.py", line 2918, in amin return _wrapreduction(a, np.minimum, 'min', axis, None, out, 
File "C:\Program Files\Python310\lib\site-packages\numpy\core\fromnumeric.py", line 86, in _wrapreduction return ufunc.reduce(obj, axis, dtype, out, **passkwargs) 
ValueError: zero-size array to reduction operation minimum which has no identity 
Famlam commented 1 year ago

Upon diving a bit further, I think the bug is because End index isn't the true final index (the last point), but the first index to be excluded (the last + 1 point). If correct, however, this is in conflict with the text description and the behavior of selecting points using the mouse

jtrebosc commented 1 year ago

True this looks like a bug. Current implementation works like python slices where the "last" index is not included. However, if selecting indexes through mouse click it becomes impossible to keep the last index. This should not be the intended behavior. I have a fix for this that will submit.