EasyScience / EasyDiffractionApp

Diffraction data analysis application
https://easydiffraction.org
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

Delete old temp files on write (was: Disable crysfml and gsas for projects with multiple phases) #190

Open rozyczko opened 2 years ago

rozyczko commented 2 years ago

Since multiple phases can only be currently calculated with CrysPy, we need to disable the other two calculators from the combo box.

rozyczko commented 2 years ago

Maybe exp_type_strings in interfaceTemplate needs to be extended to include polarization/multiphase information? Not all backends will support both.

This way, a proper list of interfaces can be returned on query in interface_compatibility in edL

rozyczko commented 2 years ago

This actually is a more serious bug. Loading the standard PbSO4 example and switching the CrysFML gives

  File "D:\projects\easyScience\easyCore\easyCore\Utils\UndoRedo.py", line 489, in inner_wrapper
    borg.stack.push(PropertyStack(obj, func, old_value, new_value, text=txt.format(**locals())))
  File "D:\projects\easyScience\easyCore\easyCore\Utils\UndoRedo.py", line 193, in push
    command.redo()
  File "D:\projects\easyScience\easyCore\easyCore\Utils\UndoRedo.py", line 329, in redo
    self._set_func(self._parent, self._new_value)
  File "D:\projects\easyScience\easyDiffractionApp\easyDiffractionApp\Logic\Proxies\Fitting.py", line 99, in currentCalculatorIndex
    self.logic.setCurrentCalculatorIndex(new_index)
  File "D:\projects\easyScience\easyDiffractionApp\easyDiffractionApp\Logic\Fitting.py", line 206, in setCurrentCalculatorIndex
    self.parent.l_parameters._updateCalculatedData()
  File "D:\projects\easyScience\easyDiffractionApp\easyDiffractionApp\Logic\Parameters.py", line 339, in _updateCalculatedData
    sim.y = self._interface.fit_func(sim.x)
  File "D:\projects\easyScience\easyCore\easyCore\Objects\Inferface.py", line 137, in __fit_func
    return self.__interface_obj.fit_func(*args, **kwargs)
  File "D:\projects\easyScience\easyDiffractionLib\easyDiffractionLib\Interfaces\CFML.py", line 154, in fit_func
    return self.calculator.calculate(x_array)
  File "D:\projects\easyScience\easyDiffractionLib\easyDiffractionLib\Calculators\CFML.py", line 114, in calculate
    item = list(self.known_phases.items())[idx]
IndexError: list index out of range
rozyczko commented 2 years ago

This is almost not a bug. I had some old temp cif files floating in the TEMP directory, which confused the file parser. This situation should be properly dealt with by cleaning the temp cif files on state reset/project load etc. but is no longer blocking.