Skip to content

Commit

Permalink
lt: Deprecate .mode and .fct_flg
Browse files Browse the repository at this point in the history
These attributes did not contain correct values if the non-string constructor was used.
This corrects the implementation, but also deprecates it because its not clear that it's useful anyway.
  • Loading branch information
eric-wieser committed Sep 23, 2020
1 parent c4355fa commit 8332473
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
30 changes: 27 additions & 3 deletions galgebra/lt.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,32 @@ def X(self):
DeprecationWarning, stacklevel=2)
return self.Ga.coord_vec

@property
def mode(self):
# galgebra 0.6.0
warnings.warn(
"lt.mode is deprecated, inspect lt.matrix() and its transpose to "
"determine symmetry",
DeprecationWarning, stacklevel=2)
m = self.matrix()
if m == m.T:
return 's'
elif m == -m.T:
return 'a'
else:
return 'g'

@property
def fct_flg(self):
# galgebra 0.6.0
warnings.warn(
"lt.fct_flg is deprecated, inspect lt.matrix().free_symbols to "
"determine coordinate-dependence",
DeprecationWarning, stacklevel=2)
if self.Ga.coords is None:
return False
return set(self.Ga.coords) <= self.matrix().free_symbols

def __init__(self, *args, ga, f=False, mode='g'):
"""
__init__(self, *args, ga, **kwargs)
Expand Down Expand Up @@ -222,8 +248,6 @@ def __init__(self, *args, ga, f=False, mode='g'):
Only supported in the string constructor.
"""
mat_rep = args[0]
self.fct_flg = f
self.mode = mode
self.Ga = ga
self.spinor = False
self.rho_sq = None
Expand Down Expand Up @@ -265,7 +289,7 @@ def __init__(self, *args, ga, f=False, mode='g'):
raise ValueError('In Spinor input for Lt, S*S.rev() not a scalar!\n')

elif isinstance(mat_rep, str): # String input
Amat = Symbolic_Matrix(mat_rep, coords=self.Ga.coords, mode=self.mode, f=self.fct_flg)
Amat = Symbolic_Matrix(mat_rep, coords=self.Ga.coords, mode=mode, f=f)
self.__init__(Amat, ga=self.Ga)

elif callable(mat_rep): # Linear multivector function input
Expand Down
13 changes: 13 additions & 0 deletions test/test_lt.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ def test_deprecations(self):
with pytest.warns(DeprecationWarning):
assert l.coords == l.Ga.coords

l = base.lt('L', mode='a')
with pytest.warns(DeprecationWarning):
assert l.mode == 'a'
with pytest.warns(DeprecationWarning):
assert not l.fct_flg

l = base.lt('L', mode='s', f=True)
with pytest.warns(DeprecationWarning):
assert l.mode == 's'
with pytest.warns(DeprecationWarning):
assert l.fct_flg



class TestMlt(unittest.TestCase):

Expand Down

0 comments on commit 8332473

Please sign in to comment.