lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
230 stars 285 forks source link

density_cl() for python 3 returning error #339

Open jl-bernal opened 4 years ago

jl-bernal commented 4 years ago

The function density_cl() in the python wrapper, working in python 3 returns the error "TypeError: 'float' object cannot be interpreted as an integer". This is due to the line:

size = (self.sp.d_size*(self.sp.d_size+1)-(self.sp.d_size-self.sp.non_diag)* (self.sp.d_size-1-self.sp.non_diag))/2;

I've checked and given that in python 3, 1/2 = 1/2. = 0.5, the variable size is interpreted as a float instead of an integer.

I've patched it forcing the code to take the integer part, but there might be a better way to do it:

size = int((self.sp.d_size*(self.sp.d_size+1)-(self.sp.d_size-self.sp.non_diag)* (self.sp.d_size-1-self.sp.non_diag))/2);

I haven't encountered this problem in other functions of the python wrapper so far.

Thanks!