Skip to content

Commit a6fe9c5

Browse files
committed
ensure z orignal correctly assigned to dataframe
1 parent c8374a9 commit a6fe9c5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pyopenms_viz/_core.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,18 +1118,26 @@ def known_columns(self) -> List[str]:
11181118
def _configClass(self):
11191119
return PeakMapConfig
11201120

1121+
import pandas as pd
1122+
11211123
def __init__(self, data, z_log_scale=False, **kwargs) -> None:
11221124
super().__init__(data, **kwargs)
11231125
self.z_log_scale = z_log_scale
11241126

1125-
# ✅ Store original intensity values before applying log transformation
1126-
if hasattr(self, "z"):
1127-
self.z_original = self.z.copy() # Preserve raw intensities for marginal histograms
1127+
# ✅ Store original intensity values before applying log transformation
1128+
if hasattr(self, "z") and isinstance(self.z, str):
1129+
if isinstance(self.data, pd.DataFrame) and self.z in self.data.columns:
1130+
self.z_original = self.data[self.z].copy() # Ensure it's a Series before copying
1131+
else:
1132+
self.z_original = None # Handle cases where z is not a valid column
1133+
else:
1134+
self.z_original = None # Handle unexpected cases
11281135

11291136
self._check_and_aggregate_duplicates()
11301137
self.prepare_data()
11311138
self.plot()
11321139

1140+
11331141
def prepare_data(self):
11341142
"""
11351143
Prepares the dataset for plotting.

0 commit comments

Comments
 (0)