determine step output
195400
def get_step_output(section, default_output):
    ''''''
    step_output: sos_targets = sos_targets()
    #
    if 'provides' in section.options and default_output:
        step_output = default_output

    # look for input statement.
    output_idx = find_statement(section, 'output')
    if output_idx is None:
        return step_output

    # output statement
    value = section.statements[output_idx][2]
    # output, depends, and process can be processed multiple times
    try:
        svars = ['output_from', 'named_output', 'sos_step', 'sos_variable']
        old_values = {
            x: env.sos_dict.dict()[x]
            for x in svars
            if x in env.sos_dict.dict()
        }
        env.sos_dict.quick_update({
            'output_from': no_output_from,
            'named_output': no_named_output,
            'sos_step': no_sos_step,
            'sos_variable': no_sos_variable,
        })
        args, kwargs = SoS_eval(
            f'__null_func__({value})', extra_dict=env.sos_dict.dict())
        if not any(isinstance(x, (dynamic, remote)) for x in args):
            step_output = sos_targets(
                *args, **{
                    x: y
                    for x, y in kwargs.items()
                    if x not in SOS_TARGETS_OPTIONS
                })
    except SyntaxError:
        raise
    except Exception as e:
        if 'STEP' in env.config['SOS_DEBUG'] or 'ALL' in env.config['SOS_DEBUG']:
            env.log_to_file('STEP', f"Args {value} cannot be determined: {e}")
    finally:
        [env.sos_dict.dict().pop(x) for x in svars]
        env.sos_dict.quick_update(old_values)

    if 'provides' in section.options and default_output is not None and step_output.valid(
    ):
        for out in default_output:
            # 981
            if not isinstance(out, sos_step) and out not in step_output:
                raise ValueError(
                    f'Defined output fail to produce expected output: {step_output} generated, {default_output} expected.'
                )
    return step_output
298734
def generateSteps(self, minStep):
        """"""
        self.checkFinite(minStep)

        if self.binary:
            base = 2.0
            mantissas = [1.0]
            exponent = math.floor(math.log(minStep, 2) - EPSILON)
        else:
            base = 10.0
            mantissas = [1.0, 2.0, 5.0]
            exponent = math.floor(math.log10(minStep) - EPSILON)

        while True:
            multiplier = base ** exponent
            for mantissa in mantissas:
                value = mantissa * multiplier
                if value >= minStep * (1.0 - EPSILON):
                    yield value
            exponent += 1
