diff --git a/docs/user_guide/loadflow.rst b/docs/user_guide/loadflow.rst index 6a0302886..1ab017b9d 100644 --- a/docs/user_guide/loadflow.rst +++ b/docs/user_guide/loadflow.rst @@ -91,11 +91,11 @@ possible values if applicable, using: .. doctest:: :options: +NORMALIZE_WHITESPACE - >>> lf.get_provider_parameters().iloc[:2] - description type default possible_values + >>> lf.get_provider_parameters().query('name == "slackBusSelectionMode" or name == "slackBusesIds"') + category_key description type default possible_values name - slackBusSelectionMode Slack bus selection mode STRING MOST_MESHED [FIRST, MOST_MESHED, NAME, LARGEST_GENERATOR] - slackBusesIds Slack bus IDs STRING_LIST + slackBusSelectionMode SlackDistribution Slack bus selection mode STRING MOST_MESHED [FIRST, MOST_MESHED, NAME, LARGEST_GENERATOR] + slackBusesIds SlackDistribution Slack bus IDs STRING_LIST For instance, OLF supports configuration of slack bus from its ID like this: diff --git a/java/src/main/java/com/powsybl/python/loadflow/LoadFlowCUtils.java b/java/src/main/java/com/powsybl/python/loadflow/LoadFlowCUtils.java index 60f47f1fb..c323b2e3f 100644 --- a/java/src/main/java/com/powsybl/python/loadflow/LoadFlowCUtils.java +++ b/java/src/main/java/com/powsybl/python/loadflow/LoadFlowCUtils.java @@ -21,6 +21,7 @@ import com.powsybl.python.commons.PyPowsyblConfiguration; import org.graalvm.nativeimage.UnmanagedMemory; +import java.util.Comparator; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -31,8 +32,9 @@ public final class LoadFlowCUtils { static final DataframeMapper SPECIFIC_PARAMETERS_MAPPER = new DataframeMapperBuilder() - .itemsProvider(provider -> provider.getSpecificParameters()) + .itemsProvider(provider -> provider.getSpecificParameters().stream().sorted(Comparator.comparing(Parameter::getCategoryKey).thenComparing(Parameter::getName)).toList()) .stringsIndex("name", Parameter::getName) + .strings("category_key", p -> Objects.toString(p.getCategoryKey(), "")) .strings("description", Parameter::getDescription) .enums("type", ParameterType.class, Parameter::getType) .strings("default", p -> Objects.toString(p.getDefaultValue(), "")) diff --git a/pypowsybl/loadflow/impl/loadflow.py b/pypowsybl/loadflow/impl/loadflow.py index c6ea7902f..998c166b1 100644 --- a/pypowsybl/loadflow/impl/loadflow.py +++ b/pypowsybl/loadflow/impl/loadflow.py @@ -135,12 +135,16 @@ def get_provider_parameters(provider: str = None) -> DataFrame: .. doctest:: >>> parameters = pp.loadflow.get_provider_parameters('OpenLoadFlow') + >>> parameters['category_key']['slackBusSelectionMode'] + 'SlackDistribution' >>> parameters['description']['slackBusSelectionMode'] 'Slack bus selection mode' >>> parameters['type']['slackBusSelectionMode'] 'STRING' >>> parameters['default']['slackBusSelectionMode'] 'MOST_MESHED' + >>> parameters['possible_values']['slackBusSelectionMode'] + '[FIRST, MOST_MESHED, NAME, LARGEST_GENERATOR]' """ series_array = _pypowsybl.create_loadflow_provider_parameters_series_array('' if provider is None else provider) return create_data_frame_from_series_array(series_array)