// PredictFullConeNAT checks whether the local host is behind full cone NAT. It predicts by
// checking whether any statement has been received from a node we didn't contact before
// the statement was made.
182947
func (it *IPTracker) PredictFullConeNAT() bool {
	now := it.clock.Now()
	it.gcContact(now)
	it.gcStatements(now)
	for host, st := range it.statements {
		if c, ok := it.contact[host]; !ok || c > st.time {
			return true
		}
	}
	return false
}
1121559
func expectThat(
	x interface{},
	m oglematchers.Matcher,
	depth int,
	errorParts []interface{}) (passed bool) {
	// Check whether the value matches. If it does, we are finished.
	matcherErr := m.Matches(x)
	if matcherErr == nil {
		passed = true
		return
	}

	var r FailureRecord

	// Get information about the call site.
	var ok bool
	if _, r.FileName, r.LineNumber, ok = runtime.Caller(depth + 1); !ok {
		panic("expectThat: runtime.Caller")
	}

	r.FileName = path.Base(r.FileName)

	// Create an appropriate failure message. Make sure that the expected and
	// actual values align properly.
	relativeClause := ""
	if matcherErr.Error() != "" {
		relativeClause = fmt.Sprintf(", %s", matcherErr.Error())
	}

	r.Error = fmt.Sprintf(
		"Expected: %s\nActual:   %v%s",
		m.Description(),
		x,
		relativeClause)

	// Add the user error, if any.
	if len(errorParts) != 0 {
		v := reflect.ValueOf(errorParts[0])
		if v.Kind() != reflect.String {
			panic(fmt.Sprintf("ExpectThat: invalid format string type %v", v.Kind()))
		}

		r.Error = fmt.Sprintf(
			"%s\n%s",
			r.Error,
			fmt.Sprintf(v.String(), errorParts[1:]...))
	}

	// Report the failure.
	AddFailureRecord(r)

	return
}
406717
func (p *provider) fillFullCommit(signedHeader types.SignedHeader) (fc lite.FullCommit, err error) {

	// Get the validators.
	valset, err := p.getValidatorSet(signedHeader.ChainID, signedHeader.Height)
	if err != nil {
		return lite.FullCommit{}, err
	}

	// Get the next validators.
	nextValset, err := p.getValidatorSet(signedHeader.ChainID, signedHeader.Height+1)
	if err != nil {
		return lite.FullCommit{}, err
	}

	return lite.NewFullCommit(signedHeader, valset, nextValset), nil
}
638311
func IsErrTokenNotFound(err error) bool {
	return err != nil && strings.Contains(err.Error(), errTokenNotFound)
}
29865
func ParseKnownHost(
	ctx types.Context,
	text string) (*types.TLSKnownHost, error) {

	m := knownHostRX.FindStringSubmatch(text)
	if len(m) == 0 {
		return nil, nil
	}

	ctx.WithFields(map[string]interface{}{
		"khHost": m[1],
		"khAlg":  m[2],
		"khSig":  m[3],
	}).Debug("parsing known_hosts file fields")

	buf, err := hex.DecodeString(strings.Replace(m[3], ":", "", -1))
	if err != nil {
		return nil, goof.WithError(
			"error decoding known host fingerprint", err)
	}
	return &types.TLSKnownHost{
		Host:        m[1],
		Alg:         m[2],
		Fingerprint: buf,
	}, nil
}
361351
func (em *ExpectationMaximization) Predict(inst base.FixedDataGrid) (ClusterMap, error) {
	if !em.fitted {
		return nil, NoTrainingDataError
	}

	_, n_obs := inst.Size()
	n_feats := len(em.attrs)

	// Numeric attrs
	attrSpecs := base.ResolveAttributes(inst, em.attrs)

	// Build the input matrix
	X := mat.NewDense(n_obs, n_feats, nil)
	inst.MapOverRows(attrSpecs, func(row [][]byte, i int) (bool, error) {
		for j, r := range row {
			X.Set(i, j, base.UnpackBytesToFloat(r))
		}
		return true, nil
	})

	// Vector of predictions
	preds := estimateLogProb(X, em.Params, em.n_comps)

	clusterMap := make(map[int][]int)
	for ix, pred := range vecToInts(preds) {
		clusterMap[pred] = append(clusterMap[pred], ix)
	}

	return ClusterMap(clusterMap), nil
}
1245819
func NewSimpleClient(hosts []string) (*simpleEtcdClient, error) {
	cfg := client.Config{
		Endpoints: hosts,
	}

	r, err := client.New(cfg)
	if err != nil {
		return nil, err
	}

	return &simpleEtcdClient{
		realClient: r,
	}, nil
}
751221
func (r *runtimeOCI) libcontainerStats(ctr *Container) (*libcontainer.Stats, error) {
	factory, err := loadFactory(r.root)
	if err != nil {
		return nil, err
	}
	container, err := factory.Load(ctr.ID())
	if err != nil {
		return nil, err
	}
	return container.Stats()
}
265717
func (rt *RandomTree) Predict(from base.FixedDataGrid) (base.FixedDataGrid, error) {
	return rt.Root.Predict(from)
}
1320758
func predictPackages(a complete.Args) (prediction []string) {
	prediction = []string{a.Last}
	lastPrediction := ""
	for len(prediction) == 1 && (lastPrediction == "" || lastPrediction != prediction[0]) {
		// if only one prediction, predict files within this prediction,
		// for example, if the user entered 'pk' and we have a package named 'pkg',
		// which is the only package prefixed with 'pk', we will automatically go one
		// level deeper and give the user the 'pkg' and all the nested packages within
		// that package.
		lastPrediction = prediction[0]
		a.Last = prediction[0]
		prediction = predictLocalAndSystem(a)
	}
	return
}
698169
func HostnameMatchSpecCandidates(hostname string) []string {
	if len(hostname) == 0 {
		return nil
	}

	// Exact match has priority
	candidates := []string{hostname}

	// Replace successive labels in the name with wildcards, to require an exact match on number of
	// path segments, because certificates cannot wildcard multiple levels of subdomains
	//
	// This is primarily to be consistent with tls.Config#getCertificate implementation
	//
	// It using a cert signed for *.foo.example.com and *.bar.example.com by specifying the name *.*.example.com
	labels := strings.Split(hostname, ".")
	for i := range labels {
		labels[i] = "*"
		candidates = append(candidates, strings.Join(labels, "."))
	}
	return candidates
}
521605
func (s *Prediction) SetPredictedLabel(v string) *Prediction {
	s.PredictedLabel = &v
	return s
}
464884
func IsLimitExceeded(data string) bool {
	data = strings.ToLower(data)
	return strings.Contains(data, "limit exceeded")
}
889761
func newStatefulSets(c *AppsV1beta1Client, namespace string) *statefulSets {
	return &statefulSets{
		client: c.RESTClient(),
		ns:     namespace,
	}
}
558897
func (mc *multiProvider) SaveFullCommit(fc FullCommit) (err error) {
	for _, p := range mc.providers {
		err = p.SaveFullCommit(fc)
		if err != nil {
			return
		}
	}
	return
}
979942
func (n *NeutrinoNotifier) onRelevantTx(tx *btcutil.Tx, details *btcjson.BlockDetails) {
	select {
	case n.txUpdates.ChanIn() <- &relevantTx{tx, details}:
	case <-n.quit:
	}
}
1156592
func (c *cubicSender) maybeIncreaseCwnd(
	ackedPacketNumber protocol.PacketNumber,
	ackedBytes protocol.ByteCount,
	priorInFlight protocol.ByteCount,
	eventTime time.Time,
) {
	// Do not increase the congestion window unless the sender is close to using
	// the current window.
	if !c.isCwndLimited(priorInFlight) {
		c.cubic.OnApplicationLimited()
		return
	}
	if c.congestionWindow >= c.maxCongestionWindow {
		return
	}
	if c.InSlowStart() {
		// TCP slow start, exponential growth, increase by one for each ACK.
		c.congestionWindow += protocol.DefaultTCPMSS
		return
	}
	// Congestion avoidance
	if c.reno {
		// Classic Reno congestion avoidance.
		c.numAckedPackets++
		// Divide by num_connections to smoothly increase the CWND at a faster
		// rate than conventional Reno.
		if c.numAckedPackets*uint64(c.numConnections) >= uint64(c.congestionWindow)/uint64(protocol.DefaultTCPMSS) {
			c.congestionWindow += protocol.DefaultTCPMSS
			c.numAckedPackets = 0
		}
	} else {
		c.congestionWindow = utils.MinByteCount(c.maxCongestionWindow, c.cubic.CongestionWindowAfterAck(ackedBytes, c.congestionWindow, c.rttStats.MinRTT(), eventTime))
	}
}