Dear All, I know this error occurs when one tries to multiply a string with a fraction i.e float. In my case , I can't figure out how can a numpy floating point array be a string. Interestingly, the concerned expression gets printed in the loop for the first time but on the second go it fails.
The concerned snippet of code is given below : for t in t_range(0,1,0.1): print t p_za=[] pv_za=[] # Opening file in file_t format fname = 'file_' + str(t) + '.dat' fo = open(fname,'w') # p_za.append(p_initial - t*K*np.sin(K*p_initial)) print 'K=',K print 'pv_za_temp =',pv_za_temp print '- t*K*np.sin(K*p_initial) = ',- t*K*np.sin(K*p_initial) print '-K*np.sin(K*pv_za_temp) = ',-K*np.sin(K*pv_za_temp) pv_za.append(-K*np.sin(K*pv_za_temp)) pv_za_temp = [] pv_za_temp.append(np.array(pv_za)) Here is paste the output,which clearly shows that the concerned expression i.e -K*np.sin(K*pv_za_temp) prints perfectly for the first looping. Also see the error that comes on the second looping. I'm clueless. 0 K= 3.14159265359 pv_za_temp = [ 0. 0.5 1. 1.5 2. ] - t*K*np.sin(K*p_initial) = [ 0. 0. -0. -0. 0.] *-K*np.sin(K*pv_za_temp) = [ -0.00000000e+00 -3.14159265e+00 6.49753967e-13 3.14159265e+00* * -1.29950793e-12] PRINTS PERFECTLY* * * 0.1 K= 3.14159265359 pv_za_temp = [array([[ -0.00000000e+00, -3.14159265e+00, 6.49753967e-13, 3.14159265e+00, -1.29950793e-12]])] - t*K*np.sin(K*p_initial) = [ -0.00000000e+00 -3.14159265e-01 6.49753967e-14 3.14159265e-01 -1.29950793e-13] -K*np.sin(K*pv_za_temp) = *ERROR* Traceback (most recent call last): File "ZA.py", line 45, in <module> print '-K*np.sin(K*pv_za_temp) = ',-K*np.sin(K*pv_za_temp) *TypeError: can't multiply sequence by non-int of type 'float'* Please Help!!!! Cheers, Sayan -- -------------------------------------------------------------------------- *Sayan Chatterjee* Dept. of Physics and Meteorology IIT Kharagpur Lal Bahadur Shastry Hall of Residence Room AB 205 Mob: +91 9874513565 blog: www.blissprofound.blogspot.com Volunteer , Padakshep www.padakshep.org
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor