Coverage for src/ufig/workflow_util.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-12 19:08 +0000

1# Copyright (C) 2016 ETH Zurich, Institute for Astronomy 

2 

3""" 

4Created on Jun 15, 2016 

5author: Joerg Herbel 

6""" 

7 

8from ivy.context import loop_ctx 

9from ivy.utils.stop_criteria import StopCriteria 

10from ivy.utils.struct import WorkflowState 

11 

12 

13class FiltersStopCriteria(StopCriteria): 

14 """ 

15 Stopping criteria for ivy-loops which makes the loop iterate over all filters in 

16 ctx.parameters.filters. It also sets the variable ctx.current_filter according 

17 to the current loop iteration. 

18 """ 

19 

20 def is_stop(self): 

21 ctx = self.parent.ctx 

22 l_ctx = loop_ctx(self.parent) 

23 

24 if l_ctx.iter >= len(ctx.parameters.filters): 

25 l_ctx.stop() 

26 else: 

27 ctx.current_filter = ctx.parameters.filters[l_ctx.iter] 

28 

29 return l_ctx.state == WorkflowState.STOP