Convert the schedule to a circuit.

        This discards most timing information from the schedule, but does place
        operations that are scheduled at the same time in the same Moment.
18156
def to_circuit(self) -> Circuit:
        
        circuit = Circuit(device=self.device)
        time = None  # type: Optional[Timestamp]
        for so in self.scheduled_operations:
            if so.time != time:
                circuit.append(so.operation,
                               strategy=InsertStrategy.NEW_THEN_INLINE)
                time = so.time
            else:
                circuit.append(so.operation,
                               strategy=InsertStrategy.INLINE)
        return circuit
416810
protected void convertToHours(LinkedList<TimephasedWork> list)
   {
      for (TimephasedWork assignment : list)
      {
         Duration totalWork = assignment.getTotalAmount();
         Duration workPerDay = assignment.getAmountPerDay();
         totalWork = Duration.getInstance(totalWork.getDuration() / 60, TimeUnit.HOURS);
         workPerDay = Duration.getInstance(workPerDay.getDuration() / 60, TimeUnit.HOURS);
         assignment.setTotalAmount(totalWork);
         assignment.setAmountPerDay(workPerDay);
      }
   }
241536
def skip(self, sched_rule_id):
        """"""
        path = 'schedulerule/skip'
        payload = {'id': sched_rule_id}
        return self.rachio.put(path, payload)
474222
def reload(self, schedule):
        '''
        
        '''
        # Remove all jobs from self.intervals
        self.intervals = {}

        if 'schedule' in schedule:
            schedule = schedule['schedule']
        self.opts.setdefault('schedule', {}).update(schedule)
1129670
def _GetTripSequence(self, schedule=None):
    
    if schedule is None:
      schedule = getattr(self, "_schedule", None)
    if schedule is None:
      warnings.warn("No longer supported. _schedule attribute is  used to get "
                    "stop_times table", DeprecationWarning)
    cursor = schedule._connection.cursor()
    cursor.execute("SELECT trip_id,stop_sequence FROM stop_times "
                   "WHERE stop_id=?",
                   (self.stop_id, ))
    return [(schedule.GetTrip(row[0]), row[1]) for row in cursor]
743350
def reset(self):
        '''
        
        '''
        self.skip_function = None
        self.skip_during_range = None
        self.enabled = True
        self.splay = None
        self.opts['schedule'] = {}
490898
def schedule(demand: dict, alterations: set, looped: set=None, altered: set=None):
	""""""
	if looped is not None and len(demand) != len(looped):
		for func in looped: del demand[func]
	if keep_temp in demand:
		demand.pop(increase_temp, None)
		demand.pop(lower_temp, None)
	elif lower_temp in demand:
		demand.pop(increase_temp, None)
	return demand, alterations
710531
public void start() {
        CircuitManager cm = this.stack.getCircuitManager();
        long[] channelIDs = cm.getChannelIDs();
        this.cic2Circuit.clear();

        for (long channelID : channelIDs) {
            Circuit c = new Circuit(cm.getCIC(channelID), cm.getDPC(channelID), this, scheduler);
            cic2Circuit.put(channelID, c);
        }
    }
387841
function trip(item, ctx) {
		item.state = C.CIRCUIT_OPEN;
		item.ep.state = false;

		if (item.cbTimer) {
			clearTimeout(item.cbTimer);
			item.cbTimer = null;
		}

		item.cbTimer = setTimeout(() => halfOpen(item, ctx), item.opts.halfOpenTime);
		item.cbTimer.unref();

		const rate = item.count > 0 ? item.failures / item.count : 0;
		logger.debug(`Circuit breaker has been opened on '${item.ep.name}' endpoint.`, { nodeID: item.ep.id, action: item.ep.action.name, failures: item.failures, count: item.count, rate });
		broker.broadcast("$circuit-breaker.opened", { nodeID: item.ep.id, action: item.ep.action.name, failures: item.failures, count: item.count, rate });
	}
