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 random | |
import time | |
import sys | |
from multiprocessing import Pool | |
random.seed() | |
def genList (size): | |
randomList = [] | |
#initialize random list with values between 0 and 100 | |
for i in range(size): |
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 git_version(): | |
from subprocess import Popen, PIPE | |
gitproc = Popen(['git', 'rev-parse','HEAD'], stdout = PIPE) | |
(stdout, _) = gitproc.communicate() | |
return stdout.strip() |
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 argparse | |
def main(c=1, C=1): | |
for iteration in [iteration for iteration in range(config.iterations) if iteration % C == c - 1]: | |
logger.info("This is iteration %s" % iteration) | |
seed(iteration) | |
np.random.seed(iteration) | |
pass | |
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
R> dd[with(dd, order(-z, b)), ] | |
b x y z | |
4 Low C 9 2 | |
2 Med D 3 1 | |
1 Hi A 8 1 | |
3 Hi A 9 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
sshfs user@remotesystem:/remote/dir /some/local/dir |
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
# do this before importing pylab or pyplot | |
import matplotlib | |
matplotlib.use('Agg') | |
from matplotlib import pyplot as plt |
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
plot.area<-function(x,col=NULL,horiz=F,prop=T,stp.ln=T,grp.ln=T,axs.cex=1,axs.lab=T,lab.cex=1, | |
names=c('Group','Step','Value'),...){ | |
#sort out color fector | |
if(!is.null(col)){ | |
if(sum(col %in% colors()) != length(col)) stop('col vector must be in "colors()"') | |
col<-colorRampPalette(col)(ncol(x)) | |
} | |
else col<-colorRampPalette(c('lightblue','green'))(ncol(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
@profile # python -m memory_profiler example.py | |
def my_func(): | |
a = [1] * (10 ** 6) | |
b = [2] * (2 * 10 ** 7) | |
del b | |
return a | |
if __name__ == '__main__': | |
my_func() |
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 pylab import * | |
>>> plot([1,3,2]) | |
[<matplotlib.lines.Line2D object at 0x102bc8950>] | |
>>> gca() | |
<matplotlib.axes.AxesSubplot object at 0x102790cd0> | |
>>> gca().add_patch(Rectangle((1,1),1,1)) | |
<matplotlib.patches.Rectangle object at 0x102790510> | |
>>> savefig("rect.png") |
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
baseClass = self.__class__.__name__ | |
methodToCall = getattr(self,"selectJobs"+baseClass) | |
#now = self.selectJobsExpectation(J) | |
now = methodToCall(J) |
NewerOlder