Feynman Diagrams in Tikz

There is a package for making Feynman diagrams in LaTeX. Unfortunately, it is old and dvi latex only. If you are using pdflatex or lualatex, as you should be, it does not work. Even in regular LaTeX, it’s a bit of a pain. Why is there not a new package for pdflatex? Turns out, you don’t need one. Due to the powerful drawing library Tikz, you can create any diagram easily, and can customize it completely. For example:

Example diagram
[Read More]
Categories: Physics  Tags: latex feynman-diagrams tikz 

GTest Submodule

Note: There is a better way to do this described here.

If you’ve ever tried apt-get or brew to try to install gtest, you are probably familiar with the fact that gtest is not “recommended” for global install on your system. As an alternative, the recommendation is that you make it part of your project. The process for making gtest part of your project, however, is not well documented, at least for modern git projects. What follows is the procedure I used to do so.

[Read More]
Categories: CMake  Tags: programming cpp tests cmake 

Basics of metaclasses

This is a quick tutorial over the basics of what metaclasses do.

The Metaclass

Metaclasses, while seemingly a complex topic, really just do something very simple. They control what happens when you have code that turns into a class object. The normal place they are executed is right after the class statement. Let’s see that in action by using print as our metaclass.

[Read More]
Categories: Python  Tags: programming python 

Making an autoload extension for IPython

I recently decided to try my hand at making an auto-load extension for Python and Plumbum. I was planning to suggest it as a new feature, then I thought it might be an experimental feature, and now it’s just a blog post. But it was an interesting idea and didn’t seem to be well documented process on the web. So, here it is.

The plan was to make commands like this:

[Read More]
Categories: Python  Tags: programming python ipython 

Uncertainty extension for IPython

Wouldn’t it be nice if we had uncertainty with a nice notation in IPython? The current method would be to use raw Python,

from uncertainties import ufloat

print(ufloat(12.34, 0.01))
12.340+/-0.010

Let’s use the infix library to make the notation easier. We’ll define |pm| to mean +/-.

[Read More]
Categories: Python  Tags: programming python ipython physics