669556
def xstep(self):
        
        """

        self.X, self.ss = sp.prox_nuclear(self.S - self.Y - self.U,
                                          1/self.rho)
399526
function progress( $step )
    {
        $totalSteps = 0;
        foreach ( $this->StepTable as $tableStep )
        {
            if ( !isset( $tableStep['count_step'] ) or
                 $tableStep['count_step'] )
                ++$totalSteps;
        }

        $currentStep = 0;
        foreach ( $this->StepTable as $key => $tableStep )
        {
            if ( $step['class'] == $tableStep['class'] )
            {
                break;
            }
            else if ( !isset( $tableStep['count_step'] ) or
                      $tableStep['count_step'] )
                ++$currentStep;
        }

        return (int) ( $currentStep * 100 / ( $totalSteps - 1 ) );
    }
1229894
function() {
            var next = steps.indexOf( activeStep ) + 1;
            next = next < steps.length ? steps[ next ] : steps[ 0 ];

            return goto( next );
        }
1106495
public static StepEndState calculateStepMacroEndState(List<StepToken> executedSteps) {
        StepEndState stepMacroEndState = StepEndState.PASSED;
        for ( StepToken s : executedSteps) {
            if ( s.getEndState() != StepEndState.PASSED) {
                stepMacroEndState = s.getEndState();
                break;
            }
        }
        return stepMacroEndState;
    }
938599
def _estimate_progress(self):
        
        estimate = True
        # ==== get the current subscript and the time it takes to execute it =====
        current_subscript = self._current_subscript_stage['current_subscript']

        # ==== get the number of subscripts =====
        num_subscripts = len(self.scripts)

        # ==== get number of iterations and loop index ======================
        if self.iterator_type == 'loop':
            num_iterations = self.settings['num_loops']
        elif self.iterator_type == 'sweep':
            sweep_range = self.settings['sweep_range']
            if self.settings['stepping_mode'] == 'value_step':
                num_iterations = int((sweep_range['max_value'] - sweep_range['min_value']) / sweep_range['N/value_step']) + 1
                # len(np.linspace(sweep_range['min_value'], sweep_range['max_value'],
                #                                        (sweep_range['max_value'] - sweep_range['min_value']) /
                #                                        sweep_range['N/value_step'] + 1, endpoint=True).tolist())
            elif self.settings['stepping_mode'] == 'N':
                num_iterations = sweep_range['N/value_step']
            else:
                raise KeyError('unknown key' + self.settings['stepping_mode'])

        else:
            print('unknown iterator type in Iterator receive signal - can\'t estimate ramining time')
            estimate = False


        if estimate:
            # get number of loops (completed + 1)
            loop_index = self.loop_index


            if num_subscripts > 1:
                # estimate the progress based on the duration the individual subscripts

                loop_execution_time = 0.  # time for a single loop execution in s
                sub_progress_time = 0.  # progress of current loop iteration in s

                # ==== get typical duration of current subscript ======================
                if current_subscript is not None:
                    current_subscript_exec_duration = self._current_subscript_stage['subscript_exec_duration'][
                        current_subscript.name].total_seconds()
                else:
                    current_subscript_exec_duration = 0.0


                current_subscript_elapsed_time = (datetime.datetime.now() - current_subscript.start_time).total_seconds()
                # estimate the duration of the current subscript if the script hasn't been executed once fully and subscript_exec_duration is 0
                if current_subscript_exec_duration == 0.0:
                    remaining_time = current_subscript.remaining_time.total_seconds()
                    current_subscript_exec_duration = remaining_time + current_subscript_elapsed_time

                # ==== get typical duration of one loop iteration ======================
                remaining_scripts = 0  # script that remain to be executed for the first time
                for subscript_name, duration in self._current_subscript_stage['subscript_exec_duration'].items():
                    if duration.total_seconds() == 0.0:
                        remaining_scripts += 1
                    loop_execution_time += duration.total_seconds()
                    # add the times of the subscripts that have been executed in the current loop
                    # ignore the current subscript, because that will be taken care of later
                    if self._current_subscript_stage['subscript_exec_count'][subscript_name] == loop_index \
                            and subscript_name is not current_subscript.name:
                        # this subscript has already been executed in this iteration
                        sub_progress_time += duration.total_seconds()

                # add the proportional duration of the current subscript given by the subscript progress
                sub_progress_time += current_subscript_elapsed_time

                # if there are scripts that have not been executed yet
                # assume that all the scripts that have not been executed yet take as long as the average of the other scripts
                if remaining_scripts == num_subscripts:
                    # none of the subscript has been finished. assume that all the scripts take as long as the first
                    loop_execution_time = num_subscripts * current_subscript_exec_duration
                elif remaining_scripts > 1:
                    loop_execution_time = 1. * num_subscripts / (num_subscripts - remaining_scripts)
                elif remaining_scripts == 1:
                    # there is only one script left which is the current script
                    loop_execution_time += current_subscript_exec_duration

                if loop_execution_time > 0:
                    progress_subscript = 100. * sub_progress_time / loop_execution_time
                else:
                    progress_subscript = 1. * progress_subscript / num_subscripts

            # print(' === script iterator progress estimation loop_index = {:d}/{:d}, progress_subscript = {:f}'.format(loop_index, number_of_iterations, progress_subscript))
            progress = 100. * (loop_index - 1. + 0.01 * progress_subscript) / num_iterations

        else:
            # if can't estimate the remaining time set to half
            progress = 50
        return progress
1245183
def num_time_steps(self):
    """"""

    num_time_steps = sum(t.num_time_steps for t in self.trajectories)
    return num_time_steps + self.num_completed_time_steps
1302663
def stage_output(self):
        """"""

        if self.workdir == self.outdir:
            return
        elif not os.path.isdir(self.workdir):
            self.logger.error('Working directory does not exist.')
            return

        regex = self.config['fileio']['outdir_regex']
        savefits = self.config['fileio']['savefits']
        files = os.listdir(self.workdir)
        self.logger.info('Staging files to %s', self.outdir)

        fitsfiles = []
        for c in self.components:
            for f in c.files.values():

                if f is None:
                    continue

                fitsfiles += [os.path.basename(f)]

        for f in files:

            wpath = os.path.join(self.workdir, f)
            opath = os.path.join(self.outdir, f)

            if not utils.match_regex_list(regex, os.path.basename(f)):
                continue
            if os.path.isfile(opath) and filecmp.cmp(wpath, opath, False):
                continue
            if not savefits and f in fitsfiles:
                continue


            self.logger.debug('Copying ' + f)
            self.logger.info('Copying ' + f)
            shutil.copy(wpath, self.outdir)

        self.logger.info('Finished.')
1237156
def M_step(self):

        

        for k in range(self.K):
            self.rho[k] = self.type_prob[:, k].sum() / self.N

        for k in range(self.K):
            for m in range(self.M):
                temp_prob = np.dot(self.type_prob[:, k],
                                   self.feature_counts[:, m])
                if temp_prob < 1e-99:
                    temp_prob = 1e-99
                self.mu[k, m] = temp_prob / np.dot(self.type_prob[:, k],
                                                   self.observations)
626774
def step_through(self, msg='', shutit_pexpect_child=None, level=1, print_input=True, value=True):
		
		shutit_global.shutit_global_object.yield_to_draw()
		shutit_pexpect_child = shutit_pexpect_child or self.get_current_shutit_pexpect_session().pexpect_child
		shutit_pexpect_session = self.get_shutit_pexpect_session_from_child(shutit_pexpect_child)
		if (not shutit_global.shutit_global_object.determine_interactive() or not shutit_global.shutit_global_object.interactive or
			shutit_global.shutit_global_object.interactive < level):
			return True
		self.build['step_through'] = value
		shutit_pexpect_session.pause_point(msg, print_input=print_input, level=level)
		return True
770552
def ystep(self):
        
        """

        self.Y = self.Pcn(self.AX + self.U)
