[PyFeyn] Fix for PyX Version Problem

Georg von Hippel hippel at kph.uni-mainz.de
Mon Jan 27 18:55:06 GMT 2014


Dear George,

thanks a lot for this contribution! I will include it in the next update 
for PyFeyn.

Many thanks again, and all the best wishes,

    Georg

-- 
============================================================================

  Dr. Georg von Hippel
  Institut für Kernphysik                 Phone:  +49 6131 39-22933
  Johannes Gutenberg-Universität Mainz    Fax:    +49 6131 39-22964
  Johann-Joachim-Becher-Weg 45            Email:  hippel at kph.uni-mainz.de
  55099 Mainz, Germany

============================================================================


On Mon, 27 Jan 2014, George S. Williams wrote:

> 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
> .
>
>
>
>


More information about the PyFeyn mailing list