Coverage for backend/core/auxiliary/methods/CompoundSuggestionMethods.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-11-06 23:27 +0000

1 

2 

3from core.auxiliary.models.Flowsheet import Flowsheet 

4from core.auxiliary.views.ExtractSegmentDataFromFS import get_compounds 

5from flowsheetInternals.unitops.models.SimulationObject import SimulationObject 

6 

7 

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(objectType="stream", flowsheet=flowsheet).exclude(id=stream_id) 

11 stream_comp_data = get_compounds(SimulationObject.objects.get(id=stream_id), include_null=True) 

12 stream_compounds_set = set(compound for compound, _ in stream_comp_data) 

13 suggestions = set() 

14 

15 for stream in other_streams: 

16 compounds = get_compounds(stream, include_null=True) 

17 for compound, _ in list(compounds): 

18 if compound not in list(stream_compounds_set): 

19 suggestions.add(compound) 

20 return list(suggestions)