I'm creating some functions that I can call use keywords to call out specific functions,
import scipy.integrate as integrate
import numpy as npdef HubbleParam(a, model = "None"):if model == "LCDM":Omega_L0 = 0.7Omega_m0 = 0.3 return np.sqrt( Omega_m0/a/a/a+ Omega_L0 )if model == "Q":Omega_Q0 = 0.7Omega_m0 = 0.3 return np.sqrt( Omega_m0/a/a/a + Omega_Q0/a )def EmitterDistance(z, model = "None"):a = 1./(1.+z)if model == 'LCDM':integrand = 1./a/a/HubbleParam(a, model="LCDM")return [z , integrate.quad(integrand, a, 1.)[0] ]if model == "Q":integrand = 1/a/a/HubbleParam(a, model="Q")return [z, integrate.quad(inta, a, 1.)[0] ]z = np.linspace(0.,5., 1000)print EmitterDistance(z, model="LCDM")
When trying to print this array, this is returned,
Traceback (most recent call last):File "/Users/alexandres/Desktop/Formation_Galaxies/Homework1/FoG_HW1.py", line 95, in <module>print EmitterDistance(z, model="LCDM")File "/Users/alexandres/Desktop/Formation_Galaxies/Homework1/FoG_HW1.py", line 87, in EmitterDistancereturn [z , integrate.quad(integrand, a, a)[0] ]File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/integrate/quadpack.py", line 315, in quad
points)File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/integrate/quadpack.py", line 364, in _quadif (b != Inf and a != -Inf):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
[Finished in 0.5s with exit code 1]
[shell_cmd: python -u "/Users/alexandres/Desktop/Formation_Galaxies/Homework1/FoG_HW1.py"]
[dir: /Users/alexandres/Desktop/Formation_Galaxies/Homework1]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
or more importantly
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
What is wrong here?