|
7 | 7 | from itertools import combinations
|
8 | 8 | import functools
|
9 | 9 | from functools import reduce
|
10 |
| -from typing import Tuple, TypeVar, Callable, Dict |
| 10 | +from typing import Tuple, TypeVar, Callable, Dict, Sequence |
11 | 11 | from ._backports.typing import OrderedDict
|
12 | 12 |
|
13 | 13 | from sympy import (
|
@@ -1976,14 +1976,27 @@ def connection(self, rbase, key_base, mode, left):
|
1976 | 1976 | self.connect[mode_key].append((key, C))
|
1977 | 1977 | return C
|
1978 | 1978 |
|
1979 |
| - def ReciprocalFrame(self, basis, mode='norm'): |
1980 |
| - """ |
1981 |
| - If ``basis`` is a list/tuple of vectors, ``ReciprocalFrame()`` returns a tuple of reciprocal vectors. |
| 1979 | + def ReciprocalFrame(self, basis: Sequence[_mv.Mv], mode: str = 'norm') -> Tuple[_mv.Mv]: |
| 1980 | + r""" |
| 1981 | + Compute the reciprocal frame :math:`v^i` of a set of vectors :math:`v_i`. |
1982 | 1982 |
|
1983 |
| - If ``mode=norm`` the vectors are normalized. |
1984 |
| - If ``mode`` is anything other than ``norm`` the vectors are unnormalized |
1985 |
| - and the normalization coefficient is added to the end of the tuple. |
1986 |
| - One must divide by this coefficient to normalize the vectors. |
| 1983 | + Parameters |
| 1984 | + ---------- |
| 1985 | + basis : |
| 1986 | + The sequence of vectors :math:`v_i` defining the input frame. |
| 1987 | + mode : |
| 1988 | + * ``"norm"`` -- indicates that the reciprocal vectors should be |
| 1989 | + normalized such that their product with the input vectors is 1, |
| 1990 | + :math:`v^i \cdot v_j = \delta_{ij}`. |
| 1991 | + * ``"append"`` -- indicates that instead of normalizing, the |
| 1992 | + normalization coefficient :math:`E^2` should be appended to the returned tuple. |
| 1993 | + One can divide by this coefficient to normalize the vectors. |
| 1994 | + The returned vectors are such that |
| 1995 | + :math:`v^i \cdot v_j = E^2\delta_{ij}`. |
| 1996 | +
|
| 1997 | + .. deprecated:: 0.5.0 |
| 1998 | + Arbitrary strings are interpreted as ``"append"``, but in |
| 1999 | + future will be an error |
1987 | 2000 | """
|
1988 | 2001 | dim = len(basis)
|
1989 | 2002 |
|
@@ -2017,11 +2030,17 @@ def ReciprocalFrame(self, basis, mode='norm'):
|
2017 | 2030 | rbasis.append(recpv)
|
2018 | 2031 | sgn = -sgn
|
2019 | 2032 |
|
2020 |
| - if mode != 'norm': |
2021 |
| - rbasis.append(E_sq) |
2022 |
| - else: |
| 2033 | + if mode == 'norm': |
2023 | 2034 | for i in range(dim):
|
2024 | 2035 | rbasis[i] = rbasis[i] / E_sq
|
| 2036 | + else: |
| 2037 | + if mode != 'append': |
| 2038 | + # galgebra 0.5.0 |
| 2039 | + warnings.warn( |
| 2040 | + "Mode {!r} not understood, falling back to {!r} but this " |
| 2041 | + "is deprecated".format(mode, 'append'), |
| 2042 | + DeprecationWarning, stacklevel=2) |
| 2043 | + rbasis.append(E_sq) |
2025 | 2044 |
|
2026 | 2045 | return tuple(rbasis)
|
2027 | 2046 |
|
|
0 commit comments