This file contains hidden or 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
b = ['b = ', "print('%s' % str(x[0]), end='')", '\n', 'def f(*x): eval(b[1]) if type(x[0]) is str else [g(s) for s in x]', "def g(x): print('f(b[%d])' % x if type(x) is int else 'f(%s)' % x)", "0, 'b', 4, 2, 3", '2, b[5], b[6]'] | |
def g(x): print('f(b[%d])' % x if type(x) is int else 'f(%s)' % x) | |
def f(*x): eval(b[1]) if type(x[0]) is str else [g(s) for s in x] | |
f(b[0]) | |
f(b) | |
f(b[4]) | |
f(b[2]) | |
f(b[3]) | |
f(b[2]) | |
f(0, 'b', 4, 2, 3) |
This file contains hidden or 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
# leads to a segfault in version 1.2.1 | |
import numpy | |
bad = (numpy.array([0]), numpy.array(0)) | |
numpy.asarray(bad) |
This file contains hidden or 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 cmepy.solver | |
def do_something_fancy(y): | |
""" | |
transforms the solution y in some interesting and useful manner | |
""" | |
return y # TODO IMPLEMENT ME | |
class FancySolver(object): |
This file contains hidden or 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 to_sparse(p_dense): | |
states = numpy.indices(numpy.shape(p_dense)) | |
p_sparse = {} | |
for state in states.transpose(): | |
state = tuple(state) | |
probability = p_dense[state] | |
if probability > 0: | |
p_sparse[state] = p_dense[state] | |
return p_sparse |
NewerOlder