This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
def zoom_factory(ax,base_scale = 2.): | |
def zoom_fun(event): | |
# get the current x and y limits | |
cur_xlim = ax.get_xlim() | |
cur_ylim = ax.get_ylim() | |
# set the range | |
cur_xrange = (cur_xlim[1] - cur_xlim[0])*.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def euler_rot(XYZ,phi,theta,psi): | |
'''Returns the points XYZ rotated by the given euler angles''' | |
ERot = np.array([[np.cos(theta)*np.cos(psi), | |
-np.cos(phi)*np.sin(psi) + np.sin(phi)*np.sin(theta)*np.cos(psi), | |
np.sin(phi)*np.sin(psi) + np.cos(phi)*np.sin(theta)*np.cos(psi)], | |
[np.cos(theta)*np.sin(psi), | |
np.cos(phi)*np.cos(psi) + np.sin(phi)*np.sin(theta)*np.sin(psi), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class push_to_advance(object): | |
def __init__(self): | |
self.fig = plt.figure() | |
self.ax = self.fig.gca() | |
self.bound_keys = [] | |
self.bound_cid = {} | |
def add_step_through(self, gen, key): | |
key = key[0] # make a single char | |
if key in self.bound_keys: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def format_frac(fr): | |
'''Convert a/b to latex''' | |
sp = str(fr).split('/') | |
if len(sp) == 1: | |
return sp[0] | |
else: | |
return r'$\frac{%s}{%s}$' % tuple(sp) | |
frac_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4 import QtGui | |
import time | |
#app = QtGui.QApplication([]) | |
class exception_munger(object): | |
def __init__(self): | |
self.flag = True | |
self.txt = '' | |
self.type = None | |
def indicate_fail(self,etype=None, txt=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
N = 15 | |
scatter_data = rand(3, N) ** 2 | |
G=nx.Graph() | |
data_nodes = [] | |
init_pos = {} | |
for j, b in enumerate(scatter_data.T): | |
x, y, _ = b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#Copyright 2009-2013 Thomas A Caswell | |
#[email protected] | |
#http://jfi.uchicago.edu/~tcaswell | |
# | |
#This program is free software; you can redistribute it and/or modify | |
#it under the terms of the GNU General Public License as published by | |
#the Free Software Foundation; either version 3 of the License, or (at | |
#your option) any later version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib.legend_handler import HandlerLine2D | |
class HandlerXoffset(HandlerLine2D): | |
def __init__(self, marker_pad=0.3, numpoints=1, x_offset=0, **kw): | |
HandlerLine2D.__init__(self, marker_pad=marker_pad, numpoints=numpoints, **kw) | |
self._xoffset = x_offset | |
def get_xdata(self, legend, xdescent, ydescent, width, height, fontsize): | |
numpoints = self.get_numpoints(legend) | |
if numpoints > 1: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Copyright (C) 2006 Stefan van der Walt <[email protected]> | |
## | |
## Redistribution and use in source and binary forms, with or without | |
## modification, are permitted provided that the following conditions are | |
## met: | |
## | |
## 1. Redistributions of source code must retain the above copyright | |
## notice, this list of conditions and the following disclaimer. | |
## 2. Redistributions in binary form must reproduce the above copyright | |
## notice, this list of conditions and the following disclaimer in |
OlderNewer