Skip to content

Commit bc6bc28

Browse files
authored
Merge pull request #195 from eric-wieser/deprecate-other-members
Deprecate compatibility members of Ga objects
2 parents 0b8c38a + 7a03fc6 commit bc6bc28

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

galgebra/ga.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def __init__(self, bases, **kwargs):
447447
self.a = [] # List of dummy vectors for Mlt calculations
448448
self._agrads = {} # cache of gradient operator with respect to vector a
449449
self.dslot = -1 # args slot for dervative, -1 for coordinates
450-
self.XOX = self.mv('XOX','vector') # Versor test vector
450+
self._XOX = self.mv('XOX','vector') # cached vector for use in is_versor
451451

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

@@ -484,14 +484,22 @@ def I(self): # Noromalized pseudo-scalar
484484
@property
485485
def mv_I(self):
486486
# This exists for backwards compatibility. Note this is not `I()`!
487+
# galgebra 0.4.5
488+
warnings.warn(
489+
"`ga.mv_I` is deprecated, use `ga.E()` instead, or perhaps `ga.I()`",
490+
DeprecationWarning, stacklevel=2)
487491
# default pseudoscalar
488492
return self.E()
489493

490494
@property
491495
def mv_x(self):
492496
# This exists for backwards compatibility.
497+
# galgebra 0.4.5
498+
warnings.warn(
499+
"`ga.mv_x` is deprecated, use `ga.mv(your_name, 'vector')` instead",
500+
DeprecationWarning, stacklevel=2)
493501
# testing vectors
494-
return Mv('XxXx', 'vector', ga=self)
502+
return mv.Mv('XxXx', 'vector', ga=self)
495503

496504
def X(self):
497505
return self.mv(sum([coord*base for (coord, base) in zip(self.coords, self.basis)]))

galgebra/mv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ def is_versor(self):
981981
if not test.is_scalar():
982982
return self.versor_flg
983983
# see if self*x*self.rev() returns a vector for x an arbitrary vector
984-
test = self * self.Ga.XOX * self.rev()
984+
test = self * self.Ga._XOX * self.rev()
985985
self.versor_flg = test.is_vector()
986986
return self.versor_flg
987987

test/test_mv.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import unittest
2+
3+
import pytest
24
from sympy import Symbol
35
from galgebra.ga import Ga
46
from galgebra import utils
57

68
class TestMv(unittest.TestCase):
79

10+
def test_deprecations(self):
11+
ga, e_1, e_2, e_3 = Ga.build('e*1|2|3')
12+
with pytest.warns(DeprecationWarning):
13+
ga.mv_x
14+
with pytest.warns(DeprecationWarning):
15+
ga.mv_I
16+
817
def test_is_base(self):
918
"""
1019
Various tests on several multivectors.

0 commit comments

Comments
 (0)