From e6768a9b5f3cf6877c261b8aa9d6b1bd6782d620 Mon Sep 17 00:00:00 2001 From: JaerongA Date: Tue, 19 Mar 2024 23:14:58 +0000 Subject: [PATCH 1/2] fix: :bug: fix KeyError in BlockDetection --- aeon/dj_pipeline/analysis/block_analysis.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aeon/dj_pipeline/analysis/block_analysis.py b/aeon/dj_pipeline/analysis/block_analysis.py index 08cab6e4..ebed430b 100644 --- a/aeon/dj_pipeline/analysis/block_analysis.py +++ b/aeon/dj_pipeline/analysis/block_analysis.py @@ -8,8 +8,10 @@ from matplotlib import path as mpl_path from aeon.analysis import utils as analysis_utils -from aeon.dj_pipeline import acquisition, fetch_stream, get_schema_name, streams, tracking -from aeon.dj_pipeline.analysis.visit import filter_out_maintenance_periods, get_maintenance_periods +from aeon.dj_pipeline import (acquisition, fetch_stream, get_schema_name, + streams, tracking) +from aeon.dj_pipeline.analysis.visit import (filter_out_maintenance_periods, + get_maintenance_periods) schema = dj.schema(get_schema_name("block_analysis")) logger = dj.logger @@ -516,7 +518,8 @@ def make(self, key): ) block_query = acquisition.Environment.BlockState & chunk_restriction - block_df = fetch_stream(block_query)[previous_block_start:chunk_end] + block_df = fetch_stream(block_query) + block_df = block_df[block_df.index.to_series().between(previous_block_start, chunk_end)] block_ends = block_df[block_df.pellet_ct.diff() < 0] From 6fd1d84632fefeba6e8cb36e597a89a2372bca7a Mon Sep 17 00:00:00 2001 From: JaerongA Date: Wed, 20 Mar 2024 00:55:39 +0000 Subject: [PATCH 2/2] apply .sort_index() inside BlockDetection make function --- aeon/dj_pipeline/analysis/block_analysis.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/aeon/dj_pipeline/analysis/block_analysis.py b/aeon/dj_pipeline/analysis/block_analysis.py index ebed430b..d7c134b8 100644 --- a/aeon/dj_pipeline/analysis/block_analysis.py +++ b/aeon/dj_pipeline/analysis/block_analysis.py @@ -518,8 +518,7 @@ def make(self, key): ) block_query = acquisition.Environment.BlockState & chunk_restriction - block_df = fetch_stream(block_query) - block_df = block_df[block_df.index.to_series().between(previous_block_start, chunk_end)] + block_df = fetch_stream(block_query).sort_index()[previous_block_start:chunk_end] block_ends = block_df[block_df.pellet_ct.diff() < 0]