593493
def _run(
        self,
        circuit: circuits.Circuit,
        param_resolver: study.ParamResolver,
        repetitions: int) -> Dict[str, List[np.ndarray]]:
        """"""
        param_resolver = param_resolver or study.ParamResolver({})
        resolved_circuit = protocols.resolve_parameters(circuit, param_resolver)
        def measure_or_mixture(op):
            return protocols.is_measurement(op) or protocols.has_mixture(op)
        if circuit.are_all_matches_terminal(measure_or_mixture):
            return self._run_sweep_sample(resolved_circuit, repetitions)
        else:
            return self._run_sweep_repeat(resolved_circuit, repetitions)
353605
function scheduleToSentence(schedule) {
    var outputText = locale.Every + ' ';

    if (schedule['h'] && schedule['m'] && schedule['h'].length <= 2 && schedule['m'].length <= 2) {
      // If there are only one or two specified values for
      // hour or minute, print them in HH:MM format

      var hm = [];
      for (var i = 0; i < schedule['h'].length; i++) {
        for (var j = 0; j < schedule['m'].length; j++) {
          hm.push(zeroPad(schedule['h'][i]) + ':' + zeroPad(schedule['m'][j]));
        }
      }
      if (hm.length < 2) {
        outputText = hm[0];
      } else {
        var lastVal = hm.pop();
        outputText = hm.join(', ') + ` ${locale.and} ` + lastVal;
      }
      if (!schedule['d'] && !schedule['D']) {
        outputText += ` ${locale['every day']}`;
      }
    } else {
      // Otherwise, list out every specified hour/minute value.

      if (schedule['h']) { // runs only at specific hours
        if (schedule['m']) { // and only at specific minutes
          outputText += numberList(schedule['m']) + ` ${locale['minute past the']} ` + numberList(schedule['h']) + ` ${locale['hour']}`;
        } else { // specific hours, but every minute
          outputText += `${locale['minute of']} ` + numberList(schedule['h']) + ` ${locale['hour']}`;
        }
      } else if (schedule['m']) { // every hour, but specific minutes
        outputText += numberList(schedule['m']) + ` ${locale['minute every hour']}`;
      } else { // cronspec has "*" for both hour and minute
        outputText += locale['minute'];
      }
    }

    if (schedule['D']) { // runs only on specific day(s) of month
      outputText += (locale['on the'] ? ` ${locale['on the']} ` : ' ') + numberList(schedule['D']);
      if (!schedule['M']) {
        outputText += ` ${locale['of every month']}`;
      }
    }

    if (schedule['d']) { // runs only on specific day(s) of week
      if (schedule['D']) {
        // if both day fields are specified, cron uses both; superuser.com/a/348372
        outputText += ` ${locale['and every']} `;
      } else {
        outputText += ` ${locale['on']} `;
      }
      outputText += dateList(schedule['d'], 'dow');
    }

    if (schedule['M']) {
      // runs only in specific months; put this output last
      outputText += ` ${locale['in']} ` + dateList(schedule['M'], 'mon');
    }

    return outputText;
  }
1261988
def _cancelScheduledRestart(self, justification=None) -> None:
        

        if self.scheduledAction:
            why_prefix = ": "
            why = justification
            if justification is None:
                why_prefix = ", "
                why = "cancellation reason not specified"

            ev_data = self.scheduledAction
            logger.info("Cancelling restart"
                        " of node {}"
                        " scheduled on {}"
                        "{}{}"
                        .format(self.nodeName,
                                ev_data.when,
                                why_prefix,
                                why))

            self._unscheduleAction()
            self._actionLog.append_cancelled(ev_data)
            logger.info(
                "Restart of node '{}'"
                "has been cancelled due to {}".format(
                    self.nodeName, why))
1215696
private void reschedule() {
        // set up a daily roll
        Calendar cal = Calendar.getInstance();
        long today = cal.getTimeInMillis();

        // adjust to somewhere after midnight of the next day
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.add(Calendar.DATE, 1);
        long tomorrow = cal.getTimeInMillis();

        if (executorService != null) {
            future = executorService.schedule(this, tomorrow - today, TimeUnit.MILLISECONDS);
        }
    }
