Tarbell configuration routine.
197622
def tarbell_configure(command, args):
    
    puts("Configuring Tarbell. Press ctrl-c to bail out!")

    # Check if there's settings configured
    settings = Settings()
    path = settings.path

    prompt = True
    if len(args):
        prompt = False

    config = _get_or_create_config(path)

    if prompt or "drive" in args:
        config.update(_setup_google_spreadsheets(config, path, prompt))
    if prompt or "s3" in args:
        config.update(_setup_s3(config, path, prompt))
    if prompt or "path" in args:
        config.update(_setup_tarbell_project_path(config, path, prompt))
    if prompt or "templates" in args:
        if "project_templates" in config:
            override_templates = raw_input("\nFound Base Template config. Would you like to override them? [Default: No, 'none' to skip]")
            if override_templates and override_templates != "No" and  override_templates != "no" and override_templates != "N" and override_templates != "n":
                config.update(_setup_default_templates(config, path, prompt))
            else:
                puts("\nPreserving Base Template config...")
        else:
            config.update(_setup_default_templates(config, path, prompt))

    settings.config = config

    with open(path, 'w') as f:
        puts("\nWriting {0}".format(colored.green(path)))
        settings.save()

    if all:
        puts("\n- Done configuring Tarbell. Type `{0}` for help.\n"
             .format(colored.green("tarbell")))

    return settings
655736
def apply_taper(delta_t, taper, f_0, tau, amp, phi, l, m, inclination):
    

    # Times of tapering do not include t=0
    taper_times = -numpy.arange(1, int(taper*tau/delta_t))[::-1] * delta_t
    Y_plus, Y_cross = spher_harms(l, m, inclination)
    taper_hp = amp * Y_plus * numpy.exp(10*taper_times/tau) * \
                     numpy.cos(two_pi*f_0*taper_times + phi)
    taper_hc = amp * Y_cross * numpy.exp(10*taper_times/tau) * \
                     numpy.sin(two_pi*f_0*taper_times + phi)

    return taper_hp, taper_hc
724168
private function setupDefaultConfigs()
    {
        $this->setLayout();
        $this->setSummary();

        if (!$this->isEmpty()) {
            $this->setActionBar();
        }

        $this->showOnEmpty = false;
    }
691388
private MethodSpec.Builder buildSkeletonType(Set<String> dateSkeletons, Set<String> timeSkeletons) {
    MethodSpec.Builder method = MethodSpec.methodBuilder("skeletonType")
        .addJavadoc("Indicates whether a given skeleton pattern is a DATE or TIME.\n")
        .addModifiers(PUBLIC, STATIC)
        .addParameter(String.class, "skeleton")
        .returns(SKELETON);

    method.beginControlFlow("switch (skeleton)");
    
    for (String skel : dateSkeletons) {
      method.addCode("case $S:\n", skel);
    }
    method.addStatement("  return $T.DATE", SKELETON);
    
    for (String skel : timeSkeletons) {
      method.addCode("case $S:\n", skel);
    }
    method.addStatement("  return $T.TIME", SKELETON);

    method.addCode("default:\n");
    method.addStatement("  return null");
    method.endControlFlow();

    return method;
  }
111302
def _setup_tarbell_project_path(settings, path, prompt=True):
    
    default_path = os.path.expanduser(os.path.join("~", "tarbell"))
    projects_path = raw_input("\nWhat is your Tarbell projects path? [Default: {0}, 'none' to skip] ".format(default_path))
    if projects_path == "":
        projects_path = default_path
    if projects_path.lower() == 'none':
        puts("\n- Not creating projects directory.")
        return {}

    if os.path.isdir(projects_path):
        puts("\nDirectory exists!")
    else:
        puts("\nDirectory does not exist.")
        make = raw_input("\nWould you like to create it? [Y/n] ")
        if make.lower() == "y" or not make:
            os.makedirs(projects_path)
    puts("\nProjects path is {0}".format(projects_path))
    puts("\n- Done setting up projects path.")
    return {"projects_path": projects_path}
