Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cmp= in mv.py (brombo/galgebra#34) #126

Closed
eric-wieser opened this issue Dec 4, 2019 · 1 comment
Closed

fix cmp= in mv.py (brombo/galgebra#34) #126

eric-wieser opened this issue Dec 4, 2019 · 1 comment
Labels
from brombo/galgebra Scraped from old webcaches of the now-deleted https://github.com/brombo/galgebra

Comments

@eric-wieser
Copy link
Member

eric-wieser commented Dec 4, 2019

@chaowenguo commented on Jan 19, 2017

example:

import ga,sympy
bases=ga.Ga('e_t|x',g=[1,-1],coords=sympy.symbols('t,x',real=True))

print bases.grad

If I use python -3 to run the source code, it will show:
mv.py:1485: DeprecationWarning: the cmp argument is not supported in 3.x
self.terms.sort(key=operator.itemgetter(1), cmp=Pdop.compare)
that means you can not use cmp in sort in python3.

I look at all the program, just line 1485 in mv.py use Pdop.compare, so just change line 1485 in mv.py into
self.terms.sort(key=Pdop.compare)

change the whole definition of Pdop.compare in line 1765 in mv.py into:

def compare(pdop): # compare two Pdops
keys = list(pdop[1].pdiffs.keys())
return (pdop[1].order,-len(keys),''.join([str(pdop[1].Ga.coords.index(x)) for x in keys]))

Now use order to sort first aka to
if pdop1.order > pdop2.order:
return 1
if pdop1.order < pdop2.order:
return -1

-len(keys) to sort second aka to
if lkeys1 < lkeys2:
return 1
else:
return -1

''.join([str(pdop[1].Ga.coords.index(x)) for x in keys]) to sort third aka to
if lkeys1 == lkeys2:
s1 = ''.join([str(pdop1.Ga.coords.index(x)) for x in keys1])
s2 = ''.join([str(pdop1.Ga.coords.index(x)) for x in keys2])
if s1 < s2:
return -1
else:
return 1
reference https://docs.python.org/3/howto/sorting.html


From http://cc.bingj.com/cache.aspx?q=https%3a%2f%2fgithub.com%2fbrombo%2fgalgebra%2fissues%2f34&d=5055631851848655&mkt=en-GB&setlang=en-US&w=lez4CYMwRC77CTRGlKMukgviK_qX7JO6

@eric-wieser eric-wieser created this issue from a note in Fix lingering issues in brombo/galgebra (Needs triage) Dec 4, 2019
@eric-wieser eric-wieser added the from brombo/galgebra Scraped from old webcaches of the now-deleted https://github.com/brombo/galgebra label Dec 4, 2019
@eric-wieser
Copy link
Member Author

This was fixed in e727e9e, although we could do some more cleanup here if we wanted.

Fix lingering issues in brombo/galgebra automation moved this from Needs triage to Done Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from brombo/galgebra Scraped from old webcaches of the now-deleted https://github.com/brombo/galgebra
Development

No branches or pull requests

1 participant