I'm in trouble because I can't do anything about the error.TypeError: loop of ufunc does not support argument 0 of type Float which has no callable exp method

Asked 1 years ago, Updated 1 years ago, 66 views

Error Message

------------------------------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
AttributeError: 'Float' object has no attribute' exp'

The above exception was the direct cause of the following exception:

TypeError Traceback (most recent call last)
<ipython-input-19-6078c30c8f23>in<module>
     11 y = np.zeros (10000)
     12 fork in range (10000):
--- > 13y[k] = P(v[k])

<ipython-input-19-6078c30c8f23>in P(v)
      8 v = np.logspace (6,23,10000)
      9defP(v):
--->10 return(np.sqrt(3)*q**3*B*sin_pa/(m*c**2)*A(v/v_c)
     11 y = np.zeros (10000)
     12 fork in range (10000):

<ipython-input-8-a3e9f923667c>in A(x)
      5 return F(x)
      6 else:
---->7 return H(x)

<ipython-input-7-9ec1b5e6fe54>in H(x)
      2 return(4*np.pi/np.sqrt(3)/a)*(x/2)**(1/3)
      3def H(x):
---->4 return(np.pi/2)**(1/2))*(x**(1/2)*(np.exp(-x))

TypeError: loop of ufunc does not support argument 0 of type Float which has no callable exp method

Source Codes Affected

A(x), sin_pa, m, c, q, are defined as functions or numbers in the previous step.
The code below is the first conversion to A(x)→A(v/v_c).

 from scipy.special import kv
import matplotlib.pyplot asplt
from scope.integrate import quad
import numpy as np
import path
from path import gamma
from sympy import*
importos
for i in range(5):
    BmG = 10**i
    B=BmG*10**(-6)
    
    for jin range (6):
        g = 10**i
        v_c=3*a**2*q*B*sin_pa/(2*m*c*(2*np.pi))
        v=np.logspace (6,23,10000)
        defP(v):
            return(np.sqrt(3)*q**3*B*sin_pa/(m*c**2))*A(v/v_c)
        y = np.zeros (10000)
        fork in range (10000):
            y[k] = P(v[k])

Alternatively,

defP(v):
    v.float()
    return(np.sqrt(3)*q**3*B*sin_pa/(m*c**2))*A(v/v_c)

AttributeError Traceback (most recent call last)
<ipython-input-22-6eb167a8524>in<module>
     12 y = np.zeros (10000)
     13 for kin range (10000):
--- > 14y[k] = P(v[k])

<ipython-input-22-6eb167a8524>in P(v)
      8 v = np.logspace (6,23,10000)
      9defP(v):
--- >10 v. float()
     11 return(np.sqrt(3)*q**3*B*sin_pa/(m*c**2)*A(v/v_c)
     12 y = np.zeros (10000)

AttributeError: 'numpy.float64' object has no attribute 'float'

to become

Alternatively, if A(v) instead of A(v/V_c), the error will not appear.

defP(v):
            return(np.sqrt(3)*q**3*B*sin_pa/(m*c**2)*A(v)

I don't think the transition from A(x) to A(v/v_c) is going well, but I don't know how to deal with it...

python python3 numpy

2022-09-30 20:13

1 Answers

v_c to int(v_c) resolved itself.


2022-09-30 20:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.