Skip to content

Commit

Permalink
fix a bug introduced in a breaking change of pypowsybl 1.10.0
Browse files Browse the repository at this point in the history
Signed-off-by: DONNOT Benjamin <[email protected]>
  • Loading branch information
BDonnot committed Feb 12, 2025
1 parent 0277110 commit d2f7411
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Benjamin DONNOT'

# The full version, including alpha/beta/rc tags
release = "0.10.1"
release = "0.10.1.post1"
version = '0.10'

# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lightsim2grid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# SPDX-License-Identifier: MPL-2.0
# This file is part of LightSim2grid, LightSim2grid implements a c++ backend targeting the Grid2Op platform.

__version__ = "0.10.1"
__version__ = "0.10.1.post1"

__all__ = ["newtonpf", "SolverType", "ErrorType", "solver", "compilation_options"]

Expand Down
12 changes: 7 additions & 5 deletions lightsim2grid/gridmodel/from_pypowsybl/_from_pypowsybl.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Optional, Union
from packaging import version

PP_BUG_RATIO_TAP_CHANGER = version.parse("1.9.0")
PP_BUG_RATIO_TAP_CHANGER = version.parse("1.9")
PYPOWSYBL_VER = version.parse(pypo.__version__)
from lightsim2grid_cpp import GridModel

Expand Down Expand Up @@ -251,12 +251,14 @@ def init(net : pypo.network.Network,
model.set_line_names(df_line.index)

# for trafo
# I extract trafo with `all_attributes=True` so that I have access to the
# `rho`
if sort_index:
df_trafo = net.get_2_windings_transformers().sort_index()
df_trafo = net.get_2_windings_transformers(all_attributes=True).sort_index()
else:
df_trafo = net.get_2_windings_transformers()
df_trafo = net.get_2_windings_transformers(all_attributes=True)

df_trafo_pu = net_pu.get_2_windings_transformers().loc[df_trafo.index]
df_trafo_pu = net_pu.get_2_windings_transformers(all_attributes=True).loc[df_trafo.index]
ratio_tap_changer = net_pu.get_ratio_tap_changers()
if net.get_phase_tap_changers().shape[0] > 0:
raise RuntimeError("Phase tap changer are not handled by the pypowsybl converter (but they are by lightsim2grid)")
Expand Down Expand Up @@ -296,7 +298,7 @@ def init(net : pypo.network.Network,
# bug in per unit view in both python and java
ratio[has_r_tap_changer] = 1. * ratio_tap_changer.loc[df_trafo_pu.loc[has_r_tap_changer].index, "rho"].values
else:
ratio[has_r_tap_changer] *= 1. * ratio_tap_changer.loc[df_trafo_pu.loc[has_r_tap_changer].index, "rho"].values
ratio[has_r_tap_changer] = 1. * df_trafo_pu.loc[has_r_tap_changer, "rho"].values
no_tap = ratio == 1.
tap_neg = ratio < 1.
tap_positive = ratio > 1.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pybind11.setup_helpers import Pybind11Extension, build_ext


__version__ = "0.10.1"
__version__ = "0.10.1.post1"
KLU_SOLVER_AVAILABLE = False

# Try to link against SuiteSparse (if available)
Expand Down

0 comments on commit d2f7411

Please sign in to comment.