@@ -22,9 +22,7 @@ def generic_allocation(
22
22
act : Union [dict , Activity ],
23
23
func : Callable ,
24
24
strategy_label : Optional [str ] = None ,
25
- supplemental_functions : Optional [List [Callable ]] = [
26
- add_product_node_properties_to_exchange
27
- ],
25
+ supplemental_functions : Optional [List [Callable ]] = [add_product_node_properties_to_exchange ],
28
26
) -> List [dict ]:
29
27
"""Allocation by single allocation factor generated by `func`.
30
28
@@ -70,14 +68,6 @@ def generic_allocation(
70
68
del original_exc ["properties" ][key ]
71
69
del original_exc ["__mf__properties_from_product" ]
72
70
73
- # if not factor:
74
- # # Functional product of multifunctional process, but with allocation factor of zero
75
- # # We need to link to *something*, so link to original multifunctional process to avoid
76
- # # unlinked exchanges
77
- # if not original_exc.get("input"):
78
- # original_exc["input"] = (act["database"], act["code"])
79
- # continue
80
-
81
71
logger .debug (
82
72
"Using allocation factor {f} for functional edge {e} on activity {a}" ,
83
73
f = factor ,
@@ -122,9 +112,7 @@ def generic_allocation(
122
112
if original_exc ["mf_manual_input_product" ]:
123
113
# Get product name and unit attributes from the separate node, if available
124
114
try :
125
- product = get_node (
126
- database = new_exc ["input" ][0 ], code = new_exc ["input" ][1 ]
127
- )
115
+ product = get_node (database = new_exc ["input" ][0 ], code = new_exc ["input" ][1 ])
128
116
except UnknownObject :
129
117
# Try using attributes stored on the edge
130
118
# Might not work, but better than trying to give access to whole raw database
@@ -137,21 +125,18 @@ def generic_allocation(
137
125
if "id" in allocated_process :
138
126
del allocated_process ["id" ]
139
127
if strategy_label :
140
- allocated_process ["mf_strategy_label" ] = act ["mf_strategy_label" ] = (
141
- strategy_label
142
- )
128
+ allocated_process ["mf_strategy_label" ] = act ["mf_strategy_label" ] = strategy_label
143
129
allocated_process ["code" ] = process_code
144
130
allocated_process ["mf_parent_key" ] = (act ["database" ], act ["code" ])
131
+ # Used to filter out previous read only processes
145
132
allocated_process ["type" ] = "readonly_process"
146
133
allocated_process ["production amount" ] = original_exc ["amount" ]
147
134
if product :
148
135
allocated_process ["reference product" ] = product .get ("name" , "(unknown)" )
149
136
allocated_process ["unit" ] = product .get ("unit" , "(unknown)" )
150
137
else :
151
138
allocated_process ["reference product" ] = new_exc .get ("name" , "(unknown)" )
152
- allocated_process ["unit" ] = new_exc .get ("unit" ) or act .get (
153
- "unit" , "(unknown)"
154
- )
139
+ allocated_process ["unit" ] = new_exc .get ("unit" ) or act .get ("unit" , "(unknown)" )
155
140
allocated_process ["exchanges" ] = [new_exc ]
156
141
157
142
for other in filter (lambda x : not x .get ("functional" ), act ["exchanges" ]):
@@ -205,7 +190,5 @@ def property_allocation(
205
190
"manual_allocation" , normalize_by_production_amount = False
206
191
),
207
192
"mass" : property_allocation ("mass" ),
208
- "equal" : partial (
209
- generic_allocation , func = lambda x , y : 1.0 , strategy_label = "equal_allocation"
210
- ),
193
+ "equal" : partial (generic_allocation , func = lambda x , y : 1.0 , strategy_label = "equal_allocation" ),
211
194
}
0 commit comments