-
Notifications
You must be signed in to change notification settings - Fork 56
Fix unstable connectable ordering #3786
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
184f97b
275a016
db36e3c
42cc225
49ac905
e18c7a6
73702cd
1ee0b69
ccf8384
c15bfe5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -351,7 +351,9 @@ public static <T extends Identifiable> Iterable<T> sorted(Iterable<T> identifiab | |
| return exportOptions.isSorted() ? StreamSupport.stream(identifiables.spliterator(), false) | ||
| .sorted(Comparator.comparing(Identifiable::getId)) | ||
| .collect(Collectors.toList()) | ||
| : identifiables; | ||
| : StreamSupport.stream(identifiables.spliterator(), false) | ||
| .sorted(Comparator.comparing(Identifiable::getSortIndex)) | ||
| .collect(Collectors.toList()); | ||
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** | ||
| * Copyright (c) 2025, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| * SPDX-License-Identifier: MPL-2.0 | ||
| */ | ||
| package com.powsybl.iidm.serde; | ||
|
|
||
| import com.powsybl.iidm.network.Network; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| /** | ||
| * @author Florian Dupuy {@literal <florian.dupuy at rte-france.com>} | ||
| */ | ||
| class ConnectableOrderingXmlTest extends AbstractIidmSerDeTest { | ||
|
|
||
| @Test | ||
| void testAttributOrderingKO() throws IOException { | ||
| ExportOptions exportOptions = new ExportOptions(); | ||
| roundTripTest(Network.read("/twtOrdering.xiidm", getNetworkAsStream("/twtOrdering.xiidm")), | ||
| (n, p) -> NetworkSerDe.write(n, exportOptions, p), | ||
| NetworkSerDe::validateAndRead, | ||
| "/twtOrdering.xiidm"); | ||
| } | ||
|
|
||
| @Test | ||
| void testCopy() throws IOException { | ||
| Network network = Network.read("/twtOrdering.xiidm", getNetworkAsStream("/twtOrdering.xiidm")); | ||
| Network exportNetwork = NetworkSerDe.copy(network); | ||
| assertEquals(exportNetwork.getTwoWindingsTransformers().toString(), network.getTwoWindingsTransformers().toString()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_15" id="sim1" caseDate="2013-01-15T18:45:00.000+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS"> | ||
alicecaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A"> | ||
| <iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER"> | ||
| <iidm:busBreakerTopology> | ||
| <iidm:bus id="NGEN1"/> | ||
| <iidm:bus id="NGEN2"/> | ||
| </iidm:busBreakerTopology> | ||
| <iidm:generator id="GEN" energySource="OTHER" minP="-9999.99" maxP="9999.99" voltageRegulatorOn="true" targetP="607.0" targetV="24.5" targetQ="301.0" bus="NGEN1" connectableBus="NGEN1"> | ||
| <iidm:minMaxReactiveLimits minQ="-9999.99" maxQ="9999.99"/> | ||
| </iidm:generator> | ||
| </iidm:voltageLevel> | ||
| <iidm:voltageLevel id="VLHV1" nominalV="380.0" topologyKind="BUS_BREAKER"> | ||
| <iidm:busBreakerTopology> | ||
| <iidm:bus id="NHV1"/> | ||
| </iidm:busBreakerTopology> | ||
| </iidm:voltageLevel> | ||
| <iidm:twoWindingsTransformer id="NGEN_NHV1" r="0.2" x="11.1" g="0.0" b="0.0" ratedU1="24.0" ratedU2="400.0" bus1="NGEN1" connectableBus1="NGEN1" voltageLevelId1="VLGEN" bus2="NHV1" connectableBus2="NHV1" voltageLevelId2="VLHV1"/> | ||
alicecaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <iidm:twoWindingsTransformer id="NGEN_NHV2" r="0.2" x="11.1" g="0.0" b="0.0" ratedU1="24.0" ratedU2="400.0" bus1="NGEN2" connectableBus1="NGEN2" voltageLevelId1="VLGEN" bus2="NHV1" connectableBus2="NHV1" voltageLevelId2="VLHV1"/> | ||
| <iidm:twoWindingsTransformer id="twtTest" r="1.0" x="1.0" g="0.0" b="0.0" ratedU1="220.0" ratedU2="400.0" bus1="NGEN1" connectableBus1="NGEN1" voltageLevelId1="VLGEN" bus2="NHV1" connectableBus2="NHV1" voltageLevelId2="VLHV1"/> | ||
| </iidm:substation> | ||
| </iidm:network> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
alicecaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_15" id="sim1" caseDate="2013-01-15T18:45:00.000+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS"> | ||
| <iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A"> | ||
| <iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER"> | ||
| <iidm:busBreakerTopology> | ||
| <iidm:bus id="NGEN1"/> | ||
| <iidm:bus id="NGEN2"/> | ||
| </iidm:busBreakerTopology> | ||
| <iidm:generator id="GEN" energySource="OTHER" minP="-9999.99" maxP="9999.99" voltageRegulatorOn="true" targetP="607.0" targetV="24.5" targetQ="301.0" bus="NGEN1" connectableBus="NGEN1"> | ||
| <iidm:minMaxReactiveLimits minQ="-9999.99" maxQ="9999.99"/> | ||
| </iidm:generator> | ||
| </iidm:voltageLevel> | ||
| <iidm:voltageLevel id="VLHV1" nominalV="380.0" topologyKind="BUS_BREAKER"> | ||
| <iidm:busBreakerTopology> | ||
| <iidm:bus id="NHV1"/> | ||
| </iidm:busBreakerTopology> | ||
| </iidm:voltageLevel> | ||
| <iidm:twoWindingsTransformer id="NGEN_NHV1" r="0.2" x="11.1" g="0.0" b="0.0" ratedU1="24.0" ratedU2="400.0" voltageLevelId1="VLGEN" bus1="NGEN1" connectableBus1="NGEN1" voltageLevelId2="VLHV1" bus2="NHV1" connectableBus2="NHV1"/> | ||
| <iidm:twoWindingsTransformer id="twtTest" r="1.0" x="1.0" g="0.0" b="0.0" ratedU1="220.0" ratedU2="400.0" voltageLevelId1="VLGEN" bus1="NGEN1" connectableBus1="NGEN1" voltageLevelId2="VLHV1" bus2="NHV1" connectableBus2="NHV1"/> | ||
| <iidm:twoWindingsTransformer id="NGEN_NHV2" r="0.2" x="11.1" g="0.0" b="0.0" ratedU1="24.0" ratedU2="400.0" voltageLevelId1="VLGEN" bus1="NGEN2" connectableBus1="NGEN2" voltageLevelId2="VLHV1" bus2="NHV1" connectableBus2="NHV1"/> | ||
| </iidm:substation> | ||
| </iidm:network> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test should be added in the TCK to ensure that the custom IIDM implementations handle it correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done