1106840
def _step(self):
        

        # Pull and check data
        input_bag = self._get()

        # Sent through the stack
        results = self._stack(input_bag)

        # self._exec_time += timer.duration
        # Put data onto output channels

        if isinstance(results, GeneratorType):
            while True:
                try:
                    # if kill flag was step, stop iterating.
                    if self._killed:
                        break
                    result = next(results)
                except StopIteration:
                    # That's not an error, we're just done.
                    break
                else:
                    # Push data (in case of an iterator)
                    self._put(self._cast(input_bag, result))
        elif results:
            # Push data (returned value)
            self._put(self._cast(input_bag, results))
        else:
            # case with no result, an execution went through anyway, use for stats.
            # self._exec_count += 1
            pass
560425
def step(self)->Number:
        ""
        self.n += 1
        return self.func(self.start, self.end, self.n/self.n_iter)
1204898
private int getNextStep(int currentStep) {
        int nextStep = -1;
        
        // we find the next available step.
        for (int i = currentStep + 1; i <= STEP_THANKS; i++) {
            if(isStepEnabled(i)) {
                nextStep = i;
                break;
            }
        }

        return nextStep;
    }
141197
def _get_step_inout(step):
    
    inputs = []
    outputs = []
    prescatter = collections.defaultdict(list)
    remapped = {}
    assert step.outputs_record_schema["type"] == "record"
    output_names = set([])
    for outp in step.outputs_record_schema["fields"]:
        outputs.append({"id": outp["name"]})
        output_names.add(outp["name"])
    assert step.inputs_record_schema["type"] == "record"
    for inp in step.inputs_record_schema["fields"]:
        source = inp["source"].split("#")[-1].replace("/", ".")
        # Check if we're unpacking from a record, and unpack from our object
        if "valueFrom" in inp:
            attr_access = "['%s']" % inp["name"]
            if inp["valueFrom"].find(attr_access) > 0:
                source += ".%s" % inp["name"]
                if isinstance(inp["type"], dict) and isinstance(inp["type"].get("items"), dict):
                    if inp["type"]["items"].get("type") == "array" and "inputBinding" in inp["type"]:
                        source, prescatter = _unpack_object_array(inp, source, prescatter)
        # Avoid clashing input and output names, WDL requires unique
        if inp["name"] in output_names:
            new_name = inp["name"] + "_input"
            remapped[inp["name"]] = new_name
            inp["name"] = new_name
        inputs.append({"id": inp["name"], "value": source})
    return inputs, outputs, remapped, dict(prescatter)
26943
def nominal_step(x=None):
    """"""
    if x is None:
        return 1.0
    return np.log1p(np.abs(x)).clip(min=1.0)