anp-scp commited on
Commit
b3bb8b2
1 Parent(s): f7111bf

removed plotting of complex types

Browse files
Files changed (1) hide show
  1. app.py +21 -17
app.py CHANGED
@@ -42,20 +42,24 @@ x_dash_down, y_dash_down = transform(x,-y)
42
 
43
  t = np.array([[a_00,a_01], [a_10, a_11]], dtype=np.float64)
44
 
45
- try:
46
- evl, evec = np.linalg.eig(t)
47
- fig, ax = plt.subplots()
48
- ax.plot(x_dash_up,y_dash_up,'r')
49
- ax.plot(x_dash_down,y_dash_down, 'g')
50
- ax.quiver(0,0,evec[0][0],evec[0][1],scale=1,scale_units ='xy',angles='xy', facecolor='yellow', label='$\lambda_0$')
51
- ax.quiver(0,0,evec[1][0],evec[1][1],scale=1,scale_units ='xy',angles='xy', facecolor='blue',label='$\lambda_1$')
52
- ax.set_xlim(-5,5)
53
- ax.set_ylim(-5,5)
54
- ax.set_aspect('equal', adjustable='box')
55
- fig.legend()
56
- st.pyplot(fig)
57
-
58
- df = pd.DataFrame({'Eigen Values': evl, 'Eigen Vectors': [str(evec[0]), str(evec[1])]})
59
- st.table(df)
60
- except:
61
- st.write("Given matrix has eigen vectors in complex space")
 
 
 
 
 
42
 
43
  t = np.array([[a_00,a_01], [a_10, a_11]], dtype=np.float64)
44
 
45
+
46
+ evl, evec = np.linalg.eig(t)
47
+ fig, ax = plt.subplots()
48
+ ax.plot(x_dash_up,y_dash_up,'r')
49
+ ax.plot(x_dash_down,y_dash_down, 'g')
50
+ if not (np.iscomplex(evl).any() or np.iscomplex(evec).any()):
51
+ ax.quiver(0,0,evec[0,0]*evl[0],evec[1,0]*evl[0],scale=1,scale_units ='xy',angles='xy', facecolor='yellow', label='$eigen\ vector_{\lambda_0}$')
52
+ ax.quiver(0,0,evec[0,1]*evl[1],evec[1,1]*evl[1],scale=1,scale_units ='xy',angles='xy', facecolor='blue',label='$eigen\ vector_{\lambda_1}$')
53
+ ax.set_xlim(-10,10)
54
+ ax.set_ylim(-10,10)
55
+ ax.set_aspect('equal', adjustable='box')
56
+ fig.legend()
57
+ st.pyplot(fig)
58
+
59
+ df = pd.DataFrame({'Eigen Values': evl, 'Eigen Vectors': [str(evec[:,0]), str(evec[:,1])],\
60
+ 'Transformed Eigen Vectors': [str(evec[:,0]*evl[0]), str(evec[:,1]*evl[1])]})
61
+ st.table(df)
62
+
63
+ if np.iscomplex(evl).any() or np.iscomplex(evec).any():
64
+ st.write("Due to complex eigen vectors or eigne values, the transformed eigen vectors are not\
65
+ displayed...")