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 gifbounce import "github.com/sgreben/yeetgif/pkg/box2d" func (p *Params) New() *World { w := box2d.MakeWorld(box2d.Point{X: 0, Y: -p.Gravity}) w.ContinuousPhysics = true w.AllowSleep = true world := &World{Params: p, Box2d: &w} if world.Worker == nil { world.Worker = func(n int, f func(int), _ ...strin...
pkg/gifbounce/build.go
0.545528
0.447219
build.go
starcoder
package main import ( "github.com/c-bata/go-prompt" "os" ) func executor(t string) { switch t { case "exit": fallthrough case "quit": os.Exit(0) default: println("READY") } return } func completer(in prompt.Document) []prompt.Suggest { s := []prompt.Suggest{ {Text: "ABS", Description: "Returns the ...
article_20/08_basic_statements.go
0.567457
0.481271
08_basic_statements.go
starcoder
package parse import ( "errors" "fmt" "github.com/orange-lang/orange/pkg/ast" "github.com/orange-lang/orange/pkg/token" "github.com/orange-lang/orange/pkg/types" ) func isExpressionToken(t token.Token) bool { return isConstantToken(t) || t == token.OpenParen || t == token.Identifier || isUnaryToken(t) || t =...
pkg/parse/parse_expression.go
0.725454
0.414188
parse_expression.go
starcoder
package geo import ( "math" "github.com/dadadamarine/orb" ) // NewBoundAroundPoint creates a new bound given a center point, // and a distance from the center point in meters. func NewBoundAroundPoint(center orb.Point, distance float64) orb.Bound { radDist := distance / orb.EarthRadius radLat := deg2rad(center[1...
geo/bound.go
0.872931
0.640594
bound.go
starcoder
package systems import ( "math" "time" gc "github.com/x-hgg-x/arkanoid-go/lib/components" gm "github.com/x-hgg-x/arkanoid-go/lib/math" "github.com/x-hgg-x/arkanoid-go/lib/resources" ecs "github.com/x-hgg-x/goecs/v2" ec "github.com/x-hgg-x/goecsengine/components" em "github.com/x-hgg-x/goecsengine/math" w "g...
lib/systems/collision.go
0.639961
0.403714
collision.go
starcoder
package main import ( "gorgonia.org/gorgonia" "gorgonia.org/tensor" ) // TinyYOLOv2Net Tiniy YOLO v2 architecture type TinyYOLOv2Net struct { g *gorgonia.ExprGraph classesNum, boxesPerCel...
examples/tiny-yolo-v2-coco/net.go
0.578686
0.54056
net.go
starcoder
// Package usesgenerics defines an Analyzer that checks for usage of generic // features added in Go 1.18. package usesgenerics import ( "reflect" "github.com/kdy1/tools/go/analysis" "github.com/kdy1/tools/go/analysis/passes/inspect" "github.com/kdy1/tools/go/ast/inspector" "github.com/kdy1/tools/internal/typep...
go/analysis/passes/usesgenerics/usesgenerics.go
0.749637
0.432603
usesgenerics.go
starcoder
package bitutil import ( "math/bits" "reflect" "unsafe" ) var ( BitMask = [8]byte{1, 2, 4, 8, 16, 32, 64, 128} FlippedBitMask = [8]byte{254, 253, 251, 247, 239, 223, 191, 127} ) // IsMultipleOf8 returns whether v is a multiple of 8. func IsMultipleOf8(v int64) bool { return v&7 == 0 } // IsMultipleOf64...
go/arrow/bitutil/bitutil.go
0.66888
0.425963
bitutil.go
starcoder
package dasel import ( "bytes" "github.com/Masterminds/sprig/v3" "text/template" ) // FormatNode formats a node with the format template and returns the result. func FormatNode(node *Node, format string) (*bytes.Buffer, error) { tpl, err := formatNodeTemplate( &templateNode{ Node: node, isFirst: true, ...
output_formatter.go
0.683208
0.474388
output_formatter.go
starcoder
package continuous import ( gsl "github.com/jtejido/ggsl" "github.com/jtejido/ggsl/specfunc" "github.com/jtejido/stats" "math" "math/rand" ) // Bates distribution // https://en.wikipedia.org/wiki/Bates_distribution type Bates struct { baseContinuousWithSource a, b float64 n uint } func NewBates(a, b float...
dist/continuous/bates.go
0.814127
0.433742
bates.go
starcoder
package metric import "github.com/goki/ki/kit" // Func32 is a distance / similarity metric operating on slices of float32 numbers type Func32 func(a, b []float32) float32 // Func64 is a distance / similarity metric operating on slices of float64 numbers type Func64 func(a, b []float64) float64 // StdMetrics are st...
metric/metrics.go
0.856677
0.410047
metrics.go
starcoder
package structures import ( "math" "strconv" "strings" ) type FlatValuePlot [][]int func (plot FlatValuePlot) Get(point Point) int { if plot.IsInbound(point) { return plot[point.Y][point.X] } else { return math.MaxInt } } func (plot FlatValuePlot) Set(point Point, value int) { if plot.IsInbound(point) { ...
pkg/structures/flatvalueplot.go
0.737253
0.64491
flatvalueplot.go
starcoder
package main import ( "math/rand" . "github.com/jakecoffman/cp" "github.com/jakecoffman/cp/examples" ) var KinematicBoxBox *Body func main() { space := NewSpace() space.SetGravity(Vector{0, -600}) // We create an infinite mass rogue body to attach the line segments to // This way we can control the rotation...
examples/tumble/tumble.go
0.740925
0.536556
tumble.go
starcoder
package srpolicy import ( "encoding/binary" "encoding/json" "fmt" "github.com/golang/glog" "github.com/sbezverk/gobmp/pkg/tools" ) // SegmentType defines a type of Segment in Segment List type SegmentType int const ( // TypeA Segment Sub-TLV encodes a single SR-MPLS SID TypeA SegmentType = 1 // TypeB Segmen...
pkg/srpolicy/srpolicy-segment.go
0.629547
0.539711
srpolicy-segment.go
starcoder
package rnd import ( "math" "gosl/chk" ) /* Lower tail quantile for standard normal distribution function. * * This function returns an approximation of the inverse cumulative * standard normal distribution function. I.e., given P, it returns * an approximation to the X satisfying P = Pr{Z <= X} where Z is a...
rnd/ltqnorm.go
0.615435
0.563558
ltqnorm.go
starcoder
package simulator import "fmt" const ( notstarted = iota executing = iota completed = iota ) // Result is used to indicate the result of the simulation. // LastAlive referes to the position of the person, who will be lastalive. // KillingOrder referes to the position, in which the killing was performed. type R...
simulator/circle.go
0.580947
0.430028
circle.go
starcoder
package api import "math" const BLACK = 0 const WHITE = 255 func Binarize(in, out *Matrix) { var sum float64 bounds := in.Bounds() for x := bounds.Min.X; x < bounds.Max.X; x++ { for y := bounds.Min.Y; y < bounds.Max.Y; y++ { sum += in.At(x, y) } } mean := sum / float64(bounds.Dx()*bounds.Dy()) for x :...
api/binarize.go
0.57081
0.555435
binarize.go
starcoder
package rel import ( "reflect" ) // sliceLiteral represents a relation that came from a slice of a struct type sliceLiteral struct { // the slice of tuples in the relation rbody reflect.Value // set of candidate keys cKeys CandKeys // the type of the tuples contained within the relation zero interface{} /...
sliceliteral.go
0.715026
0.406803
sliceliteral.go
starcoder
package binlog import ( "fmt" "math" "reflect" "strconv" "github.com/pcncadcache/cachesystem/extern/redis-port/pkg/libs/errors" ) func Num64(i interface{}) interface{} { switch x := i.(type) { case int: return int64(x) case int8: return int64(x) case int16: return int64(x) case int32: return int64...
extern/redis-binlog/pkg/binlog/format.go
0.533641
0.434461
format.go
starcoder
package bot import ( "log" "math/rand" ) // BoardSZ number of lines and colums of a board const BoardSZ = 4 // Tile a cell board type Tile struct { y uint8 x uint8 } // enumeration of the agent type const ( Board = iota Player ) // enumeration of the move type const ( Left = iota Right Up Down nrMove ) ...
bot/bot.go
0.577376
0.405537
bot.go
starcoder
package main import ( "fmt" "math" ) type polymer struct { // The trick here is to make left and right subtrees overlap by one // element. Then (a) we don't need special logic for the boundary between // left and right, and (b) the input and output of reactions can both be // represented by the same type. left...
2021/14/b.go
0.55254
0.471223
b.go
starcoder
package pgsql import ( "database/sql" "database/sql/driver" ) // TSVectorFromStringSlice returns a driver.Valuer that produces a PostgreSQL tsvector from the given Go []string. func TSVectorFromStringSlice(val []string) driver.Valuer { return tsVectorFromStringSlice{val: val} } // TSVectorToStringSlice returns an...
pgsql/tsvector.go
0.724091
0.615926
tsvector.go
starcoder
package types import ( "io" "github.com/lyraproj/puppet-evaluator/errors" "github.com/lyraproj/puppet-evaluator/eval" ) type IterableType struct { typ eval.Type } var Iterable_Type eval.ObjectType func init() { Iterable_Type = newObjectType(`Pcore::IterableType`, `Pcore::AnyType { attributes => { typ...
types/iterabletype.go
0.6508
0.460592
iterabletype.go
starcoder
package DG1D import ( "fmt" "math" "github.com/james-bowman/sparse" "github.com/notargets/gocfd/utils" ) func (el *Elements1D) Startup1D(nt NODE_TYPE) { var ( err error N = el.Np - 1 ) switch nt { case GAUSS: el.R, _ = JacobiGQ(1, 1, N) case GAUSS_LOBATO: el.R = JacobiGL(0, 0, N) } el.V = Vander...
DG1D/startup.go
0.501221
0.521776
startup.go
starcoder
package xpath import ( "errors" "strings" ) // The XPath function list. func predicate(q query) func(NodeNavigator) bool { type Predicater interface { Test(NodeNavigator) bool } if p, ok := q.(Predicater); ok { return p.Test } return func(NodeNavigator) bool { return true } } // positionFunc is a XPath N...
vendor/github.com/antchfx/xpath/func.go
0.665411
0.438845
func.go
starcoder
package metrics import ( "sort" "time" "github.com/dvasilas/proteus/internal/libqpu" "github.com/golang/protobuf/ptypes" "google.golang.org/grpc/benchmark/stats" ) var ( histogramOpts = stats.HistogramOptions{ // up to 2s NumBuckets: 200000, GrowthFactor: .01, } ) // LatencyM ... type LatencyM struct...
internal/metrics/metrics.go
0.53607
0.480844
metrics.go
starcoder
package q2file import ( "bytes" "encoding/binary" "fmt" "io" "unsafe" ) const ( LumpPlanes = 1 LumpVertices = 2 LumpVisibility = 3 LumpBSPNodes = 4 LumpTexInfos = 5 LumpFaces = 6 LumpLightmaps = 7 LumpBSPLeaves = 8 LumpLeafFaces = 9 LumpEdges = 11 LumpFaceEdges = 12 ) type Hea...
src/q2file/q2bsp.go
0.664758
0.524212
q2bsp.go
starcoder
package x import "fmt" // Error messages. var Errs = map[string]string{ `file_not_x`: `this is not x source file: %s`, `invalid_token`: `undefined code content: %c`, `invalid_syntax`: `invalid syntax`, `no_entry_point`: `entry point ...
pkg/x/errs.go
0.586049
0.516108
errs.go
starcoder
package internal import ( "math" ) // Projects an image into a new coordinate system with the given transformation. // Fills in missing pixels with the given out of bounds value. Uses bilinear interpolation for now. func (img *FITSImage) Project(destNaxisn []int32, trans Transform2D, outOfBounds float32) (res *FIT...
internal/project.go
0.500977
0.502869
project.go
starcoder
package alt import ( "fmt" ) 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'. // 'start' does not need to ...
go/turing.go
0.535827
0.453443
turing.go
starcoder
// Package msgs defines some test messages for Mute unit tests. package msgs // Message1 is a test message. const Message1 = `Security is mostly a superstition. It does not exist in nature, nor do the children of men as a whole experience it. God Himself is not secure, having given man dominion over His works! Avoidi...
util/msgs/msgs.go
0.501221
0.529872
msgs.go
starcoder
package consensus import ( "github.com/axiom-org/axiom/util" ) // consensus.Block implements the convergence algorithm for a single block, // according to the Stellar Consensus Protocol. See: // https://www.stellar.org/papers/stellar-consensus-protocol.pdf // Most logic is not in the Block itself, but is delegated t...
consensus/block.go
0.724091
0.460956
block.go
starcoder
package types import ( "encoding/hex" "errors" "fmt" "golang.org/x/crypto/sha3" "math/big" "sort" "strconv" "strings" ) type HeadItem struct { StartOffset uint64 EndOffset uint64 Arg ContractABIArgument } func ParseInt(bytes []byte) *big.Int { //2s complement, so negative is Most Significant Bi...
types/abi_parser.go
0.644449
0.471527
abi_parser.go
starcoder
package merge import ( "math" "sync" ) // symSearch is like symBinarySearch but operates // on two sorted lists instead of a sorted list and an index. // It's duplication of code but you buy performance. func symSearch(u, w Comparators) int { start, stop, p := 0, len(u), len(w)-1 for start < stop { mid := (star...
vendor/src/github.com/Workiva/go-datastructures/sort/symmerge.go
0.689306
0.454714
symmerge.go
starcoder
package aoc_2021 import "strconv" func Day3Part1(input []string) int { positions := countPositions(input) gamma, epsilon := gammaRate(positions), epsilonRate(positions) return gamma * epsilon } type Position struct{ ones, zeroes int } func (p *Position) mostCommon() rune { if p.ones >= p.zeroes { return '1' ...
go/day3.go
0.696578
0.510313
day3.go
starcoder
package gotree // BinarySearchTree https://en.wikipedia.org/wiki/Binary_search_tree type BinarySearchTree struct { Root *Node } // Height is the longest distance from the root to a leaf in a binary tree, simply extends BinaryTree.Height() func (tree *BinarySearchTree) Height() int { if tree.Root == nil || (tree.Roo...
binary-search-tree.go
0.855474
0.600686
binary-search-tree.go
starcoder
package cell import ( "math" "strconv" "github.com/wdevore/Deuron5/deuron" ) type ProtoDendrite struct { baseDendrite neuron ICell } func NewProtoDendrite(cell ICell) IDendrite { n := new(ProtoDendrite) // Bidirectional associations n.neuron = cell n.baseDendrite.initialize() return n } // 1st pass /...
cell/proto_dendrite.go
0.749454
0.470554
proto_dendrite.go
starcoder
package ent import ( "fmt" "strings" "entgo.io/ent/dialect/sql" "github.com/Yiling-J/carrier/examples/ent_recipe/ent/ingredient" "github.com/Yiling-J/carrier/examples/ent_recipe/ent/recipeingredient" ) // RecipeIngredient is the model entity for the RecipeIngredient schema. type RecipeIngredient struct { conf...
examples/ent_recipe/ent/recipeingredient.go
0.665628
0.444505
recipeingredient.go
starcoder
package rpmutils import ( "regexp" "strings" ) var ( R_NONALNUMTILDE = regexp.MustCompile(`^([^a-zA-Z0-9~]*)(.*)$`) R_NUM = regexp.MustCompile(`^([\d]+)(.*)$`) R_ALPHA = regexp.MustCompile(`^([a-zA-Z]+)(.*)$`) ) // VersionSlice provides the Sort interface for sorting version strings. type Vers...
vendor/github.com/sassoftware/go-rpmutils/vercmp.go
0.558568
0.433022
vercmp.go
starcoder
package clairvoyant import ( "log" "github.com/bethanyj28/battlesnek/internal" ) type direction int const ( left direction = iota + 1 right up down ) // Convert direction to string func (d direction) String() string { return [...]string{"", "left", "right", "up", "down"}[d] } type boardObject int const ( ...
internal/battle/clairvoyant/util.go
0.659295
0.428652
util.go
starcoder
package day8 import ( "fmt" "sort" "strconv" "strings" ) type Entry struct { pattern []string digits []string } func sortString(str string) string { chars := strings.Split(str, "") sort.Strings(chars) return strings.Join(chars, "") } func parseInput(input string) []Entry { lines := strings.Split(input, "...
advent-of-code-2021/day8/day8.go
0.607081
0.400192
day8.go
starcoder
package eventbus import ( "errors" "path" "regexp" "strings" ) type ( mustBeEqual struct { not bool name string values []string } mustBeLike struct { not bool name string values []string } mustMatch struct { not bool name string values []*regexp.Regexp } ConstraintMatche...
pkg/eventbus/constraints.go
0.57344
0.409811
constraints.go
starcoder
package common import ( "github.com/newkedison/go-utils/internal/types" "math" "reflect" "strconv" ) type Number float64 const ( MaxNumber Number = Number(math.MaxFloat64) MinNumber Number = Number(-math.MaxFloat64) // Ref: https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-p...
common/number.go
0.796846
0.528351
number.go
starcoder
package dna import ( "log" "strings" ) // RuneToBase converts a rune into a dna.Base if it matches one of the acceptable DNA characters. // Note: '*', used by VCF to denote deleted alleles becomes Nil func RuneToBase(r rune) Base { switch r { case 'A': return A case 'C': return C case 'G': return G case ...
dna/convert.go
0.738763
0.486149
convert.go
starcoder
package main // MutationRate is the rate of mutation /*var MutationRate = 0.005 // PopSize is the size of the population var PopSize = 500 // Letters need to be chosen from var Letters = []rune(" aąbcčdeęėfghiįyjklmnoprsštuųūvzž") func main() { start := time.Now() rand.Seed(time.Now().UTC().UnixNano()) target :...
schedule-ga/main2.go
0.530723
0.485356
main2.go
starcoder
package owl import ( "github.com/meowpub/meow/ld" "github.com/meowpub/meow/ld/ns/rdf" ) // The class of collections of pairwise different individuals. type AllDifferent struct{ rdf.Resource } func NewAllDifferent(id string) AllDifferent { return AsAllDifferent(ld.NewObject(id, Class_AllDifferent.ID)) } // Duckty...
ld/ns/owl/classes.gen.go
0.828037
0.434521
classes.gen.go
starcoder
package expr import "aparser/ast" /* Creates an arithmetic expression parser that can parse common arithmetic expressions Supported operations: - unary: - - binary: +, -, *, /, ^ (power), % (modulo) - ternary: cond ? a : b, if (cond) a else b - logic: &&, ||, !, ^ (exclusive or) - relational: ==, !=, <, <=, >, >= - ...
expr/arithmeticexpression.go
0.54577
0.465327
arithmeticexpression.go
starcoder
package gosoh import ( "image/color" "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/ebitenutil" ) // returns true if these two CollisionBoxes overlap each other func (a *CollisionBox) Overlaps(b CollisionBox) bool { return a.X < b.X+b.Width && a.X+a.Width > b.X && a.Y < b.Y+b.Height && ...
gosoh/collisionmanager.go
0.847463
0.485234
collisionmanager.go
starcoder
package pca import ( "gonum.org/v1/gonum/mat" ) type PCA struct { Num_components int svd *mat.SVD } // Number of components. 0 - by default, use number of features as number of components func NewPCA(num_components int) *PCA { return &PCA{Num_components: num_components} } // Fit PCA model and transfo...
pca/pca.go
0.775095
0.563558
pca.go
starcoder
package dense import ( "fmt" "gorgonia.org/tensor" ) // ToF32 will attempt to cast the given tensor int values to float32 vals. func ToF32(t *tensor.Dense) (*tensor.Dense, error) { new := tensor.New(tensor.WithShape(t.Shape()...), tensor.Of(tensor.Float32)) iterator := t.Iterator() for i, err := iterator.Next()...
pkg/v1/dense/conversion.go
0.76074
0.537223
conversion.go
starcoder
package value import ( "github.com/advanderveer/jqp/token" ) // A Binary operations takes two operations type Binary struct { Op token.TokenType Left Expr Right Expr } // Eval will evaluate the binary operation func (b *Binary) Eval(ctx Context) Value { op := binaryOps[b.Op] if op == nil { panic("binary ...
value/binary.go
0.690455
0.456652
binary.go
starcoder
package sqlbuilder import "strings" // Insert returns a new INSERT statement with the default dialect. func Insert() InsertStatement { return InsertStatement{dialect: DefaultDialect} } type insertSet struct { col string arg interface{} raw bool } type insertRet struct { sql string dest interface{} } // Inse...
vendor/github.com/thcyron/sqlbuilder/insert.go
0.700075
0.500549
insert.go
starcoder
package genpack import ( "fmt" "math/rand" "sort" ) // Population contains a population for the genetic algorithm type Population struct { DNSs []*DNS fitnessSum float64 fitnessFunc func(*DNS) float64 allowedBytes []byte } // CreateNewPopulation generates a population. All compulsory elements // ar...
population.go
0.631367
0.410993
population.go
starcoder
package year2021 import ( "fmt" "math" "github.com/dhruvmanila/advent-of-code/go/util" ) type ratingType int const ( oxygenGenerator ratingType = iota co2Scrubber ) func recursiveFilter(binaryNums []string, rt ratingType, pos int) string { // Base case: There is only one value in the slice which is the final...
go/year2021/sol03.go
0.634317
0.536434
sol03.go
starcoder
package shape import ( "fmt" "io" "math" "strings" "github.com/gregoryv/draw/xy" "github.com/gregoryv/nexus" ) func NewArrow(x1, y1, x2, y2 int) *Line { head := NewTriangle() head.SetX(x2) head.SetY(y2) head.SetClass("arrow-head") return &Line{ Start: xy.Point{x1, y1}, End: xy.Point{x2, y2}, Head:...
shape/line.go
0.784526
0.477676
line.go
starcoder
package engine import ( "fmt" "strconv" ) type expression interface { eval(value func(v *Variable) string) string } type binOp struct { e1 expression e2 expression op string } type number int type assignment struct { v *Variable e expression } type condition struct { e1 expression e2 expression op stri...
engine/expression.go
0.659844
0.470189
expression.go
starcoder
package igor import ( "log" "github.com/biogo/biogo/align/pals" "github.com/biogo/biogo/seq" "github.com/biogo/graph" ) // GroupConfig specifies Group behaviour type GroupConfig struct { // PileDiff specifies the acceptable fractional difference between // piles for assignment to the same group. PileDiff flo...
third_party/biogo-examples/igor/igor/group.go
0.580352
0.458106
group.go
starcoder
package docs import ( "bytes" "encoding/json" "strings" "github.com/alecthomas/template" "github.com/swaggo/swag" ) var doc = `{ "schemes": {{ marshal .Schemes }}, "swagger": "2.0", "info": { "description": "{{.Description}}", "title": "{{.Title}}", "contact": { ...
docs/docs.go
0.572125
0.422743
docs.go
starcoder
package fsm import ( "errors" ) // StateNode represents a state node in FSM graph type StateNode int // EventType represents an event that makes the state transfer from one to another type EventType int // Event is the concrete structure type Event interface { // Type returns the event type Type() EventType // ...
fsm.go
0.720073
0.425486
fsm.go
starcoder
package storage // Tx is an interface for representing a storage transaction. The calls // executed by a transaction must be wrapped in a transaction context by // engine implementations. type Tx interface { // Get takes a key and returns the associated bytes. Get(part, key string) ([]byte, error) // Set takes a k...
storage/engine.go
0.889822
0.525978
engine.go
starcoder
package boundaryh // Returns class of last rune in s which is not equal to l0. func gLastNotEqualToInString(s string, l0 gClass) gClass { for len(s) > 0 { c, pos := gLastClassInString(s) if c != l0 { return c } s = s[:pos] } return gClassOther } // True if l0 is RI and it opens RI sequence in string <...
unicodeh/boundaryh/grapheme-gen.go
0.561215
0.444203
grapheme-gen.go
starcoder
package wire import ( "bytes" "io" "time" "github.com/soteria-dag/soterd/chaincfg/chainhash" ) // MaxBlockHeaderPayload is the maximum number of bytes a block header can be. // Version 4 bytes + Timestamp 4 bytes + Bits 4 bytes + Nonce 4 bytes + // PrevBlock and MerkleRoot hashes. const MaxBlockHeaderPayload = ...
wire/blockheader.go
0.764276
0.487673
blockheader.go
starcoder
package main import ( "fmt" ) // An example of a function that takes one input parameter, but does not return // anything back. Thus, it is considered a void function. func oddOrEven(x int) { // Functions have a local scope. The variable x is only accessible within this function. // For that reason we can consid...
volume1/section2/funwithfuncs/funwithfuncs.go
0.6137
0.505737
funwithfuncs.go
starcoder
package vm //go:generate go run ./generate import ( "fmt" "math" "reflect" ) type Call struct { Name string Size int } type Scope map[string]interface{} func fetch(from interface{}, i interface{}) interface{} { v := reflect.ValueOf(from) kind := v.Kind() // Structures can be access through a pointer or th...
vendor/github.com/antonmedv/expr/vm/runtime.go
0.566978
0.443359
runtime.go
starcoder
package dvid import ( "bytes" "encoding/binary" "encoding/json" "fmt" "io" ) var ( emptyValue = []byte{} ) func EmptyValue() []byte { return emptyValue } // DataType is a unique ID for each type of data within DVID, e.g., a uint8 or a float32. type DataType uint8 const ( T_uint8 DataType = iota T_int8 T_...
dvid/datavalues.go
0.633297
0.480905
datavalues.go
starcoder
package draw_vector import ( "math" "math/cmplx" "api/app/drawing/types" "api/app/util" ) type VectorBuilder struct { currentOriginalPointsIndex int originalPoints []types.OriginalPoint } func (vectorBuilder *VectorBuilder) Build(n int, providedOriginalPoints []types.OriginalPoint) types.DrawVecto...
app/drawing/processing/draw_vector/vector_builder.go
0.753013
0.417212
vector_builder.go
starcoder
package chart import ( "errors" "fmt" "io" "math" "github.com/golang/freetype/truetype" "github.com/leesjensen/go-chart/util" ) const ( _pi = math.Pi _pi2 = math.Pi / 2.0 _pi4 = math.Pi / 4.0 ) // PieChart is a chart that draws sections of a circle based on percentages. type PieChart struct { Title ...
pie_chart.go
0.747708
0.469277
pie_chart.go
starcoder
package chunk import ( "bytes" "sync" ) // Chunk is a segment in the world with a size of 16x16x256 blocks. A chunk contains multiple sub chunks // and stores other information such as biomes. // It is not safe to call methods on Chunk simultaneously from multiple goroutines. type Chunk struct { sync.Mutex // air...
dragonfly/world/chunk/chunk.go
0.657538
0.575528
chunk.go
starcoder
package testme import ( "os" "reflect" "runtime" "strings" "testing" ) const libraryName = "testme.go" // E function wraps standard testing type T with expect assertions func E(t *testing.T) Expecter { return &tester{t} } // Expecter interface serves as a starting point for expect assertions type Expecter int...
testme.go
0.654674
0.519399
testme.go
starcoder
package jsonlogic import ( "bytes" "encoding/json" "io" "math" "reflect" "strings" "github.com/mitchellh/copystructure" ) func between(operator string, values []interface{}, data interface{}) interface{} { a := values[0] b := values[1] c := values[2] if operator == "<" { return less(a, b) && less(b, c)...
jsonlogic.go
0.598782
0.413773
jsonlogic.go
starcoder
package style import ( "RenG/src/lang/ast" "RenG/src/lang/object" ) func evalInfixExpression(operator string, left, right object.Object) object.Object { switch { case left.Type() == object.INTEGER_OBJ && right.Type() == object.INTEGER_OBJ: return evalIntegerInfixExpression(operator, left, right) case left.Type...
src/reng/style/infixExpression.go
0.552781
0.514156
infixExpression.go
starcoder
package gdb import ( "github.com/rglujing/gf/container/gvar" "github.com/rglujing/gf/encoding/gparser" "github.com/rglujing/gf/util/gconv" "math" ) // Interface converts and returns `r` as type of interface{}. func (r Result) Interface() interface{} { return r } // IsEmpty checks and returns whether `r` is emp...
database/gdb/gdb_type_result.go
0.78316
0.44089
gdb_type_result.go
starcoder
package rbxmk import ( lua "github.com/anaminus/gopher-lua" "github.com/anaminus/rbxmk/dump" "github.com/anaminus/rbxmk/rtypes" "github.com/robloxapi/types" ) // Pusher converts a types.Value to a Lua value. If err is nil, then lv must not // be nil. type Pusher func(s Context, v types.Value) (lv lua.LValue, err ...
reflect.go
0.649134
0.434881
reflect.go
starcoder
package cluster /** * Configuration for Node group object type resource. */ type Clusternodegroup struct { /** * Name of the nodegroup. The name uniquely identifies the nodegroup on the cluster. */ Name string `json:"name,omitempty"` /** * Specifies whether cluster nodes, that are not part of the nodegroup, will...
resource/config/cluster/clusternodegroup.go
0.61231
0.426202
clusternodegroup.go
starcoder
package rules import ( "fmt" "log" "strconv" "github.com/influxdata/influxdb/models" "github.com/influxdata/influxdb/tsdb/engine/tsm1" "github.com/influxdata/influxql" "github.com/oktal/infix/logging" "github.com/oktal/infix/storage" ) // UpdateMeasurementFieldTypeRule will update a field type for a given m...
rules/update_type.go
0.676406
0.429848
update_type.go
starcoder
package parser // reserveBuffer checks cap(buf) and expand buffer to len(buf) + appendSize. // If cap(buf) is not enough, reallocate new buffer. func reserveBuffer(buf []byte, appendSize int) []byte { newSize := len(buf) + appendSize if cap(buf) < newSize { // Grow buffer exponentially newBuf := make([]byte, len...
db/parser/escape.go
0.561455
0.437343
escape.go
starcoder
package varnamelen import ( "go/ast" "strings" "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/inspector" ) // varNameLen is an analyzer that checks that the length of a variable's name matches its usage scope. // It will create a report for a variable...
vendor/github.com/blizzy78/varnamelen/varnamelen.go
0.685318
0.424651
varnamelen.go
starcoder
package parse import ( "os" "github.com/auyer/federal/ast" "github.com/auyer/federal/scan" "github.com/auyer/federal/token" ) // ParseFile initializes the parser, and makes the first lexical analysis. func ParseFile(filename, src string) *ast.Source { var p parser p.init(filename, src) f := p.parseSource() i...
parse/parse.go
0.549157
0.478346
parse.go
starcoder
package main import "math" // O((v+e)*log(v)) time | O(v) space - where v is the number of vertices and // e is the number of edges in the input graph func DijkstrasAlgorithm(start int, edges [][][]int) []int { numberOfVertices := len(edges) minDistances := make([]int, 0, numberOfVertices) for range edges { min...
FamousAlgo/Dijkstra'sAlgorithm/soultion.go
0.6137
0.49762
soultion.go
starcoder
package ball import ( "crypto/rand" "math/big" "github.com/gltchitm/pong-go/consts" "github.com/veandco/go-sdl2/sdl" ) type Ball struct { X int Y int XVelocity int YVelocity int renderer *sdl.Renderer } func NewBall(renderer *sdl.Renderer) (*Ball, error) { ball := Ball{ X: 0, ...
ball/ball.go
0.540439
0.444866
ball.go
starcoder
package gease import ( "image/color" "time" "github.com/lucasb-eyer/go-colorful" ) // ColorEasing smoothly animates a color transition. It operates in LAB space with // seperate alpha interpolation for a visually smooth transition. type ColorEasing struct { target [3]float64 targetAlpha float64 l, a, b, ...
color.go
0.822937
0.566858
color.go
starcoder
package pterm import ( "fmt" "io" "strings" "github.com/gookit/color" ) // SetDefaultOutput sets the default output of pterm. func SetDefaultOutput(w io.Writer) { color.SetOutput(w) } // Sprint formats using the default formats for its operands and returns the resulting string. // Spaces are added between oper...
print.go
0.654674
0.480844
print.go
starcoder
package sqltestutil import ( "github.com/google/uuid" "github.com/liquidata-inc/dolt/go/libraries/doltcore/row" "github.com/liquidata-inc/dolt/go/libraries/doltcore/schema" ) // Structure for a test of an update query type UpdateTest struct { // The name of this test. Names should be unique and descriptive. Na...
go/libraries/doltcore/sql/sqltestutil/updatequeries.go
0.543833
0.561215
updatequeries.go
starcoder
package missing_network_segmentation import ( "sort" "github.com/threagile/threagile/model" ) const raaLimit = 50 func Category() model.RiskCategory { return model.RiskCategory{ Id: "missing-network-segmentation", Title: "Missing Network Segmentation", Description: "Ativos altamente sensíveis e/ou armaz...
risks/built-in/missing-network-segmentation/missing-network-segmentation-rule.go
0.5083
0.44571
missing-network-segmentation-rule.go
starcoder
package rtree import "container/heap" // Nearest finds the record in the RTree that is the closest to the input box // as measured by the Euclidean metric. Note that there may be multiple records // that are equidistant from the input box, in which case one is chosen // arbitrarily. If the RTree is empty, then false ...
rtree/nearest.go
0.720368
0.48249
nearest.go
starcoder
package harbor //Until these data models become part of the official API //See https://github.com/goharbor/harbor/tree/master/src/pkg/scan/report const ( // None - only used to mark the overall severity of the scanned artifacts, // means no vulnerabilities attached with the artifacts, // (might be bypassed by the ...
pkg/vulnprovider/harbor/vuln_report.go
0.731538
0.412412
vuln_report.go
starcoder
package neat import ( "github.com/klokare/evo" "github.com/klokare/evo/config" "github.com/klokare/evo/neat/mutator" "github.com/klokare/evo/network/forward" "github.com/klokare/evo/searcher/parallel" ) // Ensure the experiment struct implements the experiment interface var ( _ evo.Experiment = &Experiment{} ) ...
neat/experiment.go
0.636692
0.475849
experiment.go
starcoder
package pathfinding import ( "fmt" "image" "image/color" "math" "github.com/beefsack/go-astar" "github.com/pkg/errors" "gitlab.com/256/Underbot/cv/params" "gitlab.com/256/Underbot/cv/rect" ) // Tile is a section of the screen for pathfinding type Tile struct { Pos string // String representation ...
ai/pathfinding/tiles.go
0.664867
0.525673
tiles.go
starcoder
package restic import ( "fmt" "sort" "github.com/rubiojr/rapi/internal/errors" "github.com/rubiojr/rapi/internal/debug" ) // Tree is an ordered list of nodes. type Tree struct { Nodes []*Node `json:"nodes"` } // NewTree creates a new tree object. func NewTree() *Tree { return &Tree{ Nodes: []*Node{}, } } ...
restic/tree.go
0.713631
0.413951
tree.go
starcoder
package poly2tri import ( "container/list" "log" "sort" ) // Point represents a point. type Point struct { X, Y float64 edges []*Edge } // NewPoint returns a new point. func NewPoint(x, y float64) *Point { return &Point{x, y, []*Edge{}} } // PointArray attaches the methods of Interface to []*Point, sorting i...
shapes.go
0.717309
0.698715
shapes.go
starcoder
package series import "github.com/WinPooh32/math" type AlphaType int const ( // Specify smoothing factor α directly, 0<α≤1. Alpha AlphaType = iota // Specify decay in terms of center of mass, α=1/(1+com), for com ≥ 0. AlphaCom // Specify decay in terms of span, α=2/(span+1), for span ≥ 1. AlphaSpan // Specify...
exp_window.go
0.611962
0.400603
exp_window.go
starcoder
package rules import ( "regexp" "github.com/alecthomas/participle/lexer" ) // StartCondition indicates a particular lexer state in which a rule should apply. // By default, start conditions are inclusive and will match rules belonging to an empty // set of start conditions as well as those which are explicitly spe...
cmakelib/lexer/rules/rules.go
0.764979
0.434161
rules.go
starcoder
package pythagorean import "sort" // Triplet represents a pythagorean triplet type Triplet [3]int // TripSlice is a list of triplets type TripSlice []Triplet // Len computes the length of a triplet slice func (a TripSlice) Len() int { return len(a) } //Swap trades the position of two elements in the slice func (a ...
pythagorean-triplet/pythagorean_triplet.go
0.824037
0.513729
pythagorean_triplet.go
starcoder
package charts import ( "github.com/kva3umoda/goecharts/axis" "github.com/kva3umoda/goecharts/model" "github.com/kva3umoda/goecharts/series" ) // The x axis in cartesian(rectangular) coordinate type Chart2D struct { model *model.Option name string index int xAxis *axis.XYAxis yAxis *axis.XYAxis series ...
charts/2d.go
0.751101
0.44089
2d.go
starcoder
package main import ( "math/rand" ) func createMatrix(size int) [][]int64 { matrix := make([][]int64, size) for i := range matrix { matrix[i] = make([]int64, size) } return matrix } func computeNullSpace(matrix [][]int64, n int, char int64) ([][]int64, int) { cols := make([]int, n) for i := range cols { ...
factorization.go
0.755186
0.461805
factorization.go
starcoder
package volume import "math" // Volume is a mixable volume type Volume float32 var ( // VolumeUseInstVol tells the system to use the volume stored on the instrument // This is useful for trackers and other musical applications VolumeUseInstVol = Volume(math.Inf(-1)) ) // Matrix is an array of Volumes type Matrix...
volume/volume.go
0.791861
0.457561
volume.go
starcoder
package proximityhash import ( "math" ) const ( meanEarthRadKm = 6371.0 toRadians = math.Pi / 180 kmToMeters = 1000 ) // The point struct represents a geographic location specified by a latitude, longitude coordinate pair. type point struct { lat float64 lng float64 } func (p *point) equals(p2 point)...
math_utils.go
0.902382
0.583114
math_utils.go
starcoder
package executor func addintAndfloat32(a int, b float32) float32 { return float32(a) + b } func substractintAndfloat32(a int, b float32) float32 { return float32(a) - b } func divintAndfloat32(a int, b float32) float32 { return float32(a) / b } func multiplyintAndfloat32(a int, b float32) float32 { return floa...
go/executor/math_funcs_float_gen.go
0.870281
0.471406
math_funcs_float_gen.go
starcoder
package haraka // aesRound is the AES round function with little-endian 32-bit key and state // using the T-tables suggested in section 5.2.1 of the Rijndael submission // https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/documents/aes-development/rijndael-ammended.pdf func aesRound(key...
aes.go
0.505371
0.527682
aes.go
starcoder
package hmath import ( "fmt" "github.com/barnex/fmath" ) type Quaternion [4]float32 func (quaternion Quaternion) String() string { return fmt.Sprintf("[%f,%f,%f,%f]", quaternion[0], quaternion[1], quaternion[2], quaternion[3]) } func (quaternion Quaternion) XYZVec() Vec3 { return Vec3{quaternion[0], quaternion...
code/pkg/hmath/quaternion.go
0.754373
0.512388
quaternion.go
starcoder