From b66b224caeab9e3cf75de61fcfdccd0712fb9027 Mon Sep 17 00:00:00 2001 From: appel_c Date: Fri, 15 Mar 2024 11:38:35 +0100 Subject: [PATCH] fix: add numpy and scipy to dynamic_pseudo --- .gitignore | 3 +++ ophyd_devices/utils/dynamic_pseudo.py | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 74235c6..72ad625 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ # file writer data **.h5 +# ignore recover_config files +recovery_config* + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/ophyd_devices/utils/dynamic_pseudo.py b/ophyd_devices/utils/dynamic_pseudo.py index 2392dbe..f803caf 100644 --- a/ophyd_devices/utils/dynamic_pseudo.py +++ b/ophyd_devices/utils/dynamic_pseudo.py @@ -2,6 +2,9 @@ This module provides a class for creating a pseudo signal that is computed from other signals. """ +import numpy +import scipy + from functools import reduce from typing import Callable @@ -70,7 +73,18 @@ class ComputedSignal(SignalRO): @property def compute_method(self) -> Callable | None: """ - Set the compute method for the pseudo signal + Property that returns the compute method for the pseudo signal. + Example: + >>> signal.compute_method = "def test(a, b): return a.get() + b.get()" + + """ + return self._compute_method_str + + @compute_method.setter + def compute_method(self, method: str): + """ + Set the compute method for the pseudo signal. We import numpy and scipy as packages + that are also available for user to use in their compute method. Args: compute_method (str): The compute method to be used. This should be a string @@ -81,10 +95,6 @@ class ComputedSignal(SignalRO): >>> signal.compute_method = "def test(a, b): return a.get() + b.get()" """ - return self._compute_method_str - - @compute_method.setter - def compute_method(self, method: str): logger.info(f"Updating compute method for {self.name}.") method = method.strip() if not method.startswith("def"):