Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4866352
Remove .pyc files and add standard .gitignore for python
utensil May 8, 2016
2d6606e
A minimal setup.py that works
utensil May 8, 2016
7ec591e
Add option --noconflict
utensil May 8, 2016
907c920
Make setuptools recognize tests
utensil May 15, 2016
bfe9064
Bypass test_test to run test_mv
utensil May 15, 2016
3c25e96
Pass test_basic_multivector_operations
utensil May 15, 2016
271897a
Pass check_generalized_BAC_CAB_formulas with failed simplification
utensil May 15, 2016
0b97cac
Print_Function() is not required
utensil May 15, 2016
7b9425e
(a|(b^c))+(c|(a^b))+(b|(c^a)).simplify() => 0
utensil May 15, 2016
d3d8153
Pass test_derivatives_in_rectangular_coordinates
utensil May 15, 2016
df77bfa
Postpone 3 cases to pass test_derivatives_in_spherical_coordinates
utensil May 15, 2016
c992cae
Verified and pass grad|A
utensil May 16, 2016
eb254e6
Verified -s3d.I()*(grad^A)
utensil May 16, 2016
7347fb0
Verified grad^B but found a print_latex bug
utensil May 21, 2016
b646014
Pass test_rounding_numerical_components
utensil May 21, 2016
efe76f4
Pass test_noneuclidian_distance_calculation with postponed tests
utensil May 22, 2016
498a16b
Merge branch 'master' of https://github.com/brombo/galgebra into 14-pip
utensil Jun 9, 2016
7abb105
Pass the rest of tests
utensil Jun 9, 2016
50cb844
Code clean up
utensil Jun 9, 2016
6f01094
Fixes #19
utensil Jun 27, 2016
10a16cc
Fixes #20
utensil Jun 27, 2016
ba2230e
git pull upstream master and resolve conflicts
utensil Sep 15, 2018
abe1a00
Merge brombo/galgebra#15 and resolve conflicts
utensil Sep 19, 2018
8d55fa4
Run `2to3 -w *.py`
utensil Sep 19, 2018
97612fe
Pass tests under py3
utensil Sep 19, 2018
db89f83
Add .travis.yml
utensil Sep 19, 2018
4c275ea
Update setup.py
utensil Sep 19, 2018
01c9d7b
Add "from __future__ import" triple
utensil Sep 19, 2018
2838a1c
Remove cirular dependencies
utensil Sep 20, 2018
3a81bbd
Verify and remove old tests
utensil Sep 20, 2018
d4c5efd
Accept equivalent results
utensil Sep 20, 2018
4c41528
Fix more py3 tests
utensil Sep 20, 2018
b4a3672
Fix py2 tests
utensil Sep 20, 2018
582f8a1
Pass both py 2 & 3 tests
utensil Sep 20, 2018
3a29736
Revert to using the legacy Rational HALF
utensil Sep 21, 2018
0f7c76c
Clean up obsolete code in setup.py and make it simple
utensil Sep 21, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ __pycache__/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand Down Expand Up @@ -43,7 +44,7 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
*.cover
*.covercover
.hypothesis/

# Translations
Expand Down Expand Up @@ -102,3 +103,9 @@ venv.bak/

# mypy
.mypy_cache/

# py.test cache
.pytest_cache

