1
1
import warnings
2
2
from heapq import heappop , heappush
3
- from typing import Dict , Optional , List
3
+ from typing import Dict , List , Optional
4
4
5
5
import matrix_utils as mu
6
6
import numpy as np
13
13
except ImportError :
14
14
databases = {}
15
15
16
- from bw_graph_tools .matrix_tools import guess_production_exchanges
17
- from bw_graph_tools .graph_traversal .settings import GraphTraversalSettings
18
16
from bw_graph_tools .graph_traversal .base import BaseGraphTraversal
19
17
from bw_graph_tools .graph_traversal .graph_objects import Edge , Flow , Node
20
- from bw_graph_tools .graph_traversal .utils import CachingSolver , Counter , get_demand_vector_for_activity
18
+ from bw_graph_tools .graph_traversal .settings import GraphTraversalSettings
19
+ from bw_graph_tools .graph_traversal .utils import (
20
+ CachingSolver ,
21
+ Counter ,
22
+ get_demand_vector_for_activity ,
23
+ )
24
+ from bw_graph_tools .matrix_tools import guess_production_exchanges
21
25
22
26
23
27
class NewNodeEachVisitGraphTraversal (BaseGraphTraversal [GraphTraversalSettings ]):
@@ -310,7 +314,10 @@ def traverse(
310
314
if self .settings .separate_biosphere_flows :
311
315
self .add_biosphere_flows (
312
316
flows = self ._flows ,
313
- matrix = (node .supply_amount * self .characterized_biosphere [:, node .activity_index ]).tocoo (),
317
+ matrix = (
318
+ node .supply_amount
319
+ * self .characterized_biosphere [:, node .activity_index ]
320
+ ).tocoo (),
314
321
lca = self .lca ,
315
322
node = node ,
316
323
biosphere_cutoff_score = self .biosphere_cutoff_score ,
@@ -323,7 +330,7 @@ def traverse(
323
330
324
331
non_terminal_nodes = {edge .consumer_unique_id for edge in self ._edges }
325
332
for key , obj in self ._nodes .items ():
326
- obj .terminal = ( key not in non_terminal_nodes )
333
+ obj .terminal = key not in non_terminal_nodes
327
334
328
335
@property
329
336
def exceeded_calculation_count (self ):
@@ -463,7 +470,9 @@ def traverse_edges(
463
470
# Local max depth overrides everything, and already include global max depth
464
471
satisfies_depth_constraint = producing_node .max_depth > producing_node .depth
465
472
else :
466
- satisfies_depth_constraint = (max_depth is None ) or (producing_node .depth < max_depth )
473
+ satisfies_depth_constraint = (max_depth is None ) or (
474
+ producing_node .depth < max_depth
475
+ )
467
476
468
477
if satisfies_depth_constraint :
469
478
heappush (heap , (abs (1 / cumulative_score ), producing_node ))
0 commit comments