Skip to content

Commit 69c1915

Browse files
Tommy Odlanddafeda
authored andcommitted
Fix crash when plotting correlated discrete variables
1 parent d13ff6a commit 69c1915

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/semeio/fmudesign/quality_report.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,9 @@ def print_correlation(self, corr_name: str, df_corr: pd.DataFrame) -> None:
283283
else:
284284
print("The desired correlation matrix is valid")
285285

286-
print("Correlation in samples:")
287-
print(corr.round(2))
286+
if not corr.empty:
287+
print("Correlation in samples:")
288+
print(corr.round(2))
288289

289290
def plot_correlation(
290291
self,
@@ -323,8 +324,8 @@ def add_grid(*args: Any, **kwargs: Any) -> None: # noqa: ANN401
323324

324325
df = self.df[df_corr.columns].select_dtypes(include="number")
325326

326-
# Do not plot if only a single variable remains
327-
if df.shape[1] == 1:
327+
# Only plot if two or more variables remain
328+
if df.shape[1] <= 1:
328329
return
329330

330331
pairgrid = sns.PairGrid(df)

0 commit comments

Comments
 (0)