Closed spyder-bot closed 9 years ago
From contrebasse on 2013-11-17T23:50:45Z
You have to add "from future import division" at the top to get the result you want. By default, python2 uses integer division, where for example 1/2 = 0. When you import division from future, the divisions yields floats.
"from future import division" is executed in the spyder console, that's why you see different results.
I have a few remarks about your script:
From whwang...@gmail.com on 2013-11-18T00:09:16Z
Thanks for the feedback! I'd better modify my code.
Wonseok
Wonseok Hwang Ph.D candidate in Physics
room#: 22-311 phone#: 82-2-871-8097 Department of Physics and Astronomy Seoul National University Seoul 151-747, Korea.
From ccordoba12 on 2014-05-05T06:10:10Z
Fixed by revision 37076687f95b I deactivated the option that introduced
from future import division
by default so that this won't confuse newbies again.
Summary: Different numerical results from "runfile" and "execfile" (was: different numerical results from "runfile" and "execfile")
Status: Fixed
Labels: Cat-Console MS-v2.3
From ccordoba12 on 2014-07-24T07:23:20Z
issue #1902 has been merged into this issue.
From ccordoba12 on 2014-07-24T09:47:32Z
issue #1902 has been merged into this issue.
From whwang...@gmail.com on 2013-11-17T23:06:24Z
Spyder Version: 2.2.0 Python Version: 2.7.5 Qt Version: 4.8.4, PyQt4 (API v2) 4.9.6 on Windows
What steps will reproduce the problem?
1.When run the script file using shortkey('F5', i.e. using "runfile" command) What is the expected output? What do you see instead? show much smaller numeric value
Please provide any additional information below
. Hi. I'm graduate student major in biophysics. I've been using this program very usefully. But, recently I encountered some bug. Following is my test code
def stageI(t, k1, k1i, k2, k3): import matplotlib.pylab as plt return -((k1 - k1i - k3)_plt.sinh(1/2_plt.sqrt(k12 + 2_k1_k1i + k1i2 - 2_(k1 - k1i)_k3 + k3*2)t)/plt.sqrt(k12 + 2_k1_k1i + k1i2 - 2_(k1 - k1i)_k3 + k3*2) - plt.cosh(1/2_sqrt(k12 + 2_k1_k1i + k1i2 - 2_(k1 - k1i)_k3 + k32)_t))_plt.e(-1/2_(k1 + k1i + k3)t)
print stageI(11,0.1,1,0.1,0.6)
When I executed this code with 'F5' (thus via "runfile") it gave "7.56298411827e-09". But when execute this code block with F9 or "execfile" it gave 0.646152616418. This later value is correct one (checked with other program like matlab).
Could you fix this bug and, if possible, let me know what is the problem?
Thanks for the reading
Best Regards Wonseok
Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1646