Skip to content

Instantly share code, notes, and snippets.

View tacaswell's full-sized avatar

Thomas A Caswell tacaswell

View GitHub Profile
@tacaswell
tacaswell / annotate_range.py
Created August 26, 2013 01:45
gist for working on annotation range function
def add_range_annotation(ax, start, end, txt_str, y_height=.5, txt_kwargs=None, arrow_kwargs=None):
"""
Adds horizontal arrow annotation with text in the middle
Parameters
----------
ax : matplotlib.Axes
The axes to draw to
start : float
@tacaswell
tacaswell / snippits.el
Created October 5, 2013 19:22
useful elisp
(defun tac-python-header ()
(interactive "*")
(occur "^\\s-*\\(\\(class\\)\\|\\(def\\)\\)\\|\\(@\\)")
)
(define-skeleton py-np-def
"Skeleton for function definition that includes numppydoc style "
"Name: "
"def " str "(" ("Parameter, %s: " (unless (equal ?\( (char-before)) ", ")
str) "):" \n
class uneven_FFT_recon(object):
"""
A class to wrap up dealing with the irregularly sampled periodic
data
"""
@classmethod
def reconstruct_iterative(cls, phi, h, target_error,
start_N=3, bound_N=15, iters=25):
"""
reconstruct a band-limited a curve from unevenly
@tacaswell
tacaswell / label_axes_iterate.py
Last active August 13, 2021 04:22
A quick little function to walk through the axes in a Figure instance and label each one with annotate.
import string
from itertools import cycle
from six.moves import zip
def label_axes(fig, labels=None, loc=None, **kwargs):
"""
Walks through axes and labels each.
kwargs are collected and passed to `annotate`
@tacaswell
tacaswell / stack_bar.py
Created July 6, 2014 01:10
stacked bar
import numpy as np
import matplotlib.pyplot as plt
from itertools import cycle
from six.moves import zip
def stack_bar(ax, list_of_vals, color_cyle=None, **kwargs):
"""
Generalized stacked bar graph.
kwargs are passed through to the call to `bar`
# this bit of code makes sure that the head stays a fixed size in terms of
# axes fractions. To tune this size change `head_size`
head_size = 30
# to tun the ratio between the head size and the shaft, change `ascale`
ascale = .2
# tunes how 'pinched' the arrow head is, < 1 and the bottom will be indented
# > 1 the arrow will be a distorted diamond
pinched = .7
@tacaswell
tacaswell / xraylib_draft.py
Last active August 29, 2015 14:05
draft of xraylib wrapping and new Element class
from collections import Mapping
import six
_XRAYLIB_MAP_MAP = {'edges': ({'Ka1': xraylib.KALPHA,..}, xraylib.CS_FlourLine),
'levels': ({'K': xraylib.K, }),
}
_OTHER_VALUES = {'H': {'Z': 1, 'rho': .524, },
@tacaswell
tacaswell / wo
Last active September 21, 2018 11:17
patch over conda vs venvs idea of activate
#! /bin/bash
if [ -a $1/bin/conda ]; then
# we are in a conda env
# save old QT_PLUGIN_PATH
OLD_QT=$QT_PLUGIN_PATH
from vistrails import api
csv = api.add_module(100, 100, 'org.vistrails.vistrails.tabledata', 'CSVFile', 'read')
fd = api.add_module(65, 50, 'org.vistrails.vistrails.url', 'DownloadFile', '')
api.add_connection(fd.id, 'file', csv.id, 'file')
api.change_parameter(fd.id, 'url',['http://www.vistrails.org/download/download.php?type=DATA&id=citibike_from_launch.csv'])
@tacaswell
tacaswell / .condarc
Created September 4, 2014 21:59
condarc_for_travis
channels:
- tacaswell
- defaults