This file contains 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
rewrite(x::Number) = x | |
rewrite(x::Symbol) = x | |
rewrite(x::String) = x | |
function rewrite(expr) | |
if expr.head == :ref | |
return Expr(expr.head, expr.args[1], [rewrite(:( 1 + $i)) for i in expr.args[2:end]]...) | |
else | |
return Expr(expr.head, [rewrite(i) for i in expr.args]...) | |
end |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import sys | |
from PySide.QtCore import * | |
from PySide.QtGui import * | |
from PySide import QtGui | |
from PySide.QtWebKit import * | |
from PySide import QtWebKit |
This file contains 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
###################################################################### | |
using PyPlot | |
using Grid | |
using Dierckx | |
using NumericalMath | |
using splines | |
#using ApproXD | |
meshgrid(x::Vector, y::Vector) = (repmat(x, 1, length(y))', | |
repmat(y, 1, length(x))) |
This file contains 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
from dolo import yaml_import | |
model = yaml_import('examples/models/rbc.yaml') | |
s = model.calibration['states'] | |
x = model.calibration['controls'] | |
y = model.calibration['auxiliaries'] | |
e = model.calibration['shocks'] | |
v = model.calibration['values'] | |
p = model.calibration['parameters'] |
This file contains 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
""" | |
Filename: watcher.py | |
Authors: Pablo Winant | |
Time long computation and send a message when finished. | |
""" | |
import contextlib | |
@contextlib.contextmanager | |
def watcher(task_name=None, email=None): |
This file contains 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
<html> | |
<head> | |
<style> | |
.annotation_table { | |
color: #000000; | |
font-family: monospace; | |
margin: 5px; |
This file contains 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
d = 3 # number of dimensions | |
K = 50 # number of points along each dimension | |
N = 100000 # number of points at which to interpolate | |
A = rand([K for i = 1:d]...) # filtered coefficients | |
B = rand(N,d) # points at which to evaluate the splines | |
max(B, minimum(A)+0.01) | |
min(B, maximum(A)-0.01) | |
This file contains 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
from __future__ import division | |
from numba import double, int64 | |
from numba import jit, njit | |
import numpy as np | |
from numpy import zeros, array |
This file contains 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
from math import floor | |
from numba import njit | |
#### | |
#### Working | |
#### | |
@njit | |
def native_index_1d(mat, vec): | |
return mat[vec[0]] |
This file contains 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
from cffi import FFI | |
ffi = FFI() | |
ffi.cdef('double erfc(double x);') | |
libm = ffi.dlopen("m") | |
erfc = libm.erfc | |
from math import erfc as p_erfc | |
from numba import njit | |
from numpy import linspace |
OlderNewer