759508
def setup(self, check_all=None, exclude_private=None,
              exclude_uppercase=None, exclude_capitalized=None,
              exclude_unsupported=None, excluded_names=None,
              minmax=None, dataframe_format=None):
        
        assert self.shellwidget is not None
        
        self.check_all = check_all
        self.exclude_private = exclude_private
        self.exclude_uppercase = exclude_uppercase
        self.exclude_capitalized = exclude_capitalized
        self.exclude_unsupported = exclude_unsupported
        self.excluded_names = excluded_names
        self.minmax = minmax
        self.dataframe_format = dataframe_format
        
        if self.editor is not None:
            self.editor.setup_menu(minmax)
            self.editor.set_dataframe_format(dataframe_format)
            self.exclude_private_action.setChecked(exclude_private)
            self.exclude_uppercase_action.setChecked(exclude_uppercase)
            self.exclude_capitalized_action.setChecked(exclude_capitalized)
            self.exclude_unsupported_action.setChecked(exclude_unsupported)
            self.refresh_table()
            return

        self.editor = RemoteCollectionsEditorTableView(
                        self,
                        data=None,
                        minmax=minmax,
                        shellwidget=self.shellwidget,
                        dataframe_format=dataframe_format)

        self.editor.sig_option_changed.connect(self.sig_option_changed.emit)
        self.editor.sig_files_dropped.connect(self.import_data)
        self.editor.sig_free_memory.connect(self.sig_free_memory.emit)

        self.setup_option_actions(exclude_private, exclude_uppercase,
                                  exclude_capitalized, exclude_unsupported)

        # Setup toolbar layout.

        self.tools_layout = QHBoxLayout()
        toolbar = self.setup_toolbar()
        for widget in toolbar:
            self.tools_layout.addWidget(widget)
        self.tools_layout.addStretch()
        self.setup_options_button()

        # Setup layout.

        layout = create_plugin_layout(self.tools_layout, self.editor)
        self.setLayout(layout)

        self.sig_option_changed.connect(self.option_changed)
170329
protected void generatePythonSetup(IStyleAppendable it, String basename) {
		it.appendNl("# -*- coding: {0} -*-", getCodeConfig().getEncoding().toLowerCase()); //$NON-NLS-1$
		it.appendHeader();
		it.newLine();
		it.append("from setuptools import setup"); //$NON-NLS-1$
		it.newLine().newLine();
		it.append("setup ("); //$NON-NLS-1$
		it.increaseIndentation().newLine();
		it.append("name='").append(basename).append("lexer',"); //$NON-NLS-1$ //$NON-NLS-2$
		it.newLine();
		it.append("version='").append(getLanguageVersion()).append("',"); //$NON-NLS-1$ //$NON-NLS-2$
		it.newLine();
		it.append("packages=['").append(basename).append("lexer'],"); //$NON-NLS-1$ //$NON-NLS-2$
		it.newLine();
		it.append("entry_points ="); //$NON-NLS-1$
		it.newLine();
		it.append("\"\"\""); //$NON-NLS-1$
		it.newLine();
		it.append("[pygments.lexers]"); //$NON-NLS-1$
		it.newLine();
		it.append("sarllexer = ").append(basename).append("lexer.").append(basename); //$NON-NLS-1$ //$NON-NLS-2$
		it.append(":SarlLexer"); //$NON-NLS-1$
		it.newLine();
		it.append("\"\"\","); //$NON-NLS-1$
		it.decreaseIndentation().newLine();
		it.append(")"); //$NON-NLS-1$
		it.newLine();
	}
1112647
private function processConfig()
    {
        $processor = new Processor();
        $coreConfig = Yaml::parse(file_get_contents(__DIR__.'/Resources/core_filters.yml'));
        $configs = array($this->config, $coreConfig);
        $configuration = new StereoConfiguration();
        $processedConfiguration = $processor->processConfiguration(
          $configuration,
          $configs
        );

        foreach ($processedConfiguration['core_filters'] as $filterClass) {
            $this->mixer->addFilter($filterClass);
        }

        foreach ($processedConfiguration['custom_filters'] as $customFilterClass) {
            $this->mixer->addFilter($customFilterClass);
        }

        foreach ($processedConfiguration['tapes'] as $name => $settings) {
            $tape = new Tape($name);
            foreach ($settings['filters'] as $k => $args) {
                $filter = $this->mixer->createFilter($k, $args);
                $tape->addFilter($filter);
            }
            $this->addTape($tape);
        }
    }
