Skip to content

Commit

Permalink
Merge branch 'main' into improve_documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
colinepiloquet authored Jul 16, 2024
2 parents 55729a0 + 5aa73ef commit 44b7347
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
name: Build linux ${{ matrix.python.name }} wheel
runs-on: ubuntu-latest
container: quay.io/pypa/manylinux2014_x86_64:2024-07-01-8dac23b
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
strategy:
matrix:
python:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
name: Build linux ${{ matrix.python.name }} wheel
runs-on: ubuntu-latest
container: quay.io/pypa/manylinux2014_x86_64:2024-07-01-8dac23b
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
strategy:
matrix:
python:
Expand Down
13 changes: 13 additions & 0 deletions cpp/powsybl-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
cmake_minimum_required(VERSION 3.14)
project(powsybl-cpp)

# Enable static linkage to prevent any future runtime binary compatibility issue
if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()

include(ExternalProject)

set(POWSYBL_CPP_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}powsybl-cpp${CMAKE_SHARED_LIBRARY_SUFFIX})
Expand Down Expand Up @@ -95,4 +101,11 @@ if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
add_custom_command(TARGET powsybl-cpp POST_BUILD ${POWSYBL_CPP_INSTALL_EXTRA_COMMAND} COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:powsybl-cpp> ${PYPOWSYBL_JAVA_BIN_DIR}/${PYPOWSYBL_JAVA_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${POWSYBL_MATH_NATIVE_JAR_ENTRY_DIR}/${POWSYBL_MATH_NATIVE_LIB} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endif(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)

# Fix related to issue describred here https://github.com/actions/runner-images/issues/10004#issuecomment-2156109231
# Should fix incompatibility between MSVC runtime 14.40.XXX and previous version
if(MSVC)
target_compile_definitions(powsybl-cpp
PRIVATE _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
endif()

target_link_libraries(powsybl-cpp PUBLIC ${PYPOWSYBL_JAVA_LIB})
14 changes: 14 additions & 0 deletions cpp/pypowsybl-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
cmake_minimum_required(VERSION 3.14)
project(pypowsybl-cpp)

# Enable static linkage to prevent any future runtime binary compatibility issue
if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()

set(POWSYBL_CPP_SOURCE_DIR "../powsybl-cpp")
set(PYPOWSYBL_JAVA_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/../java)
include_directories(${POWSYBL_CPP_SOURCE_DIR} ${PYPOWSYBL_JAVA_BIN_DIR})
Expand All @@ -16,4 +22,12 @@ pybind11_add_module(_pypowsybl pylogging.cpp bindings.cpp)

add_dependencies(_pypowsybl native-image math-native)
add_dependencies(math-native native-image) # because mvn command also copy math native jar

# Fix related to issue describred here https://github.com/actions/runner-images/issues/10004#issuecomment-2156109231
# Should fix incompatibility between MSVC runtime 14.40.XXX and previous version
if(MSVC)
target_compile_definitions(_pypowsybl
PRIVATE _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
endif()

target_link_libraries(_pypowsybl PRIVATE powsybl-cpp)
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static String toStringOrNull(CCharPointer charPtr) {

public static String[][] toString2DArray(CCharPointerPointer charPtrPtr, int length, int rows) {
int cols = length / rows;
String[][] string2DArray = new String[rows][length / cols];
String[][] string2DArray = new String[rows][cols];
int index = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
Expand Down
4 changes: 2 additions & 2 deletions pypowsybl/network/impl/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1776,8 +1776,8 @@ def get_hvdc_lines(self, all_attributes: bool = False, attributes: List[str] = N
Notes:
The resulting dataframe, depending on the parameters, will include the following columns:
- **converters_mode**:
- **target_p**: (in MW)
- **converters_mode**: the mode of the converter stations. It can be either SIDE_1_RECTIFIER_SIDE_2_INVERTER or SIDE_1_INVERTER_SIDE_2_RECTIFIER
- **target_p**: active power target (in MW)
- **max_p**: the maximum of active power that can pass through the hvdc line (in MW)
- **nominal_v**: nominal voltage (in kV)
- **r**: the resistance of the hvdc line (in Ohm)
Expand Down
4 changes: 3 additions & 1 deletion pypowsybl/voltage_initializer/impl/voltage_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .voltage_initializer_results import VoltageInitializerResults


def run(network: Network, params: VoltageInitializerParameters = VoltageInitializerParameters(), debug: bool = False) \
def run(network: Network, params: VoltageInitializerParameters, debug: bool = False) \
-> VoltageInitializerResults:
"""
Run voltage initializer on the network with the given params.
Expand All @@ -20,5 +20,7 @@ def run(network: Network, params: VoltageInitializerParameters = VoltageInitiali
params: The parameters used to customize the run
debug: if true, the tmp directory of the voltage initializer run will not be erased.
"""
if params is None:
params = VoltageInitializerParameters()
result_handle = run_voltage_initializer(debug, network._handle, params._handle)
return VoltageInitializerResults(result_handle)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ pandas==2.2.2; python_version >= "3.9"
pandas==2.0.3; python_version <= "3.8"
prettytable==2.0.0
networkx
matplotlib
matplotlib==3.9.0; python_version >= "3.9"
matplotlib; python_version <= "3.8"

# documentation dependencies
sphinx==7.1.2
Expand Down
8 changes: 8 additions & 0 deletions tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,14 @@ def test_sld_svg():
assert re.search('.*<svg.*', sld_multi_substation2.svg)
assert len(sld_multi_substation2.metadata) > 0

sld_multi_substation3 = n.get_matrix_multi_substation_single_line_diagram([['S1'],['S2']])
assert re.search('.*<svg.*', sld_multi_substation3.svg)
assert len(sld_multi_substation3.metadata) > 0

sld_multi_substation4 = n.get_matrix_multi_substation_single_line_diagram([['S1', 'S2']])
assert re.search('.*<svg.*', sld_multi_substation4.svg)
assert len(sld_multi_substation4.metadata) > 0

def test_sld_svg_backward_compatibility():
n = pp.network.create_four_substations_node_breaker_network()
sld = n.get_single_line_diagram('S1VL1', LayoutParameters(use_name=True, center_name=True, diagonal_label=True,
Expand Down

0 comments on commit 44b7347

Please sign in to comment.