319674
def handle_schedule(self):
        '''
        
        '''
        try:
            self.schedule.eval()
            # Check if scheduler requires lower loop interval than
            # the loop_interval setting
            if self.schedule.loop_interval < self.loop_interval:
                self.loop_interval = self.schedule.loop_interval
        except Exception as exc:
            log.error('Exception %s occurred in scheduled job', exc)
219739
def _transform_to_time_spent(records, split_interval, sections):
    

    t_records = []
    week_nr = records[0].datetime.isocalendar()[1]

    # contrary to the rest of the binning process, this is done with second
    # precision
    for r in filter(lambda rec: rec.interaction == 'call' and rec.call_duration > 0, records):
        t_left = r.call_duration
        t_to_next_section = _seconds_to_section_split(r, sections)
        t_spent_total = 0

        while (t_left > 0):
            t_spent = min(t_to_next_section, t_left)
            dt_new = r.datetime + dt.timedelta(seconds=t_spent_total)

            if dt_new.isocalendar()[1] > week_nr:
                dt_new -= dt.timedelta(days=7)
            t_records.append(
                Record('call', r.direction, None, dt_new, t_spent, None))

            t_left -= t_spent
            t_spent_total += t_spent
            t_to_next_section = split_interval * 60

    return sorted(t_records, key=lambda r: _find_weektime(r.datetime))
62992
public void setSchedules(java.util.Collection<Schedule> schedules) {
        if (schedules == null) {
            this.schedules = null;
            return;
        }

        this.schedules = new java.util.ArrayList<Schedule>(schedules);
    }
686100
function cycle(clone, options) {
      options || (options = {});

      var deferred;
      if (clone instanceof Deferred) {
        deferred = clone;
        clone = clone.benchmark;
      }
      var clocked,
          cycles,
          divisor,
          event,
          minTime,
          period,
          async = options.async,
          bench = clone._original,
          count = clone.count,
          times = clone.times;

      // Continue, if not aborted between cycles.
      if (clone.running) {
        // `minTime` is set to `Benchmark.options.minTime` in `clock()`.
        cycles = ++clone.cycles;
        clocked = deferred ? deferred.elapsed : clock(clone);
        minTime = clone.minTime;

        if (cycles > bench.cycles) {
          bench.cycles = cycles;
        }
        if (clone.error) {
          event = Event('error');
          event.message = clone.error;
          clone.emit(event);
          if (!event.cancelled) {
            clone.abort();
          }
        }
      }
      // Continue, if not errored.
      if (clone.running) {
        // Compute the time taken to complete last test cycle.
        bench.times.cycle = times.cycle = clocked;
        // Compute the seconds per operation.
        period = bench.times.period = times.period = clocked / count;
        // Compute the ops per second.
        bench.hz = clone.hz = 1 / period;
        // Avoid working our way up to this next time.
        bench.initCount = clone.initCount = count;
        // Do we need to do another cycle?
        clone.running = clocked < minTime;

        if (clone.running) {
          // Tests may clock at `0` when `initCount` is a small number,
          // to avoid that we set its count to something a bit higher.
          if (!clocked && (divisor = divisors[clone.cycles]) != null) {
            count = floor(4e6 / divisor);
          }
          // Calculate how many more iterations it will take to achieve the `minTime`.
          if (count <= clone.count) {
            count += Math.ceil((minTime - clocked) / period);
          }
          clone.running = count != Infinity;
        }
      }
      // Should we exit early?
      event = Event('cycle');
      clone.emit(event);
      if (event.aborted) {
        clone.abort();
      }
      // Figure out what to do next.
      if (clone.running) {
        // Start a new cycle.
        clone.count = count;
        if (deferred) {
          clone.compiled.call(deferred, context, timer);
        } else if (async) {
          delay(clone, function() { cycle(clone, options); });
        } else {
          cycle(clone);
        }
      }
      else {
        // Fix TraceMonkey bug associated with clock fallbacks.
        // For more information see http://bugzil.la/509069.
        if (support.browser) {
          runScript(uid + '=1;delete ' + uid);
        }
        // We're done.
        clone.emit('complete');
      }
    }