Skip to content

Instantly share code, notes, and snippets.

View ntezak's full-sized avatar

Nikolas Tezak ntezak

View GitHub Profile
@ntezak
ntezak / GateNoiseModels.html
Created November 17, 2017 19:47
Gate Noise Models on the Rigetti QVM
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>GateNoiseModels</title><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style type="text/css">
/*!
*
def time_dependent_to_qutip(operator, full_space=None, t=symbols("t", real=True)):
import re
if t in operator.all_symbols():
operator = operator.expand()
if isinstance(operator, OperatorPlus):
return [time_dependent_to_qutip(o, full_space) for o in operator.operands]
elif isinstance(operator, ScalarTimesOperator):
return [operator.term.to_qutip(full_space),
re.sub("I", "(1.0j)", str(operator.coeff))] # a bit of a hack to replace imaginary unit
return [operator.to_qutip(full_space), "1"]
@ntezak
ntezak / my_lambdify.py
Last active December 1, 2015 18:44
Snippet to improve execution speed of lambdify by identifying common subexpressions
import sympy
from collections import defaultdict
def walk_exprs(exprs, subexpr=None):
"""
Return a dict {expr: frequency} for all subexpressions in the sequence of expressions `expr`.
"""
if subexpr is None:
subexpr = defaultdict(int)
for e in exprs:
set nocompatible " Fuck VI... That's for grandpas.
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Vundle let's you specify a plugin in a number of formats, but my favorite
" allows you to grab plugins straight off of github, just specify the bundle
" in the following format:
" Bundle 'githubUsername/repoName'
@ntezak
ntezak / my.patch
Last active March 11, 2016 07:38
Patch for homebrew formula to build macvim with anaconda's (or another non-system/non-framework) python distribution
diff --git a/src/configure.in b/src/configure.in
index e57be41..7606d1f 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1011,9 +1011,14 @@ AC_ARG_ENABLE(pythoninterp,
[enable_pythoninterp="no"])
AC_MSG_RESULT($enable_pythoninterp)
if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
- dnl -- find the python executable
- AC_PATH_PROGS(vi_cv_path_python, python2 python)
@ntezak
ntezak / cavity_model.py
Created December 11, 2012 01:59
QNET code example
import qnet.circuit_algebra as ca
import sympy
Q = ca.local_space('Q')
a = ca.Destroy(Q)
Delta, kappa = sympy.symbols('Delta, kappa', real = True)
H = Delta * a.dag() * a
L = ca.Matrix(ca.sqrt(Delta) * a)
S = ca.identity_matrix(1)
cavity_model = ca.SLH(S, L, H)