smeerten / ssnake

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

Uncaught ValueError when multiplying real data with an array of incorrect size #141

Open Famlam opened 1 year ago

Famlam commented 1 year ago

Minor inconvenience, as the operation is invalid anyway, but instead of showing that the data has the wrong size in the regular way, an error ("program error, please report") is shown in the toolbar.

  1. Put the attached example data in a JSON file, load it in ssnake
  2. Matrix -> Multiply this data with [2,2] or [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] (anything with a non-matching size)
  3. "Program error, please report"
Traceback (most recent call last): 
File "widgetClasses.py", line 407, in applyAndClose self.applyFunc() 
File "ssNake.py", line 6048, in applyFunc self.father.current.multiply(np.array(val), self.singleSlice.isChecked()) 
File "views.py", line 1861, in multiply self.data.multiply(data, self.axes[-1], select=selectSlice) 
File "spectrum.py", line 578, in multiply self.data[select] *= data 
File "hypercomplex.py", line 209, in __imul__ self.data *= other 
ValueError: operands could not be broadcast together with shapes (1,1,2,14) (15,) (1,1,2,14) 

Example data

{"dataReal": [[[[949700.0, 1739000.0, 3040000.0, 4876000.0, 9451000.0, 16740000.0, 26700000.0, 39540000.0, 50380000.0, 57020000.0, 61480000.0, 62550000.0, 62910000.0, 62800000.0], [8748000.0, 9675000.0, 11700000.0, 17420000.0, 22880000.0, 36130000.0, 59950000.0, 92950000.0, 141600000.0, 206200000.0, 274800000.0, 327700000.0, 350300000.0, 354300000.0]]]], "dataImag": [[[[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]]], "hyper": [0], "freq": [300146481.8, 300146481.8, 0.0], "sw": [500000.0, 500000.0, 1.0], "spec": [0.0, 0.0, 0.0], "wholeEcho": [0.0, 0.0, 0.0], "ref": [NaN, NaN, NaN], "history": ["Data obtained from fit", "X-axis of dimension 3 was set to [1.000e-02 2.000e-02 4.000e-02 8.000e-02 1.600e-01 3.200e-01 6.400e-01 1.280e+00 2.560e+00 5.120e+00 1.024e+01 2.048e+01 4.096e+01 8.192e+01]"], "metaData": {"# Scans": "-", "Acquisition Time [s]": "-", "Experiment Name": "-", "Receiver Gain": "-", "Recycle Delay [s]": "-", "Sample": "-", "Offset [Hz]": "-", "Time Completed": "-"}, "xaxArray": [[0.0], [0.0, 2e-06], [0.01, 0.020000000000000004, 0.04000000000000001, 0.07999999999999999, 0.16, 0.32000000000000006, 0.6399999999999999, 1.2799999999999998, 2.56, 5.120000000000001, 10.240000000000004, 20.48000000000001, 40.95999999999998, 81.92000000000002]]}