Skip to content

Instantly share code, notes, and snippets.

@pierre-haessig
pierre-haessig / add_trait_bug.py
Created October 7, 2013 16:01
A bug with add_trait ? -> is there a need to call a "register" function after adding a trait ?
#!/usr/bin/python
# -*- coding: utf-8 -*-
""" A bug with add_trait ?
-> is there a need to call a "register" function after adding a trait ?
Documentation reference for `add_trait` :
http://docs.enthought.com/traits/traits_user_manual/advanced.html#per-object-trait-attributes
Pierre Haessig — October 2013
"""
@pierre-haessig
pierre-haessig / ampl.lang
Last active December 26, 2015 03:19
basic Ampl/GNU MathProg language description for gtksourceview (e.g. syntax highlighting in gedit) Pierre Haessig, 2013
<?xml version="1.0" encoding="UTF-8"?>
<!--
basic Ampl/GNU MathProg language description for gtksourceview
(e.g. syntax highlighting in gedit)
to be placed in /usr/share/gtksourceview-3.0/language-specs/ directory
Pierre Haessig, 2013
-->
<language id="ampl" _name="Ampl" version="2.0" _section="Scientific">
@pierre-haessig
pierre-haessig / index.html
Created January 3, 2014 20:22
Energy storage animation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Storage animation</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
body { font-family: sans-serif;}
@pierre-haessig
pierre-haessig / tictoc.py
Created January 9, 2014 15:38
TicToc timing class 1st time an instance is called, it sets a timestamp (time.time()) 2nd time, it computes and returns the difference (in seconds, float).
class TicToc(object):
'''Timing class
1st time an instance is called, it sets a timestamp (time.time())
2nd time, it computes and returns the difference (in seconds, float).
Examples
--------
>>> t = TicToc()
>>> t() # returns time.time()
@pierre-haessig
pierre-haessig / sympy_interactive_plot.ipynb
Created March 20, 2014 16:02
Interactive plot of a SymPy expression (using Traits)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierre-haessig
pierre-haessig / mpl_background.ipynb
Created March 26, 2014 09:53
change the background color of a Matplotlib plot
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierre-haessig
pierre-haessig / opt_robot_traj.ipynb
Created March 27, 2014 14:14
Optimal pick-and-place trajectory for a robot : attempt to find it on a Fourier basis
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierre-haessig
pierre-haessig / traitsui_mpl_qt.py
Last active January 18, 2019 22:05
Matplotlib integration with Enthought's traitsui, using Qt toolkit (instead of wx)
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Pierre Haessig — March 2014
"""
Qt adaptation of Gael Varoquaux's tutorial to integrate Matplotlib
http://docs.enthought.com/traitsui/tutorials/traits_ui_scientific_app.html#extending-traitsui-adding-a-matplotlib-figure-to-our-application
based on Qt-based code shared by Didrik Pinte, May 2012
http://markmail.org/message/z3hnoqruk56g2bje
#!/usr/bin/env python
# Original source : https://gist.github.com/iMichka/9901318
# Change : use a timer
import sys
import numpy
from PyQt4 import QtGui, QtCore
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
from matplotlib.collections import PolyCollection
@pierre-haessig
pierre-haessig / second order process.ipynb
Created May 7, 2014 11:14
Study of 2nd order autoregressive process (AR(2))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.