Skip to content

Instantly share code, notes, and snippets.

View cgranade's full-sized avatar

Cassandra Granade cgranade

View GitHub Profile
@cgranade
cgranade / tensor_contract_example
Created December 1, 2014 06:39
QuTiP Example: Superoperators, Pauli Basis and Channel Contraction
{
"metadata": {
"name": "",
"signature": "sha256:d7454350e8574bbb2d317221e2bcdea00fd12b8579a7168fea3b30a93785dc20"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@cgranade
cgranade / find_package.py
Created December 17, 2014 19:46
Pretty and automatic source code printing in LaTeX.
#!/usr/bin/env python
##
# find_package.py: Locates Python modules and generates LaTeX commands.
##
# Christopher Granade (cgranade@cgranade.com). Committed to the public
# domain (17 Dec 2014), but please cite/acknowledge/pass along if this is
# useful to you.
##
r"""
@cgranade
cgranade / scirate.user.js
Created January 12, 2015 23:04
Link arXiv → SciRate
// ==UserScript==
// @name Link arXiv → SciRate
// @namespace http://www.cgranade.com/
// @version 0.1
// @description Adds links to SciRate from arXiv papers.
// @match http://arxiv.org/abs/*
// @copyright 2015+, You
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// ==/UserScript==
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cgranade
cgranade / gist:8f7fce10b6deaf06ce01
Last active August 29, 2015 14:19
Additional documentation for QuTiP issue report "extra dims and mul".
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
(*Suppose that data is stored in a CSV-like format, with newline-delimted rows of comma-separated fields.*)
StringSplit[#, ","]& /@ StringSplit["a,b,c\nd,e,f", "\n"]
(*If certain fields are missing, then let's suppose this is represented by an empty string as the contents for that field.*)
StringSplit[#, ","]& /@ StringSplit["a,,c\nd,e,f", "\n"]
(*This is inconvienent, so let's write a function to parse that as the special values Missing[].*)
MarkMissingValues[dataStr_] := Map[
Function[row, StringSplit[row, ","]],
StringSplit[dataStr, "\n"]
@cgranade
cgranade / gist:dc7bca3d990412b8543e
Created July 15, 2015 01:29
Defeating {revtex4-1} and @control with the power of unforgivable hacks.
\documentclass[aps,pra,twocolumn,superscriptaddress,nofootinbib]{revtex4-1}
%=============================================================================
% BEGIN UNFORGIVABLE HACKS
%=============================================================================
\makeatletter
\def\@bibdataout@aps{%
\immediate\write\@bibdataout{%
@CONTROL{%
apsrev41Control,author="08",editor="1",pages="0",title="0",year="1"%
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cgranade
cgranade / Animations.ipynb
Last active January 16, 2016 04:37
Practical Bayesian Tomography: Supplementary Material
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cgranade
cgranade / dnorm-known-cases-qu-matlab.ipynb
Created March 17, 2016 06:45
Known Cases for the Diamond Norm
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.