see-insight / see-segment

Simple Evolutionary Exploration - Image Segmentation
MIT License
6 stars 21 forks source link

Fix print_best_algorithm_code function to work with all segmentors #6

Closed colbrydi closed 4 years ago

colbrydi commented 4 years ago

While giving a demo, I noticed that some of the segmentors do not work when we run the "print_best_algorithm_code". I do not have an exmaple. We should unit test all of the segmentors and find/fix the ones that do not work.

kai-pinckard commented 4 years ago

Running the following code can reproduce the error.

from see import GeneticSearch, Segmentors

params = ["CT", 4301, 0.237, 9512, 0.21, 5951, 5937, 10, 0.77, 2971, 3685, 3, 1, 100, 0.97, [1, 1], 0.0, "checkerboard", "checkerboard", 3, 493, -28, 0.0, 0.0, 0.0] code = GeneticSearch.print_best_algorithm_code(params)

kai-pinckard commented 4 years ago

This issue has been resolved. It turns out that the error occurs because the code relies on the assumption that the first ']' in the file will always be the closing bracket immediately following the first occurrence of "self.params". This was fixed by searching for the first ']' that occurs after the first occurrence of "self.params".