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 provider import "github.com/elastic/beats/libbeat/feature" // getNamespace return the namespace for functions of a specific provider. The registry have a flat view // representation of the plugin world this mean we don't really have a tree, instead what we do is // to create a unique keys per providers that ...
x-pack/functionbeat/provider/feature.go
0.716615
0.406008
feature.go
starcoder
package imagevector // ReadImageVector reads the image vector yaml file in the charts directory, unmarshals the content import ( "fmt" "io/ioutil" "path/filepath" "strings" "github.com/gardener/gardener/pkg/operation/common" "github.com/gardener/gardener/pkg/utils" yaml "gopkg.in/yaml.v2" ) // ReadImageVecto...
vendor/github.com/gardener/gardener/pkg/utils/imagevector/imagevector.go
0.816772
0.404272
imagevector.go
starcoder
package clients import ( "github.com/BurntSushi/xgb" "github.com/BurntSushi/xgb/xproto" ) type Floatr interface { FRectangle() xproto.Rectangle X(int16) Y(int16) Reposition(int16, int16) Width(uint16) Height(uint16) Size(uint16, uint16) Center(xproto.Rectangle, int16) Embrace(xproto.Rectangle) Translate(x...
euclid/clients/float.go
0.641085
0.525064
float.go
starcoder
package golang import ( "fmt" "regexp" ) var idRE = regexp.MustCompile("^[\\pL_][\\pL_\\pN]*$") // ArrayN creates a `[n]elt` ArrayType. func ArrayN(n int, elt Expr) *ArrayType { return &ArrayType{Len: Int(n), Elt: elt} } // ArrayEllipsis creates a `[...]elt` ArrayType. func ArrayEllipsis(elt Expr) *ArrayType { ...
sysl2/codegen/golang/ast_helpers.go
0.732496
0.469277
ast_helpers.go
starcoder
package rendering import ( "github.com/boombuler/voxel/mgl" "github.com/go-gl-legacy/gl" ) type plane struct { mgl.Vec3 D float32 } func GLProjection() mgl.Mat4 { var projM [16]float32 gl.GetFloatv(gl.PROJECTION_MATRIX, projM[:]) return mgl.Mat4(projM) } func GLModelView() mgl.Mat4 { var modM [16]float32 g...
rendering/frustumculling.go
0.683631
0.436862
frustumculling.go
starcoder
package turing type Symbol byte type Motion byte const ( Left Motion = 'L' Right Motion = 'R' Stay Motion = 'N' ) type Tape struct { data []Symbol pos, left int blank Symbol } // NewTape returns a new tape filled with 'data' and position set to 'start'. //...
lang/Go/universal-turing-machine-1.go
0.728265
0.473292
universal-turing-machine-1.go
starcoder
package selection import ( "fmt" "reflect" "github.com/onsi/gomega/format" "github.com/sclevine/agouti/matchers/internal/colorparser" ) type HaveCSSMatcher struct { ExpectedProperty string ExpectedValue string actualValue string isColorComparison bool expectedColor colorparser.Color actualColo...
src/acceptance-tests/vendor/src/github.com/sclevine/agouti/matchers/internal/selection/have_css.go
0.757884
0.411554
have_css.go
starcoder
package monitoring import ( "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" ) const ( // tag names used by runtime packages configID = "configID" initConfigID = "initConfigID" // the id of the config, at which the adapter was instantiated. handler = "handler" meshFuncti...
mixer/pkg/runtime/monitoring/monitoring.go
0.517083
0.46308
monitoring.go
starcoder
package logf import ( "runtime" "time" "unsafe" ) // TimeEncoder is the function type to encode the given Time. type TimeEncoder func(time.Time, TypeEncoder) // DurationEncoder is the function type to encode the given Duration. type DurationEncoder func(time.Duration, TypeEncoder) // RFC3339TimeEncoder encodes t...
time.go
0.77081
0.414366
time.go
starcoder
package types import ( "encoding/json" "fmt" "github.com/leekchan/accounting" "math" "strconv" "time" ) type Duration time.Duration func (d Duration) Duration() time.Duration { return time.Duration(d) } func (d *Duration) UnmarshalJSON(data []byte) error { var o interface{} if err := json.Unmarshal(data, ...
pkg/types/market.go
0.754282
0.403449
market.go
starcoder
package ent import ( "fmt" "strings" "time" "entgo.io/ent/dialect/sql" "github.com/crowdsecurity/crowdsec/pkg/database/ent/machine" ) // Machine is the model entity for the Machine schema. type Machine struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // CreatedAt holds the value of...
pkg/database/ent/machine.go
0.604165
0.420421
machine.go
starcoder
package utils import ( "reflect" "strconv" "time" ) func IsInts(k reflect.Kind) bool { switch k { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return true } return false } func IsUints(k reflect.Kind) bool { switch k { case reflect.Uint, reflect.Uint8, reflect.Uint16, refle...
utils/utils.go
0.566498
0.582729
utils.go
starcoder
package benchparse // OrderedStringStringMap is a map of strings to strings that maintains ordering. Ordering allows symmetric encode/decode // operations of a benchmark run. Plus, ordering is not strictly mentioned as unimportant in the spec. // This statement implies uniqueness of keys per benchmark. // "The inter...
orderedstringstringmap.go
0.792825
0.41484
orderedstringstringmap.go
starcoder
package binaryop import ( "math" ) var nan = math.NaN() // Eq returns true of left == right. func Eq(left, right float64) bool { // Special handling for nan == nan. // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/150 . if math.IsNaN(left) { return math.IsNaN(right) } return left == right } ...
vendor/github.com/VictoriaMetrics/metricsql/binaryop/funcs.go
0.886273
0.592107
funcs.go
starcoder
package processor import ( "errors" "fmt" "sort" "strconv" "strings" "time" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/metrics" "github.com/Jeffail/benthos/v3/lib/types" "github.com/Jeffail/benthos/v3/lib/util/text" ) //------------------------------------------------------...
lib/processor/metric.go
0.856362
0.704122
metric.go
starcoder
package sampler import ( "math" "time" "github.com/DataDog/datadog-trace-agent/model" "github.com/DataDog/datadog-trace-agent/watchdog" ) const ( // Sampler parameters not (yet?) configurable defaultDecayPeriod time.Duration = 5 * time.Second // With this factor, any past trace counts for less than 50% after ...
sampler/coresampler.go
0.734881
0.453141
coresampler.go
starcoder
package doudizhu import ( "game/internal/poker" "reflect" ) type cardPatternSequenceOfTripletsWithPairs struct { cardPatternBase } func (r cardPatternSequenceOfTripletsWithPairs) Name() string { return reflect.TypeOf(r).Name() } func (r cardPatternSequenceOfTripletsWithPairs) Valid() bool { if r.Cards().Exists...
internal/poker/doudizhu/cardPatternSequenceOfTripletsWithPairs.go
0.528047
0.412826
cardPatternSequenceOfTripletsWithPairs.go
starcoder
package services import ( "errors" "github.com/miguelbemartin/vat/models" ) // RatesService handle the rates of vat for the given country code. type RatesService struct{} // NewRatesService creates a new handler for this service. func NewRatesService() *RatesService { return &RatesService{} } // Get will return...
services/rates.go
0.620622
0.451629
rates.go
starcoder
package integration import ( "errors" "testing" "github.com/CyCoreSystems/ari/v5" ) func TestDeviceData(t *testing.T, s Server) { key := ari.NewKey(ari.DeviceStateKey, "d1") runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) { var expected ari.DeviceStateData expected.State = "deviceData1" exp...
internal/integration/device.go
0.542621
0.529081
device.go
starcoder
package semver import ( "errors" "fmt" "github.com/spf13/cast" "math" "regexp" "strings" ) type Constraint struct { operator string version *Version constraints []*Constraint conjunctive bool isEmpty bool } var ( versionReg = `v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?` + stabilit...
constraint.go
0.545528
0.44059
constraint.go
starcoder
package streamer import ( "time" "github.com/tada/catch" "github.com/tada/dgo/dgo" "github.com/tada/dgo/vf" ) const ( // NoDedup effectively prevents any attempt to do data deduplication NoDedup = DedupLevel(iota) // NoKeyDedup prevents that keys in maps are deduplicated. This will only affect consumers that...
streamer/streamer.go
0.650134
0.403038
streamer.go
starcoder
package main import ( "encoding/json" "fmt" "io/ioutil" "os" "strings" // CaltechLibrary Packages "github.com/caltechlibrary/cli" "github.com/caltechlibrary/datatools" "github.com/caltechlibrary/dotpath" ) var ( description = ` %s returns returns a range of values based on the JSON structure being read and...
cmd/jsonrange/jsonrange.go
0.617282
0.423041
jsonrange.go
starcoder
package rpc import ( "time" "cloud.google.com/go/civil" "github.com/gogo/protobuf/types" tspb "github.com/zhihu/zetta-proto/pkg/tablestore" // sppb "google.golang.org/genproto/googleapis/spanner/v1" ) // Helpers to generate protobuf values and Cloud Spanner types. func StringProto(s string) *tspb.Value { retu...
tablestore/rpc/protoutils.go
0.687
0.60577
protoutils.go
starcoder
package main import ( "strings" . "github.com/mmcloughlin/avo/build" . "github.com/mmcloughlin/avo/operand" . "github.com/mmcloughlin/avo/reg" ) func main() { generate("and") generate("andnot") generate("or") generate("xor") Generate() } // generate generates an SIMD "and", "or" , "andnot"operations. func...
simd/asm.go
0.571049
0.462716
asm.go
starcoder
package durafmt import ( "fmt" "strings" ) // DefaultUnitsCoder default units coder using `":"` as PluralSep and `","` as UnitsSep var DefaultUnitsCoder = UnitsCoder{":", ","} // Unit the pair of singular and plural units type Unit struct { Singular, Plural string } // Units duration units type Units struct { Y...
vendor/github.com/hako/durafmt/unit.go
0.692954
0.477067
unit.go
starcoder
package main import "math/rand" const boundsPenality = 1000 const overlapPenalty = 1000 const sameNeighbourPenality = 10 const gapPenality = 10 const notConnectedPenalty = 5000 const neighbourCountBonus = 20 const rotateProb = 0.25 const translateProb = 0.15 const translateStdDev = 2 const swapPosProb = 0.1 /* Bo...
board.go
0.648355
0.538073
board.go
starcoder
package util import ( "crypto/rand" "encoding/binary" "github.com/Workiva/go-datastructures/bitarray" "github.com/stretchr/testify/assert" "math" "math/big" "math/bits" "strings" "testing" ) // POST math utils funcs // Get big-endian bytes encoding of i // Result is 1 to 8 bytes long. 0x0 bytes is returned ...
util/math.go
0.567697
0.442697
math.go
starcoder
package cast import "strconv" // <!> for now, no overflow detection // AsInt to convert as a int func AsInt(v interface{}) (int, bool) { switch d := indirect(v).(type) { case bool: if d { return 1, true } return 0, true case int: return d, true case int64: return int(d), true case int32: return i...
int.go
0.516839
0.403449
int.go
starcoder
package main import ( "fmt" "math" "sort" "strings" "github.com/deckarep/golang-set" "github.com/microhod/adventofcode/internal/file" "github.com/microhod/adventofcode/internal/puzzle" ) const ( EntriesFile = "entries.txt" TestFile = "test.txt" Digit0 = "abcefg" Digit1 = "cf" Digit2 = "acdeg" Digit...
2021/08/main.go
0.571049
0.426859
main.go
starcoder
package wgs84 import ( "math" ) type webMercator struct{} func (p webMercator) ToLonLat(east, north float64, s Spheroid) (lon, lat float64) { sph := spheroid{a: s.A(), fi: s.Fi()} lon = degree(east / sph.A()) lat = math.Atan(math.Exp(north/sph.A()))*degree(1)*2 - 90 return lon, lat } func (p webMercator) FromL...
system.go
0.710427
0.429429
system.go
starcoder
package navmeshv2 import "github.com/g3n/engine/math32" type Rectangle struct { Min *math32.Vector2 Max *math32.Vector2 } func NewRectangle(x, y, width, height float32) Rectangle { min := math32.NewVector2(x, y) max := math32.NewVector2(x+width, y+height) return Rectangle{ Min: min, Max: max, } } func (r...
navmeshv2/rectangle.go
0.811415
0.708023
rectangle.go
starcoder
package nanovgo import ( "github.com/micaelAlastor/nanovgo/fontstashmini" ) type nvgParams interface { edgeAntiAlias() bool renderCreate() error renderCreateFramebuffer(w, h int, flags ImageFlags) *FrameBuffer renderCreateTexture(texType nvgTextureType, w, h int, flags ImageFlags, data []byte) int renderDeleteT...
structs.go
0.555918
0.411406
structs.go
starcoder
package plotter import ( "errors" "image/color" "math" "code.google.com/p/plotinum/plot" "code.google.com/p/plotinum/vg" ) type BarChart struct { Values // Width is the width of the bars. Width vg.Length // Color is the fill color of the bars. Color color.Color // LineStyle is the...
src/code.google.com/p/plotinum/plotter/barchart.go
0.719088
0.475301
barchart.go
starcoder
package expr import ( "fmt" "reflect" ) // InvalidOpError is returned when an attempt is made to perform an operation // on a type that is not supported. type InvalidOpError struct { Op string V Value } func (e InvalidOpError) Error() string { return fmt.Sprintf("invalid operation: operator %s not defined for ...
sgx-tools/vendor/github.com/go-restruct/restruct/expr/value.go
0.744285
0.422654
value.go
starcoder
package qrencode import ( "bytes" "image" "image/color" "io" ) // The test benchmark shows that encoding with boolBitVector/boolBitGrid is // twice as fast as byteBitVector/byteBitGrid and uin32BitVector/uint32BitGrid. type BitVector struct { boolBitVector } type BitGrid struct { boolBitGrid } func (v *BitVe...
vendor/github.com/qpliu/qrencode-go/qrencode/bits.go
0.671147
0.620593
bits.go
starcoder
package zounds import ( "sort" "time" "github.com/cabify/timex" ) // StaticNode is an interface for static node. // StaticNode can be only drawn. // StaticNode cannot be updated by the World. type StaticNode interface { Bounds() Rectangle Draw() } // DynamicNode is an interface for dynamic node. // It behaves ...
world.go
0.688049
0.51562
world.go
starcoder
package nn import ( "bytes" mat "github.com/nlpodyssey/spago/pkg/mat32" "github.com/nlpodyssey/spago/pkg/ml/ag" "github.com/nlpodyssey/spago/pkg/utils/kvdb" "log" "sync" ) // Param is the interface for a Model parameter. type Param interface { ag.Node // it implies fn.Operand and ag.GradValue too // Name re...
pkg/ml/nn/param.go
0.715623
0.414129
param.go
starcoder
package kata /** link: https://www.codewars.com/kata/58c5577d61aefcf3ff000081 */ /** SITUATION: Create two functions to encode and then decode a string using the Rail Fence Cipher. This cipher is used to encode a string by placing each character successively in a diagonal along a set of "rails". First start off movin...
golang/3kyu/rail_fence_cipher_encoding.go
0.860999
0.720368
rail_fence_cipher_encoding.go
starcoder
package Movie import ( flatbuffers "github.com/google/flatbuffers/go" ) // MovieT native go object type MovieT struct { Single *CharacterT Multiple []*CharacterT } // MovieT object pack function func (t *MovieT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT { if t == nil { return 0 } singleOffse...
union-vector/Movie/Movie.go
0.739234
0.429788
Movie.go
starcoder
package sumcheck import ( "fmt" "gkr-mimc/snark/hash" "gkr-mimc/snark/polynomial" "gkr-mimc/sumcheck" "github.com/consensys/gnark/frontend" ) // Proof contains the circuit data of a sumcheck run EXCEPT WHAT IS REQUIRED FOR THE FINAL CHECK. type Proof struct { // bN int // bG int // Initia...
snark/sumcheck/sumcheck.go
0.651466
0.407952
sumcheck.go
starcoder
package la import ( "fmt" "strings" "github.com/xoba/goutil/gmath/blas" ) // vector type Vector struct { Size int Stride int Elements []float64 } func NewVector(m int) *Vector { return &Vector{Size: m, Stride: 1, Elements: make([]float64, m)} } func (m *Vector) Set(i int, v float64) { m.Elements[i*m....
gmath/la/mat.go
0.695958
0.536616
mat.go
starcoder
package quad import ( "math" ) // Implements Integral type simpsonIntegral trapezoidalIntegral // Create a new Integral, based on Simpson's rule. // This will evaluate the integral concurrently. // The argument specifies how many workers will be used // to evaluate the function. Passing workers < 1 is // the same a...
pkg/quad/simp.go
0.790288
0.537284
simp.go
starcoder
package asm import ( "assert" "backends/lapc/ir" "dt" ) type yUnit *ir.Instr type converterY struct { st *dt.DataStack labels map[int32]labelInfo gotos []branchInfo lambdaRets []branchInfo scopes *dt.ScopeStack lambdaDepths *dt.ScopeStack } type branchInfo struct { ins *ir.Instr d...
src/backends/lapc/asm/y_make.go
0.541894
0.425009
y_make.go
starcoder
package fp func (l BoolList) Cons(e bool) BoolList { return BoolList { &e, &l } } func (l StringList) Cons(e string) StringList { return StringList { &e, &l } } func (l IntList) Cons(e int) IntList { return IntList { &e, &l } } func (l Int64List) Cons(e int64) Int64List { return Int64List { &e, &l } } func (l ByteLi...
fp/bootstrap_list_prepend.go
0.688783
0.656645
bootstrap_list_prepend.go
starcoder
package support import ( "fmt" "sort" "github.com/sineatos/deag/base" ) // HallOfFame contains the best individual that ever lived in the population during the evolution. // It is lexicographically sorted at all time so that the first element of the hall of fame is the individual that has the best first fitness v...
tools/support/halloffame.go
0.622345
0.545346
halloffame.go
starcoder
// Package camera contains common camera types used for rendering 3D scenes. package camera import ( "github.com/thommil/tge-g3n/core" "github.com/thommil/tge-g3n/math32" ) // ICamera is interface for all camera types. type ICamera interface { GetCamera() *Camera SetAspect(float32) ViewMatrix(*math32.Matrix4) ...
camera/camera.go
0.723114
0.585753
camera.go
starcoder
package main import ( "cartog/tile" "context" "errors" "log" "sync" ) const ( MAX_ZOOM = 16 MIN_ZOOM = 2 ) type Coord struct { X float32 Y float32 Z float32 } type TileGrid struct { location Coord tileWidth float32 tileHeight float32 halfTileWidth float32 halfTileHeight float32 cache...
grid.go
0.536556
0.496704
grid.go
starcoder
package s2 import "github.com/golang/geo/s1" // roundAngle returns the value rounded to nearest as an int32. // This does not match C++ exactly for the case of x.5. func roundAngle(val s1.Angle) int32 { if val < 0 { return int32(val - 0.5) } return int32(val + 0.5) } // minAngle returns the smallest of the giv...
vendor/github.com/golang/geo/s2/util.go
0.841565
0.482612
util.go
starcoder
package sim import ( "fmt" "regexp" "strconv" "strings" ) //ParseOptions contains details about how to parse data from the incoming file //Identifier provides the index of the column to use as an Agnent Identifier //Parent provides the index of the column to use as the Identifier of a Parent Agent //Regex provide...
sim/networkparser.go
0.617743
0.661554
networkparser.go
starcoder
package slices import ( "errors" "reflect" "github.com/golodash/godash/internal" ) // This method is like IndexOf except that it performs a binary search on a sorted slice. func SortedIndexOf(slice interface{}, value interface{}) (int, error) { if err := internal.SliceCheck(slice); err != nil { return -1, err ...
slices/sorted_index_of.go
0.824497
0.492737
sorted_index_of.go
starcoder
package graph import ( "sort" "strconv" ) // Iterator is a non-weighted graph; an Iterator can be used // to describe both ordinary graphs and multigraphs type Iterator interface { Order() int Visit(v int, do func(w int, c int64) (skip bool)) (aborted bool) VisitBoth(v int, doIn func(w int, c int64) (skip bool),...
utils/graph/graph.go
0.695131
0.48249
graph.go
starcoder
package models import ( "math" "github.com/go-gl/mathgl/mgl32" "gonum.org/v1/gonum/mat" "gonum.org/v1/gonum/stat/distmv" "gonum.org/v1/gonum/stat/samplemv" ) type ProjectionType int const ( Perspective ProjectionType = iota Ortographic ) type Camera struct { Transform mgl32.Mat4 ProjectionPl...
src/backend/models/camera.go
0.807195
0.564819
camera.go
starcoder
package gohome // A 3D model consisting of multiple meshes type Model3D struct { // The name of the model Name string meshes []Mesh3D // The bounding box going around the model AABB AxisAlignedBoundingBox } // Adds a mesh to the model func (this *Model3D) AddMesh3D(m Mesh3D) { this.meshes = app...
src/gohome/model3d.go
0.645343
0.483953
model3d.go
starcoder
package continuous import ( "github.com/jtejido/ggsl/specfunc" "github.com/jtejido/linear" "github.com/jtejido/stats" "github.com/jtejido/stats/err" smath "github.com/jtejido/stats/math" "math" "math/rand" ) // Gamma distribution // https://en.wikipedia.org/wiki/Gamma_distribution type InverseGamma struct { s...
dist/continuous/inverse_gamma.go
0.797872
0.445288
inverse_gamma.go
starcoder
package pathutil import ( "github.com/pkg/errors" "github.com/stackrox/rox/pkg/utils" ) type tree struct { children map[Step]*tree values map[string][]string } func newTree() *tree { return &tree{ children: make(map[Step]*tree), } } func (t *tree) addPath(steps []Step, fieldName string, values []string) {...
pkg/booleanpolicy/evaluator/pathutil/filter_linked.go
0.589953
0.545649
filter_linked.go
starcoder
package structures import ( "fmt" "math" "reflect" "gonum.org/v1/gonum/mat" ) const ( solveAccuracy = 1E-6 ) // Structure type contains the necessary parameters for solving a structural problem type Structure struct { M, N int Coord, Con, Re, Load, W, E, G, A, I...
solve.go
0.54952
0.477737
solve.go
starcoder
package main import ( "fmt" "strconv" "strings" ) // Our first test, we are only checking // American Express, Mastercard, and Visa. // We check that the passed card has a length of // 13 characters, 15 characters, or 16 characters. func checkCardLengthValidity(card string) bool { // If our length is 13, 15, or 1...
cs50/pset1/credit/credit.go
0.553505
0.447581
credit.go
starcoder
package timer import ( "github.com/shasderias/ilysa/internal/calc" ) type Sequence interface { // SeqT is the current time for current sequence on a 0-1 scale. As a special // case, SeqT returns 1 when the sequence only has one beat. SeqT() float64 SeqOrdinal() int SeqLen() int SeqNextB() float64 SeqNextBOffs...
timer/sequence.go
0.820362
0.457016
sequence.go
starcoder
package redisearch import ( "fmt" "github.com/gomodule/redigo/redis" "sort" ) // SpellCheckOptions are options which are passed when performing spelling correction on a query type SpellCheckOptions struct { Distance int ExclusionDicts []string InclusionDicts []string } func NewSpellCheckOptionsDefaults()...
redisearch/spellcheck.go
0.696165
0.454048
spellcheck.go
starcoder
package skiplist import ( "time" ) // Duplist is a modified skiplist implementation allowing duplicate time // keys to exist inside the same list. Elements with duplicate keys are // adjacent inside Duplist, with a later insert placed left of earlier ones. // Elements with different keys are sorted in ascending orde...
skiplist/duplist.go
0.596081
0.455138
duplist.go
starcoder
package snigo import ( "math" ) const ( DefaultGamma = 1 DefaultTheta = 1 DefaultDetectionRequirement = 3 ) // Detect source window using positive and negative reference signals for a trend. // You should loop this function in your worker until detection requirement is met. // So if...
snigo.go
0.88113
0.524334
snigo.go
starcoder
package ml import ( "fmt" "math" "sync" ) type Quadratic struct { X, Y []float64 A, B, C float64 } type resource struct { prop string value float64 } /* source: https://www.easycalculation.com/statistics/learn-quadratic-regression.php Quadratic Regression Equation(y) = a x^2 + b x + c a = { [ . x2 y * . ...
quadratic.go
0.531696
0.525369
quadratic.go
starcoder
package local import ( "encoding/binary" "github.com/pingcap/errors" "github.com/pingcap/tidb/util/codec" ) // KeyAdapter is used to encode and decode keys. type KeyAdapter interface { // Encode encodes key with rowID and offset. It guarantees the encoded key is in ascending order for comparison. // `buf` is u...
br/pkg/lightning/backend/local/key_adapter.go
0.739328
0.411939
key_adapter.go
starcoder
package collection // Indexable provides the methods necessary for using an object in the indexing structures. type Indexable interface { GetID() string GetField(string) interface{} } // Index for a field on an Indexable type Index interface { // Add the passed indexable to the index Add(obj Indexable) // Update...
collection/indexer.go
0.639398
0.492859
indexer.go
starcoder
package main import "strconv" /* Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numeri...
main/myAtoi.go
0.784855
0.697107
myAtoi.go
starcoder
package types // Reference: https://www.ietf.org/rfc/rfc4120.txt // Section: 5.2.8 import ( "github.com/jcmturner/asn1" ) /* KerberosFlags For several message types, a specific constrained bit string type, KerberosFlags, is used. KerberosFlags ::= BIT STRING (SIZE (32..MAX)) -- minimum number of bits shall be s...
types/KerberosFlags.go
0.790409
0.573649
KerberosFlags.go
starcoder
package shape import ( "github.com/oakmound/oak/alg/intgeom" ) // GetHoles finds sets of points which are not In this shape that // are adjacent. func GetHoles(sh Shape, w, h int) [][]intgeom.Point2 { return getHoles(sh, w, h, false) } // GetBorderHoles finds sets of points which are not In this shape that // are ...
shape/holes.go
0.688154
0.493042
holes.go
starcoder
package isk import ( "math" "strconv" "strings" ) //RoundPrec Round a number to given precision credit to https://github.com/DeyV/gotools/blob/master/numbers.go func RoundPrec(x float64, prec int) float64 { if math.IsNaN(x) || math.IsInf(x, 0) { return x } sign := 1.0 if x < 0 { sign = -1 x *= -1 } v...
isk/isk.go
0.841565
0.461077
isk.go
starcoder
package DG2D import ( "fmt" "github.com/notargets/gocfd/utils" ) type LagrangeElement2D struct { N, Nfp, Np, NFaces int R, S utils.Vector Dr, Ds utils.Matrix V, Vinv, MassMatrix utils.Matrix Cub *Cubature } type Cubature struct { r, s, w utils.Vec...
DG2D/LagrangeElement.go
0.641871
0.546375
LagrangeElement.go
starcoder
package shape import ( "math" . "github.com/tatsy/gopt/src/core" ) // Triangle is a triangle which holds three positions, // normals and texture cooridnates. type Triangle struct { Points [3]*Vector3d Normals [3]*Vector3d TexCoords [3]*Vector2d } // NewTriangleWithP create a triangle with three positions....
src/shape/triangle.go
0.713032
0.846958
triangle.go
starcoder
package graph import ( "math/rand" "github.com/Tom-Johnston/mamba/comb" "github.com/Tom-Johnston/mamba/sortints" ) //Random Graphs //RandomGraph returns an Erdős–Rényi graph with n vertices and edge probability p. The pseudorandomness is determined by the seed. func RandomGraph(n int, p float64, seed int64) *Den...
graph/generating.go
0.716913
0.518302
generating.go
starcoder
package fsm import ( log "github.com/golang/glog" ) // Index is the index of the state in a FSM type Index int // Action is the action to take when a signal is received, prior to transition // to the next state. The error returned by the function is an exception which // will put the state machine in an error stat...
pkg/fsm/fsm.go
0.706899
0.53777
fsm.go
starcoder
package lab import ( "image" "image/color" "image/draw" "math" ) // Observer = 2°, Illuminant = D65 const RefX float64 = 95.047 const RefY float64 = 100.000 const RefZ float64 = 108.883 func rgb2xyz(r, g, b uint8) (X, Y, Z float64) { var ( R = float64(r) / 255.0 G = float64(g) / 255.0 B = float...
lab/lab.go
0.723016
0.548129
lab.go
starcoder
package discrete import ( "math" ) func PX(pxyz [][][]float64) []float64 { r := make([]float64, 2, 2) r[0] = pxyz[0][0][0] + pxyz[0][0][1] + pxyz[0][1][0] + pxyz[0][1][1] r[1] = pxyz[1][0][0] + pxyz[1][0][1] + pxyz[1][1][0] + pxyz[1][1][1] return r } func PY(pxyz [][][]float64) []float64 { r := make([]float64,...
discrete/InformationDecomposition.go
0.629888
0.418281
InformationDecomposition.go
starcoder
Flanges */ //----------------------------------------------------------------------------- package sdf import "math" //----------------------------------------------------------------------------- type Flange1 struct { distance float64 // distance from center to side center_radius float64 // radius of cent...
sdf/flange.go
0.864896
0.578329
flange.go
starcoder
package box2d import ( "math" ) // Compute contact points for edge versus circle. // This accounts for edge connectivity. func B2CollideEdgeAndCircle(manifold *B2Manifold, edgeA *B2EdgeShape, xfA B2Transform, circleB *B2CircleShape, xfB B2Transform) { manifold.PointCount = 0 // Compute circle in frame of edge Q ...
CollisionB2CollideEdge.go
0.807423
0.810704
CollisionB2CollideEdge.go
starcoder
package azblob // ListContainersOptions provides set of configurations for ListContainers operation type ListContainersOptions struct { Include ListContainersDetail // A string value that identifies the portion of the list of containers to be returned with the next listing operation. The // operation returns the ...
sdk/storage/azblob/zm_service_request_options.go
0.851398
0.562237
zm_service_request_options.go
starcoder
package main import ( "fmt" "io/ioutil" "os" "strconv" "strings" "time" ) func applyOrder(orderType string, orderMagnitude int, startPosX int, startPosY int, direction int) (int, int, int) { // change F order into right move order to have single way of handling moves computedOrderType := orderTy...
day-12/part-1/troisdiz.go
0.552781
0.462959
troisdiz.go
starcoder
package state import "errors" // The starting position for a standard game of chess // Splitting on spaces; // The first substring is the piece placement // the second substring is the side to move // the third substring is the castling ability // the fourth substring is the en passant target square // the fifth subs...
internal/state/state.go
0.510252
0.450903
state.go
starcoder
package bin import "encoding/binary" // I8be wraps a byte array into a big endian encoded 8bit signed integer. type I8be [1]byte // Len returns the number of bytes required to store the value. func (b *I8be) Len() int { return 1 } // Get returns the decoded value. func (b *I8be) Get() int8 { return int8(b[0]) } /...
vendor/github.com/urso/go-bin/bin.generated.go
0.914823
0.523359
bin.generated.go
starcoder
package sjtsk2gps import "math" // Convert accept czech S-JTSK coordinates and convert them to GPS // it is rewritten javascript code from http://martin.hinner.info/geo/ func Convert(X float64, Y float64, H float64) (float64, float64, float64) { if X < 0 && Y < 0 { X = -X Y = -Y } if Y > X { X, Y = Y, X }...
sjtsk2gps.go
0.612889
0.427875
sjtsk2gps.go
starcoder
package goban func (b *Box) Enclose(title string) *Box { newb := b.DrawSides(title, 1, 1, 1, 1) newb.Clear() return newb } func (b *Box) DrawSides(title string, left, top, right, bottom int) *Box { newb := b.InsideSides(left, top, right, bottom) if left != 0 { x := newb.Pos.X - 1 for y := 0; y < newb.Size.Y...
box_sides.go
0.567457
0.426023
box_sides.go
starcoder
package ql import ( "fmt" "io" ) // SelectStatement represents a QL SELECT statement. type SelectStatement struct { Fields []string Store string Comps [][]string } // Parser represents a parser. type Parser struct { s *Scanner buf struct { tok Token // last read token lit string // last read literal ...
plugins/data/parser/ql/ql/v1/parser.go
0.650245
0.458773
parser.go
starcoder
package tetra3d const ( FogOff = iota // No fog FogAdd // Additive blended fog FogMultiply // Multiplicative blended fog FogOverwrite // Color overwriting fog (mixing base with fog color over depth distance) ) type FogMode int // Library represents a collection of Scenes, Meshes...
scene.go
0.818882
0.471832
scene.go
starcoder
package main import ( "bufio" "fmt" "io" "math" "os" "strconv" "strings" ) /* * Complete the 'reachTheEnd' function below. * * The function is expected to return a STRING. * The function accepts following parameters: * 1. STRING_ARRAY grid * 2. INTEGER maxTime */ func reachTheEnd(grid []string, maxTi...
challenges/reach-the-end/main.go
0.725746
0.414721
main.go
starcoder
package graphblas import ( "sync" "github.com/rossmerr/graphblas/constraints" ) // MutexMatrix a matrix wrapper that has a mutex lock support type MutexMatrix[T constraints.Number] struct { sync.RWMutex matrix Matrix[T] } // NewMutexMatrix returns a MutexMatrix func NewMutexMatrix[T constraints.Number](matrix ...
mutexMatrix.go
0.859103
0.580887
mutexMatrix.go
starcoder
package anomalydetector import ( "log" "math" "math/rand" "time" ) type AnomalyDetector struct { Term int R float64 last float64 lastScore float64 lastProbe float64 Mu float64 Sigma float64 C []float64 Data []float64 DataSize int Identity []float64 Matrix ...
anomalydetector.go
0.543348
0.472623
anomalydetector.go
starcoder
package seq import ( "fmt" ) // Alignment represents the result of aligning two sequences. type Alignment struct { A []Residue // Reference B []Residue // Query } func newAlignment(length int) Alignment { return Alignment{ A: make([]Residue, 0, length), B: make([]Residue, 0, length), } } // Performs the Ne...
sequence_align.go
0.746139
0.454835
sequence_align.go
starcoder
package bls12381 import ( "io" "github.com/coinbase/kryptology/internal" "github.com/coinbase/kryptology/pkg/core/curves/native" ) // GtFieldBytes is the number of bytes needed to represent this field const GtFieldBytes = 576 // Gt is the target group type Gt fp12 // Random generates a random field element func...
pkg/core/curves/native/bls12381/gt.go
0.806472
0.508727
gt.go
starcoder
package signals import ( "strings" ) func isUniqueDigit(digit string) bool { length := len(digit) if length == 7 || length == 4 || length == 3 || length == 2 { return true } return false } func getUniqueDigit(digit string) int { length := len(digit) if length == 7 { return 8 } if length == 4 { ret...
day8/signals/mapping.go
0.63624
0.501953
mapping.go
starcoder
package main import "github.com/xidongc/go-leetcode/utils" /* 64 Minimum Path Sum Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time. co-ordinate ...
dp/64-min-path-sum.go
0.655005
0.52543
64-min-path-sum.go
starcoder
package dbase // Row represents data stored in any row. Data can be from any type so it is // stored in a generic way as an array of interface{}. type Row struct { Data []interface{} } // NewRow creates a new Row instance. Data from every column is provided in a // variadic way. func NewRow(cols ...interface{}) *Row...
dbase/row.go
0.850469
0.44734
row.go
starcoder
package stubs // Fragment stores a section of cells in the board // StartRow points to the row in the main board where this section starts // EndRow points to the next row in the main board after this section ends (like an exclusive upper bound) type Fragment struct { StartRow int EndRow int BitBoard *BitBoard } ...
stubs/stubs.go
0.596668
0.468851
stubs.go
starcoder
package vec import ( "math" ) const defaultBranchingFactor = 32 // Vec builds an immutable vector using a COW tree. func Vec(values ...int) *Vector { return buildTree(defaultBranchingFactor, values...) } func buildTree(branchingFactor int, values ...int) *Vector { size := len(values) leafCount := int(math.Ceil(...
vec/vec.go
0.83772
0.521715
vec.go
starcoder
package paths import ( "github.com/anaseto/gruid" ) // Astar is the interface that allows to use the A* algorithm used by the // AstarPath function. type Astar interface { Dijkstra // Estimation offers an estimation cost for a path from a position to // another one. The estimation should always give a value low...
paths/astar.go
0.655777
0.47244
astar.go
starcoder
package locale import ( "encoding/binary" "unicode/utf8" ) // The affix type is a concatenation of multiple strings. It starts with // the offsets for each string followed by the actual strings. // The affix lookup consists of all affix strings concatenated. // It is prefixed with an offset for each affix block an...
internal/locale/numbers.go
0.679285
0.60013
numbers.go
starcoder
package camera import ( "github.com/austingebauer/go-ray-tracer/canvas" "github.com/austingebauer/go-ray-tracer/matrix" "github.com/austingebauer/go-ray-tracer/point" "github.com/austingebauer/go-ray-tracer/ray" "github.com/austingebauer/go-ray-tracer/vector" "github.com/austingebauer/go-ray-tracer/world" "math...
camera/camera.go
0.891315
0.701483
camera.go
starcoder
package kmeans import ( "fmt" "image" "image/color" "math" "math/rand" "runtime" "sync" ) type Mean = []float64 type SegmentData = struct { Sum []uint64 Count int } func Kmeans(k int, img image.Image, means []Mean, prevVariance float64, iter int, maxIter int, tol float64) []Mean { if means == nil { mea...
kmeans/kmeans.go
0.554953
0.424889
kmeans.go
starcoder
package mud import ( "fmt" "time" ) const ( //MobRegenTime marks how long the routine sleep between regens MobRegenTime = 1 * time.Minute //MobSpawnTime marks how long does it take for a mob to reswpawn MobSpawnTime = 5 * time.Minute ) func (m *Mob) finishMobRoutine() bool { select { case <-worldShutDown: ...
server/mud/mob.go
0.719285
0.401365
mob.go
starcoder
package iso639_3 // LanguagesPart3 lookup table. Keys are ISO 639-3 codes var LanguagesPart3 = map[string]Language{ "aaa": {Part3: "aaa", Scope: 'I', LanguageType: 'L', Name: "Ghotuo"}, "aab": {Part3: "aab", Scope: 'I', LanguageType: 'L', Name: "Alumu-Tesu"}, "aac": {Part3: "aac", Scope: 'I', LanguageType: 'L', Nam...
lang-db.go
0.506103
0.57818
lang-db.go
starcoder