sampsapursiainen / zeffiro_interface

Interface for using finite elements in inverse problems with complex domains
GNU General Public License v3.0
23 stars 15 forks source link

zef_waitbar does not progress with loops with less than 500 iterations #227

Closed SeSodesa closed 1 year ago

SeSodesa commented 1 year ago

Description

The function zef_waitbar does the following assignment right when the function starts:

https://github.com/sampsapursiainen/zeffiro_interface/blob/a3d39452d78f898028be437c225bc1fe8da7782b/m/zef_waitbar.m#L2-L5

This is later used to determine whether the function does anything, when the third argument is a string that the waitbar should update:

https://github.com/sampsapursiainen/zeffiro_interface/blob/a3d39452d78f898028be437c225bc1fe8da7782b/m/zef_waitbar.m#L43-L56

If a loop which utilizes zef_waitbar to display progress then has less than 500 iterations (or something to that effect), it seems that the waitbar will never be updated. I am aware that we need a condition like this to prevent loops with millions of laborious iterations taking longer than necessary, because updating the waitbar is a rather slow operation, but this hard-coded threshold value needs to be handled differently. Otherwise zef_waitbar will be useless with loops that only have a "few" iterations.

Steps to reproduce

  1. Create a zef_waitbar before a loop with, say, 300 iterations: wb = zef_waitbar(0, "Title.");,
  2. Then in the loop, where the loop index variable is ii and the number of iterations N is 300, update the waitbar with text that shows the progress: zef_waitbar(ii / N, wb, "Title: " + ii + " / " + N); and
  3. observe that the waitbar is not visibly progressed, when zef_waitbar is called.

Expected behavior

The waitbar updated with the call zef_waitbar(<progress_ratio>, <waitbar_handle>, <progress_text>) should also update itself in the case of loops that contain only a few iterations.

Context

Name Value
Version f958de80 Merge pull request #193 from sampsapursiainen/192-fs2zefsh-improvements
OS Any and all
Shell Any and all
SeSodesa commented 1 year ago

Correction, it does progress, after 5 iterations of a 10-iteration loop. But since one step of said test loop takes a while, the user is left wondering if anything is progressing at all.

SeSodesa commented 1 year ago

Closed by the merge of #239.