PhysiCell-Tools / PhysiCell-Studio

PhysiCell Studio is a graphical tool to allow easy editing of a (XML) model, create initial positions of cells, run a simulation, and visualize results. To contribute, fork and make PRs to the development branch.
GNU General Public License v3.0
19 stars 11 forks source link

allow negative integer parameters. #212

Closed elmbeech closed 2 months ago

elmbeech commented 2 months ago

small bugfix to be compatible with the underlining PhysiCell patrameter.ints implementation.

rheiland commented 2 months ago

This is a nice example of how such a trivial thing (conceptually) can be tricky. What is a valid string representation of an integer? Based on your fix, this would fail "1e6". Personally, I'd consider that value to be an integer. Unrelated to that type of test, doesn't your "re" check allow for alpha chars in the string, e.g., "42o"? And doesn't this pass your test: "1-2"?

What would you think of something like this as a fix to check for an integer value in a string, sval?

try:
  if abs(float(sval) - int(float(sval))) < 1.e-6:
    continue
  else:
    notify user
except:
  notify user
elmbeech commented 2 months ago

I am fine with the test you suggest too! There are many ways leading to Roma. I just need the possibility to set negative integers.

rheiland commented 2 months ago

I went with a better fix and committed it. Thanks for discovering this oversight!