mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
fix(plots/waveform1d): pandas import clean up, export curves with none skipped
This commit is contained in:
@ -5,7 +5,7 @@ from typing import Literal, Optional, Any
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
from pydantic import Field, BaseModel, field_validator, ValidationError
|
from pydantic import Field, BaseModel, ValidationError
|
||||||
from pyqtgraph import mkBrush
|
from pyqtgraph import mkBrush
|
||||||
from qtpy import QtCore
|
from qtpy import QtCore
|
||||||
from qtpy.QtCore import Signal as pyqtSignal
|
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.utils import Colors, ConnectionConfig, BECConnector, EntryValidator
|
||||||
from bec_widgets.widgets.plots import BECPlotBase, WidgetConfig
|
from bec_widgets.widgets.plots import BECPlotBase, WidgetConfig
|
||||||
|
|
||||||
try:
|
|
||||||
import pandas as pd
|
|
||||||
except ImportError:
|
|
||||||
pd = None
|
|
||||||
|
|
||||||
|
|
||||||
class SignalData(BaseModel):
|
class SignalData(BaseModel):
|
||||||
"""The data configuration of a signal in the 1D waveform widget for x and y axis."""
|
"""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:
|
for curve in self.curves:
|
||||||
x_data, y_data = curve.get_data()
|
x_data, y_data = curve.get_data()
|
||||||
if output == "dict":
|
if x_data is not None or y_data is not None:
|
||||||
data[curve.name()] = {"x": x_data.tolist(), "y": y_data.tolist()}
|
if output == "dict":
|
||||||
elif output == "pandas" and pd is not None:
|
data[curve.name()] = {"x": x_data.tolist(), "y": y_data.tolist()}
|
||||||
data[curve.name()] = pd.DataFrame({"x": x_data, "y": y_data})
|
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:
|
if output == "pandas" and pd is not None:
|
||||||
combined_data = pd.concat(
|
combined_data = pd.concat(
|
||||||
|
Reference in New Issue
Block a user