Thursday, June 8th, 2006

PyX - Python graphics package

Filed under: — Daniel Lemire @ 7:07

PyX is a Python package for the creation of PostScript and PDF files. It combines an abstraction of the PostScript drawing model with a TeX/LaTeX interface. Complex tasks like 2d and 3d plots in publication-ready quality are built out of these primitives.

Here is the type of things you can do:

Naturally, the code is a bit hairy:


from math import pi, cos
from pyx import *
from pyx.deco import barrow, earrow
from pyx.style import linewidth, linestyle
from pyx.graph import graphxy
from pyx.graph.axis import linear
from pyx.graph.axis.painter import regular
from pyx.graph.style import line
from pyx.graph.data import function
mypainter = regular(basepathattrs=[earrow.normal], titlepos=1)
def mycos(x): return -cos(x)+.10*x
g = graphxy(height=5, x2=None, y2=None,
x=linear(min=-2.5*pi, max=3.3*pi, parter=None,
painter=mypainter, title=r”$\delta\phi$”),
y=linear(min=-2.3, max=2, painter=None))
g.plot(function(”y(x)=mycos(x)”, context=locals()),
[line(lineattrs=[linewidth.Thick])])
g.finish()
x1, y1 = g.pos(-pi+.1, mycos(-pi+.1))
x2, y2 = g.pos(-.1, mycos(-.1))
x3, y3 = g.pos(pi+.1, mycos(pi+.1))
g.stroke(path.line(x1-.5, y1, x1+.5, y1), [linestyle.dashed])
g.stroke(path.line(x1-.5, y3, x3+.5, y3), [linestyle.dashed])
g.stroke(path.line(x2-.5, y2, x3+.5, y2), [linestyle.dashed])
g.stroke(path.line(x1, y1, x1, y3), [barrow.normal, earrow.normal])
g.stroke(path.line(x3, y2, x3, y3), [barrow.normal, earrow.normal])
g.text(x1+.2, 0.5*(y1+y3), r”$2\pi\gamma k\Omega$”, [text.vshift.middlezero])
g.text(x1-.6, y1-.1, r”$E_{\rm b}$”, [text.halign.right])
g.text(x3+.15, y2+.20, r”$2J_k(\varepsilon/\Omega)+\pi\gamma k\Omega$”)
g.writeEPSfile(”washboard”)
g.writePDFfile(”washboard”)

(Source: 0xDE)

Wednesday, June 7th, 2006

Canadian Semantic Web Working Symposium

Filed under: — Daniel Lemire @ 16:14

The Canadian Semantic Web Working Symposium was held yesterday in Quebec City and it was a great success. Of particular interest was the keynote speaker, Michael Huhns who argued that web services ought to be thought of as agents. The best paper award was given out to Jie Zhang and Robin Cohen for their paper “A Trust Model for Sharing Ratings of Information Providers on the Semantic Web” which I thought was really well thought out. You can buy the proceedings on amazon.

Friday, June 2nd, 2006

How to recover “lost” changes in CVS

Filed under: — Daniel Lemire @ 20:09

Suppose someone destroyed one of your file revisions by checking in a file undoing any changes you made. While your version is still in the CVS tree (you are using version control, aren’t you?), you don’t know how to merge them with the current version of the file.

Well, here’s a hack that will do it:


cvs update myfile
cvs update -r 1.39 -p myfile > mychanges
cvs update -r 1.38 -p myfile > beforemychanges
merge myfile beforemychanges mychanges

I’m sure there is a cleaner way to do it.

ACL 2006 accepted papers

Filed under: — Daniel Lemire @ 9:24

The list of ACL 2006 accepted papers is up. Here are a few that caught my eye:

You Can’t Beat Frequency (Unless You Use Linguistic Knowledge) — A Qualitative Evaluation of Association Measures for Collocation and Term Extraction
Joachim Wermter and Udo Hahn

Are These Documents Written from Different Perspectives?
A Test of Different Perspectives Based On Statistical Distribution Divergence
Wei-Hao Lin and Alexander Hauptmann

Scaling Distributional Similarity to Large Corpora
James Gorman and James Curran

Expressing Implicit Semantic Relations without Supervision
Peter Turney

Thursday, June 1st, 2006

Autocompletion in the Python console

Filed under: — Daniel Lemire @ 12:45

Hans tells us how to have autocompletion in the Python console:


import readline, rlcompleter
readline.parse_and_bind("tab: complete")

This is brilliant, but I wonder how I would ever have guessed this exact sequence of code. Isn’t it a bit obscur?

Anyhow. Hans also tells us how to have this run automatically every time the console is launched. I think it is very nice.

« Previous Page

30 queries. 0.368 seconds. Valid XHTML

Powered by WordPress

Subscribe to this blog in a reader or by Email.