code stringlengths 114 1.05M | path stringlengths 3 312 | quality_prob float64 0.5 0.99 | learning_prob float64 0.2 1 | filename stringlengths 3 168 | kind stringclasses 1
value |
|---|---|---|---|---|---|
package expressions
import (
"regexp"
"strconv"
"strings"
)
func BuildEqExpressionFn(expr string) func([]byte) bool {
isNumericValue := false
fExpValue, err := strconv.ParseFloat(expr, 64)
if err == nil {
isNumericValue = true
}
return func(value []byte) bool {
if isNumericValue {
fValue, err := strco... | config/expressions/builder.go | 0.620737 | 0.429609 | builder.go | starcoder |
package main
import (
"time"
"math/rand"
"math"
)
type Zipfian struct {
items int64
alpha, zetaN, eta, theta float64
r *rand.Rand
}
func NewZipfian(items int64, constant float64) Zipfian {
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
return NewZipfianWithRand(items, constant, rng)
}
func NewZipfi... | cmd/experiments/zipfian.go | 0.575946 | 0.448004 | zipfian.go | starcoder |
package aoc2021
/*
Describe the problem
*/
const DAY_2021_02_TEST_DATA = `forward 5
down 5
forward 8
up 3
down 8
forward 2`
const DAY_2021_02_DATA = `forward 3
down 7
forward 7
down 4
down 9
down 7
forward 5
forward 9
forward 3
forward 8
down 4
down 6
down 3
forward 7
forward 1
forward 4
down 1
forward 7
forward 9
d... | app/aoc2021/aoc2021_02_data.go | 0.756717 | 0.546315 | aoc2021_02_data.go | starcoder |
package constants
const (
// UnitAcres is a unit of land measurement in the British Imperial and United States Customary systems, equal to 43,560 square feet, or 4,840 square yards. One acre is equivalent to 0.4047 hectare (4,047 square metres
UnitAcres = "acres"
// UnitHectares is a unit of area in the metric syst... | constants/constants.go | 0.806014 | 0.817356 | constants.go | starcoder |
package board
// Resolves effects of the given battle on the board.
// Forwards the given battle to the appropriate battle resolver based on its type.
// Returns any retreating move orders that could not be resolved.
func (board Board) resolveBattle(battle Battle) (retreats []Order) {
if battle.isBorderConflict() {
... | game/board/resolve_battle.go | 0.792625 | 0.495728 | resolve_battle.go | starcoder |
package builds
import (
"path/filepath"
"time"
g "github.com/onsi/ginkgo"
o "github.com/onsi/gomega"
buildv1 "github.com/openshift/api/build/v1"
exutil "github.com/openshift/origin/test/extended/util"
)
func verifyStages(stages []buildv1.StageInfo, expectedStages map[string][]string) {
for _, stage := range ... | test/extended/builds/build_timing.go | 0.532668 | 0.421969 | build_timing.go | starcoder |
package preprocessing
import (
"github.com/wieku/gosu-pp/beatmap/difficulty"
"github.com/wieku/gosu-pp/beatmap/objects"
"github.com/wieku/gosu-pp/math/vector"
"math"
)
const (
maximumSliderRadius float32 = NormalizedRadius * 2.4
assumedSliderRadius float32 = NormalizedRadius * 1.8
)
// LazySlider is a utility ... | performance/osu/preprocessing/lazyslider.go | 0.729616 | 0.428233 | lazyslider.go | starcoder |
package main
/* Day 9 part A:
For a given input stream consisting of groups of characters bounded by {}
and optionally within {} separated by a comma, determine the total number of
groups. These may be infinitely nested.
There are special groups ("garbage") bounded by < and > within which are
excluded from the overa... | 2017/day09.go | 0.598547 | 0.404184 | day09.go | starcoder |
package pure
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"github.com/benthosdev/benthos/v4/internal/bundle"
"github.com/benthosdev/benthos/v4/internal/component/processor"
"github.com/benthosdev/benthos/v4/internal/docs"
"github.com/benthosdev/benthos/v4/internal/interop"
"github.com/benthosdev/b... | internal/impl/pure/processor_protobuf.go | 0.765155 | 0.583263 | processor_protobuf.go | starcoder |
package matrix_ops
import (
"errors"
"fmt"
)
type Matrix [][]float64
func CreateEmptyMatrix(rows, cols int) Matrix { // TODO: check for valid rows, cols
var mat Matrix = make(Matrix, rows)
for i := 0; i < rows; i++ {
mat[i] = make([]float64, cols)
}
return mat
}
func CopyMatrix(mat Matrix) Matrix {
var ne... | github.com/qwertygidq/matrix_ops/matrix_ops.go | 0.553747 | 0.617282 | matrix_ops.go | starcoder |
package processor
import (
"fmt"
"time"
"github.com/Jeffail/benthos/v3/internal/bloblang"
"github.com/Jeffail/benthos/v3/internal/bloblang/field"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message"
"github.com/Jeffail/benthos/v3/lib... | lib/processor/insert_part.go | 0.695648 | 0.519217 | insert_part.go | starcoder |
package plantri
import (
"errors"
"fmt"
)
var ErrVertexNotFound = errors.New("plantri: vertex with that id doesn't exist")
// Graph is an abstraction of a simple graph. Each vertex is guaranteed to
// have a unique identifier.
type Graph interface {
// Size returns the number of edges in the graph.
Size() int
... | graph.go | 0.520253 | 0.549157 | graph.go | starcoder |
package graph
// Indexable is expected to be implemented by all vertices and edges of a graph
// so they can be indexed and uniquely referenced.
type Indexable interface {
// Produces a unique key representing the caller. This key must be
// comparable in order to be used as the key of a map.
Key() interface{}
}
/... | graph/index.go | 0.81946 | 0.514278 | index.go | starcoder |
package overlay
import (
"encoding/json"
"github.com/mafredri/cdp/protocol/dom"
"github.com/mafredri/cdp/protocol/page"
"github.com/mafredri/cdp/protocol/runtime"
)
// GetHighlightObjectForTestArgs represents the arguments for GetHighlightObjectForTest in the Overlay domain.
type GetHighlightObjectForTestArgs s... | protocol/overlay/command.go | 0.785514 | 0.441793 | command.go | starcoder |
package geometry
import (
"github.com/Glenn-Gray-Labs/g3n/gls"
"github.com/Glenn-Gray-Labs/g3n/math32"
)
// NewCube creates a cube geometry with the specified size.
func NewCube(size float32) *Geometry {
return NewSegmentedCube(size, 1)
}
// NewSegmentedCube creates a segmented cube geometry with the specified s... | geometry/box.go | 0.846609 | 0.583975 | box.go | starcoder |
package juroku
import (
"errors"
"image"
"image/color"
"math"
"sort"
"github.com/disintegration/gift"
)
// GetPalette returns the palette of the image.
func GetPalette(img image.Image) color.Palette {
colors := make(map[color.RGBA]bool)
for y := img.Bounds().Min.Y; y < img.Bounds().Max.Y; y++ {
for x := i... | image.go | 0.780913 | 0.490419 | image.go | starcoder |
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"math"
)
//go:noinline
func fcmplt(a, b float64, x uint64) uint64 {
if a < b {
x = 0
}
return x
}
//go:noinline
func fcmp... | test/fixedbugs/issue43619.go | 0.704973 | 0.428114 | issue43619.go | starcoder |
package bigquery
import (
"errors"
"fmt"
"strconv"
"time"
bq "google.golang.org/api/bigquery/v2"
)
// Value stores the contents of a single cell from a BigQuery result.
type Value interface{}
// ValueLoader stores a slice of Values representing a result row from a Read operation.
// See RowIterator.Next for m... | vendor/cloud.google.com/go/bigquery/value.go | 0.769254 | 0.521776 | value.go | starcoder |
package geo
import (
"fmt"
"strconv"
"strings"
"github.com/cockroachdb/cockroach/pkg/geo/geopb"
"github.com/cockroachdb/cockroach/pkg/geo/geos"
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/twpayne/go-geom"
"github.com/twpayne/go-geom/encoding/ewkb"
"github.com/twpayne/go-geom/encoding/ewkbhex"
"... | pkg/geo/parse.go | 0.573917 | 0.416559 | parse.go | starcoder |
package htm
import (
"fmt"
"github.com/cznic/mathutil"
"github.com/nupic-community/htm/utils"
"github.com/zacg/floats"
"github.com/zacg/go.matrix"
//"math"
//"math/rand"
//"sort"
)
type TpStats struct {
NInfersSinceReset int
NPredictions int
PredictionScoreTotal float64
PredictionScor... | temporalPoolerStats.go | 0.682574 | 0.451266 | temporalPoolerStats.go | starcoder |
//go:build 386 || arm || mips || mipsle
// +build 386 arm mips mipsle
package runtime
// Additional index/slice error paths for 32-bit platforms.
// Used when the high word of a 64-bit index is not zero.
// failures in the comparisons for s[x], 0 <= x < y (y == len(s))
func goPanicExtendIndex(hi int, lo uint, y int... | src/runtime/panic32.go | 0.560012 | 0.451024 | panic32.go | starcoder |
package numerics
import (
"fmt"
"math"
)
const logSqrt2Pi = 0.91893853320467274178032973640562
func GaussAt(x float64) float64 {
return math.Exp(-x*x/2) / (math.Sqrt2 * math.SqrtPi)
}
func GaussCumulativeTo(x float64) float64 {
return math.Erf(x/math.Sqrt2)/2 + 0.5
}
func GaussInvCumulativeTo(x, mean, stddev f... | vendor/github.com/ChrisHines/GoSkills/skills/numerics/GaussDist.go | 0.908929 | 0.61115 | GaussDist.go | starcoder |
// This package contains string conversion function and is written in [Go][1].
// It is much alike the standard library's strconv package, but it is
// specifically tailored for the performance needs within the minify package.
// For example, the floating-point to string conversion function is
// approximately twice a... | util/byteconv/float.go | 0.615666 | 0.478894 | float.go | starcoder |
package joejson
import (
"encoding/json"
"fmt"
)
// GeometryTypeGeometryCollection is the value for a GeometryCollection's 'type' member.
const GeometryTypeGeometryCollection = "GeometryCollection"
// GeometryCollection is a slice of Geometries.
type GeometryCollection []GeometryCollectionMember
// AppendPoint ap... | geometrycollection.go | 0.799638 | 0.4231 | geometrycollection.go | starcoder |
package main
import (
"fmt"
"golang.org/x/tour/tree"
)
/*
------- Exercise: Equivalent Binary Trees
There can be many different binary trees with the same sequence of values stored in it.
For example, here are two binary trees storing the sequence 1, 1, 2, 3, 5, 8, 13.
A function to check whether two binary trees ... | 6_concurrency/exercise-equivalent-binary-trees.go | 0.772101 | 0.6597 | exercise-equivalent-binary-trees.go | starcoder |
package skyhook
import (
"encoding/json"
"io"
"io/ioutil"
"github.com/paulmach/go.geojson"
gomapinfer "github.com/mitroadmaps/gomapinfer/common"
)
type GeoJsonData struct {
Collection *geojson.FeatureCollection
}
func GetGeometryBbox(g *geojson.Geometry) gomapinfer.Rectangle {
var bbox gomapinfer.Rectangle =... | skyhook/data_geojson.go | 0.703244 | 0.453685 | data_geojson.go | starcoder |
package schema
import (
"fmt"
"regexp"
"strings"
"github.com/fatih/camelcase"
pb "github.com/semi-technologies/contextionary/contextionary"
contextionary "github.com/semi-technologies/contextionary/contextionary/core"
"github.com/semi-technologies/contextionary/errors"
)
// SearchResult is a single search res... | contextionary/schema/schema_search.go | 0.680879 | 0.402451 | schema_search.go | starcoder |
package cbor
import (
"errors"
"io"
"reflect"
)
// Decoder reads and decodes CBOR values from an input stream.
type Decoder struct {
r io.Reader
buf []byte
d decodeState
off int // start of unread data in buf
bytesRead int
}
// NewDecoder returns a new decoder that reads from r.
... | vendor/github.com/fxamacker/cbor/stream.go | 0.666931 | 0.436382 | stream.go | starcoder |
package gflowparser
import (
"github.com/flowdev/gflowparser/data"
"github.com/flowdev/gflowparser/data2svg"
"github.com/flowdev/gflowparser/parser"
"github.com/flowdev/gflowparser/svg"
"github.com/flowdev/gparselib"
)
// ConvertFlowDSLToSVG transforms a flow given as DSL string into a SVG image
// plus componen... | converter.go | 0.617859 | 0.474205 | converter.go | starcoder |
package decision_tree
import (
"sort"
"math"
)
// zips two values and allows sorting based on value
type zipColumn struct {
Value float64
Response float64
}
// container of zipColumns that implements sorting interface
type zipColumnSortable []zipColumn
func (a zipColumnSortable) Len() int { return len(a) }
func... | decision_tree/gini.go | 0.716318 | 0.634699 | gini.go | starcoder |
package grafo
import (
"bytes"
"fmt"
"github.com/jrecuero/go-cli/tools"
)
// Grafo represents ...
type Grafo struct {
id Ider
Label string
root IVertex
anchor IVertex
path *Path
vertices map[Ider]IVertex
}
// GetRoot is ...
func (grafo *Grafo) GetRoot() IVertex {
return grafo.root
}
//... | grafo/grafo.go | 0.719975 | 0.414484 | grafo.go | starcoder |
package inverted
// DeltaMerger can be used to condense the number of single writes into one big
// one. Additionally it removes overlaps between additions and deletions. It is
// meant to be used in batch situation, where 5 ref objects in a row might each
// increase the doc count by one. Instead of writing 5 additi... | adapters/repos/db/inverted/delta_merger.go | 0.689515 | 0.4881 | delta_merger.go | starcoder |
package ent
import (
"AppFactory/internal/data/ent/student"
"fmt"
"strings"
"entgo.io/ent/dialect/sql"
)
// Student is the model entity for the Student schema.
type Student struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// ExamNum holds the value of the "exam_num" field.
ExamNu... | internal/data/ent/student.go | 0.617051 | 0.444324 | student.go | starcoder |
// action package contains interfaces and behaviour for general-purpose "management actions" that change a model's
// decision variables based on their activation status.
package action
import (
"github.com/LindsayBradford/crem/internal/pkg/model/planningunit"
)
// ManagementActionType identifies a set of managemen... | internal/pkg/model/action/ManagementAction.go | 0.782413 | 0.459743 | ManagementAction.go | starcoder |
package writer
import (
"fmt"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/jedib0t/go-pretty/v6/text"
"github.com/jedib0t/go-sudoku/sudoku"
)
// RenderSamurai renders a Samurai Sudoku which is a combination of 5 Sudokus.
func RenderSamurai(grids []*sudoku.Grid) (string, error) {
if len(grids) != 5 {
re... | writer/samurai_sudoku.go | 0.575111 | 0.5083 | samurai_sudoku.go | starcoder |
package monotone_convex
/*
implementation based on Hagan, <NAME>., and <NAME>. "Methods for constructing a yield curve." Wilmott Magazine, May (2008): 70-81.
*/
import (
m "../../measures"
"log"
"math"
"sort"
)
type mcInput struct {
lambda float64
terms []m.Time
rates []m.Rate
}
func (inp *mcInput) N() in... | src/bond/monotone_convex/interpolator.go | 0.655336 | 0.488588 | interpolator.go | starcoder |
package consumererror
import (
"errors"
"go.opentelemetry.io/collector/consumer/pdata"
)
// Traces is an error that may carry associated Trace data for a subset of received data
// that faiiled to be processed or sent.
type Traces struct {
error
failed pdata.Traces
}
// NewTraces creates a Traces that can enca... | consumer/consumererror/signalerrors.go | 0.710528 | 0.469034 | signalerrors.go | starcoder |
package neural
// See https://github.com/ArztSamuel/Applying_EANNs for the inspiration for this.
import (
"math"
"math/rand"
)
// Defines a deeply-connected neuron with weights to the neurons on the next layer
type Neuron struct {
Weights []float32
}
type NeuralLayer struct {
NextLayerSize int
Neurons []N... | voxelli/neural/neuralLayer.go | 0.841207 | 0.593698 | neuralLayer.go | starcoder |
package xgeneric
import "math/rand"
// Uniq returns a duplicate-free version of an array
func Uniq[T comparable](collection []T) []T {
result := make([]T, 0, len(collection))
seen := make(map[T]struct{}, len(collection))
for _, item := range collection {
if _, ok := seen[item]; ok {
continue
}
seen[item... | pkg/util/xgeneric/slice.go | 0.826222 | 0.435181 | slice.go | starcoder |
package mesh
import (
"github.com/weqqr/panorama/lm"
)
type Vertex struct {
Position lm.Vector3
Texcoord lm.Vector2
Normal lm.Vector3
}
type Mesh struct {
Vertices []Vertex
}
func NewMesh() Mesh {
return Mesh{
Vertices: []Vertex{},
}
}
type Model struct {
Meshes []Mesh
}
func NewModel() Model {
retur... | mesh/mesh.go | 0.551091 | 0.701362 | mesh.go | starcoder |
package integrationtests
import (
"context"
"testing"
ethAbi "github.com/ethereum/go-ethereum/accounts/abi"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/consensys/orchestrate/pkg/encoding/json"
"github.com/consensys/or... | services/api/integration-tests/contracts.go | 0.607197 | 0.436142 | contracts.go | starcoder |
package message
import (
"github.com/mschoenlaub/grip/level"
)
type condComposer struct {
cond bool
msg Composer
}
// When returns a conditional message that is only logged if the
// condition is bool. Converts the second argument to a composer, if
// needed, using the same rules that the logging methods use.
fu... | message/conditional.go | 0.657758 | 0.452113 | conditional.go | starcoder |
package sort
// BinaryInsertionSort is an implementation of the binary insertion sort
// algorithm borrowed from timsort, with some minor modifications.
// It requires O(n log n) compares, but O(n^2) data movement (worst case).
func BinaryInsertionSort(arr []string) {
binaryInsertionSortDepth(arr, 0)
}
// binaryIns... | sort/binaryinsertionsort.go | 0.807878 | 0.638497 | binaryinsertionsort.go | starcoder |
package main
// mainUsage describes usage of the overall tool.
const mainUsage string = `
A Swiss Army knife for vending your own Go packages.
vend [subcommand] [arguments]
Valid subcommands :
vend init
vend cp
vend mv
vend path
vend list
vend info
For help with subcommands run :
vend [subcommand]... | usage.go | 0.686895 | 0.618593 | usage.go | starcoder |
package matcher
import (
"reflect"
"strings"
)
// StructMatcher defines a generic structure matcher. Implements Matcher interface
type StructMatcher struct {
// pattern with a map with the name of the field an its value
pattern map[string]interface{}
}
// NewStructMatcher creates a generic structure matcher with... | pkg/matcher/struct.go | 0.768993 | 0.420719 | struct.go | starcoder |
package heatmap
import (
"github.com/K-Phoen/grabana/heatmap/axis"
"github.com/K-Phoen/grabana/target/graphite"
"github.com/K-Phoen/grabana/target/influxdb"
"github.com/K-Phoen/grabana/target/prometheus"
"github.com/K-Phoen/grabana/target/stackdriver"
"github.com/grafana-tools/sdk"
)
// DataFormatMode represent... | vendor/github.com/K-Phoen/grabana/heatmap/heatmap.go | 0.851675 | 0.422505 | heatmap.go | starcoder |
package main
import (
"container/heap"
"math"
)
// Check whether a leaf node has a circle event and add to event queue if true
func checkCircleEvent(leafNode *node, sweepline float64, eventQueue *PriorityQueue) *Item {
if leafNode.previous == nil || leafNode.next == nil {
return nil
}
leftSite := leafNode.pre... | circle.go | 0.71113 | 0.47384 | circle.go | starcoder |
package config
import (
"strings"
)
// Partial defined a type used to store configuration information.
type Partial map[string]interface{}
// ToPartial will try to convert a map value into a packed Partial
// instance (recursively).
// The rules of conversion are:
// - Partial : recursively convert the stored eleme... | config/partial.go | 0.659624 | 0.512998 | partial.go | starcoder |
package ride
import (
"encoding/base64"
"github.com/pkg/errors"
)
type TreeEstimation struct {
Estimation int `cbor:"0,keyasint"`
Verifier int `cbor:"1,keyasint,omitempty"`
Functions map[string]int `cbor:"2,keyasint,omitempty"`
}
func EstimateTree(tree *Tree, v int) (TreeEstimation, er... | pkg/ride/tree_estimation.go | 0.656658 | 0.479077 | tree_estimation.go | starcoder |
package types
import (
"reflect"
"strconv"
"sync"
)
var (
stringType = reflect.TypeOf((*string)(nil)).Elem()
sliceStringType = reflect.TypeOf([]string(nil))
intType = reflect.TypeOf((*int)(nil)).Elem()
sliceIntType = reflect.TypeOf([]int(nil))
int64Type = reflect.TypeOf((*int64)(nil)).Elem()
... | types/array_append.go | 0.536556 | 0.507202 | array_append.go | starcoder |
package framework
import (
"fmt"
"strings"
"github.com/kiegroup/kogito-cloud-operator/pkg/infrastructure"
)
// KogitoInfraComponent defines the KogitoInfra component
type KogitoInfraComponent struct {
name string
}
const (
infinispanKey = "infinispan"
kafkaKey = "kafka"
keycloakKey = "keycloak"
)
va... | test/framework/kogitoinfra.go | 0.634317 | 0.422207 | kogitoinfra.go | starcoder |
package internal
import (
"bytes"
"time"
api "github.com/tigrisdata/tigris/api/server/v1"
ulog "github.com/tigrisdata/tigris/util/log"
"github.com/ugorji/go/codec"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/types/known/timestamppb"
)
var (
bh codec.BincHandle
)
// DataType is to define the ... | internal/data.go | 0.740737 | 0.412885 | data.go | starcoder |
package model
const VarianceStatMask = ^uint64(0) >> (64 - 5)
type WeaponVariance struct {
Durability int
PhyReinforce int
MagReinforce int
HitRate int
PhyAttack int
MagAttack int
CriticalRate int
}
type ArmorVariance struct {
Durability int
PhyReinforce int
MagReinforce int
PhyDefense in... | model/item_variance.go | 0.62601 | 0.569015 | item_variance.go | starcoder |
package holtwinters
// Creates an array of forcasted data points based on the given time series
func TripleExponentialSmoothing(series []float64, alpha, beta, gamma float64, seasonLength, nPredictions int) []float64 {
// initialize the predicted series
predictedValues := make([]float64, 0, len(series)+nPredictions)
... | holtwinters.go | 0.780579 | 0.657916 | holtwinters.go | starcoder |
package semantic
import "github.com/google/gapid/gapil/ast"
// Length represents a length of object expression.
// Object must be of either pointer, slice, map or string type.
// The length expression is allowed to be of any numeric type
type Length struct {
AST *ast.Call // the underlying syntax node this was ... | gapil/semantic/internal.go | 0.800536 | 0.504822 | internal.go | starcoder |
package reltest
import (
"context"
"fmt"
"reflect"
"strings"
"github.com/go-rel/rel"
)
type insertAll []*MockInsertAll
func (ia *insertAll) register(ctxData ctxData) *MockInsertAll {
mia := &MockInsertAll{
assert: &Assert{ctxData: ctxData},
}
*ia = append(*ia, mia)
return mia
}
func (ia insertAll) execu... | insert_all.go | 0.623033 | 0.428473 | insert_all.go | starcoder |
package ua
// StatusCode is the result of the service call.
type StatusCode uint32
// IsGood returns true if the StatusCode is good.
func (c StatusCode) IsGood() bool {
return (uint32(c) & SeverityMask) == SeverityGood
}
// IsBad returns true if the StatusCode is bad.
func (c StatusCode) IsBad() bool {
return (ui... | ua/status_code.go | 0.755997 | 0.416737 | status_code.go | starcoder |
package util
// FloatSlidingWindow is a buffer with a fixed capacity. Elements are
// inserted/removed in the FIFO order. Elements are removed from the buffer
// only when it runs out of capacity and a new element is inserted.
type FloatSlidingWindow interface {
// Add a value to the end of the queue. On overflow ret... | vertical-pod-autoscaler/recommender/util/slidingwindow.go | 0.821367 | 0.564879 | slidingwindow.go | starcoder |
package types
import (
"fmt"
"time"
)
// TimeValue is a struct that holds a time value.
type TimeValue struct {
value time.Time
}
// IsSameAs returns true if the value is the same as the expected value, else false.
func (t TimeValue) IsSameAs(expected interface{}) bool {
return t.value == expected
}
// IsAlmost... | internal/pkg/types/time_value.go | 0.871871 | 0.639912 | time_value.go | starcoder |
package text
import (
tf "github.com/tensorflow/tensorflow/tensorflow/go"
"github.com/tensorflow/tensorflow/tensorflow/go/op"
)
// ReadText from a file
func ReadText(s *op.Scope, fileName string) (indices tf.Output) {
read := op.ReadFile(s, op.Const(s.SubScope("file_name"), fileName))
indices = op.DecodeRaw(s, re... | text/text.go | 0.768038 | 0.413832 | text.go | starcoder |
package gofiql
import (
"bytes"
"fmt"
"regexp"
)
// spitExpression takes in input a constraint expression and splits it
// into its component parts, i.e. left operand, right operand and
// operator.
// It makese uses of a regular expression.
func splitExpression(expression *string) (*string, *string, *string, erro... | gofiql/util.go | 0.63341 | 0.468 | util.go | starcoder |
package cp
import "fmt"
//Draw flags
const (
DRAW_SHAPES = 1 << 0
DRAW_CONSTRAINTS = 1 << 1
DRAW_COLLISION_POINTS = 1 << 2
)
// 16 bytes
type FColor struct {
R, G, B, A float32
}
type Drawer interface {
DrawCircle(pos Vector, angle, radius float64, outline, fill FColor, data interface{})
DrawSe... | draw.go | 0.603815 | 0.413004 | draw.go | starcoder |
package dsf
import (
"encoding/binary"
"fmt"
)
// DsdChunk is the file structure of the DSD chunk within a DSD stream file.
// See "DSF File Format Specification", v1.01, Sony Corporation. All data is
// little-endian. This is exported to allow reading with binary.Read.
type DsdChunk struct {
// DSD chunk header.... | audio/dsf/dsd.go | 0.574634 | 0.473231 | dsd.go | starcoder |
package raspivid
/*
Usage:
cam := Motion{}
castMotion := broker.New()
go castMotion.Start()
go cam.Start(castMotion)
reader := castMotion.Subscribe()
defer castMotion.Unsubscribe(reader)
for {
fmt.Println(<-reader)
}
*/
import (
"bufio"
"log"
"os"
"time"
"sentry-picam/broker"
)
const ignoreFirstFra... | pkg/raspivid/raspividmotion.go | 0.555556 | 0.407216 | raspividmotion.go | starcoder |
package main
import (
"container/heap"
)
// 480 sliding window median using hash heap
type intHeap struct {
arr []*Element
hash map[int]int
isSmall bool
}
type Element struct {
value int
index int
}
func (ih *intHeap) Len() int {
return len((*ih).arr)
}
func (ih *intHeap) Less(i, j int) bool {
if ih.is... | sliding-window/480-sliding-window-median.go | 0.560974 | 0.441733 | 480-sliding-window-median.go | starcoder |
package mmaths
import (
"fmt"
"math"
)
// Matrix alias for a 2d slice
type Matrix [][]float64
// Print matrix
func (mt Matrix) Print() {
n := len(mt)
m := len(mt[0])
for i := 0; i < n; i++ {
for j := 0; j < m; j++ {
fmt.Printf("%5f", mt[i][j])
fmt.Print(" ")
}
println()
}
}
// T transpose matrix... | matrix.go | 0.610105 | 0.462655 | matrix.go | starcoder |
package evaluate_cluster
import (
dist "github.com/verlandz/clustering-phone/utility/distance"
"math"
)
/*
Measure by level of cohesion and separation
ref :
- https://en.wikipedia.org/wiki/Davies%E2%80%93Bouldin_index
- https://www.hackerearth.com/problem/approximate/davies-bouldin-index/
- https://caridokume... | utility/evaluate_cluster/evaluate_cluster.go | 0.635562 | 0.441613 | evaluate_cluster.go | starcoder |
package nifi
import (
"encoding/json"
)
// Position The position of a component on the graph
type Position struct {
// The x coordinate.
X *float64 `json:"x,omitempty"`
// The y coordinate.
Y *float64 `json:"y,omitempty"`
}
// NewPosition instantiates a new Position object
// This constructor will assign defau... | model_position.go | 0.865224 | 0.468426 | model_position.go | starcoder |
package openmessaging
type Headers interface {
/**
* The {@code DESTINATION} header field contains the destination to which the message is being sent.
* <p>
* When a message is sent this value is set to the right {@code Queue}, then the message will be sent to the
* specified destination.
* <p>
* When a message... | openmessaging/headers.go | 0.839306 | 0.576661 | headers.go | starcoder |
package core
import (
"bytes"
"log"
"strconv"
)
// SizeEstimator estimates the Jaccard coefficients between the different
// datasets. The Jaccard coefficient between two datasets is defined as
// the cardinality of the intersection divided by the cardinality of the
// union of the two datasets.
type SizeEstimator... | core/similaritysize.go | 0.848471 | 0.635915 | similaritysize.go | starcoder |
package banana
import "time"
type GameID string
type DB interface {
// Creates a new game with the given name and creator.
NewGame(name string, creator PlayerID, config *Config) (GameID, error)
// Get all of the games.
Games() ([]*Game, error)
// Loads a game with the given ID.
Game(id GameID) (*Game, error)
... | banana/banana.go | 0.666497 | 0.548069 | banana.go | starcoder |
package ledger
import (
"fmt"
"github.com/72nd/acc/pkg/schema"
"github.com/72nd/acc/pkg/util"
)
// EntriesForTransaction returns the journal entries for a given schema.Transaction.
func EntriesForTransaction(s schema.Schema, trn schema.Transaction) []Entry {
if trn.AssociatedDocument.Empty() {
return entriesFo... | pkg/ledger/transactions.go | 0.664649 | 0.405684 | transactions.go | starcoder |
package geo
import "fmt"
type Cylinder struct {
EndDistanceNM int // Nautical Miles. Start distance is end of inner cylinder (or origin)
Floor int // In hundreds of feet
Ceil int // In hundreds of feet
}
// Each sector is a pie wedge, with consistent floor/ceil cylinders
type ClassBSector stru... | classb.go | 0.525856 | 0.585457 | classb.go | starcoder |
package valuepb
import (
"fmt"
"strconv"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/types/known/structpb"
)
func BoolValue(b bool) *structpb.Value {
return &structpb.Value{
Kind: &structpb.Value_BoolValue{
BoolValue: b,
},
}
}
func Bool(v *structpb.Value) bool {
return int64(Float6... | util/valuepb/value.go | 0.692226 | 0.405772 | value.go | starcoder |
package crawl
import (
"math/rand"
"strings"
"sync"
"time"
)
// Peer defines a node structure that exists in the NodePool. Every Peer should
// have an RPC address defined, but a network is not strictly required.
type Peer struct {
RPCAddr string
Network string
}
func (p Peer) String() string {
if p.RPCAddr !... | server/crawl/pool.go | 0.658198 | 0.483283 | pool.go | starcoder |
package algs
import (
"fmt"
"math"
)
/*
IntToRoman solves the following problem:
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M ... | algs/0012.integer_to_roman.go | 0.669961 | 0.575439 | 0012.integer_to_roman.go | starcoder |
package main
import "fmt"
import "os"
type point struct {
x, y int
}
func main() {
// Go ofrece varios "verbos" de impresión, diseñados
// para dar formato a valores de Go simples. Por
// ejemplo, esto imprime una instancia de nuestra
// estructura `point`.
p := point{1, 2}
fmt.Printf("... | examples/formateo-de-cadenas/formateo-de-cadenas.go | 0.530966 | 0.471527 | formateo-de-cadenas.go | starcoder |
package trie
import (
"fmt"
)
const (
endOfWord = rune(0x7fffffff)
)
// Trie implements a dead simple trie data structure.
type Trie struct {
data []rune
next []*Trie
}
// New returns a new instance of a `Trie` data structure.
func New() *Trie {
return &Trie{
data: []rune{},
next: []*Trie{},
}
}
func new... | trie.go | 0.635222 | 0.669394 | trie.go | starcoder |
package lkf
const (
BlockSize = 512 // The block size in bytes
blockSizeInWords = BlockSize / 4 // The block size in words. Each word is uint32
delta = 0x9e3779b9 // Magic constant
)
// The 128-bit key for encrypting/decrypting lkf files. It is divided into 4 parts of 32 bit each.
va... | lkf.go | 0.643441 | 0.419351 | lkf.go | starcoder |
package utils
import (
"fmt"
"math/big"
"strconv"
"strings"
)
//PrintAnswer - Prints a formatted answer for problemNum and answer
func PrintAnswer(problemNum int, answer int) {
fmt.Printf("The answer to Project Euler Problem #%d is :%d\n", problemNum, answer)
}
func PrintBigIntAnswer(problemNum int, answer *b... | utils/utils.go | 0.554712 | 0.507629 | utils.go | starcoder |
package xtime
import (
"database/sql/driver"
"encoding/json"
"fmt"
"strconv"
"time"
"ksitigarbha/timezone"
)
type Timestamp struct{ time.Time }
func (m Timestamp) timestamp() int64 {
return m.UnixMilli()
}
func (m Timestamp) UnixMilli() int64 {
return m.Time.UnixNano() / int64(time.Millisecond)
}
func (m Ti... | xtime/timestamp.go | 0.732496 | 0.449091 | timestamp.go | starcoder |
package pipeline
import (
"errors"
"fmt"
"reflect"
)
/*
As Go does not support overloading and/or defining new infix operators, we have to implement the pipe operator as a function.
We start by defining Pipe function and Pipeline type for its result.
This presents a rather simple method to implement a pipe ope... | pipeline/pipeline.go | 0.617974 | 0.538983 | pipeline.go | starcoder |
//-----------------------------------------------------------------------------
package sdf
import (
"fmt"
"github.com/fogleman/pt/pt"
)
//-----------------------------------------------------------------------------
func RenderPNG(s SDF3, render_floor bool) {
scene := pt.Scene{}
light := pt.LightMaterial(p... | sdf/render.go | 0.567457 | 0.435301 | render.go | starcoder |
package noodle
//GLEnum represents all available WebGL constants, prefixed with Gl and turned into UpperCamelCase. For example, DEPTH_BUFFER_BIT is now GlDepthBufferBit
type GLEnum = int
const (
//GlDepthBufferBit passed to <code>clear</code> to clear the current depth buffer.
GlDepthBufferBit GLEnum = 0x00000100
//Gl... | glconsts.go | 0.696475 | 0.490053 | glconsts.go | starcoder |
package simple
import (
"fmt"
"strings"
)
/* twoSum: https://leetcode.com/problems/two-sum/
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element ... | Algorithm-go/simple/map.go | 0.813498 | 0.518241 | map.go | starcoder |
package ast
// Literal represents a Literal node.
type Literal struct {
NullLiteral string
BooleanLiteral string
NumericLiteral *NumericLiteral
StringLiteral string
}
// NumericLiteral represents a NumericLiteral node.
type NumericLiteral struct {
DecimalLiteral string
BinaryIntegerLiteral string
Oct... | internal/parser/ast/literal.go | 0.669637 | 0.406567 | literal.go | starcoder |
package models
import (
"github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/api/custom"
)
// Represents a resource assignment in a project.
type ResourceAssignment struct {
// Returns or sets a task unique id to which a resource is assigned.
TaskUid int32 `json:"taskUid"`
// Returns or sets a resource unique id ... | api/models/resource_assignment.go | 0.808143 | 0.581303 | resource_assignment.go | starcoder |
package processing
import (
"math"
"github.com/go-gl/mathgl/mgl32"
"github.com/kyroy/kdtree"
"github.com/kyroy/kdtree/points"
"github.com/roboticeyes/gometry/geom"
)
// RemoveDuplicates removes vertex duplicates of a triangle mesh. If two vertices are closer than
// the given distanceThreshold, then the vertice... | processing/mesh.go | 0.681515 | 0.582135 | mesh.go | starcoder |
package blockcf
import (
"encoding/binary"
"github.com/endurio/ndrd/chaincfg/chainhash"
"github.com/endurio/ndrd/gcs"
"github.com/endurio/ndrd/txscript"
"github.com/endurio/ndrd/wire"
)
// P is the collision probability used for block committed filters (2^-20)
const P = 20
// Entries describes all of the filte... | gcs/blockcf/blockcf.go | 0.77373 | 0.460895 | blockcf.go | starcoder |
package types
import "time"
// SeriesChannel channel to report series on
type SeriesChannel chan Series
// Series represents a series of candles of a symbol
type Series struct {
// Symbol of the series
Symbol Symbol
// Timeframe of the series
Timeframe Timeframe
// Candles of the series (last candle in the ar... | types/series.go | 0.751101 | 0.519399 | series.go | starcoder |
package layer
// GetAutoOrient returns the AutoOrient field if it's non-nil, zero value otherwise.
func (i *ImageT) GetAutoOrient() int {
if i == nil || i.AutoOrient == nil {
return 0
}
return *i.AutoOrient
}
// GetBlendMode returns the BlendMode field if it's non-nil, zero value otherwise.
func (i *ImageT) Get... | lottie/layer/layer-accessors.go | 0.841125 | 0.535584 | layer-accessors.go | starcoder |
package synthetics
import (
"encoding/json"
)
// V202101beta1DNS struct for V202101beta1DNS
type V202101beta1DNS struct {
Name *string `json:"name,omitempty"`
}
// NewV202101beta1DNS instantiates a new V202101beta1DNS object
// This constructor will assign default values to properties that have it defined,
// and... | kentikapi/synthetics/model_v202101beta1_dns.go | 0.710528 | 0.406273 | model_v202101beta1_dns.go | starcoder |
package gspeed
import (
"fmt"
"github.com/cryptowilliam/goutil/basic/gerrors"
"github.com/cryptowilliam/goutil/container/gstring"
"strconv"
"strings"
"time"
"unicode"
)
// bit size of speed
// 为什么用float64而不用uint64?float64的表示范围比uint64大很多,unint64根本达不到YB级别
type Speed float64
// Map between speed unit of bit and ... | container/gspeed/speed.go | 0.528533 | 0.473657 | speed.go | starcoder |
// Package diff implements the difference algorithm, which is based upon
// <NAME>, <NAME>, <NAME>, and <NAME>,
// "An O(NP) Sequence Comparison Algorithm" August 1989.
package diff
type Interface interface {
// Equal returns whether the elements at i and j are equal.
Equal(i, j int) bool
}
// Bytes returns the di... | diff.go | 0.721743 | 0.520679 | diff.go | starcoder |
package core
import (
"context"
"fmt"
"github.com/kmgreen2/agglo/internal/common"
"github.com/kmgreen2/agglo/pkg/util"
"reflect"
"regexp"
)
type Transformable struct {
value interface{}
}
func NewTransformable(value interface{}) *Transformable {
return &Transformable{value}
}
func (t Transformable) Kind() r... | internal/core/transformation.go | 0.546738 | 0.450299 | transformation.go | starcoder |
package qrencode
import (
"bytes"
"image"
"image/color"
)
/*BitVector*/
type BitVector struct {
boolBitVector
}
func (v *BitVector) AppendBits(b BitVector) {
v.boolBitVector.AppendBits(b.boolBitVector)
}
func (v *BitVector) String() string {
b := bytes.Buffer{}
for i, l := 0, v.Length(); i < l; i++ {
if v.... | tools/qrencode/bits.go | 0.68742 | 0.55935 | bits.go | starcoder |
package sqlite
import (
"bytes"
"database/sql/driver"
"fmt"
"time"
)
const (
julianDay = 2440587.5 // 1970-01-01 00:00:00 is JD 2440587.5
dayInSeconds = 60 * 60 * 24
)
// JulianDayToUTC transforms a julian day number into an UTC Time.
func JulianDayToUTC(jd float64) time.Time {
jd -= julianDay
jd *= dayI... | vendor/github.com/gwenn/gosqlite/date.go | 0.783285 | 0.51818 | date.go | starcoder |
package np
import (
"errors"
"math"
"github.com/ryadzenine/dolphin/models"
)
type EstimatorState struct {
State []float64
version int
}
func (r EstimatorState) Values() []float64 {
return r.State
}
func (r EstimatorState) Version() int {
return r.version
}
type RevezEstimator struct {
Vectors []models.... | models/np/estimators.go | 0.616012 | 0.556882 | estimators.go | starcoder |
package immutablestack
// Iterator is a function taking a each substack of a given stack.
// It can return an error to break iteration.
type Iterator func(ImmutableStack) error
// Functor is a function capable of modifying stack elements.
type Functor func(interface{}) interface{}
// ImmutableStack is an abstract im... | immutablestack.go | 0.803174 | 0.490663 | immutablestack.go | starcoder |
package game
// PieceType abstraction for a single piece
type PieceType interface {
Name() string
BlackSymbol() rune
WhiteSymbol() rune
IsValidMove(currentLocation, newLocation Location, color Color) bool
CanCapture(currentLocation, opponentLocation Location, color Color) bool
}
// Piece an actual piece
type Pie... | pkg/game/piece.go | 0.869507 | 0.457561 | piece.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.