TypeError: Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe' again

20 Views Asked by At

This error is shown and it is pointing to the line y = s(x):

def de_interpolation(x):
    # given values
    xi = pressureT 
    yi = energyT
    # spline order: 1 linear, 2 quadratic, 3 cubic ... 
    order = 3      
    # do inter/extrapolation
    s = InterpolatedUnivariateSpline(xi, yi, ext=3)
    y = s(x)  
    return y

It is fed with:

c, a, b  = np.loadtxt('eos_compOSE_NL3.dat', delimiter=' ', unpack=True, dtype=np.float64)  #EoS in mevfm-3
mev_fm_to_msolar = 2.886515033e-6
pressureT = a*mev_fm_to_msolar
energyT = b*mev_fm_to_msolar

I tried changing all the variables involved and their assignments to float but the problem persists.

0

There are 0 best solutions below