From 115dfc0abff2da3fb4c282c74d823be82b2b9917 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Thu, 28 Nov 2024 21:14:40 +0100 Subject: [PATCH] bugfix on iteration and returning master file --- conda-recipe/meta.yaml | 2 +- pyproject.toml | 2 +- python/aare/RawFile.py | 2 +- src/RawFile.cpp | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 990f58b2..86fc9a8a 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -1,6 +1,6 @@ package: name: aare - version: 2024.11.27.dev0 #TODO! how to not duplicate this? + version: 2024.11.28.dev0 #TODO! how to not duplicate this? source: diff --git a/pyproject.toml b/pyproject.toml index e721f830..4c050297 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "aare" -version = "2024.11.27.dev0" +version = "2024.11.28.dev0" [tool.scikit-build] diff --git a/python/aare/RawFile.py b/python/aare/RawFile.py index 87df4402..98d03949 100644 --- a/python/aare/RawFile.py +++ b/python/aare/RawFile.py @@ -34,7 +34,7 @@ def master(self): Returns: RawMasterFile: Master file. """ - return super().master() + return super().master def __len__(self) -> int: """Return the number of frames in the file. diff --git a/src/RawFile.cpp b/src/RawFile.cpp index 452bee57..744064f9 100644 --- a/src/RawFile.cpp +++ b/src/RawFile.cpp @@ -266,8 +266,7 @@ size_t RawFile::bytes_per_pixel() const { } void RawFile::get_frame_into(size_t frame_index, std::byte *frame_buffer, DetectorHeader *header) { - - if (frame_index > total_frames()) { + if (frame_index >= total_frames()) { throw std::runtime_error(LOCATION + "Frame number out of range"); } std::vector frame_numbers(n_subfile_parts); @@ -319,7 +318,8 @@ void RawFile::get_frame_into(size_t frame_index, std::byte *frame_buffer, Detect if (m_module_pixel_0[part_idx].x!=0) throw std::runtime_error(LOCATION + "Implementation error. x pos not 0."); - + + //TODO! Risk for out of range access subfiles[subfile_id][part_idx]->seek(corrected_idx % m_master.max_frames_per_file()); subfiles[subfile_id][part_idx]->read_into(frame_buffer + offset, header); if (header)