diff --git a/pyproject.toml b/pyproject.toml index e65533e..e8fdba6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "jabs-postprocess" -version = "0.5.2" +version = "0.5.3" description = "A python library for JABS postprocessing utilities." readme = "README.md" license = "LicenseRef-PLATFORM-LICENSE-AGREEMENT-FOR-NON-COMMERCIAL-USE" diff --git a/src/jabs_postprocess/compare_gt.py b/src/jabs_postprocess/compare_gt.py index 1dfef70..3cdc47e 100644 --- a/src/jabs_postprocess/compare_gt.py +++ b/src/jabs_postprocess/compare_gt.py @@ -498,6 +498,19 @@ def generate_output_paths(results_folder: Path): def _expand_intervals_to_frames(df): """Expand behavior intervals into per-frame rows.""" expanded = df.copy() + # Ensure integer frame boundaries so range() receives ints even if upstream data was cast to float + # (e.g., when concatenating empty int DataFrames with dict-based DataFrames, pandas upcasts to float) + for col in ["animal_idx", "start", "duration"]: + if col in expanded.columns: + # Check for NaN values which indicate data quality issues + if expanded[col].isna().any(): + raise ValueError( + f"Column '{col}' contains NaN values. " + f"Expected valid numeric values for frame interval calculation." + ) + # Convert to int, allowing for float values that can be safely cast + # (e.g., 5.0 -> 5, but 5.5 would truncate to 5) + expanded[col] = expanded[col].astype(int) expanded["frame"] = expanded.apply( lambda row: range(row["start"], row["start"] + row["duration"]), axis=1 ) diff --git a/uv.lock b/uv.lock index e1d23cd..38b93d0 100644 --- a/uv.lock +++ b/uv.lock @@ -512,7 +512,7 @@ wheels = [ [[package]] name = "jabs-postprocess" -version = "0.5.2" +version = "0.5.3" source = { editable = "." } dependencies = [ { name = "black" },