Re: [PyX-user] expression parser From: Andre Wobst - 2005-09-12 06:50:46 ```Hi, On 10.09.05, Simson Garfinkel wrote: > >The reason for this being that we removed our own expressions > >parser in favour of using the Python eval function. Commenting on > >the graph style, I'll happily leave to André... > > You had an expression parser? Oh my. I always assumed you used eval(). Right: oh my goodness. I'm happy we finally could remove it, but let me tell you the story from the beginning. Before we started PyX I created a non-linear fitting system used in a commercial application. This thing was written in Delphi, a Pascal dialect. I had to create an expression parser to do that, which turned expressions in so called math trees (basically a tree where each knot is a operator or function and the leaves are constants and variables). And since it was funny to do, I also implemented a symbolic derivative calculator base on those math trees. It turned out, that symbolic derivatives are a great help for non-linear curve fitting in terms of speed, stability and precession. When I started to work on PyX and its graph system, I ported the expression parser. It was one of the first things I did in Python and I was uncertain of Pythons eval (and compile and so on) to be a better solution. At the same time it was quite easy to add special syntax like the \$-notation for columns and the inplicit variable notation. Think of the expression "y=sin(x)", where the system understood to create a function y(x). It got into troubles for functions like "y=1", which was an error for a long time. In 0.8 we introduced the explicit notation "y(x)=1" with an deprication warning for the old implicit notation ... and for 0.9 I now could remove the old math tree. (The expression parser itself was removed earlier by Michael.) This also allows us now to use different types in the expressions than we had before. For bar graphs and split axes the tuples are now visible to the end user. At the same time, the mathtree removal in the CVS was smooth; all examples and test cases worked without a modification (beside some changes in nested bar axes, which are a wanted feature). However, there are some changes visible to the end user, since the mathtree always worked on floats in favour of integers. As you well know, integers are error-prone in divisions (new style division is a great solution, but unfortunately it's not yet the default). But one thing we missed in the discussion is, that the context feature was available for years already. It has nothing to do with the removal of our old expression handling. André -- by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ ```
 [PyX-user] expression parser From: Simson Garfinkel - 2005-09-10 15:17:49 Attachments: Message as HTML ```> > >> I would like to invite anyone to take at look at this and would be =20= >> glad about >> any comment or suggestion. >> >> The module pyxmath.py included in Simply Draw contains additional >> functionality for PyX (two graph data sources and a graph style). =20 >> Perhaps you >> may want to think about including similar functionality to PyX =20 >> itself. >> > > Concering the Python function stuff, I'm not sure whether this will be > needed in PyX 0.9 anymore (but it could still be useful). The =20 > reason for > this being that we removed our own expressions parser in favour of =20 > using > the Python eval function. Commenting on the graph style, I'll happily > leave to Andr=E9... You had an expression parser? Oh my. I always assumed you used eval(). ```
 Re: [PyX-user] expression parser From: Andre Wobst - 2005-09-12 06:50:46 ```Hi, On 10.09.05, Simson Garfinkel wrote: > >The reason for this being that we removed our own expressions > >parser in favour of using the Python eval function. Commenting on > >the graph style, I'll happily leave to André... > > You had an expression parser? Oh my. I always assumed you used eval(). Right: oh my goodness. I'm happy we finally could remove it, but let me tell you the story from the beginning. Before we started PyX I created a non-linear fitting system used in a commercial application. This thing was written in Delphi, a Pascal dialect. I had to create an expression parser to do that, which turned expressions in so called math trees (basically a tree where each knot is a operator or function and the leaves are constants and variables). And since it was funny to do, I also implemented a symbolic derivative calculator base on those math trees. It turned out, that symbolic derivatives are a great help for non-linear curve fitting in terms of speed, stability and precession. When I started to work on PyX and its graph system, I ported the expression parser. It was one of the first things I did in Python and I was uncertain of Pythons eval (and compile and so on) to be a better solution. At the same time it was quite easy to add special syntax like the \$-notation for columns and the inplicit variable notation. Think of the expression "y=sin(x)", where the system understood to create a function y(x). It got into troubles for functions like "y=1", which was an error for a long time. In 0.8 we introduced the explicit notation "y(x)=1" with an deprication warning for the old implicit notation ... and for 0.9 I now could remove the old math tree. (The expression parser itself was removed earlier by Michael.) This also allows us now to use different types in the expressions than we had before. For bar graphs and split axes the tuples are now visible to the end user. At the same time, the mathtree removal in the CVS was smooth; all examples and test cases worked without a modification (beside some changes in nested bar axes, which are a wanted feature). However, there are some changes visible to the end user, since the mathtree always worked on floats in favour of integers. As you well know, integers are error-prone in divisions (new style division is a great solution, but unfortunately it's not yet the default). But one thing we missed in the discussion is, that the context feature was available for years already. It has nothing to do with the removal of our old expression handling. André -- by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ ```