From f2cc2bcd29fac20553374eb06470cd0dd7d5df59 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Tue, 12 Mar 2024 08:41:24 +0100 Subject: [PATCH] Fix MacOS ARM build (#725) Signed-off-by: Geoffroy Jamgotchian --- .../python/security/SecurityAnalysisTest.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/java/src/test/java/com/powsybl/python/security/SecurityAnalysisTest.java b/java/src/test/java/com/powsybl/python/security/SecurityAnalysisTest.java index 1f7ab99eed..1936997f8d 100644 --- a/java/src/test/java/com/powsybl/python/security/SecurityAnalysisTest.java +++ b/java/src/test/java/com/powsybl/python/security/SecurityAnalysisTest.java @@ -12,7 +12,6 @@ import com.powsybl.dataframe.impl.Series; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; -import com.powsybl.openloadflow.OpenLoadFlowParameters; import com.powsybl.python.network.Dataframes; import com.powsybl.python.network.Networks; import com.powsybl.security.SecurityAnalysisParameters; @@ -20,6 +19,7 @@ import com.powsybl.security.monitor.StateMonitor; import com.powsybl.security.results.BranchResult; import org.assertj.core.api.Assertions; +import org.assertj.core.data.Offset; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -34,7 +34,6 @@ class SecurityAnalysisTest { @Test void testStateMonitors() { - var params = new OpenLoadFlowParameters(); SecurityAnalysisContext analysisContext = new SecurityAnalysisContext(); analysisContext.addContingency("NHV1_NHV2_1", Collections.singletonList("NHV1_NHV2_1")); analysisContext.addMonitor(new StateMonitor(new ContingencyContext("NHV1_NHV2_1", ContingencyContextType.SPECIFIC), @@ -43,13 +42,24 @@ void testStateMonitors() { Collections.singleton("NHV1_NHV2_2"), Collections.emptySet(), Collections.emptySet())); Network network = Networks.createEurostagTutorialExample1(); SecurityAnalysisResult result = analysisContext.run(network, new SecurityAnalysisParameters(), "OpenLoadFlow", Reporter.NO_OP); - assertThat(result.getPreContingencyResult().getNetworkResult().getBranchResults()).containsExactly(new BranchResult("NHV1_NHV2_2", - 302.44404914466014, 98.74027438014933, 456.7689759899916, -300.43389523337316, - -137.18849307164064, 488.99279636727357)); + assertThat(result.getPreContingencyResult().getNetworkResult().getBranchResults()).hasSize(1); + BranchResult branchResult = result.getPreContingencyResult().getNetworkResult().getBranchResults().get(0); + var eps = Offset.offset(1e-12); + assertThat(branchResult.getP1()).isCloseTo(302.44404914466014, eps); + assertThat(branchResult.getQ1()).isCloseTo(98.74027438014933, eps); + assertThat(branchResult.getI1()).isCloseTo(456.7689759899916, eps); + assertThat(branchResult.getP2()).isCloseTo(-300.43389523337316, eps); + assertThat(branchResult.getQ2()).isCloseTo(-137.18849307164064, eps); + assertThat(branchResult.getI2()).isCloseTo(488.99279636727357, eps); assertThat(result.getPostContingencyResults()).hasSize(1); - assertThat(result.getPostContingencyResults().get(0).getNetworkResult().getBranchResults()).containsExactly(new BranchResult("NHV1_NHV2_2", - 610.5621535433198, 334.0562715296571, 1008.9287882269945, -600.9961559564284, - -285.3791465506596, 1047.8257691455574)); + assertThat(result.getPreContingencyResult().getNetworkResult().getBranchResults()).hasSize(1); + branchResult = result.getPostContingencyResults().get(0).getNetworkResult().getBranchResults().get(0); + assertThat(branchResult.getP1()).isCloseTo(610.5621535433198, eps); + assertThat(branchResult.getQ1()).isCloseTo(334.0562715296571, eps); + assertThat(branchResult.getI1()).isCloseTo(1008.9287882269945, eps); + assertThat(branchResult.getP2()).isCloseTo(-600.9961559564284, eps); + assertThat(branchResult.getQ2()).isCloseTo(-285.3791465506596, eps); + assertThat(branchResult.getI2()).isCloseTo(1047.8257691455574, eps); } @Test