New projects: PyFDE and PeakUtils

02 Nov 2014

I’ve been using (and learning) Python in the last months, and it has been a great experience. For me, learning a new programming language is a very interesting task, as it allows me to review the way that I structure programs and allows me to add new tools to the toolbox. In one exercise to learn the Python language, I’ve translated a program that I’ve written in C++ to Python, and in the process, found a subtle bug.

I’m really enjoying working with IPython Notebook/NumPy/Scipy/Matplotlib to process and visualize experimental data, as it allows one to have an enhanced REPL (better editor, with nice output that can be saved and even exported to reStructuredText).

This month I’ve written two Python packages to scratch my own itches: one is a fast implementation of the differential evolution method (PyFDE) and the other implements peak detection routines for 1D data (PeakUtils). The packages are available at PyPI and are briefly described bellow.


PyFDE implements the DE/rand/1/bin scheme for Python 3. It is written in Cython for performance (near C performance, see the performance section of the official documentation for details).

It has a simple API, as described by the sample program bellow that minimizes the Rastrigin function:

import pyfde
from math import cos, pi

def fitness(p):
    x, y = p[0], p[1]
    val = 20 + (x**2 - 10*cos(2*pi*x)) + (y**2 - 10*cos(2*pi*y))
    return -val

solver = pyfde.Solver(fitness, n_dim=2, n_pop=40, limits=(-5.12, 512)), solver.f = 0.9, 0.45

best, fit =
print("**Best solution found**")
print("x, y    = {:.2f}, {:.2f}".format(best[0], best[1]))
print("Fitness = {:.2f}".format(fit))


PeakUtils is written in pure Python (for Python 3.4), and provides simple functions to find the indexes of the peaks in 1D data and to further enhance the resolution by using Gaussian fitting or centroid computation.

An example with images can be found at the official documentation.


Both projects were released under the MIT license and are open for contribution.