2626one = S (1 )
2727zero = S (0 )
2828
29+
2930def all_same (items ):
3031 return all (x == items [0 ] for x in items )
3132
@@ -138,6 +139,7 @@ def nc_subs(expr, base_keys, base_values=None):
138139_T = TypeVar ('T' )
139140_U = TypeVar ('T' )
140141
142+
141143class GradedTuple (Tuple [Tuple [_T , ...], ...]):
142144 """ A nested tuple grouped by grade.
143145
@@ -352,7 +354,6 @@ class Ga(metric.Metric):
352354 'sph3d' : 'r,theta,phi:[1,X[0]**2,X[0]**2*cos(X[1])**2]:[1,1,0]:norm=True' ,
353355 'para3d' : 'u,v,z:[u**2+v**2,u**2+v**2,1]:[1,1,0]:norm=True' }
354356
355-
356357 @staticmethod
357358 def dual_mode (mode = 'I+' ):
358359 """
@@ -476,15 +477,15 @@ def __init__(self, bases, *, wedge=True, **kwargs):
476477 if self .e_sq == S (0 ):
477478 self .sing_flg = True
478479 print ('!!!!If I**2 = 0, I cannot be normalized!!!!' )
479- #raise ValueError('!!!!If I**2 = 0, I cannot be normalized!!!!')
480+ # raise ValueError('!!!!If I**2 = 0, I cannot be normalized!!!!')
480481 if self .e_sq > S (0 ):
481482 self .i = self .e / sqrt (self .e_sq )
482483 self .i_inv = self .i
483484 else : # I**2 = -1
484485 self .i = self .e / sqrt (- self .e_sq )
485486 self .i_inv = - self .i
486487 else :
487- if self .Isq == '+' : # I**2 = 1
488+ if self .Isq == '+' : # I**2 = 1
488489 self .i = self .e / sqrt (self .e_sq )
489490 self .i_inv = self .i
490491 else : # I**2 = -1
@@ -675,7 +676,7 @@ def bases_dict(self, prefix=None):
675676 >>> locals().update(ga.bases())
676677 '''
677678 if prefix is None :
678- prefix = 'e'
679+ prefix = 'e'
679680 bl = self .blades .flat [1 :] # do not include the scalar, which is not named
680681 var_names = [prefix + '' .join ([k for k in str (b ) if k .isdigit ()]) for b in bl ]
681682
@@ -950,7 +951,7 @@ def _build_connection(self):
950951
951952 ######## Functions for Calculation products of blades/bases ########
952953
953- #******************** Geometric Product (*) *********************** #
954+ # ******************* Geometric Product (*) ********************** #
954955
955956 def geometric_product_basis_blades (self , blade12 ):
956957 # geometric (*) product for orthogonal basis
@@ -1036,9 +1037,9 @@ def reduce_basis(self, blst):
10361037 blst_flg [i ] = tmp [2 ]
10371038 else : # blst_expand[i] revised
10381039 blst_coef [i ] = - blst_coef [i ]
1039- #if revision force one more pass in case revision
1040- #causes repeated index previous to revised pair of
1041- #indexes
1040+ # if revision force one more pass in case revision
1041+ # causes repeated index previous to revised pair of
1042+ # indexes
10421043 blst_flg [i ] = False
10431044 blst_expand [i ] = tmp [3 ]
10441045 blst_coef .append (- blst_coef [i ] * tmp [0 ])
@@ -1106,10 +1107,10 @@ def reduce_basis_loop(g, blst):
11061107 else :
11071108 blst1_flg = False # more revision needed
11081109 return a1 , blst1 , blst1_flg , blst
1109-
1110+
11101111 return True # revision complete, blst in normal order
11111112
1112- #******************* Outer/wedge (^) product ********************** #
1113+ # ****************** Outer/wedge (^) product ********************* #
11131114
11141115 @staticmethod
11151116 def blade_reduce (lst ):
@@ -1151,7 +1152,7 @@ def wedge_product_basis_blades(self, blade12): # blade12 = blade1*blade2
11511152 else :
11521153 return S (0 )
11531154
1154- #****** Dot (|) product, reft (<) and right (>) contractions ****** #
1155+ # ***** Dot (|) product, reft (<) and right (>) contractions ***** #
11551156
11561157 def _dot_product_grade (self , grade1 , grade2 , mode ):
11571158 """
@@ -1456,7 +1457,6 @@ def split_multivector(self, A):
14561457 else :
14571458 return (0 , A )
14581459
1459-
14601460 def remove_scalar_part (self , A ):
14611461 """
14621462 Return non-commutative part (sympy object) of ``A.obj``.
@@ -1478,7 +1478,6 @@ def remove_scalar_part(self, A):
14781478 else :
14791479 return A
14801480
1481-
14821481 def scalar_part (self , A ):
14831482
14841483 if isinstance (A , mv .Mv ):
@@ -1498,7 +1497,6 @@ def scalar_part(self, A):
14981497 else :
14991498 return 0
15001499
1501-
15021500 """
15031501 else:
15041502 if A.is_commutative:
@@ -1955,6 +1953,7 @@ def ReciprocalFrame(self, basis, mode='norm'):
19551953 def Mlt (self ,* args ,** kwargs ):
19561954 return lt .Mlt (args [0 ], self , * args [1 :], ** kwargs )
19571955
1956+
19581957class Sm (Ga ):
19591958 """
19601959 Submanifold is a geometric algebra defined on a submanifold of a
@@ -2011,7 +2010,7 @@ def __init__(self, __u, __coords, *, ga, norm=False, name=None, root='e', debug=
20112010 Base Geometric Algebra
20122011 """
20132012
2014- #print '!!!Enter Sm!!!'
2013+ # print '!!!Enter Sm!!!'
20152014
20162015 if printer .GaLatexPrinter .latex_flg :
20172016 printer .GaLatexPrinter .restore ()
@@ -2034,19 +2033,19 @@ def __init__(self, __u, __coords, *, ga, norm=False, name=None, root='e', debug=
20342033 basis_str = basis_str[:-1]
20352034 """
20362035
2037- #print 'u =', u
2036+ # print 'u =', u
20382037
2039- if isinstance (u ,mv .Mv ): #Define vector manifold
2038+ if isinstance (u ,mv .Mv ): # Define vector manifold
20402039 self .ebasis = []
20412040 for coord in coords :
2042- #Partial derivation of vector function to get basis vectors
2041+ # Partial derivation of vector function to get basis vectors
20432042 self .ebasis .append (u .diff (coord ))
20442043
2045- #print 'sm ebasis =', self.ebasis
2044+ # print 'sm ebasis =', self.ebasis
20462045
20472046 self .g = []
20482047 for b1 in self .ebasis :
2049- #Metric tensor from dot products of basis vectors
2048+ # Metric tensor from dot products of basis vectors
20502049 tmp = []
20512050 for b2 in self .ebasis :
20522051 tmp .append (b1 | b2 )
@@ -2064,12 +2063,12 @@ def __init__(self, __u, __coords, *, ga, norm=False, name=None, root='e', debug=
20642063 tmp .append (diff (x_i , u_j ))
20652064 dxdu .append (tmp )
20662065
2067- #print 'dxdu =', dxdu
2066+ # print 'dxdu =', dxdu
20682067
20692068 sub_pairs = list (zip (ga .coords , u ))
20702069
2071- #Construct metric tensor form coordinate maps
2072- g = eye (n_sub ) #Zero n_sub x n_sub sympy matrix
2070+ # Construct metric tensor form coordinate maps
2071+ g = eye (n_sub ) # Zero n_sub x n_sub sympy matrix
20732072 n_range = list (range (n_sub ))
20742073 for i in n_range :
20752074 for j in n_range :
@@ -2084,8 +2083,8 @@ def __init__(self, __u, __coords, *, ga, norm=False, name=None, root='e', debug=
20842083
20852084 Ga .__init__ (self , root , g = g , coords = coords , norm = norm , debug = debug )
20862085
2087- if isinstance (u ,mv .Mv ): #Construct additional functions for vector manifold
2088- #self.r_basis_mv under construction
2086+ if isinstance (u ,mv .Mv ): # Construct additional functions for vector manifold
2087+ # self.r_basis_mv under construction
20892088
20902089 pass
20912090
0 commit comments