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
import imageio | |
import os, sys | |
class TargetFormat(object): | |
GIF = ".gif" | |
MP4 = ".mp4" | |
AVI = ".avi" | |
def convertFile(inputpath, targetFormat): | |
"""Reference: http://imageio.readthedocs.io/en/latest/examples.html#convert-a-movie""" |
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
def weirdimport(*paths): | |
import os, sys | |
fullpath = os.path.abspath(os.path.join(*paths)) | |
global project | |
sys.path.append(os.path.dirname(fullpath)) | |
try: | |
project = __import__(os.path.basename(fullpath)) | |
sys.modules['project'] = project | |
finally: | |
del sys.path[-1] |
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
public class BroadcastReceiver : IDisposable | |
{ | |
//OnMessageReceived | |
public delegate void AddOnMessageReceivedDelegate(string message, IPEndPoint remoteEndpoint); | |
public event AddOnMessageReceivedDelegate MessageReceived; | |
private void OnMessageReceivedEvent(string message, IPEndPoint remoteEndpoint) | |
{ | |
if (MessageReceived != null) | |
MessageReceived(message, remoteEndpoint); | |
} |
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 System.Text; | |
#if UNITY_EDITOR | |
using System.Net.Sockets; | |
using System.Threading; | |
#else | |
using Windows.Networking.Sockets; | |
using Windows.Storage.Streams; | |
using System.Threading.Tasks; | |
using System.IO; | |
using Windows.Networking; |
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
import time | |
class Measurement(object): | |
def __init__(self, name): | |
self.name = name | |
return | |
def __enter__(self): | |
self.t_start = time.time() | |
return |
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
import theano | |
import theano.tensor as T | |
import numpy | |
import h5py | |
import os | |
import time | |
def rungekuttastep(h, y, fprime, *theta): | |
k1 = h*fprime(y,*theta) |
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
import numpy | |
from matplotlib import pyplot | |
def interpolate(x_fix, y_fix, x_var): | |
x_repeat = numpy.tile(x_var[:,None], (len(x_fix),)) | |
distances = numpy.abs(x_repeat - x_fix) | |
x_indices = numpy.searchsorted(x_fix, x_var) |
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
year | hare | lynx | |
---|---|---|---|
1847 | 21000 | 49000 | |
1848 | 12000 | 21000 | |
1849 | 24000 | 9000 | |
1850 | 50000 | 7000 | |
1851 | 80000 | 5000 | |
1852 | 80000 | 5000 | |
1853 | 90000 | 11000 | |
1854 | 69000 | 22000 | |
1855 | 80000 | 33000 |
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
# saving a DataFrame to an Excel spreadsheet | |
writer = pandas.ExcelWriter(fp_xlsx) | |
df.to_excel(writer, 'Sheetname') | |
writer.save() |
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
"""Sampling parameters of a lorenz attractor. | |
The forward pass integrates the lorenz attractor ODE system using | |
tt.scan with a Runge-Kutta integrator. The predicted high-resolution | |
timecourse is interpolated down so it can be compared to low-density | |
observations. | |
""" | |
import abc | |
import numpy | |
import pymc3 |
OlderNewer