Skip to content

Commit 67ebfbb

Browse files
authored
Scenarios/plot network (#262)
* Catch bug in plot_network with 2D arrays * Add plot_network() to test_io.py
1 parent c0cbaae commit 67ebfbb

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

flixopt/structure.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@ def describe_numpy_arrays(arr: np.ndarray) -> Union[str, List]:
636636

637637
def normalized_center_of_mass(array: Any) -> float:
638638
# position in array (0 bis 1 normiert)
639+
if array.ndim >= 2: # No good way to calculate center of mass for 2D arrays
640+
return np.nan
639641
positions = np.linspace(0, 1, len(array)) # weights w_i
640642
# mass center
641643
if np.sum(array) == 0:

tests/test_io.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def test_flow_system_file_io(flow_system, highs_solver):
2828
calculation_0 = fx.FullCalculation('IO', flow_system=flow_system)
2929
calculation_0.do_modeling()
3030
calculation_0.solve(highs_solver)
31+
calculation_0.flow_system.plot_network()
3132

3233
calculation_0.results.to_file()
3334
paths = CalculationResultsPaths(calculation_0.folder, calculation_0.name)
@@ -36,6 +37,7 @@ def test_flow_system_file_io(flow_system, highs_solver):
3637
calculation_1 = fx.FullCalculation('Loaded_IO', flow_system=flow_system_1)
3738
calculation_1.do_modeling()
3839
calculation_1.solve(highs_solver)
40+
calculation_1.flow_system.plot_network()
3941

4042
assert_almost_equal_numeric(
4143
calculation_0.results.model.objective.value,

0 commit comments

Comments
 (0)