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
require(forecast) | |
resultsAR = NULL | |
resultsMA = NULL | |
# start a loop here and feed it new data | |
tmp = data$Value | |
tmp = tmp[1:100] | |
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
library(ggplot2) | |
library(gridExtra) | |
mtcars$cyl <- ordered(mtcars$cyl) | |
p <- ggplot(mtcars, aes(mpg, hp, colour = cyl)) + geom_point() | |
p1 <- p + theme(legend.position = "none") | |
p2 <- ggplot(mtcars, aes(x=mpg, group=cyl, colour=cyl)) | |
p2 <- p2 + stat_density(fill = NA, position="dodge") |
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
class Foo(object): | |
pass | |
class Bar(object): | |
pass | |
dispatch_dict = {"Foo": Foo, "Bar": Bar} | |
dispatch_dict["Foo"]() # returns an instance of Foo |
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 foo | |
methodToCall = getattr(foo, 'bar') | |
result = methodToCall() |
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 itertools | |
>>> x = itertools.count(0) | |
>>> x.__class__.__name__ | |
'count' |
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) |
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
@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
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
# do this before importing pylab or pyplot | |
import matplotlib | |
matplotlib.use('Agg') | |
from matplotlib import pyplot as plt |
OlderNewer