Loading analysis/analysisview.py +5 −3 Original line number Diff line number Diff line Loading @@ -220,9 +220,11 @@ class ParticleAnalysis(QtWidgets.QMainWindow): self.layout.addLayout(self.menuLayout) self.layout.addLayout(viewLayout) if self.datastats.config['minHQI'] is not None: self.hqiSpinBox.setValue(self.datastats.config['minHQI']) self.compHqiSpinBox.setValue(self.datastats.config['compHQI']) minHQI = self.datastats.dataset.resultParams['minHQI'] compHQI = self.datastats.dataset.resultParams['compHQI'] if minHQI is not None: self.hqiSpinBox.setValue(minHQI) self.compHqiSpinBox.setValue(compHQI) self.createActions() self.createMenus() Loading analysis/datastats.py +5 −5 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ If not, see <https://www.gnu.org/licenses/>. import os import numpy as np import operator from dataset import loadData from dataset import loadData, recursiveDictCompare def readDataStats(fname): Loading @@ -38,7 +38,6 @@ def readDataStats(fname): class DataStats(object): def __init__(self, dataset): self.dataset = dataset self.config = dataset.resultParams self.spectraResults = None #entire List of all spectra assignments self.additiveResults = None #entire List of all additives Loading Loading @@ -209,11 +208,12 @@ class DataStats(object): self.dataset.resultParams = {'minHQI': minHQI, 'compHQI': compHQI} self.dataset.save() print('saved dataset; Valid:', self.testRead()) testresult = self.testRead() print('saved dataset; Valid:', testresult) return testresult def testRead(self): statsread = readDataStats(self.dataset.fname) return statsread.__dict__ == self.__dict__ return recursiveDictCompare(self.__dict__, statsread.__dict__) No newline at end of file analysis/loadresults.py +6 −1 Original line number Diff line number Diff line Loading @@ -261,7 +261,12 @@ class LoadWITecResults(QtWidgets.QDialog): self.parent.updateBtn.clicked.connect(self.parent.formatResults) self.parent.formatResults() self.parent.show_hide_labels() self.parent.saveAnalysisResults() minHQI = self.parent.hqiSpinBox.value() compHQI = self.parent.compHqiSpinBox.value() if not self.parent.datastats.saveAnalysisResults(minHQI, compHQI): QtWidgets.QMessageBox.warning(self.parent, 'Error!', 'Data inconsistency after saving!', QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok) self.parent.setEnabled(True) event.accept() Loading analysis/particleeditor.py +13 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License along with this program, see COPYING. If not, see <https://www.gnu.org/licenses/>. """ import numpy as np import cv2 from PyQt5 import QtWidgets Loading Loading @@ -134,7 +135,12 @@ class ParticleEditor(object): del self.datastats.dataset.particles2spectra[index] #save data self.datastats.saveAnalysisResults() minHQI = self.parent.hqiSpinBox.value() compHQI = self.parent.compHqiSpinBox.value() if not self.datastats.saveAnalysisResults(minHQI, compHQI): QtWidgets.QMessageBox.warning(self.parent, 'Error!', 'Data inconsistency after saving!', QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok) #update contours in sampleview self.parent.parent.contouritem.resetContours(self.datastats.dataset.particlecontours) Loading @@ -156,7 +162,12 @@ class ParticleEditor(object): self.datastats.hqis[specIndex] = 100 #save data self.datastats.saveAnalysisResults() minHQI = self.parent.hqiSpinBox.value() compHQI = self.parent.compHqiSpinBox.value() if not self.datastats.saveAnalysisResults(minHQI, compHQI): QtWidgets.QMessageBox.warning(self.parent, 'Error!', 'Data inconsistency after saving!', QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok) self.parent.loadParticleData() Loading dataset.py +4 −2 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ def saveData(dataset, fname): dataset.zvalimg = zvalimg def arrayCompare(a1, a2): print("array compare") ind = np.isnan(a1) if not np.any(ind): return np.all(a1==a2) Loading @@ -63,7 +62,6 @@ def arrayCompare(a1, a2): return np.all(a1[~ind]==a2[~ind]) def listCompare(l1, l2): print("list compare") if len(l1)!=len(l2): return False for l1i, l2i in zip(l1, l2): Loading @@ -86,16 +84,20 @@ def recursiveDictCompare(d1, d2): print(key, type(a), type(b)) if isinstance(a, np.ndarray): if not isinstance(b, np.ndarray) or not arrayCompare(a, b): print("data is different!", a, b) return False elif isinstance(a, dict): if not isinstance(b, dict): print("data is different!", a, b) return False if not recursiveDictCompare(a, b): return False elif isinstance(a, (list, tuple)): if not isinstance(b, (list, tuple)) or not listCompare(a, b): print("data is different!", a, b) return False elif a != b: print("data is different!", a, b) return False return True Loading Loading
analysis/analysisview.py +5 −3 Original line number Diff line number Diff line Loading @@ -220,9 +220,11 @@ class ParticleAnalysis(QtWidgets.QMainWindow): self.layout.addLayout(self.menuLayout) self.layout.addLayout(viewLayout) if self.datastats.config['minHQI'] is not None: self.hqiSpinBox.setValue(self.datastats.config['minHQI']) self.compHqiSpinBox.setValue(self.datastats.config['compHQI']) minHQI = self.datastats.dataset.resultParams['minHQI'] compHQI = self.datastats.dataset.resultParams['compHQI'] if minHQI is not None: self.hqiSpinBox.setValue(minHQI) self.compHqiSpinBox.setValue(compHQI) self.createActions() self.createMenus() Loading
analysis/datastats.py +5 −5 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ If not, see <https://www.gnu.org/licenses/>. import os import numpy as np import operator from dataset import loadData from dataset import loadData, recursiveDictCompare def readDataStats(fname): Loading @@ -38,7 +38,6 @@ def readDataStats(fname): class DataStats(object): def __init__(self, dataset): self.dataset = dataset self.config = dataset.resultParams self.spectraResults = None #entire List of all spectra assignments self.additiveResults = None #entire List of all additives Loading Loading @@ -209,11 +208,12 @@ class DataStats(object): self.dataset.resultParams = {'minHQI': minHQI, 'compHQI': compHQI} self.dataset.save() print('saved dataset; Valid:', self.testRead()) testresult = self.testRead() print('saved dataset; Valid:', testresult) return testresult def testRead(self): statsread = readDataStats(self.dataset.fname) return statsread.__dict__ == self.__dict__ return recursiveDictCompare(self.__dict__, statsread.__dict__) No newline at end of file
analysis/loadresults.py +6 −1 Original line number Diff line number Diff line Loading @@ -261,7 +261,12 @@ class LoadWITecResults(QtWidgets.QDialog): self.parent.updateBtn.clicked.connect(self.parent.formatResults) self.parent.formatResults() self.parent.show_hide_labels() self.parent.saveAnalysisResults() minHQI = self.parent.hqiSpinBox.value() compHQI = self.parent.compHqiSpinBox.value() if not self.parent.datastats.saveAnalysisResults(minHQI, compHQI): QtWidgets.QMessageBox.warning(self.parent, 'Error!', 'Data inconsistency after saving!', QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok) self.parent.setEnabled(True) event.accept() Loading
analysis/particleeditor.py +13 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License along with this program, see COPYING. If not, see <https://www.gnu.org/licenses/>. """ import numpy as np import cv2 from PyQt5 import QtWidgets Loading Loading @@ -134,7 +135,12 @@ class ParticleEditor(object): del self.datastats.dataset.particles2spectra[index] #save data self.datastats.saveAnalysisResults() minHQI = self.parent.hqiSpinBox.value() compHQI = self.parent.compHqiSpinBox.value() if not self.datastats.saveAnalysisResults(minHQI, compHQI): QtWidgets.QMessageBox.warning(self.parent, 'Error!', 'Data inconsistency after saving!', QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok) #update contours in sampleview self.parent.parent.contouritem.resetContours(self.datastats.dataset.particlecontours) Loading @@ -156,7 +162,12 @@ class ParticleEditor(object): self.datastats.hqis[specIndex] = 100 #save data self.datastats.saveAnalysisResults() minHQI = self.parent.hqiSpinBox.value() compHQI = self.parent.compHqiSpinBox.value() if not self.datastats.saveAnalysisResults(minHQI, compHQI): QtWidgets.QMessageBox.warning(self.parent, 'Error!', 'Data inconsistency after saving!', QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok) self.parent.loadParticleData() Loading
dataset.py +4 −2 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ def saveData(dataset, fname): dataset.zvalimg = zvalimg def arrayCompare(a1, a2): print("array compare") ind = np.isnan(a1) if not np.any(ind): return np.all(a1==a2) Loading @@ -63,7 +62,6 @@ def arrayCompare(a1, a2): return np.all(a1[~ind]==a2[~ind]) def listCompare(l1, l2): print("list compare") if len(l1)!=len(l2): return False for l1i, l2i in zip(l1, l2): Loading @@ -86,16 +84,20 @@ def recursiveDictCompare(d1, d2): print(key, type(a), type(b)) if isinstance(a, np.ndarray): if not isinstance(b, np.ndarray) or not arrayCompare(a, b): print("data is different!", a, b) return False elif isinstance(a, dict): if not isinstance(b, dict): print("data is different!", a, b) return False if not recursiveDictCompare(a, b): return False elif isinstance(a, (list, tuple)): if not isinstance(b, (list, tuple)) or not listCompare(a, b): print("data is different!", a, b) return False elif a != b: print("data is different!", a, b) return False return True Loading