280463
protected function configure()
    {
        parent::configure();

        $this
            ->setName('run_jobs')
            ->setDescription('Run jobs that are next in line for up to N seconds')
            ->addOption(
                'seconds',
                's',
                InputOption::VALUE_REQUIRED,
                'Run jobs for -s seconds before quitting the process',
                50
            )
            ->addOption(
                'channels',
                'c',
                InputOption::VALUE_REQUIRED,
                'Select one or more channels for jobs for process',
                QueueInterface::MAIN_CHANNEL
            )
            ->addOption(
                'jobs-per-batch',
                '',
                InputOption::VALUE_REQUIRED,
                'Number of jobs that should be fetched and executed per single run',
                1
            );
    }
242057
private void prepareFFTTables()
	{
		int n2 = ss2;
		int nu1 = nu-1;
		int k = 0;
		int x = 0;
		for (int l=1; l<=nu; l++)
		{
			while (k < ss)
			{
				for (int i=1; i<=n2; i++)
				{
					double p = (double)bitrev(k >> nu1, nu);
					double arg = (Math.PI * p * 2.0D) / (double) ss;
					fftSin[x] = (long) (Math.sin(arg) * FRAC_FAC);
					fftCos[x] = (long) (Math.cos(arg) * FRAC_FAC);
					k++;
					x++;
				}

				k += n2;
			}
			k = 0;
			nu1--;
			n2 >>= 1;
		}

		for (k=0; k<ss; k++)
			fftBr[k] = bitrev(k, nu);
	}
398579
def fit(ts, fs=[], all_params=[], fit_vars=None,
        alg='leastsq', make_bounded=True):
    
    if fit_vars is None:
        fit_vars = [f._peakargs for f in fs]
    initc = [min(ts.values)]
    for f, peak_params, to_fit in zip(fs, all_params, fit_vars):
        if 'v' in to_fit:
            to_fit.remove('v')

        if make_bounded and hasattr(f, '_pbounds'):
            new_v = _to_unbnd_p({i: peak_params[i] for i in to_fit},
                                f._pbounds)
            initc += [new_v[i] for i in to_fit]
        else:
            initc += [peak_params[i] for i in to_fit]

    def errfunc_lsq(fit_params, t, y, all_params):
        # first value in fit_params is baseline
        # fit_y = np.ones(len(t)) * fit_params[0]
        fit_y = np.zeros(len(t))
        param_i = 1
        for f, peak_params, to_fit in zip(fs, all_params, fit_vars):
            for k in to_fit:
                peak_params[k] = fit_params[param_i]
                param_i += 1
            if make_bounded and hasattr(f, '_pbounds'):
                fit_y += f(t, **_to_bound_p(peak_params, f._pbounds))
            else:
                fit_y += f(t, **peak_params)
        return fit_y - y

    def errfunc(p, t, y, all_params):
        return np.sum(errfunc_lsq(p, t, y, all_params) ** 2)

    if alg == 'simplex':
        fit_p, _ = fmin(errfunc, initc, args=(ts.index, ts.values,
                                              peak_params))
