Skip to content

Commit

Permalink
Merge pull request #212 from eric-wieser/drop-python-2.7
Browse files Browse the repository at this point in the history
Drop python 2.7
  • Loading branch information
utensil authored Jan 4, 2020
2 parents bd43141 + 33ddee7 commit a8466cf
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 195 deletions.
5 changes: 0 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ jobs:
<<: *defaults
docker:
- image: circleci/python:3.5
"python-2.7":
<<: *defaults
docker:
- image: circleci/python:2.7
"publish":
docker:
- image: circleci/python:3.7
Expand All @@ -89,7 +85,6 @@ workflows:
only: /^v.*$/
- "python-3.6"
- "python-3.5"
- "python-2.7"
- publish:
requires:
- "python-3.7"
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: python
matrix:
include:
- os: linux
python: '2.7'
python: '3.5'
env: CONDA=true
- os: linux
python: '3.6'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Installing GAlgebra
### Prerequisites

- Works on Linux, Windows, Mac OSX
- [Python](https://www.python.org/) 2.7 or >=3.5
- [Python](https://www.python.org/) >=3.5
- [SymPy](https://www.sympy.org) 1.3, 1.4 or preferably 1.5

### Installing GAlgebra From PyPI (Recommended for users)
Expand Down
2 changes: 0 additions & 2 deletions doc/python/BACCAB.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division
from __future__ import print_function
from galgebra.printer import Format, xpdf
from galgebra.ga import Ga

Expand Down
2 changes: 0 additions & 2 deletions doc/python/Dirac.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division
from __future__ import print_function
import sys
from sympy import symbols, sin, cos
from galgebra.printer import Format, xpdf, Get_Program, Print_Function
Expand Down
2 changes: 0 additions & 2 deletions doc/python/Dop.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division
from __future__ import print_function
from sympy import symbols, sin
from galgebra.printer import Format, xpdf
from galgebra.ga import Ga
Expand Down
2 changes: 0 additions & 2 deletions doc/python/EMWaves.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division
from __future__ import print_function
import sys
from sympy import symbols, exp, I, Matrix, solve, simplify
from galgebra.printer import Format, xpdf, Get_Program, Print_Function
Expand Down
2 changes: 0 additions & 2 deletions doc/python/LinearTrans.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division
from __future__ import print_function
from sympy import symbols, sin, cos
from galgebra.ga import Ga
from galgebra.printer import Format, xpdf
Expand Down
2 changes: 0 additions & 2 deletions doc/python/Ltrans.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division
from __future__ import print_function
from sympy import symbols, sin, cos, latex
from galgebra.ga import Ga
from galgebra.printer import Format, xpdf
Expand Down
2 changes: 0 additions & 2 deletions doc/python/ReciprocalBasis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division
from __future__ import print_function
from sympy import expand, simplify
from galgebra.printer import Format, xpdf
from galgebra.ga import Ga
Expand Down
2 changes: 0 additions & 2 deletions doc/python/SphericalCoordinates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division
from __future__ import print_function
import sys
from sympy import symbols, sin
from galgebra.printer import Format, xpdf
Expand Down
2 changes: 0 additions & 2 deletions doc/python/submanifold.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division
from __future__ import print_function
from sympy import symbols, sin, pi, latex
from galgebra.ga import Ga
from galgebra.printer import Format, xpdf
Expand Down
2 changes: 0 additions & 2 deletions galgebra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@
utils
"""

from __future__ import absolute_import, division
from __future__ import print_function
from ._version import __version__
3 changes: 1 addition & 2 deletions galgebra/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from sympy import trigsimp, S
from . import ga
from .mv import Mv
from . import utils

################################# MV class for backward compatibility ###################

Expand All @@ -23,7 +22,7 @@ def convert_metric(gstr):
@staticmethod
def setup(basis, metric=None, coords=None, rframe=False, debug=False, curv=(None,None)):

if utils.isstr(metric):
if isinstance(metric, str):
metric = MV.convert_metric(metric)
if curv != (None,None):
MV.GA = ga.Ga(basis, g=None, coords=coords, X=curv[0], debug=debug)
Expand Down
98 changes: 50 additions & 48 deletions galgebra/ga.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Geometric Algebra (inherits Metric)
"""
import sys
import warnings
import operator
import copy
Expand All @@ -20,7 +19,6 @@
from . import metric
from . import mv
from . import lt
from . import utils

half = Rational(1, 2)
one = S(1)
Expand Down Expand Up @@ -377,20 +375,24 @@ def __hash__(self):
def __eq__(self, ga):
return self.name == ga.name

if sys.version_info.major < 3:
def __ne__(self, other):
return not (self == other)

def __init__(self, bases, **kwargs):
def __init__(self, bases, *, wedge=True, **kwargs):
"""
Parameters
----------
bases :
Passed as ``basis`` to ``Metric``.
wedge :
Use ``^`` symbol to print basis blades
**kwargs :
See :class:`galgebra.metric.Metric`.
"""

# Each time a geometric algebra is intialized in setup of append
# the printer must be restored to the simple text mode (not
# enhanced text of latex printing) so that when 'str' is used to
# create symbol names the names are not mangled.

kwargs = metric.test_init_slots(metric.Metric.init_slots, **kwargs)

self.wedge_print = kwargs['wedge']
self.wedge_print = wedge

if printer.GaLatexPrinter.latex_flg:
printer.GaLatexPrinter.restore()
Expand Down Expand Up @@ -545,7 +547,7 @@ def mv(self, root=None, *args, **kwargs):
# ensure that ga is not already in kwargs
kwargs = dict(ga=self, **kwargs)

if not utils.isstr(root):
if not isinstance(root, str):
return mv.Mv(root, *args, **kwargs)

if ' ' in root and ' ' not in args[0]:
Expand Down Expand Up @@ -1903,31 +1905,10 @@ class Sm(Ga):
the coordinates of the submanifold. The inputs required to define
the submanifold are:
Parameters
----------
u :
(``args[0]``) The coordinate map defining the submanifold
which is a list of functions of coordinates of the base
manifold in terms of the coordinates of the submanifold.
for example if the manifold is a unit sphere then -
``u = [sin(u)*cos(v),sin(u)*sin(v),cos(u)]``.
Alternatively (``args[0]``) is a parametric vector function
of the basis vectors of the base manifold. The
coefficients of the bases are functions of the coordinates
(``args[1]``). In this case we would call the submanifold
a "vector" manifold and additional characteristics of the
manifold can be calculated since we have given an explicit
embedding of the manifold in the base manifold.
coords :
(``args[1]``) The coordinate list for the submanifold, for
example ``[u, v]``.
Notes
-----
See 'init_slots' for possible other inputs. The 'Ga' member function
The 'Ga' member function
'sm' can be used to instantiate the submanifold via (o3d is the base
manifold)::
Expand All @@ -1937,24 +1918,49 @@ class Sm(Ga):
(eu,ev) = sm_example.mv()
sm_grad = sm_example.grad
"""
init_slots = {'debug': (False, 'True for debug output'),
'root': ('e', 'Root symbol for basis vectors'),
'name': (None, 'Name of submanifold'),
'norm': (False, 'Normalize basis if True'),
'ga': (None, 'Base Geometric Algebra')}

def __init__(self, *args, **kwargs):
# __u is to emulate a Python 3.8 positional-only argument, with a clearer
# spelling than `*args`.
def __init__(self, __u, __coords, *, ga, norm=False, name=None, root='e', debug=False):
"""
Parameters
----------
u :
The coordinate map defining the submanifold
which is a list of functions of coordinates of the base
manifold in terms of the coordinates of the submanifold.
for example if the manifold is a unit sphere then -
``u = [sin(u)*cos(v),sin(u)*sin(v),cos(u)]``.
Alternatively, a parametric vector function
of the basis vectors of the base manifold. The
coefficients of the bases are functions of the coordinates
(``coords``). In this case we would call the submanifold
a "vector" manifold and additional characteristics of the
manifold can be calculated since we have given an explicit
embedding of the manifold in the base manifold.
coords :
The coordinate list for the submanifold, for
example ``[u, v]``.
debug :
True for debug output
root : str
Root symbol for basis vectors
name : str
Name of submanifold
norm : bool
Normalize basis if True
ga :
Base Geometric Algebra
"""

#print '!!!Enter Sm!!!'

if printer.GaLatexPrinter.latex_flg:
printer.GaLatexPrinter.restore()
Ga.restore = True

kwargs = metric.test_init_slots(Sm.init_slots, **kwargs)
u = args[0] # Coordinate map or vector embedding to define submanifold
coords = args[1] # List of cordinates
ga = kwargs['ga'] # base geometric algebra
u = __u
coords = __coords
if ga is None:
raise ValueError('Base geometric algebra must be specified for submanifold.')

Expand All @@ -1963,7 +1969,6 @@ def __init__(self, *args, **kwargs):
n_sub = len(coords)

# Construct names of basis vectors
root = kwargs['root']
"""
basis_str = ''
for x in coords:
Expand Down Expand Up @@ -2016,9 +2021,6 @@ def __init__(self, *args, **kwargs):
s += dxdu[k][i] * dxdu[l][j] * g_base[k, l].subs(sub_pairs)
g[i, j] = trigsimp(s)

norm = kwargs['norm']
debug = kwargs['debug']

if Ga.restore: # restore printer to appropriate enhanced mode after sm is instantiated
printer.GaLatexPrinter.redirect()

Expand Down
27 changes: 15 additions & 12 deletions galgebra/lt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from . import printer
from . import metric
from . import mv
from . import utils

def aprint(a):
out = ''
Expand Down Expand Up @@ -149,9 +148,6 @@ class Lt(object):
"""

mat_fmt = False
init_slots = {'ga': (None, 'Name of metric (geometric algebra)'),
'f': (False, 'True if Lt if function of coordinates.'),
'mode': ('g', 'g:general, s:symmetric, a:antisymmetric transformation.')}

@staticmethod
def setup(ga):
Expand All @@ -165,13 +161,20 @@ def format(mat_fmt=False):
Lt.mat_fmt = mat_fmt
return

def __init__(self, *args, **kwargs):
kwargs = metric.test_init_slots(Lt.init_slots, **kwargs)

def __init__(self, *args, ga, f=False, mode='g'):
"""
Parameters
----------
ga :
Name of metric (geometric algebra)
f : bool
True if Lt if function of coordinates
mode : str
g:general, s:symmetric, a:antisymmetric transformation
"""
mat_rep = args[0]
ga = kwargs['ga']
self.fct_flg = kwargs['f']
self.mode = kwargs['mode'] # General g, s, or a transformation
self.fct_flg = f
self.mode = mode
self.Ga = ga
self.coords = ga.lt_coords
self.X = ga.lt_x
Expand Down Expand Up @@ -221,7 +224,7 @@ def __init__(self, *args, **kwargs):
else:
raise ValueError('In Spinor input for Lt, S*S.rev() not a scalar!\n')

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

Expand Down Expand Up @@ -726,7 +729,7 @@ def __init__(self, f, Ga, args, fct=False):
Ga.make_grad(self.args)
self.fvalue = (self.args[0] | f(self.args[1])).obj
self.f = None
elif utils.isstr(f) and args is not None:
elif isinstance(f, str) and args is not None:
self.f = None
if isinstance(args,(list,tuple)):
self.args = args
Expand Down
Loading

0 comments on commit a8466cf

Please sign in to comment.