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

Copy array element to standard python scalar #2415

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Change Log

[upcoming release] - 2024-..-..
-------------------------------
- [FIXED] copy array element to standard python scalar
- [FIXED] replacing deprecated in1d with isin
- [ADDED] A switch to disable updating the vk and vkr values for trafo3w
- [FIXED] cast the column to the correct type before assigning values
Expand Down
4 changes: 2 additions & 2 deletions pandapower/estimation/state_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def perform_chi2_test(self, v_in_out=None, delta_in_out=None,
self.logger.debug("Result of Chi^2 test:")
self.logger.debug("Number of measurements: %d" % m)
self.logger.debug("Number of state variables: %d" % n)
self.logger.debug("Performance index: %.2f" % J)
self.logger.debug("Performance index: %.2f" % J.item())
self.logger.debug("Chi^2 test threshold: %.2f" % test_thresh)

if J <= test_thresh:
Expand Down Expand Up @@ -421,7 +421,7 @@ def perform_rn_max_test(self, v_in_out=None, delta_in_out=None,
else:
self.logger.debug(
"Largest normalized residual test failed (%.1f > %.1f)."
% (max(rN), rn_max_threshold))
% (max(rN).item(), rn_max_threshold))

# Identify bad data: Determine index corresponding to max(rN):
idx_rN = np.argsort(rN, axis=0)[-1]
Expand Down
2 changes: 1 addition & 1 deletion pandapower/grid_equivalents/rei_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def _create_net_zpbn(net, boundary_buses, all_internal_buses, all_external_buses
sn_mva=Sn, index=max_sgen_idx+len(net_zpbn.sgen)+1)
elif elm == "gen":
vm_pu = v[key+"_vm_total"][v.ext_bus == int(re.findall(r"\d+", busstr)[0])].values.real
elm_idx = pp.create_gen(net_zpbn, i, float(P), float(vm_pu), name=key+"_rei_"+busstr,
elm_idx = pp.create_gen(net_zpbn, i, float(P), float(vm_pu.item()), name=key+"_rei_"+busstr,
sn_mva=Sn, index=max_gen_idx+len(net_zpbn.gen)+1)

# ---- match other columns
Expand Down
48 changes: 24 additions & 24 deletions pandapower/test/control/test_discrete_tap_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def test_discrete_tap_control_lv():

logger.info("case1: low voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == -1

# increase voltage from 1.0 pu to 1.03 pu
Expand All @@ -56,13 +56,13 @@ def test_discrete_tap_control_lv():

logger.info("case2: high voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == -2
# reduce voltage from 1.03 pu to 0.949 pu
net.ext_grid.vm_pu = 0.949
Expand All @@ -72,13 +72,13 @@ def test_discrete_tap_control_lv():

logger.info("case2: high voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == 1


Expand All @@ -100,13 +100,13 @@ def test_discrete_tap_control_hv():

logger.info("case1: low voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == 1
# increase voltage from 1.0 pu to 1.03 pu
net.ext_grid.vm_pu = 1.03
Expand All @@ -116,13 +116,13 @@ def test_discrete_tap_control_hv():

logger.info("case2: high voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == 2
# increase voltage from 1.0 pu to 1.03 pu
net.ext_grid.vm_pu = 0.949
Expand All @@ -132,13 +132,13 @@ def test_discrete_tap_control_hv():

logger.info("case2: high voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == -1


Expand All @@ -160,13 +160,13 @@ def test_discrete_tap_control_lv_from_tap_step_percent():

logger.info("case1: low voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == -1

# check if it changes the lower and upper limits
Expand All @@ -187,13 +187,13 @@ def test_discrete_tap_control_lv_from_tap_step_percent():

logger.info("case2: high voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == -2
# reduce voltage from 1.03 pu to 0.969 pu
net.ext_grid.vm_pu = 0.969
Expand All @@ -203,13 +203,13 @@ def test_discrete_tap_control_lv_from_tap_step_percent():

logger.info("case2: high voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == 1


Expand All @@ -231,13 +231,13 @@ def test_discrete_tap_control_hv_from_tap_step_percent():

logger.info("case1: low voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == 1

# check if it changes the lower and upper limits
Expand All @@ -258,13 +258,13 @@ def test_discrete_tap_control_hv_from_tap_step_percent():

logger.info("case2: high voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == 2
# reduce voltage from 1.03 pu to 0.969 pu
net.ext_grid.vm_pu = 0.969
Expand All @@ -274,13 +274,13 @@ def test_discrete_tap_control_hv_from_tap_step_percent():

logger.info("case2: high voltage")
logger.info("before control: trafo voltage at low voltage bus is %f, tap position is %u"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))

# run control
pp.runpp(net, run_control=True)
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
% (net.res_bus.vm_pu[net.trafo.lv_bus].values.item(), net.trafo.tap_pos.values.item()))
assert net.trafo.tap_pos.at[0] == -1


Expand Down
Loading