#    elif alg == 'anneal':
#        fit_p, _ = anneal(errfunc, initc, args=(ts.index, ts.values,
#                                                peak_params))
    elif alg == 'lbfgsb':
        # TODO: use bounds param
        fitp, _ = fmin_l_bfgs_b(errfunc, fit_p,
                                args=(ts.index, ts.values, peak_params),
                                approx_grad=True)
    elif alg == 'leastsq':
        fit_p, _ = leastsq(errfunc_lsq, initc, args=(ts.index, ts.values,
                                                     all_params))
    # else:
    #     r = minimize(errfunc, initc, \
    #                  args=(ts.index, ts.values, all_params), \
    #                  jac=False, gtol=1e-2)
    #     #if not r['success']:
    #     #    print('Fail:' + str(f))
    #     #    print(r)
    #     #if np.nan in r['x']:  # not r['success']?
    #     #    fit_p = initc
    #     #else:
    #     #    fit_p = r['x']

    fit_pl = fit_p.tolist()
    v = fit_pl.pop(0)  # noqa
    fitted_params = []
    for f, to_fit in zip(fs, fit_vars):
        fit_p_dict = {v: fit_pl.pop(0) for v in to_fit}
        # fit_p_dict['v'] = v
        if make_bounded and hasattr(f, '_pbounds'):
            fitted_params.append(_to_bound_p(fit_p_dict, f._pbounds))
        else:
            fitted_params.append(fit_p_dict)

    # calculate r^2 of the fit
    ss_err = errfunc(fit_p, ts.index, ts.values, fitted_params)
    ss_tot = np.sum((ts.values - np.mean(ts.values)) ** 2)
    r2 = 1 - ss_err / ss_tot
    res = {'r^2': r2}

    return fitted_params, res
748858
def on_train_begin(self, **kwargs):
        ""
        if not self.modules:
            self.modules = [m for m in flatten_model(self.learn.model)
                            if hasattr(m, 'weight')]
        self.hooks = Hooks(self.modules, self.hook)
108560
def configuration_ES(t0: date, t1: Optional[date] = None, 
                     steps_per_day: int = None) -> Tuple[np.ndarray, np.ndarray]:
    
    # Default steps_per_day = 1
    if steps_per_day is None:
        steps_per_day = 1
        
    # Time step dt is 1.0 over steps per day
    dt: float = 1.0 / float(steps_per_day)

    # Default t1 to one day after t0
    if t1 is not None:
        # Convert t to a julian day
        jd0: int = julian_day(t0)
        jd1: int = julian_day(t1)
    else:
        jd0: int = julian_day(t0)
        jd1: int = jd0 + dt
    # Pass the times as an array of julian days
    jd: np.ndarray = np.arange(jd0, jd1, dt)

    # Position and velocity of the sun as arrays of length 3
    sun_id: int = jpl_body_id['sun']
    pos_sun, vel_sun = jpl_kernel[0, sun_id].compute_and_differentiate(jd)

    # Position and velocity of the earth as arrays of length 3
    earth_id: int = jpl_body_id['earth']
    pos_earth, vel_earth = jpl_kernel[0, earth_id].compute_and_differentiate(jd)

    # Convert positions from km to meters (multiply by km2m)
    q = np.vstack([pos_sun, pos_earth]).T * km2m
    # Convert velocities from km / day to meters / sec (multiply by km2m, divide by day2sec)
    v = np.vstack([vel_sun, vel_earth]).T * (km2m / day2sec)

    # Return tuple of Tx6 arrays for position q and velocity v
    return q, v
616365
private void configureBounds() {
    Drawable underlyingDrawable = getCurrent();
    Rect bounds = getBounds();
    int underlyingWidth = mUnderlyingWidth = underlyingDrawable.getIntrinsicWidth();
    int underlyingHeight = mUnderlyingHeight = underlyingDrawable.getIntrinsicHeight();

    // In case underlying drawable doesn't have intrinsic dimensions, we cannot set its bounds to
    // -1 so we use our bounds and discard specified matrix. In normal case we use drawable's
    // intrinsic dimensions for its bounds and apply specified matrix to it.
    if (underlyingWidth <= 0 || underlyingHeight <= 0) {
      underlyingDrawable.setBounds(bounds);
      mDrawMatrix = null;
    } else {
      underlyingDrawable.setBounds(0, 0, underlyingWidth, underlyingHeight);
      mDrawMatrix = mMatrix;
    }
  }
