jbhopkins / bioxtasraw

BioXTAS RAW is a GUI based, free, open-source Python program for reduction and analysis of small-angle solution scattering (SAS) data.
https://bioxtas-raw.readthedocs.io/en/latest/
GNU General Public License v3.0
10 stars 4 forks source link

UnboundLocalError in SECM.py in averageFrame method #5

Closed antoniocalio95 closed 9 months ago

antoniocalio95 commented 9 months ago

Here's the traceback:

Traceback (most recent call last):

  File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File c:\users\anton\desktop\dio\h5read.py:104
    avg_buff, success, error = series.averageFrames(buff_range, 'sub', 'CorMap', 0.01, 'Bonferroni', forced = True)

  File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\bioxtasraw\SECM.py:1528 in averageFrames
    avg_list = sasm_list

UnboundLocalError: cannot access local variable 'sasm_list' where it is not associated with a value

Basically sasm_list is only defined in the case of an unsubtracted series at line 1485:

if series_type == 'unsub':
        sasm_list = [self._sasm_list[idx] for idx in frame_idx]

I quickly fixed it by adding this to handle my case:


elif series_type == 'sub':
        sasm_list = [self.subtracted_sasm_list[idx] for idx in frame_idx]

Although maybe you want to fix it properly to handle all possible cases. Also, the parameters' default values for this method aren't set as they are described in the documentation, but that's also an easy fix.

jbhopkins commented 9 months ago

Thanks for the bug report. I've just pushed a new commit to the git that should fix this, as well as fixing the documentation mismatch though that won't be updated on the website until I make that update. If you can test it and let me know if it works for you that would be great.

antoniocalio95 commented 9 months ago

I just tested it with the new SECM.py and I can confirm that it works as intended now, thank you very much!

jbhopkins commented 9 months ago

Great, glad that fixed it! Let me know if you find other issues.