From f9341045874d451ad2294a459d79739ec638a740 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Mon, 12 Jun 2023 18:07:51 +0200 Subject: [PATCH] =?UTF-8?q?closes=20#80;=20evaluate=20expression=20an=20Da?= =?UTF-8?q?tens=C3=A4tzen=20mit=20gehiddenen=20Values?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui_qt/data/container.py | 4 ++-- src/nmreval/data/points.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui_qt/data/container.py b/src/gui_qt/data/container.py index 30cdb14..940ac62 100644 --- a/src/gui_qt/data/container.py +++ b/src/gui_qt/data/container.py @@ -459,7 +459,7 @@ class ExperimentContainer(QtCore.QObject): return namespace def eval_expression(self, cmds, namespace): - namespace.update({'x': self.x, 'y': self.y, 'y_err': self.y_err, 'value': self.value}) + namespace.update({'x': self._data.x, 'y': self._data.y, 'y_err': self._data.y_err, 'value': self.value}) if len(self._fits) == 1: namespace.update({"fit['%s']" % (convert(pname, old='tex', new='str')): pvalue.value @@ -474,7 +474,7 @@ class ExperimentContainer(QtCore.QObject): if c: exec(c, globals(), namespace) - new_data.set_data(x=namespace['x'], y=namespace['y'], y_err=namespace['y_err']) + new_data.set_data(x=namespace['x'], y=namespace['y'], y_err=namespace['y_err'], replace_mask=False) new_data.value = namespace['value'] return new_data diff --git a/src/nmreval/data/points.py b/src/nmreval/data/points.py index 3282627..c2169ff 100644 --- a/src/nmreval/data/points.py +++ b/src/nmreval/data/points.py @@ -483,15 +483,17 @@ class Points: return self - def set_data(self, x: np.ndarray = None, y: np.ndarray = None, y_err: np.ndarray = None) -> PointLike: + def set_data(self, x: np.ndarray = None, y: np.ndarray = None, y_err: np.ndarray = None, replace_mask=True) -> PointLike: if x is None: x = self._x if y is None: y = self._y - if y_err is not None: + if y_err is None: y_err = self._y_err - self._x, self._y, self._y_err, self.mask = self._prepare_xy(x, y, y_err) + self._x, self._y, self._y_err, mask = self._prepare_xy(x, y, y_err) + if replace_mask: + self.mask = mask return self