Scenario
In the GUI load one image, work with it, then load another image, possibly with different dimensions or other attributes.
Or load repeated images without the GUI.
Check
The second image is set the same way it would have been if it were loaded first.
Concern
The second image might carry over some settings from the first, or be missing some settings.
Background
Because of these concerns, Karl initially recreated self.mybifs with each new image load. Ross changed this to rely more on copying. I (Ross) think the motivations were two-fold:
- Code reuse. bifs_gui.py doMap had code for creating a new bifs object based on an old one. I needed that same logic elsewhere, for scanning images to get an empirical prior. So I moved the logic to a separate function (in bifs.py, since there's nothing GUI specific in it).
- Performance: many fresh allocations used lots of memory and were slow (not sure about this one).
In particular, commit 47f9171 introduced this change, with the cautionary note
# Reinitialize bifs object but keep current parameter setttings
# RB: I refactored the parameter copying to the bifs object itself.
# However, this means I set the parameters and then load the image file.
# The original code loaded the image file and then set the parameters.
# Since I don't understand why the reinitialization was necessary at all,
# it's possible this change in sequence will break something.
self.mybifs = self.mybifs.copy_params()
Extra Credit
Create one or more automated tests for these issues.
Scenario
In the GUI load one image, work with it, then load another image, possibly with different dimensions or other attributes.
Or load repeated images without the GUI.
Check
The second image is set the same way it would have been if it were loaded first.
Concern
The second image might carry over some settings from the first, or be missing some settings.
Background
Because of these concerns, Karl initially recreated self.mybifs with each new image load. Ross changed this to rely more on copying. I (Ross) think the motivations were two-fold:
In particular, commit 47f9171 introduced this change, with the cautionary note
Extra Credit
Create one or more automated tests for these issues.