Skip to content

Commit df6d338

Browse files
authored
Merge pull request #96 from eric-wieser/simplify-_make_grade
Simplify kwarg parsing in _make_grade
2 parents 09ecbd1 + 0de7425 commit df6d338

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

galgebra/mv.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,17 @@ def add_superscript(root, s):
180180
grade = __grade
181181
if utils.isstr(__name_or_coeffs):
182182
name = __name_or_coeffs
183-
if isinstance(kwargs['f'], bool) and not kwargs['f']: #Is a constant mulitvector function
184-
return sum([Symbol(add_superscript(name, super_script), real=True) * base
185-
for (super_script, base) in zip(ga.blade_super_scripts[grade], ga.blades[grade])])
186-
187-
else:
188-
if isinstance(kwargs['f'], bool): #Is a multivector function of all coordinates
183+
f = kwargs['f']
184+
if isinstance(f, bool):
185+
if f: # Is a multivector function of all coordinates
189186
return sum([Function(add_superscript(name, super_script), real=True)(*ga.coords) * base
190-
for (super_script, base) in zip(ga.blade_super_scripts[grade], ga.blades[grade])])
191-
else: #Is a multivector function of tuple kwargs['f'] variables
192-
return sum([Function(add_superscript(name, super_script), real=True)(*kwargs['f']) * base
193-
for (super_script, base) in zip(ga.blade_super_scripts[grade], ga.blades[grade])])
187+
for (super_script, base) in zip(ga.blade_super_scripts[grade], ga.blades[grade])])
188+
else: # Is a constant multivector function
189+
return sum([Symbol(add_superscript(name, super_script), real=True) * base
190+
for (super_script, base) in zip(ga.blade_super_scripts[grade], ga.blades[grade])])
191+
else: # Is a multivector function of tuple f variables
192+
return sum([Function(add_superscript(name, super_script), real=True)(*f) * base
193+
for (super_script, base) in zip(ga.blade_super_scripts[grade], ga.blades[grade])])
194194
elif isinstance(__name_or_coeffs, (list, tuple)):
195195
coeffs = __name_or_coeffs
196196
if len(coeffs) <= len(ga.blades[grade]):

0 commit comments

Comments
 (0)