The TypeError is a bug.

Regarding dsolve, can you paste the output of
print(1/beinvariantpart*Derivative(f(x), x) - f(x))?

Aaron Meurer

On Wed, Feb 12, 2014 at 9:49 PM, monde wilson <[email protected]> wrote:
> After fixed, still can not dsolve
>
> import csv as csv
> import os
> import numpy as np
> import sympy as sy
> from sympy import *
> from numpy import *
> from numpy.linalg import *
> from sympy.polys.polyfuncs import interpolate
> from sympy import Function, dsolve, Eq, Derivative, sin, cos
> from sympy.abc import x
>
> files = [f2 for f2 in os.listdir('.') if os.path.isfile(f2)]
> for f2 in files:
> #path = r'C:\Users\martin.lee\Downloads\Downloads\0016.HK.csv'
> path = os.path.abspath(f2)
> extension = os.path.splitext(f2)[1]
> if extension == '.csv':
> print(path)
>
> data = []
> open1 = []
> high1 = []
> low1 = []
> close1 = []
> date1 = []
> list_t1 = []
>
> with open(path, 'rb') as csvfile:
> readdata=csv.reader(csvfile)
> count = 0
> for row in readdata:
> if count >= 1:
> date1.append(row[0])
> open1.append(float(row[1]))
> high1.append(float(row[2]))
> low1.append(float(row[3]))
> close1.append(float(row[4]))
> count = count + 1
>
>
> print(close1[2])
> k = 0
> inputmatrix1 = []
> inputmatrix2 = []
> inputmatrix3 = []
> eigenvectormatrix1 = []
> eigenvectormatrix2 = []
> eigenvectormatrix3 = []
>
> f = Function('f')
> x = sy.Symbol("x")
> for num in range(1, 10):
> temp1 =
> array([[close1[k+num],close1[k+num+1],close1[k+num+2]],[close1[k+num+1],close1[k+num+2],0],[close1[k+num+2],0,0]])
> temp2 =
> array([[close1[k+num+1],close1[k+num+2],close1[k+num+3]],[close1[k+num+2],close1[k+num+3],0],[close1[k+num+3],0,0]])
> temp3 =
> array([[close1[k+num+2],close1[k+num+3],close1[k+num+4]],[close1[k+num+3],close1[k+num+4],0],[close1[k+num+4],0,0]])
> beinter =
> interpolate([close1[k+num],close1[k+num+1],close1[k+num+2],close1[k+num+3]],
> x);
> print(beinter)
> print(sy.diff(beinter,x))
> beinvariantpart = sy.diff(beinter,x)
> print("to dsolve =")
> try:
> print(dsolve(1/beinvariantpart*Derivative(f(x), x) - f(x), f(x)))
> except Exception as inst:
> print type(inst)     # the exception instance
> print inst.args      # arguments stored in .args
> print inst
>
> print("debug1")
> inputmatrix1.append(temp1)
> inputmatrix2.append(temp2)
> inputmatrix3.append(temp3)
> print("debug2")
> editedinputmatrix1 = temp1.transpose().dot(temp1)
> editedinputmatrix2 = temp2.transpose().dot(temp2)
> editedinputmatrix3 = temp3.transpose().dot(temp3)
> print("debug3")
> eigenvectormatrix1.append(eig(editedinputmatrix1))
> eigenvectormatrix2.append(eig(editedinputmatrix2))
> eigenvectormatrix3.append(eig(editedinputmatrix3))
>
>
> #print(eigenvectormatrix3[0][0])
> print(eigenvectormatrix3[0][1])
>
>
>
>
>
>
> monde wilson於 2014年2月13日星期四UTC+8上午11時23分57秒寫道:
>>
>> Traceback (most recent call last):
>>   File "testcsv.py", line 57, in <module>
>>     beinvariantpart =
>> diff(interpolate([close1[k+num],close1[k+num+1],close1[k+n
>> um+2],close1[k+num+3]], x), x)
>>   File "C:\Python27\lib\site-packages\numpy\lib\function_base.py", line
>> 984, in
>> diff
>>     if n < 0:
>>   File "C:\Python27\lib\site-packages\sympy\core\relational.py", line 226,
>> in __
>> nonzero__
>>     raise TypeError("symbolic boolean expression has no truth value.")
>> TypeError: symbolic boolean expression has no truth value.
>>
>>
>> import csv as csv
>> import os
>> import numpy as np
>> from sympy import *
>> from numpy import *
>> from numpy.linalg import *
>> from sympy.polys.polyfuncs import interpolate
>> from sympy import Function, dsolve, Eq, Derivative, sin, cos
>> from sympy.abc import x
>>
>> files = [f2 for f2 in os.listdir('.') if os.path.isfile(f2)]
>> for f2 in files:
>> #path = r'C:\Users\martin.lee\Downloads\Downloads\0016.HK.csv'
>> path = os.path.abspath(f2)
>> extension = os.path.splitext(f2)[1]
>> if extension == '.csv':
>> print(path)
>>
>> data = []
>> open1 = []
>> high1 = []
>> low1 = []
>> close1 = []
>> date1 = []
>> list_t1 = []
>>
>> with open(path, 'rb') as csvfile:
>> readdata=csv.reader(csvfile)
>> count = 0
>> for row in readdata:
>> if count >= 1:
>> date1.append(row[0])
>> open1.append(float(row[1]))
>> high1.append(float(row[2]))
>> low1.append(float(row[3]))
>> close1.append(float(row[4]))
>> count = count + 1
>>
>>
>> print(close1[2])
>> k = 0
>> inputmatrix1 = []
>> inputmatrix2 = []
>> inputmatrix3 = []
>> eigenvectormatrix1 = []
>> eigenvectormatrix2 = []
>> eigenvectormatrix3 = []
>>
>> x = Symbol("x")
>> f = Function('f')
>>
>> for num in range(1, 30):
>> temp1 =
>> array([[close1[k+num],close1[k+num+1],close1[k+num+2]],[close1[k+num+1],close1[k+num+2],0],[close1[k+num+2],0,0]])
>> temp2 =
>> array([[close1[k+num+1],close1[k+num+2],close1[k+num+3]],[close1[k+num+2],close1[k+num+3],0],[close1[k+num+3],0,0]])
>> temp3 =
>> array([[close1[k+num+2],close1[k+num+3],close1[k+num+4]],[close1[k+num+3],close1[k+num+4],0],[close1[k+num+4],0,0]])
>>
>> beinvariantpart =
>> diff(interpolate([close1[k+num],close1[k+num+1],close1[k+num+2],close1[k+num+3]],
>> x), x)
>> print("to dsolve =")
>> print(dsolve(1/beinvariantpart*Derivative(f(x), x) - f(x), f(x)))
>> print("debug1")
>> inputmatrix1.append(temp1)
>> inputmatrix2.append(temp2)
>> inputmatrix3.append(temp3)
>> print("debug2")
>> editedinputmatrix1 = temp1.transpose().dot(temp1)
>> editedinputmatrix2 = temp2.transpose().dot(temp2)
>> editedinputmatrix3 = temp3.transpose().dot(temp3)
>> print("debug3")
>> eigenvectormatrix1.append(eig(editedinputmatrix1))
>> eigenvectormatrix2.append(eig(editedinputmatrix2))
>> eigenvectormatrix3.append(eig(editedinputmatrix3))
>>
>>
>> #print(eigenvectormatrix3[0][0])
>> print(eigenvectormatrix3[0][1])
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" 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 http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" 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 http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to