Skip to content

Commit adb2d25

Browse files
authored
fix for test_cigre_with_bad_data (#2875)
updated state_estimation to not warn as it seems to be fine now. update in auxiliary.py to support numpy 1
1 parent bafe0a1 commit adb2d25

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

pandapower/auxiliary.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ def _sum_by_group(
731731
) -> tuple[NDArray[np.int64], NDArray[np.float64], NDArray[np.float64]]:
732732
order: NDArray[np.int64] = np.argsort(bus)
733733
bus = bus[order]
734-
index: NDArray[np.bool] = np.ones(len(bus), 'bool')
734+
index: NDArray[bool] = np.ones(len(bus), 'bool')
735735
index[:-1] = bus[1:] != bus[:-1]
736736
bus = bus[index]
737737
first_val = first_val[order]
@@ -1058,8 +1058,8 @@ def _write_to_object_attribute(
10581058

10591059

10601060
def _set_isolated_nodes_out_of_service(
1061-
ppc: PyPowerNetwork, bus_not_reachable: NDArray[np.bool], dc: bool = False
1062-
) -> tuple[NDArray[np.bool], int, int, PyPowerNetwork]:
1061+
ppc: PyPowerNetwork, bus_not_reachable: NDArray[bool], dc: bool = False
1062+
) -> tuple[NDArray[bool], int, int, PyPowerNetwork]:
10631063
isolated_nodes = np.nonzero(bus_not_reachable)[0]
10641064
if len(isolated_nodes) > 0:
10651065
logger.debug("There are isolated buses in the network! (%i nodes in the PPC)" % len(isolated_nodes))
@@ -1080,7 +1080,7 @@ def _set_isolated_nodes_out_of_service(
10801080
return isolated_nodes, pus, qus, ppc
10811081

10821082

1083-
def _check_connectivity_opf(ppc: PyPowerNetwork) -> tuple[NDArray[np.bool], int, int]:
1083+
def _check_connectivity_opf(ppc: PyPowerNetwork) -> tuple[NDArray[bool], int, int]:
10841084
"""
10851085
Checks if the ppc contains isolated buses and changes slacks to PV nodes if multiple slacks are
10861086
in net.
@@ -1120,7 +1120,7 @@ def _check_connectivity_opf(ppc: PyPowerNetwork) -> tuple[NDArray[np.bool], int,
11201120
return isolated_nodes, pus, qus
11211121

11221122

1123-
def _check_connectivity(ppc: PyPowerNetwork) -> tuple[NDArray[np.bool], int, int, NDArray[np.bool], int, int]:
1123+
def _check_connectivity(ppc: PyPowerNetwork) -> tuple[NDArray[bool], int, int, NDArray[bool], int, int]:
11241124
"""
11251125
Checks if the ppc contains isolated buses. If yes this isolated buses are set out of service
11261126
:param ppc: pypower case file
@@ -1228,14 +1228,14 @@ def _subnetworks(ppc: PyPowerNetwork) -> list[list[int]]:
12281228

12291229

12301230
def _python_set_elements_oos(
1231-
ti: NDArray[np.int64], tis: NDArray[np.bool], bis: NDArray[np.bool], lis: NDArray[np.bool]
1231+
ti: NDArray[np.int64], tis: NDArray[bool], bis: NDArray[bool], lis: NDArray[bool]
12321232
) -> None: # pragma: no cover
12331233
for i in range(len(ti)):
12341234
if tis[i] and bis[ti[i]]:
12351235
lis[i] = True
12361236

12371237

1238-
def _python_set_isolated_buses_oos(bus_in_service: NDArray[np.bool], ppc_bus_isolated: NDArray[np.bool],
1238+
def _python_set_isolated_buses_oos(bus_in_service: NDArray[bool], ppc_bus_isolated: NDArray[bool],
12391239
bus_lookup: NDArray[np.int64]): # pragma: no cover
12401240
for k in range(len(bus_in_service)):
12411241
if ppc_bus_isolated[bus_lookup[k]]:
@@ -1923,7 +1923,7 @@ def SVabc_from_SV012(
19231923
S012: NDArray[NumpyDType],
19241924
V012: NDArray[NumpyDType],
19251925
n_res: int | None = None,
1926-
idx: NDArray[np.bool] | None = None,
1926+
idx: NDArray[bool] | None = None,
19271927
) -> tuple[NDArray[NumpyDType], NDArray[NumpyDType]]:
19281928
if n_res is None:
19291929
n_res = S012.shape[1]

pandapower/estimation/state_estimation.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ def estimate(
7373
Returns:
7474
bool: Was the state estimation successful?
7575
"""
76-
# numpy 1 is not reliable with estimate. Most likely precision is at fault.
77-
if np.__version__.startswith('1.'):
78-
raise UserWarning("numpy 1.x should not be used with estimate as it has known Issues")
79-
80-
8176
if algorithm not in ALGORITHM_MAPPING:
8277
raise UserWarning("Algorithm {} is not a valid estimator".format(algorithm))
8378

pandapower/test/estimation/test_wls_estimation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,16 +448,16 @@ def test_cigre_network_with_slack_init():
448448
test_cigre_network(init='slack')
449449

450450

451-
@pytest.mark.skip(reason="numba/numpy version related issue, fix in progress")
452451
def test_cigre_with_bad_data():
453-
np.random.seed(123456)
454452
net = create_cigre_network_mv(with_der=False)
455-
net.load.q_mvar = net.load["p_mw"].apply(lambda p: p * np.tan(np.arccos(np.random.choice([0.95, 0.9, 0.97]))))
453+
net.load.q_mvar = net.load["p_mw"].apply(lambda p: p * np.tan(np.arccos(0.9)))
456454
runpp(net)
457455

458456
for bus, row in net.res_bus.iterrows():
459-
if bus == 2:
460-
continue
457+
# numerical instability in the output of runpp caused by numba installation status will make this test fail if
458+
# no measurements are provided for bus 2! See #2867
459+
# if bus == 2:
460+
# continue
461461
if bus != 6:
462462
create_measurement(net, "v", "bus", row.vm_pu * r(0.01), 0.01, bus) # skip our bad data measurement
463463
create_measurement(net, "p", "bus", row.p_mw * r(), max(0.001, abs(0.03 * row.p_mw)), bus)

0 commit comments

Comments
 (0)