Skip to content

Add multi-input-multi-output converter #1154

Add multi-input-multi-output converter

Add multi-input-multi-output converter #1154

This check has been archived and is scheduled for deletion. Learn more about checks retention
GitHub Actions / Black failed Nov 14, 2023 in 0s

6 errors

Black found 6 errors

Annotations

Check failure on line 397 in /home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_mimo_converter.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_mimo_converter.py#L377-L397

 
         def _input_output_group_relation(block):
             for p, t in m.TIMEINDEX:
                 for n in group:
                     # Connect input groups
-                    for i, ii in zip(list(n.input_groups)[:-1], list(n.input_groups)[1:]):
+                    for i, ii in zip(
+                        list(n.input_groups)[:-1], list(n.input_groups)[1:]
+                    ):
                         block.input_output_relation.add(
                             (n, i, p, t),
                             (
                                 block.INPUT_GROUP_FLOW[n, i, p, t]
                                 == block.INPUT_GROUP_FLOW[n, ii, p, t]
                             ),
                         )
                     # Connect output groups
-                    for o, oo in zip(list(n.output_groups)[:-1], list(n.output_groups)[1:]):
+                    for o, oo in zip(
+                        list(n.output_groups)[:-1], list(n.output_groups)[1:]
+                    ):
                         block.input_output_relation.add(
                             (n, o, p, t),
                             (
                                 block.OUTPUT_GROUP_FLOW[n, o, p, t]
                                 == block.OUTPUT_GROUP_FLOW[n, oo, p, t]

Check failure on line 36 in /home/runner/work/oemof-solph/oemof-solph/tests/test_scripts/test_solph/test_mimo_converter/test_mimo_converter.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/tests/test_scripts/test_solph/test_mimo_converter/test_mimo_converter.py#L21-L36

     es = EnergySystem(timeindex=idx)
 
     # resources
     b_gas = Bus(label="gas")
     es.add(b_gas)
-    es.add(Source(label="gas_station", outputs={b_gas: Flow(fix=[120, 0], nominal_value=1, variable_costs=20)}))
+    es.add(
+        Source(
+            label="gas_station",
+            outputs={
+                b_gas: Flow(fix=[120, 0], nominal_value=1, variable_costs=20)
+            },
+        )
+    )
 
     b_hydro = Bus(label="hydro")
     es.add(b_hydro)
-    es.add(Source(label="hydro_station", outputs={b_hydro: Flow(fix=[0, 130], nominal_value=1, variable_costs=20)}))
+    es.add(
+        Source(
+            label="hydro_station",
+            outputs={
+                b_hydro: Flow(fix=[0, 130], nominal_value=1, variable_costs=20)
+            },
+        )
+    )
 
     b_electricity = Bus(label="electricity")
     es.add(b_electricity)
     es.add(
         Sink(

Check failure on line 52 in /home/runner/work/oemof-solph/oemof-solph/tests/test_scripts/test_solph/test_mimo_converter/test_mimo_converter.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/tests/test_scripts/test_solph/test_mimo_converter/test_mimo_converter.py#L41-L52

     es.add(
         MultiInputMultiOutputConverter(
             label="mimo",
             inputs={"in": {b_gas: Flow(), b_hydro: Flow()}},
             outputs={b_electricity: Flow()},
-            conversion_factors={b_gas: 1.2, b_hydro: 1.3}
+            conversion_factors={b_gas: 1.2, b_hydro: 1.3},
         )
     )
 
     # create an optimization problem and solve it
     om = Model(es)

Check failure on line 80 in /home/runner/work/oemof-solph/oemof-solph/tests/test_scripts/test_solph/test_mimo_converter/test_mimo_converter.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/tests/test_scripts/test_solph/test_mimo_converter/test_mimo_converter.py#L54-L80

     om.solve(solver="cbc")
 
     # create result object
     results = processing.convert_keys_to_strings(processing.results(om))
 
-    assert all(results[("gas", "mimo")]["sequences"]["flow"].values[:-1] == [120.0, 0.0])
-    assert all(results[("hydro", "mimo")]["sequences"]["flow"].values[:-1] == [0.0, 130.0])
+    assert all(
+        results[("gas", "mimo")]["sequences"]["flow"].values[:-1]
+        == [120.0, 0.0]
+    )
+    assert all(
+        results[("hydro", "mimo")]["sequences"]["flow"].values[:-1]
+        == [0.0, 130.0]
+    )
 
 
 def test_flow_shares():
     idx = pd.date_range("1/1/2017", periods=2, freq="H")
     es = EnergySystem(timeindex=idx)
 
     # resources
     b_gas = Bus(label="gas")
     es.add(b_gas)
-    es.add(Source(label="gas_station", outputs={b_gas: Flow(variable_costs=20)}))
+    es.add(
+        Source(label="gas_station", outputs={b_gas: Flow(variable_costs=20)})
+    )
 
     b_hydro = Bus(label="hydro")
     es.add(b_hydro)
-    es.add(Source(label="hydro_station", outputs={b_hydro: Flow(variable_costs=20)}))
+    es.add(
+        Source(
+            label="hydro_station", outputs={b_hydro: Flow(variable_costs=20)}
+        )
+    )
 
     b_electricity = Bus(label="electricity")
     es.add(b_electricity)
     es.add(
         Sink(

Check failure on line 106 in /home/runner/work/oemof-solph/oemof-solph/tests/test_scripts/test_solph/test_mimo_converter/test_mimo_converter.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/tests/test_scripts/test_solph/test_mimo_converter/test_mimo_converter.py#L95-L106

         MultiInputMultiOutputConverter(
             label="mimo",
             inputs={"in": {b_gas: Flow(), b_hydro: Flow()}},
             outputs={b_electricity: Flow(), b_heat: Flow()},
             conversion_factors={b_gas: 1.2, b_hydro: 1.3},
-            input_flow_shares={b_gas: [0.8, 0.3]}
+            input_flow_shares={b_gas: [0.8, 0.3]},
         )
     )
 
     # create an optimization problem and solve it
     om = Model(es)

Check failure on line 115 in /home/runner/work/oemof-solph/oemof-solph/tests/test_scripts/test_solph/test_mimo_converter/test_mimo_converter.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/tests/test_scripts/test_solph/test_mimo_converter/test_mimo_converter.py#L108-L115

     om.solve(solver="cbc")
 
     # create result object
     results = processing.convert_keys_to_strings(processing.results(om))
 
-    assert all(results[("gas", "mimo")]["sequences"]["flow"].values[:-1] == [100 * 0.8 * 1.2, 100 * 0.3 * 1.2])
-    assert all(results[("hydro", "mimo")]["sequences"]["flow"].values[:-1] == [100 * 0.2 * 1.3, 100 * 0.7 * 1.3])
+    assert all(
+        results[("gas", "mimo")]["sequences"]["flow"].values[:-1]
+        == [100 * 0.8 * 1.2, 100 * 0.3 * 1.2]
+    )
+    assert all(
+        results[("hydro", "mimo")]["sequences"]["flow"].values[:-1]
+        == [100 * 0.2 * 1.3, 100 * 0.7 * 1.3]
+    )