From 35cd4fd6f176ba670fad5d9fec44b305094280d6 Mon Sep 17 00:00:00 2001 From: wyzula-jan <133381102+wyzula-jan@users.noreply.github.com> Date: Sun, 25 Feb 2024 18:06:33 +0100 Subject: [PATCH] fix(plots/waveform1d): pandas import clean up, export curves with none skipped --- bec_widgets/widgets/plots/waveform1d.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/bec_widgets/widgets/plots/waveform1d.py b/bec_widgets/widgets/plots/waveform1d.py index c801d72d..8c3e0237 100644 --- a/bec_widgets/widgets/plots/waveform1d.py +++ b/bec_widgets/widgets/plots/waveform1d.py @@ -5,7 +5,7 @@ from typing import Literal, Optional, Any import numpy as np import pyqtgraph as pg -from pydantic import Field, BaseModel, field_validator, ValidationError +from pydantic import Field, BaseModel, ValidationError from pyqtgraph import mkBrush from qtpy import QtCore from qtpy.QtCore import Signal as pyqtSignal @@ -17,11 +17,6 @@ from bec_lib.scan_data import ScanData from bec_widgets.utils import Colors, ConnectionConfig, BECConnector, EntryValidator from bec_widgets.widgets.plots import BECPlotBase, WidgetConfig -try: - import pandas as pd -except ImportError: - pd = None - class SignalData(BaseModel): """The data configuration of a signal in the 1D waveform widget for x and y axis.""" @@ -703,10 +698,11 @@ class BECWaveform1D(BECPlotBase): for curve in self.curves: x_data, y_data = curve.get_data() - if output == "dict": - data[curve.name()] = {"x": x_data.tolist(), "y": y_data.tolist()} - elif output == "pandas" and pd is not None: - data[curve.name()] = pd.DataFrame({"x": x_data, "y": y_data}) + if x_data is not None or y_data is not None: + if output == "dict": + data[curve.name()] = {"x": x_data.tolist(), "y": y_data.tolist()} + elif output == "pandas" and pd is not None: + data[curve.name()] = pd.DataFrame({"x": x_data, "y": y_data}) if output == "pandas" and pd is not None: combined_data = pd.concat(