Nice colors, but you should really use code tags instead (proper indentation helps). And when debugging, I normally suggest you copy/paste your exact code rather than trying to “clean up” stuff, because you can unintentionally change the behavior when “cleaning up”. (Though you can always clean up your original code, retest it, and then post it.)
Anyway. I see that you’re setting
new_min_dist = scale_X / minRat
and
minRat = scale_X / old_min_dist
so by algebraic substitution
new_min_dist == scale_X / (scale_X / old_min_dist) == scale_X * old_min_dist / scale_X == old_min_dist
The “scale_X” factors cancel out and you’re effectively just setting new_min_dist = old_min_dist (except perhaps for some floating-point rounding errors).
Your problem isn’t that you can’t assign new values; it’s that the new values are the same as the old values.