Dec-19-2017, 08:48 PM
Here's my errpr message, last time I got this I had a logic error in a loop, but I can't find anything like that in this. Does anyone spot my problem?
Error:runfile('C:/Users/after/OneDrive/Distinction Project Files 2017/Python Scripts for Distinction/Distinction/Main Program.py', wdir='C:/Users/after/OneDrive/Distinction Project Files 2017/Python Scripts for Distinction/Distinction')
C:\Python27\lib\site-packages\IPython\core\formatters.py:239: FormatterWarning: Exception in image/png formatter: Could not allocate memory for image
FormatterWarning,
<matplotlib.figure.Figure at 0x2309ef0>
Traceback (most recent call last):
File "<ipython-input-28-225e42a16155>", line 1, in <module>
runfile('C:/Users/after/OneDrive/Distinction Project Files 2017/Python Scripts for Distinction/Distinction/Main Program.py', wdir='C:/Users/after/OneDrive/Distinction Project Files 2017/Python Scripts for Distinction/Distinction')
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/after/OneDrive/Distinction Project Files 2017/Python Scripts for Distinction/Distinction/Main Program.py", line 100, in <module>
ax.plot(x, yFunction(veganGrowth, initialPopOmni, popGrowthFactor), 'p-', lw=1, alpha=0.6, label='Major Graph')
File "C:/Users/after/OneDrive/Distinction Project Files 2017/Python Scripts for Distinction/Distinction/Main Program.py", line 62, in yFunction
y = initialPop - totFunctions*y
MemoryError
Here's the code it's based on.import numpy as np from scipy.stats import lognorm import matplotlib.pyplot as plt from math import exp fig, ax = plt.subplots(1, 1) initialPop = int(326300000) initialPopOmni = 315532100 popGrowthFactor = 0.007 def runLognormal(start, current, mean, cumImpact, peakFactor): scale = exp(mean) return lognorm.pdf(current, peakFactor, start, scale)*cumImpact def runLinear(start, stop, slope): numQRun = start-stop y=[] time = start while time <= stop: time = time + 1 y.append(slope*(time-start)) return y[1:numQRun] def veganuary(x): veg = [] tTime = 48 while tTime <= 136: tTime = tTime + 4 veg.append(runLognormal(tTime, x, 0.002885, 0.00577, 0.55)-runLognormal(tTime+1, x, 0.00173, 0.00376, 0.55)) return sum(veg[1:22]) def veganuary2(x): veg2 = [] tTime = 136 while tTime <= 212: tTime = tTime + 4 veg2.append(runLognormal(tTime, x, 0.0043275, 0.008655, 0.55)-runLognormal(tTime+1, x, 0.002592, 0.00519, 0.55)) return sum(veg2[1:19]) def yFunction(totFunctions, initialPop, popGrowthFactor): x = 0 Y = [] y = initialPop * np.exp(popGrowthFactor * x/4) while x < 212: Y.append(y) y = initialPop - totFunctions*y x = x + 0.01 return Y[1:21200] x = np.linspace(0, 212, num=21200) tax1 = runLognormal(92, x, 0.036, 0.071, 0.55) tax2 = runLognormal(112, x, 0.036, 0.071, 0.55) tax3 = runLognormal(132, x, 0.071, 0.142, 0.55) tax4 = runLognormal(152, x, 0.036, 0.071, 0.55) tax5 = runLognormal(200, x, 0.1065, 0.213, 0.55) tariff = runLognormal(56, x, 0.018, 0.036, 0.55) ad1 = runLognormal(4, x, 0.000575, 0.00115, 0.55) ad2 = runLognormal(44, x, 0.00019, 0.00038, 0.55) ad3 = runLognormal(84, x, 0.00019, 0.00038, 0.55) ad4 = runLognormal(124, x, 0.000385, 0.00077, 0.55) ad5 = runLognormal(144, x, 0.000575, 0.00115, 0.55) ad6 = runLognormal(176, x, 0.00095, 0.0019, 0.55) ad7 = runLognormal(200, x, 0.000575, 0.00115, 0.55) news1 = runLognormal(1, x, 0.000345, 0.00069, 0.55)-runLognormal(2, x, 0.000207, 0.000414, 0.55) veg = veganuary(x) veg2 = veganuary2(x) label1 = runLinear(80, 160, 0.0006875) label2 = runLinear(160, 212, 0.003125) #consumptionBase = #popBase = #popOmniBase = #popVegBase = #popVeganBase = veganGrowth = tax1 + tax2 + tax3 + tax4 + tax5 + tariff + ad1 + ad2 + ad3 + ad4 + ad5 + ad6 + ad7 + news1 + veg + veg2# + label1 + label2 ax.set_title('Decrease in Omnivore Population') ax.set_xlabel('$Quarter$') ax.set_ylabel('$Population Omnivores$') ax.plot(x, yFunction(veganGrowth, initialPopOmni, popGrowthFactor), 'p-', lw=1, alpha=0.6, label='Major Graph')