1283844
protected void setLayout() {

		int sizeEnsemble = this.ensembleSizeOption.getValue();

		distributorP = new BoostingDistributorProcessor();
		distributorP.setSizeEnsemble(sizeEnsemble);
		this.builder.addProcessor(distributorP, 1);
	
		//instantiate classifier
		classifier = this.baseLearnerOption.getValue();
		classifier.init(builder, this.dataset, sizeEnsemble);
		
		BoostingPredictionCombinerProcessor predictionCombinerP= new BoostingPredictionCombinerProcessor();
		predictionCombinerP.setSizeEnsemble(sizeEnsemble);
		this.builder.addProcessor(predictionCombinerP, 1);
		
		//Streams
		resultStream = this.builder.createStream(predictionCombinerP);
		predictionCombinerP.setOutputStream(resultStream);

		for (Stream subResultStream:classifier.getResultStreams()) {
			this.builder.connectInputKeyStream(subResultStream, predictionCombinerP);
		}
		
		/* The testing stream. */
		Stream testingStream = this.builder.createStream(distributorP);
		this.builder.connectInputKeyStream(testingStream, classifier.getInputProcessor());
	
		/* The prediction stream. */
		Stream predictionStream = this.builder.createStream(distributorP);
		this.builder.connectInputKeyStream(predictionStream, classifier.getInputProcessor());
		
		distributorP.setOutputStream(testingStream);
		distributorP.setPredictionStream(predictionStream);
                
    // Addition to Bagging: stream to train
    /* The training stream. */
		Stream trainingStream = this.builder.createStream(predictionCombinerP);
		predictionCombinerP.setTrainingStream(trainingStream);
		this.builder.connectInputKeyStream(trainingStream, classifier.getInputProcessor());
                
	}
368058
def run():
  """"""
  step = tf.compat.v1.placeholder(tf.float32, shape=[])

  with tf.name_scope('loss'):
    # Specify 2 different loss values, each tagged differently.
    summary_lib.scalar('foo', tf.pow(0.9, step))
    summary_lib.scalar('bar', tf.pow(0.85, step + 2))

    # Log metric baz as well as upper and lower bounds for a margin chart.
    middle_baz_value = step + 4 * tf.random.uniform([]) - 2
    summary_lib.scalar('baz', middle_baz_value)
    summary_lib.scalar('baz_lower',
                       middle_baz_value - 6.42 - tf.random.uniform([]))
    summary_lib.scalar('baz_upper',
                       middle_baz_value + 6.42 + tf.random.uniform([]))

  with tf.name_scope('trigFunctions'):
    summary_lib.scalar('cosine', tf.cos(step))
    summary_lib.scalar('sine', tf.sin(step))
    summary_lib.scalar('tangent', tf.tan(step))

  merged_summary = tf.compat.v1.summary.merge_all()

  with tf.compat.v1.Session() as sess, tf.summary.FileWriter(LOGDIR) as writer:
    # We only need to specify the layout once (instead of per step).
    layout_summary = summary_lib.custom_scalar_pb(
        layout_pb2.Layout(category=[
            layout_pb2.Category(
                title='losses',
                chart=[
                    layout_pb2.Chart(
                        title='losses',
                        multiline=layout_pb2.MultilineChartContent(
                            tag=[r'loss(?!.*margin.*)'],)),
                    layout_pb2.Chart(
                        title='baz',
                        margin=layout_pb2.MarginChartContent(
                            series=[
                                layout_pb2.MarginChartContent.Series(
                                    value='loss/baz/scalar_summary',
                                    lower='loss/baz_lower/scalar_summary',
                                    upper='loss/baz_upper/scalar_summary'
                                ),
                            ],)),
                ]),
            layout_pb2.Category(
                title='trig functions',
                chart=[
                    layout_pb2.Chart(
                        title='wave trig functions',
                        multiline=layout_pb2.MultilineChartContent(
                            tag=[
                                r'trigFunctions/cosine', r'trigFunctions/sine'
                            ],)),
                    # The range of tangent is different. Give it its own chart.
                    layout_pb2.Chart(
                        title='tan',
                        multiline=layout_pb2.MultilineChartContent(
                            tag=[r'trigFunctions/tangent'],)),
                ],
                # This category we care less about. Make it initially closed.
                closed=True),
        ]))
    writer.add_summary(layout_summary)

    for i in xrange(42):
      summary = sess.run(merged_summary, feed_dict={step: i})
      writer.add_summary(summary, global_step=i)
903880
def ustep(self):
        """"""

        self.U += self.rsdl_r(self.AX, self.Y)