Instead of setting the breakpoint using spyder's tools and using spyder's 
Debug command, I sometimes insert this line

import pdb; pdb.set_trace() # Pause execution here with the debugger active.

as the breakpoint in my code then use spyder's Run (not Debug) command.  
Once this line is reached, spyder's variable inspector and the rest of its 
debug tools all seem to work fine (including the Continue button).

This offers multiple benefits:

   1. It averts a condition I've sometimes observed in using spyder 3.1.x's 
   Debug command where breakpoints remain visible and apparently active but 
   become ineffective after some code editing and a few rounds of debugging.  
   I'm not sure what the pattern is for this condition, but it maybe only on 
   Windows (not Linux), and maybe only when using the Python console (instead 
   of IPython console).
   2. My code seems to run faster up to the point of reaching this line 
   when using the Run command instead of the Debug command.  (Some of my codes 
   take tens of minutes to reach the line of interest, so "running faster" 
   makes a difference to me.
   3. It allows making or modifying conditional breakpoints right in the 
   code, with the conditions as simple or complex as you like.
   


On Tuesday, August 1, 2017 at 9:34:51 AM UTC-7, FinnMcGovern wrote:
>
> Hello Guys,
>
> I am new to the debugging in spyder. I usually use a step by step 
> debugging but I am getting confused because I am not able to get the 
> different values of the for loop at some point. 
>
> Here is the code :
>
> # NelSon Siegel Yield Curve Computation
> from datetime import date
> import numpy as np
> def nelsonsiegel(Beta0,Beta1,Beta2,Beta3,Lambda1,Lambda2):
>     SettleDate = date(2017,07,14)
>     Bond1MaturityDate = date(2018,7,13)
>     Bond3MaturityDate = date(2020,2,17)
>     Bond5MaturityDate = date(2022,7,21)
>     Bond10MaturityDate = date(2027,1,20)
>     Bond15MaturityDate = date(2031,9,16)
>     Bond20MaturityDate = date(2037,3,17)
>     Yearfraction = 
> [float((Bond1MaturityDate-SettleDate).days)/365,float((Bond3MaturityDate-SettleDate).days)/365,
>  
> float((Bond5MaturityDate-SettleDate).days)/365, 
> float((Bond10MaturityDate-SettleDate).days)/365, 
> float((Bond15MaturityDate-SettleDate).days)/365, 
> float((Bond20MaturityDate-SettleDate).days)/365]
> #    CouponRate = [0,0.0290,0.0321,0.0494,0.0585,0.0624]
> #    BondPrices = [0.97863,0.99745,0.9968, 0.99922,0.98724,0.96679 ]
>     NS = []
> #    df = []
> #    rst = []
> #    NSS = []
> #    result = []
>     for i in range(len(Yearfraction)):        
>       NelsonSiegel = Beta0 + (Beta1 * 
> ((1-np.exp(-Yearfraction[i]/Lambda1)/Yearfraction[i]*Lambda1))) +  (Beta2 * 
> ((((1-np.exp(-Yearfraction[i]/Lambda1))/(Yearfraction[i]*Lambda1))) - 
> (np.exp(-Yearfraction[i]/Lambda1)))) + (Beta3 * 
> ((((1-np.exp(-Yearfraction[i]/Lambda2))/(Yearfraction[i]*Lambda2))) - 
> (np.exp(-Yearfraction[i]/Lambda2)))) 
>       NS.append(NelsonSiegel)
>       a = np.array(NS) # array for nelson siegel values             
>       return NelsonSiegel
>
> to run this function I use  : nelsonsiegel(0.01,0.01,0.01,0.01,1,1)
>
> I normally put a break point one row before the return command.
>
> can you explain to me please how to debug this in the loop step by step. I 
> put the breakpoint and executed the command but it never stops at my 
> breakpoint.
>
> Thank you
>
> FMG
>

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

Reply via email to