Coverage for backend/django/core/auxiliary/methods/CompoundSuggestionMethods.py: 100%
15 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-07-22 05:22 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-07-22 05:22 +0000
3from core.auxiliary.models.Flowsheet import Flowsheet
4from core.auxiliary.views.ExtractSegmentDataFromFS import get_compounds
5from flowsheetInternals.unitops.models.SimulationObject import SimulationObject
8def get_compound_suggestions(flowsheet_id: int, stream_id: int)-> list:
9 flowsheet = Flowsheet.objects.get(id=flowsheet_id)
10 other_streams = SimulationObject.objects.filter(
11 objectType="stream",
12 flowsheet_state=flowsheet.current_state,
13 ).exclude(id=stream_id)
14 stream_comp_data = get_compounds(SimulationObject.objects.get(id=stream_id), include_null=True)
15 stream_compounds_set = set(compound for compound, _ in stream_comp_data)
16 suggestions = set()
18 for stream in other_streams:
19 compounds = get_compounds(stream, include_null=True)
20 for compound, _ in list(compounds):
21 if compound not in list(stream_compounds_set):
22 suggestions.add(compound)
23 return list(suggestions)