add flag for partial fits; closes #83

This commit is contained in:
Dominik Demuth
2023-07-12 20:48:28 +02:00
parent 33afc2ca94
commit 76cd4acfb0
13 changed files with 132 additions and 88 deletions

View File

@ -33,6 +33,7 @@ class ExperimentContainer(QtCore.QObject):
self.id = str(identifier)
self._fits = []
self._relations = kwargs.get('relations', {})
self._data = data
self._manager = kwargs.get('manager')
self.graph = ''
@ -228,6 +229,8 @@ class ExperimentContainer(QtCore.QObject):
return self.plot_real, self.plot_imag, self.plot_error
def get_state(self):
# TODO preserve relationships
ret_dic = {
'id': self.id,
'data': self._data.get_state(),
@ -269,6 +272,32 @@ class ExperimentContainer(QtCore.QObject):
else:
self._fits.extend(value)
def has_relation(self, relation_type):
return relation_type in self._relations
def get_relation(self, relation_type: int):
return self._relations.get(relation_type, [])
def add_relation(self, relation_type: int, value: str):
if relation_type not in self._relations:
self._relations[relation_type] = []
self._relations[relation_type].append(value)
def remove_relation(self, relation_type: int, value: str):
if relation_type not in self._relations:
raise ValueError(f'Relationship {relation_type!r} with id {value!r} doe not exist for {self.name}')
related_id_value = self._relations[relation_type]
idx = related_id_value.index(value)
if idx == -1:
raise ValueError(f'Relationship {relation_type!r} with id {value!r} doe not exist for {self.name}')
related_id_value.pop(idx)
if len(related_id_value) == 0:
self._relations.pop(relation_type)
def _update_actions(self):
self.actions.update({'sort': self._data.sort,
'cut': self._data.cut,

View File

@ -5,7 +5,7 @@ from nmreval.lib.colors import available_cycles
from .properties import PropWidget
from ...Qt import QtWidgets, QtGui, QtCore
from ..._py.datawidget import Ui_DataWidget
from ...lib import make_action_icons
from ...lib.iconloading import make_action_icons
from ...lib.delegates import HeaderDelegate