Skip to content

Commit

Permalink
add more conditions to summary
Browse files Browse the repository at this point in the history
  • Loading branch information
eberrigan committed Apr 11, 2024
1 parent 9b8b658 commit 6941e71
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions sleap_roots/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_summary(

X = np.atleast_1d(X)

if len(X) == 0:
if len(X) == 0 or np.all(np.isnan(X)):
return {
f"{prefix}min": np.nan,
f"{prefix}max": np.nan,
Expand All @@ -40,7 +40,7 @@ def get_summary(
f"{prefix}p75": np.nan,
f"{prefix}p95": np.nan,
}
else:
elif np.issubdtype(X.dtype, np.number):
return {
f"{prefix}min": np.nanmin(X),
f"{prefix}max": np.nanmax(X),
Expand All @@ -52,3 +52,16 @@ def get_summary(
f"{prefix}p75": np.nanpercentile(X, 75),
f"{prefix}p95": np.nanpercentile(X, 95),
}
else:
print("X contains non-numeric values")
return {
f"{prefix}min": np.nan,
f"{prefix}max": np.nan,
f"{prefix}mean": np.nan,
f"{prefix}median": np.nan,
f"{prefix}std": np.nan,
f"{prefix}p5": np.nan,
f"{prefix}p25": np.nan,
f"{prefix}p75": np.nan,
f"{prefix}p95": np.nan,
}

0 comments on commit 6941e71

Please sign in to comment.