1 year ago

#368661

test-img

PacificL

Import Error arises when I use the sympy.piecewise function whose version is 1.10

I'm facing a problem when I use the Piecewise function.

The information is "ImportError: cannot import name 'sympy_deprecation_warning' from 'sympy.utilities.exceptions'".

And the code is posted below:

# * physical constant parameters
# the absorption coefficient of cloud to singal
beta_c = sy.symbols('bate_c', real=True, positive=True, constant=True)
# the energy harvesting efficiency
eta = sy.symbols('eta', real=True, positive=True, constant=True)
# the average solar radiation intensity on earth in W/m^2
G = sy.symbols('G', real=True, positive=True, constant=True)
# the altitude of the upper boundary of the cloud in m
L_up = sy.symbols('L_up', real=True, positive=True, constant=True)
# the altitude of the lower boundary of the cloud in m
L_low = sy.symbols('L_low', real=True, positive=True, constant=True)

# * UAV parameters

d_cloud = sy.symbols('d_cloud', real=True, positive=True)
# the equivalent area of the solar panels in m^2
S = sy.symbols('S', real=True, positive=True)
# the altitude of UAV in m
z = sy.symbols('z', real=True, positive=True)

# * formulations
# the distance that the solar light propagates through the cloud
d_cloud = sy.Max(0, L_up - sy.Min(L_up, z))
# the attenuation of the solar light passing through a cloud
attenuation = sy.exp(-beta_c * d_cloud)
# the electrical output power of a solar panel at altitude
f_low = eta * S * G * sy.exp(-beta_c * (L_up - L_low))
f_mid = eta * S * G * sy.exp(-beta_c * (L_up - z))
f_up = eta * S * G

P_eh = sy.Piecewise((f_up, z >= L_up), (f_low, z <= L_low), (f_mid, True))

P_eh

The platform is vscode and the version of sympy is 1.10.

An interesting phenomenon arises that this problem only appears when I display the P_eh function. If I do not display this function, everything is ok.


Ok, I got it. Version 1.8 is ok, I degraded it to version 1.8, No Error, No Warning.

python

sympy

piecewise

0 Answers

Your Answer

Accepted video resources