Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] With new version of numpy, issue with library specifically imports #2345

Open
6 tasks done
bimbimbambam69 opened this issue Jul 15, 2024 · 3 comments
Open
6 tasks done
Labels

Comments

@bimbimbambam69
Copy link

Bug report checklis

  • Searched the issues page for similar reports

  • Read the relevant sections of the documentation

  • Browse the tutorials and tests for usefull code snippets and examples of use

  • Reproduced the issue after updating with pip install --upgrade pandapower (or git pull)

  • Tried basic troubleshooting (if a bug/error) like restarting the interpreter and checking the pythonpath

Reproducible Example

import pandapower as pp
import pandapower.plotting as plot
import matplotlib.pyplot as plt

def oc_relay_net():
       # create an empty network
    net = pp.create_empty_network()

    # create buses
    pp.create_buses(net, nr_buses=7, vn_kv=20, index=[0, 1, 2, 3, 4, 5, 6], name=None, type="n",
                    geodata=[(0, 0), (0, -1), (-2, -2), (-2, -4), (2, -2), (2, -3), (2, -4)])

    # create external grids
    pp.create_ext_grid(net, 0, vm_pu=1.0, va_degree=0, s_sc_max_mva=100, s_sc_min_mva=50, rx_max=0.1, rx_min=0.1)

    pp.create_lines(net, from_buses=[0, 1, 2, 1, 4, 5], to_buses=[1, 2, 3, 4, 5, 6], length_km=[2, 5, 4, 4, 0.5, 0.5],
                    std_type="NAYY 4x50 SE",
                    name=None, index=[0, 1, 2, 3, 4, 5], df=1., parallel=1)

    net.line["endtemp_degree"] = 250

    # Define switches
    pp.create_switches(net, buses=[0, 1, 1, 2, 4, 5], elements=
    [0, 1, 3, 2, 4, 5], et='l', type="CB_DTOC")
    # define load
    pp.create_loads(net, buses=[3, 6], p_mw=[5, 2], q_mvar=[1, 1], const_z_percent=0, const_i_percent=0, sn_mva=None,
                    name=None, scaling=1., index=[0, 1])

    return net

net = oc_relay_net()
from pandapower.protection.protection_devices.ocrelay import OCRelay

for k in range(6):
    OCRelay(net, switch_index=k, oc_relay_type='DTOC', time_settings=[0.07, 0.5, 0.3])

from pandapower.protection.utility_functions import create_sc_bus
import pandapower.shortcircuit as sc
from pandapower.protection.run_protection import calculate_protection_times

# calculate the short circuit
net_sc = create_sc_bus(net, sc_line_id=4, sc_fraction=0.5)
sc.calc_sc(net_sc, bus=max(net_sc.bus.index), branch_results=True)

# calculate the protection times
protection_results = calculate_protection_times(net_sc, scenario='sc')

# show protection_results
print(protection_results)

net.protection.object.at[2].plot_protection_characteristic(net=net, xmin=10, xmax=10000, ymin=0.01, ymax=10000)
plt.grid(True)
plt.xlabel("Ток [А]")
plt.ylabel("Время [с]")
plt.title("Relay")
plt.show()

Issue Description and Traceback

The issue with new version of numpy (2.0.0) is importing Inf, while new numpy need to import inf started with small letter

Traceback (most recent call last):
File "E:\PyCharmProjects\pythonProject````````.py", line 1, in
import pandapower as pp
File "C:\Users\Lolik\AppData\Local\Programs\Python\venv\Lib\site-packages\pandapower_init_.py", line 11, in
from pandapower.powerflow import *
File "C:\Users\Lolik\AppData\Local\Programs\Python\venv\Lib\site-packages\pandapower\powerflow.py", line 13, in
from pandapower.pf.run_bfswpf import _run_bfswpf
File "C:\Users\Lolik\AppData\Local\Programs\Python\venv\Lib\site-packages\pandapower\pf\run_bfswpf.py", line 20, in
from pandapower.pypower.newtonpf import evaluate_Fx, check_for_convergence
File "C:\Users\Lolik\AppData\Local\Programs\Python\venv\Lib\site-packages\pandapower\pypower\newtonpf.py", line 14, in
from numpy import float64, array, angle, sqrt, square, exp, linalg, conj, r
, Inf, arange, zeros,
ImportError: cannot import name 'Inf' from 'numpy' (C:\Users\Lolik\AppData\Local\Programs\Python\venv\Lib\site-packages\numpy_init
.py). Did you mean: 'inf'?

Expected Behavior

Can`t run any code with this traceback after attempt to impor pandapower

Installed Versions

  • python version: 3.12.4.final.0 * pandas version: 2.2.2 * scipy version: 1.13.0 * numpy version: 2.0.0 * Operating System name/version: Windows/10.0.19045

Label

  • Relevant labels are selected
@bimbimbambam69
Copy link
Author

bimbimbambam69 commented Jul 15, 2024

just need to rewrite from all Inf to inf

@bimbimbambam69
Copy link
Author

Official changelog of numpy 2.0.0:
Alias np.Inf has been removed. Use np.inf instead.

@pawellytaev
Copy link
Contributor

Hi, this will be fixed in the upcoming release, see the current changelog on pandapower develop:
[FIXED] namespace changes from numpy 2.0 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants