bugfix on iteration and returning master file (#110)

This commit is contained in:
Erik Fröjdh 2024-11-29 08:52:04 +01:00 committed by GitHub
commit ada4d41f4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 6 deletions

View File

@ -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:

View File

@ -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]

View File

@ -34,7 +34,7 @@ class RawFile(_aare.RawFile):
Returns:
RawMasterFile: Master file.
"""
return super().master()
return super().master
def __len__(self) -> int:
"""Return the number of frames in the file.

View File

@ -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<size_t> 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)