[PyFeyn] Fix for PyX Version Problem

George S. Williams physicist at websterling.com
Mon Jan 27 15:39:34 GMT 2014


Hello, Andy and Georg,

I have developed a solution to the PyX version problem that requires a 
minimal change to deco.py. The solution should also be easy to extend if 
the call to pyx.deco._arrowhead changes again in a future version of PyX.

The change has been tested on my system (Scientific Linux 6.3, PyX 
0.11.1, PyFeyn 0.3.3) and installed from scratch on another (Fedora 12, 
PyX 0.12.1, PyFeyn 0.3.3) All of the examples from PyFeyn 0.3.2 as well 
as my test example rendered correctly on both systems.

I added the following just below the import section in deco.py:
#######################################################
from distutils.version import StrictVersion as Version
pyxversion = Version(pyx.version.version)

def getarrowpath(arrowtopath, selfpos, var1, selfsize, var2, 
constrictionlen):
         if pyxversion >= Version("0.12"):
             arrowpath = pyx.deco._arrowhead(arrowtopath, selfpos,
                                         1, selfsize, 45, 1, 
constrictionlen)
         else:
             arrowpath = pyx.deco._arrowhead(arrowtopath, selfpos,
                                         1, selfsize, 45, constrictionlen)
         return arrowpath

#######################################################

The first 2 lines set the variable 'pyxversion'
The function 'getarrowpath' replaces the pyx.deco._arrowhead call in the 
Arrow and ParallelArrow classes and calls pyx.deco._arrowhead with the 
proper parameters according to the version of PyX being used. It should 
be easy to add another line if PyX changes again.


These are the changes in the Arrow and ParallelArrow classes- the 
commented lines have been replaced:
#######################################################
class Arrow(pyx.deco.deco, pyx.attr.attr):
##        arrowpath = pyx.deco._arrowhead(arrowtopath, 
self.pos*dp.path.arclen(),
##                                        1, self.size, 45, constrictionlen)
         arrowpath = getarrowpath(arrowtopath, self.pos*dp.path.arclen(),
                                         1, self.size, 45, constrictionlen)


class ParallelArrow(Visible):
##                arrowpath = pyx.deco._arrowhead(arrowtopath,
##                                                linepath.arclen(),
##                                                1, self.size, 45,
##                                                constrictionlen)
                 arrowpath = getarrowpath(arrowtopath,
                                                 linepath.arclen(),
                                                 1, self.size, 45,
                                                 constrictionlen)

#######################################################


The __init.py__ included with PyFeyn 0.3.3 had a problem, I think it was 
a latex thing, so I used the one from 
http://www.hepforge.org/lists-archive/pyfeyn/2013-September/000109.html 
and everything worked fine.

Attached is a tarball with all of the relevant files: the modified 
deco.py, both __init__.py, and my test diagram.

If you find this to be useful, please consider it as a contribution to 
the project.

Later,
George
.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: PyFeynFix.tar.gz
Type: application/gzip
Size: 3856 bytes
Desc: not available
URL: <http://www.hepforge.org/lists-archive/pyfeyn/attachments/20140127/8ab4518b/attachment.bin>


More information about the PyFeyn mailing list