From d2f7411aa3c95e4bc7bfe91aae6907f35b52197f Mon Sep 17 00:00:00 2001 From: DONNOT Benjamin Date: Wed, 12 Feb 2025 17:21:12 +0100 Subject: [PATCH] fix a bug introduced in a breaking change of pypowsybl 1.10.0 Signed-off-by: DONNOT Benjamin --- docs/conf.py | 2 +- lightsim2grid/__init__.py | 2 +- .../gridmodel/from_pypowsybl/_from_pypowsybl.py | 12 +++++++----- setup.py | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 7265e23..44392ff 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 --------------------------------------------------- diff --git a/lightsim2grid/__init__.py b/lightsim2grid/__init__.py index 98497a9..4de10b9 100644 --- a/lightsim2grid/__init__.py +++ b/lightsim2grid/__init__.py @@ -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"] diff --git a/lightsim2grid/gridmodel/from_pypowsybl/_from_pypowsybl.py b/lightsim2grid/gridmodel/from_pypowsybl/_from_pypowsybl.py index 0a5cee2..956c5c8 100644 --- a/lightsim2grid/gridmodel/from_pypowsybl/_from_pypowsybl.py +++ b/lightsim2grid/gridmodel/from_pypowsybl/_from_pypowsybl.py @@ -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 @@ -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)") @@ -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. diff --git a/setup.py b/setup.py index 8e51d69..77ecefb 100644 --- a/setup.py +++ b/setup.py @@ -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)