# backup files from 2to3
**/*.bak
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

sudo: false

language: python

matrix:
include:
- os: linux
python: '2.7'
env: CONDA=true
# Remove too many targets for now to speed up a build
# - os: linux
# python: '3.5'
# env: CONDA=true
- os: linux
python: '3.6'
env: CONDA=true


before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then lsb_release -a ; fi

install:
- python setup.py install

script:
- py.test galgebra/test_test.py
- py.test galgebra/test_mv.py
71 changes: 38 additions & 33 deletions galgebra/ga.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ga.py

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import operator
import copy
from sympy import diff, Rational, Symbol, S, Mul, Pow, Add, \
Expand All @@ -9,10 +13,11 @@
from collections import OrderedDict
#from sympy.core.compatibility import combinations
from itertools import combinations
import printer
import metric
import mv
import lt
from . import printer
from . import metric
from . import mv
from . import lt
from functools import reduce

half = Rational(1, 2)
one = S(1)
Expand Down Expand Up @@ -104,7 +109,7 @@ def nc_subs(expr, base_keys, base_values=None):
keys for long lists of keys.
"""
if base_values is None:
[base_keys, base_values] = zip(*base_keys)
[base_keys, base_values] = list(zip(*base_keys))

if expr.is_commutative:
return expr
Expand All @@ -129,7 +134,7 @@ def nc_subs(expr, base_keys, base_values=None):


class Ga(metric.Metric):
"""
r"""
The vector space (basis, metric, derivatives of basis vectors) is
defined by the base class 'Metric'.

Expand Down Expand Up @@ -299,7 +304,7 @@ def preset(setting, root='e', debug=False):
return Ga(*kargs, **kwargs)

def __eq__(self, ga):
if self.name == self.ga:
if self.name == ga.name:
return True
return False

Expand Down Expand Up @@ -356,7 +361,7 @@ def __init__(self, bases, **kwargs):
if self.e_sq.is_number:
if self.e_sq == S(0):
self.sing_flg = True
print '!!!!If I**2 = 0, I cannot be normalized!!!!'
print('!!!!If I**2 = 0, I cannot be normalized!!!!')
#raise ValueError('!!!!If I**2 = 0, I cannot be normalized!!!!')
if self.e_sq > S(0):
self.i = self.e/sqrt(self.e_sq)
Expand All @@ -379,7 +384,7 @@ def __init__(self, bases, **kwargs):
self.grads()

if self.debug:
print 'Exit Ga.__init__()'
print('Exit Ga.__init__()')

self.a = [] # List of dummy vectors for Mlt calculations
self.agrads = {} # Gradient operator with respect to vector a
Expand All @@ -393,7 +398,7 @@ def make_grad(self, a, cmpflg=False): # make gradient operator with respect to
self.make_grad(ai)
return

if a in self.agrads.keys():
if a in list(self.agrads.keys()):
return self.agrads[a]

if isinstance(a, mv.Mv):
Expand Down Expand Up @@ -467,7 +472,7 @@ def mv(self, root=None, *kargs, **kwargs):
return mv.Mv(root, *kargs, **kwargs)

def mvr(self,norm=True):
"""
r"""
Returns tumple of reciprocal basis vectors. If norm=True or
basis vectors are orthogonal the reciprocal basis is normalized
in the sense that
Expand Down Expand Up @@ -765,7 +770,7 @@ def basis_product_tables(self):

self.dot_mode = '|'
if self.debug:
print 'Exit basis_product_tables.\n'
print('Exit basis_product_tables.\n')
return

def build_connection(self):
Expand Down Expand Up @@ -1056,7 +1061,7 @@ def non_orthogonal_mul_table(self):
self.basic_mul_table_dict = OrderedDict(mul_table)

if self.debug:
print 'basic_mul_table =\n', self.basic_mul_table
print('basic_mul_table =\n', self.basic_mul_table)
return

def non_orthogonal_bases_products(self, base12): # base12 = (base1,base2)
Expand Down Expand Up @@ -1103,10 +1108,10 @@ def base_blade_conversions(self):
blade_expansion.append(expand(a_W_A))

self.blade_expansion = blade_expansion
self.blade_expansion_dict = OrderedDict(zip(self.blades_lst, blade_expansion))
self.blade_expansion_dict = OrderedDict(list(zip(self.blades_lst, blade_expansion)))

if self.debug:
print 'blade_expansion_dict =', self.blade_expansion_dict
print('blade_expansion_dict =', self.blade_expansion_dict)

# expand base basis in terms of blade basis

Expand All @@ -1126,7 +1131,7 @@ def base_blade_conversions(self):
self.base_expansion_dict = OrderedDict(base_expand)

if self.debug:
print 'base_expansion_dict =', self.base_expansion_dict
print('base_expansion_dict =', self.base_expansion_dict)

return

Expand Down Expand Up @@ -1236,7 +1241,7 @@ def grade_decomposition(self, A):
grade_dict = {}
for (coef,blade) in zip(coefs,blades):
if blade == one:
if 0 in grade_dict.keys():
if 0 in list(grade_dict.keys()):
grade_dict[0] += coef
else:
grade_dict[0] = coef
Expand All @@ -1247,7 +1252,7 @@ def grade_decomposition(self, A):
else:
grade_dict[grade] = coef * blade
if isinstance(A, mv.Mv):
for grade in grade_dict.keys():
for grade in list(grade_dict.keys()):
grade_dict[grade] = self.mv(grade_dict[grade])
return grade_dict

Expand Down Expand Up @@ -1422,7 +1427,7 @@ def even_odd(self, A, even=True): # Return even or odd part of A
##################### Multivector derivatives ######################

def build_reciprocal_basis(self,gsym):
"""
r"""
Calculate reciprocal basis vectors e^{j} where
e^{j}\cdot e_{k} = \delta_{k}^{j}
and \delta_{k}^{j} is the kronecker delta. We use the formula
Expand All @@ -1439,7 +1444,7 @@ def build_reciprocal_basis(self,gsym):
"""

if self.debug:
print 'Enter build_reciprocal_basis.\n'
print('Enter build_reciprocal_basis.\n')

if self.is_ortho:
self.r_basis = [self.basis[i] / self.g[i, i] for i in self.n_range]
Expand All @@ -1462,7 +1467,7 @@ def build_reciprocal_basis(self,gsym):
else:
self.e_sq = simplify((self.e * self.e).obj)
if self.debug:
print 'E**2 =', self.e_sq
print('E**2 =', self.e_sq)
duals = list(self.blades_lst[-(self.n + 1):-1])
duals.reverse()

Expand All @@ -1477,14 +1482,14 @@ def build_reciprocal_basis(self,gsym):
if self.debug:
printer.oprint('E', self.iobj, 'E**2', self.e_sq, 'unnormalized reciprocal basis =\n', self.r_basis)
self.dot_mode = '|'
print 'reciprocal basis test ='
print('reciprocal basis test =')
for ei in self.basis:
for ej in self.r_basis:
ei_dot_ej = self.dot(ei, ej)
if ei_dot_ej == zero:
print 'e_{i}|e_{j} = ' + str(ei_dot_ej)
print('e_{i}|e_{j} = ' + str(ei_dot_ej))
else:
print 'e_{i}|e_{j} = ' + str(expand(ei_dot_ej / self.e_sq))
print('e_{i}|e_{j} = ' + str(expand(ei_dot_ej / self.e_sq)))

self.e_obj = self.blades_lst[-1]

Expand Down Expand Up @@ -1527,7 +1532,7 @@ def build_reciprocal_basis(self,gsym):
self.g_inv = g_inv

if self.debug:
print 'reciprocal basis dictionary =\n', self.r_basis_dict
print('reciprocal basis dictionary =\n', self.r_basis_dict)

# True is for left derivative and False is for right derivative
self.deriv = {('*', True): [], ('^', True): [], ('|', True): [],
Expand Down Expand Up @@ -1663,9 +1668,9 @@ def grad_sqr(self, A, grad_sqr_mode, mode, left):
mode = *_{2} = *, ^, or |.
"""
(Sop, Bop) = Ga.DopFop[(grad_sqr_mode, mode)]
print '(Sop, Bop) =', Sop, Bop
print('(Sop, Bop) =', Sop, Bop)

print 'grad_sqr:A =', A
print('grad_sqr:A =', A)

self.dot_mode == '|'
s = zero
Expand All @@ -1677,7 +1682,7 @@ def grad_sqr(self, A, grad_sqr_mode, mode, left):
for coord_i in self.coords:
dA_i.append(self.pDiff(A, coord_i))

print 'dA_i =', dA_i
print('dA_i =', dA_i)

if Sop:
for i in self.n_range:
Expand All @@ -1692,8 +1697,8 @@ def grad_sqr(self, A, grad_sqr_mode, mode, left):
if Bop and self.connect_flg:
for i in self.n_range:
coord_i = self.coords[i]
print 'mode =', mode
print 'dA_i[i] =', dA_i[i]
print('mode =', mode)
print('dA_i[i] =', dA_i[i])
if left:
if mode == '|':
s += self.dot(self.grad_sq_mv_connect[coord_i], dA_i[i])
Expand Down Expand Up @@ -1882,11 +1887,11 @@ def __init__(self, *kargs, **kwargs):

#print 'dxdu =', dxdu

sub_pairs = zip(ga.coords, u)
sub_pairs = list(zip(ga.coords, u))

#Construct metric tensor form coordinate maps
g = eye(n_sub) #Zero n_sub x n_sub sympy matrix
n_range = range(n_sub)
n_range = list(range(n_sub))
for i in n_range:
for j in n_range:
s = zero
Expand All @@ -1912,7 +1917,7 @@ def __init__(self, *kargs, **kwargs):
self.u = u

if debug:
print 'Exit Sm.__init__()'
print('Exit Sm.__init__()')

def vpds(self):
if not self.is_ortho:
Expand Down
Loading