Repository navigation
Cast the image ID in ConfigData before formatting the image name - #142
Merged
kriboe90 merged 1 commit intoOct 26, 2026
Merged
Conversation
The config documents a format spec such as img{:04d}.jpg for the zero
padded IDs most cameras write, and init_functions and DataExtractor cast
the ID to int before formatting. get_start_time and
in_time_diff_to_img_time passed the ID as read from config.ini, a
string, so with a format spec they failed with "ValueError: Unknown
format code 'd' for object of type 'str'" - get_start_time whenever the
start time is taken from the first image, which is the default. Cast
the ID there as well.
New acceptance suite 09 runs the workflow with zero padded test images
and img_name_string = test_img_{:04d}.jpg, once with the start time from
the first image and once with the clock offset from a time reference
image given by its ID. Without the fix both stop with the ValueError
above.
This was referenced Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
ConfigDatadocstring and the prompt for the image names recommend a format spec such asimg{:04d}.jpgfor the zero padded IDs most cameras write (DSC_0001.CR3).init_functionsandDataExtractorcast the ID tointbefore formatting.ConfigData.get_start_timeandConfigData.in_time_diff_to_img_timepass the ID as read fromconfig.ini, which is a string. With a format spec they fail:get_start_timeis called wheneverstart_timeisNone, i.e. it is taken from the first image, which is the default. So step 3 stops for every padded template unlessstart_timeis set by hand.in_time_diff_to_img_timefails in the same way when the clock offset is computed from a time reference image given bytime_ref_img_id.Change
int(...)on the ID in both places, as ininit_functionsandDataExtractor.For a plain
{}template the name only changes if the ID inconfig.iniis written with leading zeros (0001). It is thenimg1.jpginstead ofimg0001.jpg. That is the nameinit_functionsalready uses for all experiment images, so this combination did not work before either, and no working setup changes.Tests
New suite
09_test_image_names.robot. The test images are renamed totest_img_0001.jpg… andimg_name_string = test_img_{:04d}.jpgis used. Two cases:time_ref_img_id = 1,time_ref_img_time = 12:00:00). The offset comes out as 0.0, computed fromtest_img_0001.jpg.Both run S1–S3, check that the four padded images are analysed and that the linear extinction coefficients match the ground truth (rmse 0.014 / 0.016 / 0.022 < 0.05).
master, both cases stop with theValueErrorabove, each in its own function.cp1252) from a clean export of the commit. The encoding check of the CI is clean.Rename Test Images To Padded IDsandSet Config Optionsit apart from the lines Feature/local background subtraction #131 changes inLedsaATestLibrary.py. The suite is numbered 09, because Feature/local background subtraction #131 adds08_test_background_subtraction.robot.Observation, not changed here
The second test sets
time_ref_img_idexplicitly, because the config template writes the option astime_img_id, while the code readstime_ref_img_id. As a consequence:time_img_idset inconfig.ini, as the template suggests, is ignored. Ifexif_time_infront_real_timeis not set, the user is asked for the ID instead.time_ref_img_fileand the config has notime_ref_img_id,in_time_diff_to_img_timeraisesKeyError: 'time_ref_img_id', because it indexes the option directly.Both are the same on
master; I reproduced them there. A fix would writetime_ref_img_idinto the template, read the option with a fallback, and still accepttime_img_idfrom existing configs. I left it out to keep this PR small; happy to add it here or open a separate PR, whichever you prefer.