Skip to content

Instantly share code, notes, and snippets.

@amakelov
amakelov / deps.py
Created June 6, 2023 21:06
Code for "Practical dependency tracking for Python function calls"
################################################################################
### Proposed solution
################################################################################
from types import FunctionType
from functools import wraps
from typing import Optional, Callable, Any
import copy
from functools import update_wrapper
class TracerState:
@amakelov
amakelov / minwise.py
Created November 19, 2012 22:00
cs222 homework
from random import choice
import cPickle as pickle
from scipy.weave import converters
from scipy import weave
import numpy
def ran_sub(S, k):
res = []
len_res = 0
while len_res < k:
@amakelov
amakelov / parse_excel.py
Created July 23, 2012 13:37
excel parsing
import xlrd
from collections import namedtuple
def parse(filename):
book = xlrd.open_workbook(filename)
sheet = book.sheet_by_index(0)
cols = sheet.ncols
rows = sheet.nrows
@amakelov
amakelov / docstring_example.py
Created July 5, 2012 20:37
docstring_example
def _strip(g, base, orbs, stabs):
"""
Attempt to decompose a group element using a subgroup chain ``stabs``.
This is done by treating the subgroup chain ``stabs`` as a chain of
stabilizers with respect to the sequence ``base`` (even though the groups
in ``stabs`` might only be subgroups of the respective stabilizers),
and treat ``orbs`` as basic orbits.
This process is called "sifting". A sift is unsuccessful when a certain
orbit element is not found or when after the sift the decomposition
class Representation(object):
character = []
name = None
def __init__(self, character, name = None):
self.character = character
self.name = name
def __add__(self, other):
from operator import add
from operator import mul
class Representation:
character = []
name = None
def __init__(self, character, name = None):