Skip to content

Commit

Permalink
Merge pull request #195 from eric-wieser/deprecate-other-members
Browse files Browse the repository at this point in the history
Deprecate compatibility members of Ga objects
  • Loading branch information
utensil authored Dec 19, 2019
2 parents 0b8c38a + 7a03fc6 commit bc6bc28
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
12 changes: 10 additions & 2 deletions galgebra/ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def __init__(self, bases, **kwargs):
self.a = [] # List of dummy vectors for Mlt calculations
self._agrads = {} # cache of gradient operator with respect to vector a
self.dslot = -1 # args slot for dervative, -1 for coordinates
self.XOX = self.mv('XOX','vector') # Versor test vector
self._XOX = self.mv('XOX','vector') # cached vector for use in is_versor

def make_grad(self, a, cmpflg=False): # make gradient operator with respect to vector a

Expand Down Expand Up @@ -484,14 +484,22 @@ def I(self): # Noromalized pseudo-scalar
@property
def mv_I(self):
# This exists for backwards compatibility. Note this is not `I()`!
# galgebra 0.4.5
warnings.warn(
"`ga.mv_I` is deprecated, use `ga.E()` instead, or perhaps `ga.I()`",
DeprecationWarning, stacklevel=2)
# default pseudoscalar
return self.E()

@property
def mv_x(self):
# This exists for backwards compatibility.
# galgebra 0.4.5
warnings.warn(
"`ga.mv_x` is deprecated, use `ga.mv(your_name, 'vector')` instead",
DeprecationWarning, stacklevel=2)
# testing vectors
return Mv('XxXx', 'vector', ga=self)
return mv.Mv('XxXx', 'vector', ga=self)

def X(self):
return self.mv(sum([coord*base for (coord, base) in zip(self.coords, self.basis)]))
Expand Down
2 changes: 1 addition & 1 deletion galgebra/mv.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ def is_versor(self):
if not test.is_scalar():
return self.versor_flg
# see if self*x*self.rev() returns a vector for x an arbitrary vector
test = self * self.Ga.XOX * self.rev()
test = self * self.Ga._XOX * self.rev()
self.versor_flg = test.is_vector()
return self.versor_flg

Expand Down
9 changes: 9 additions & 0 deletions test/test_mv.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import unittest

import pytest
from sympy import Symbol
from galgebra.ga import Ga
from galgebra import utils

class TestMv(unittest.TestCase):

def test_deprecations(self):
ga, e_1, e_2, e_3 = Ga.build('e*1|2|3')
with pytest.warns(DeprecationWarning):
ga.mv_x
with pytest.warns(DeprecationWarning):
ga.mv_I

def test_is_base(self):
"""
Various tests on several multivectors.
Expand Down

0 comments on commit bc6bc28

Please sign in to comment.