[IPython-User] unfold a function in ipython?

Robert Kern robert.kern@gmail....
Wed Apr 11 09:38:56 CDT 2012


On 4/11/12 3:21 PM, Chao YUE wrote:
> Thanks Robert.  Can I ask a further question, I tried, but why I have different
> output with yours?
>
> In [65]: def day_length(L,J):
>     ....:         #D = daylength
>     ....:     #L = latitude (in degree, north positive and south negative)
>     ....:     #J = day of the year
>     ....:
>     ....:     P = np.arcsin(0.39795*np.cos(0.2163108 +
> 2*np.arctan(0.9671396*np.tan(0.00860*(J-186)))))
>     ....:     x1=np.sin(0.8333*np.pi/180) + np.sin(L*np.pi/180)*np.sin(P)
>     ....:     x2=np.cos(L*np.pi/180)*np.cos(P)
>     ....:     D = 24 - (24/np.pi)*np.arccos(x1/x2)
>     ....:     return D
>     ....:
>
>
> In [69]: import pdb
>
> In [70]: pdb.runcall(day_length,89.5,180)
>  > <ipython console>(6)day_length()
> (Pdb) n
>  > <ipython console>(7)day_length()
> (Pdb) n
>  > <ipython console>(8)day_length()
> (Pdb) n
>  > <ipython console>(9)day_length()
> (Pdb) n
>  > <ipython console>(10)day_length()
> (Pdb) n
> --Return--
>  > <ipython console>(10)day_length()->nan
> (Pdb) n
> Out[70]: nan
>
> I guess I missed something somewhere?

You are using an older version of IPython that did not store the original text 
for functions that are defined at the prompt. What version of IPython are you using?

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco



More information about the IPython-User mailing list