deprecated.py
1 import warnings 2 3 from . import ga 4 from .mv import Mv 5 6 # galgebra 0.5.0 7 warnings.warn( 8 "The `galgebra.deprecated` module is deprecated", 9 DeprecationWarning, stacklevel=2) 10 11 ################################# MV class for backward compatibility ################### 12 13 14 class MV(Mv): 15 """ A deprecated version of :class:`galgebra.mv.Mv`. """ 16 17 @staticmethod 18 def convert_metric(gstr): 19 if gstr[0] == '[' and gstr[-1] == ']': 20 gstr_lst = gstr[1:-1].split(',') 21 g = [] 22 for x in gstr_lst: 23 g.append(int(x)) 24 return g 25 else: 26 return gstr 27 28 @staticmethod 29 def setup(basis, metric=None, coords=None, rframe=False, debug=False, curv=(None, None)) -> list: 30 """ 31 This function allows a single geometric algebra to be created. 32 33 If the function is called more than once the old geometric algebra is 34 overwritten by the new geometric algebra. The named input ``metric`` 35 is the same as the named input ``g`` in the current version of 36 *galgebra*. Likewise, ``basis``, ``coords``, and ``debug`` are the same 37 in the old and current versions of *galgebra* [17]_. 38 Due to improvements in *sympy* the inputs ``rframe`` and ``curv[1]`` are 39 no longer required. ``curv[0]`` is the vector function (list or tuple of 40 scalar functions) of the coordinates required to define a vector manifold. 41 For compatibility with the old version of *galgebra* if ``curv`` is used 42 ``metric`` should be a orthonormal Euclidean metric of the same 43 dimension as ``curv[0]``. 44 45 It is strongly suggested that one use the new methods of defining a 46 geometric algebra on a manifold. 47 48 .. [17] 49 If the metric is input as a list or list or lists the object is no 50 longer quoted (input as a string). For example the old 51 ``metric='[1,1,1]'`` becomes ``metric=[1,1,1]``. 52 """ 53 54 if isinstance(metric, str): 55 metric = MV.convert_metric(metric) 56 if curv != (None, None): 57 MV.GA = ga.Ga(basis, g=None, coords=coords, X=curv[0], debug=debug) 58 else: 59 MV.GA = ga.Ga(basis, g=metric, coords=coords, X=curv[0], debug=debug) 60 MV.I = MV.GA.i 61 MV.metric = MV.GA.g 62 if coords is not None: 63 MV.grad, MV.rgrad = MV.GA.grads() 64 return list(MV.GA.mv()) + [MV.grad] 65 else: 66 return list(MV.GA.mv()) 67 68 def __init__(self, base, mvtype, fct=None, blade_rep=True): 69 # galgebra 0.5.0 70 warnings.warn( 71 "The `galgebra.deprecated.MV` class is deprecated in favor of " 72 "`galgebra.mv.Mv`.", 73 DeprecationWarning, stacklevel=2) 74 kwargs = {} 75 if fct is not None: 76 kwargs['f'] = fct # only forward this argument if we received it 77 Mv.__init__(self, base, mvtype, ga=MV.GA, **kwargs) 78 79 def Fmt(self, fmt=1, title=None) -> None: 80 """ 81 ``Fmt`` in ``MV`` has inputs identical to ``Fmt`` in ``Mv`` except that 82 if ``A`` is a multivector then ``A.Fmt(2,'A')`` executes a print 83 statement from ``MV`` and returns ``None``, while from ``Mv``, 84 ``A.Fmt(2,'A')`` returns a string so that the function is compatible 85 with use in *ipython notebook*. 86 """ 87 print(Mv.Fmt(self, fmt=fmt, title=title)) 88 89 90 def ReciprocalFrame(basis, mode='norm'): 91 # galgebra 0.5.0 92 warnings.warn( 93 "The `galgebra.deprecated.ReciprocalFrame` function is deprecated in " 94 "favor of the `ReciprocalFrame` method of `Ga` objects.", 95 DeprecationWarning, stacklevel=2) 96 GA = basis[0].Ga 97 return GA.ReciprocalFrame(basis, mode=mode)