DiODeProject / MuMoT

Multiscale Modelling Tool - mathematical modelling without the maths
https://mumot.readthedocs.io/
GNU General Public License v3.0
21 stars 5 forks source link

function round_to_1(x): raises error if x is 0 #56

Closed joefresna closed 7 years ago

joefresna commented 7 years ago

@tbose1, I don't how you use it and what should return when x is zero. But I get an error, because sometimes in my code it's called with x=0. I (temporarily) put that returns 1... Please, check if correct.

tbose1 commented 7 years ago

round_to_1(x) should return an error if x is zero because of the definition of this function. This function is only used for axis formatting where the input is the plotting range, e.g. xmax-xmin on the x-axis. This cannot be zero.

joefresna commented 7 years ago

I get this error when I launch SSA for Lotka-Volterra with the initial condition: A:10 Y:0 X:0 The SSA returns only flat lines, thus ymax-ymin=0.

joefresna commented 7 years ago

Maybe it's enough to do if x == 0: x = 0.00000001

tbose1 commented 7 years ago

yes, you can make this modifiction, or you use the new keyword choose_yrange = [y1,y2], and set values if your data gives zero

joefresna commented 7 years ago

The suggested change: if x == 0: x = 0.00000001 generates other issues. Instead, if x == 0: return 1 works without issues.