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 buffer import ( "gvisor.dev/gvisor/pkg/safemem" ) // WriteBlock returns this buffer as a write Block. func (b *buffer) WriteBlock() safemem.Block { return safemem.BlockFromSafeSlice(b.WriteSlice()) } // ReadBlock returns this buffer as a read Block. func (b *buffer) ReadBlock() safemem.Block { return saf...
pkg/buffer/safemem.go
0.713631
0.427935
safemem.go
starcoder
package util import ( "time" ) // String returns a string representing the duration in the form "72h3m0.5s". // Leading zero units are omitted. As a special case, durations less than one // second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure // that the leading digit is non-zero. The zero du...
util/durationFormat.go
0.672117
0.434041
durationFormat.go
starcoder
package merkle import ( "github.com/dist-ribut-us/crypto" "github.com/dist-ribut-us/errors" "io" ) // ErrIncomplete is returned when trying to perform an operation limited to a // complete Tree (Read or ReadAll). Check if the Tree is complete with // Tree.Complete() const ErrIncomplete = errors.String("Tree is inc...
read_tree.go
0.627038
0.416441
read_tree.go
starcoder
package dao //GetCourseNumStudents returns the number of students enrolled in the course func GetCourseNumStudents(courseID uint) (int64, error) { var res int64 err := DB.Table("course_users").Where("course_id = ? OR ? = 0", courseID, courseID).Count(&res).Error return res, err } //GetCourseNumVodViews returns the...
dao/statistics.go
0.600071
0.474266
statistics.go
starcoder
package unstructpath // NumberP is a "number predicate". It's a type that decides if a // number matches or not. type NumberP interface { Match(float64) bool } // NumberNot inverts the result of the sub-predicate. func NumberNot(predicate NumberP) NumberP { return numberNot{ip: predicate} } type numberNot struct {...
pkg/framework/unstructpath/numberp.go
0.871201
0.447279
numberp.go
starcoder
package scrummy // Chart represents each graph build of a coodinates system and (possibly multiple) data lines. type Chart interface { Xaxis() []float64 Yaxis() []float64 Xlegend() string Ylegend() string Values() []float64 Legend() []string } // LineChart is a diagram with one or more data lines. type LineChar...
chart.go
0.846483
0.566019
chart.go
starcoder
package iso20022 // Information needed to process a currency exchange or conversion. type ForeignExchangeTerms33 struct { // Cash amount resulting from a foreign exchange trade. ToAmount *ActiveCurrencyAndAmount `xml:"ToAmt,omitempty"` // Cash amount for which a foreign exchange is required. FromAmount *ActiveCu...
ForeignExchangeTerms33.go
0.778733
0.482856
ForeignExchangeTerms33.go
starcoder
package mdm import ( "encoding/binary" "errors" "fmt" "io" "sort" "sync" "gitlab.com/NebulousLabs/Sia/build" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/modules" "gitlab.com/NebulousLabs/Sia/types" "gitlab.com/NebulousLabs/encoding" ) // programData is a buffer for the program data. ...
modules/host/mdm/programdata.go
0.555194
0.482246
programdata.go
starcoder
package giso import ( "image/color" "math" "github.com/fogleman/gg" "github.com/teacat/noire" ) // https://github.com/FabianTerhorst/Isometric/blob/master/lib/src/main/java/io/fabianterhorst/isometric/Isometric.java type FilledPath struct { *Path fillColorHex string } type Isometric struct { originX, origin...
isometric.go
0.812421
0.514461
isometric.go
starcoder
Finials for pillar decorations. */ //----------------------------------------------------------------------------- package main import ( "math" . "github.com/deadsy/sdfx/sdf" ) //----------------------------------------------------------------------------- func square1(l float64) SDF2 { return Polygon2D(Nagon...
examples/finial/main.go
0.63477
0.415966
main.go
starcoder
package main type ( BfWrite Handle BfRead struct { BytesLeft int } ) func (BfWrite) WriteBool(bit bool) func (BfWrite) WriteByte(byt int) func (BfWrite) WriteChar(chr int) func (BfWrite) WriteShort(shrt int) func (BfWrite) WriteWord(w int) func (BfWrite) WriteNum(num int) func (BfWrite) WriteFloat(num float) fun...
sourcemod/bitbuffer.go
0.780579
0.49939
bitbuffer.go
starcoder
package main import ( "strings" "time" influxdb2 "github.com/influxdata/influxdb-client-go/v2" dns "github.com/miekg/dns" cdns "github.com/niclabs/dnszeppelin" ) /* From: Detecting Anomalies at a TLD Name Server Based on DNS Traffic Predictions <NAME>, <NAME>, <NAME>, <NAME>, and <NAME> IEEE Transactions on Netw...
stats_influx.go
0.559771
0.420005
stats_influx.go
starcoder
package txqr import ( "fmt" "math/rand" "strings" fountain "github.com/google/gofountain" ) // Decoder represents protocol decode. type Decoder struct { chunkLen int codec fountain.Codec fd fountain.Decoder completed bool total int cache map[string]struct{} } // NewDecoder creates and ...
decode.go
0.654453
0.484075
decode.go
starcoder
package toscalib import ( "io/ioutil" "os" "path/filepath" "reflect" ) // Original source: // https://gist.github.com/hvoecking/10772475 // There is an implied assumption that all attributes on a Struct are exported. // For toscalib that will be the case so that assumption should work for us. func _deepClone(to,...
utils.go
0.601945
0.422266
utils.go
starcoder
package main import ( "log" "math/rand" "sync" ) const ( // JumpAITries contains the number of iterations JumpAI uses to find a jump JumpAITries = 100 ) const ( jumpAIprogressNormal = iota jumpAIprogressJump jumpAIprogressCrash ) type jumpAIRevert struct { X, Y, Speed, stepCounter int Direction ...
ai_jump.go
0.529507
0.444806
ai_jump.go
starcoder
package rateengine import ( "github.com/transcom/mymove/pkg/unit" ) type pricer interface { price(rate unit.Cents, q1 unit.BaseQuantity, discount *unit.DiscountRate) unit.Cents } // Basic pricer, multiplies the rate against the provided quantity type basicQuantityPricer struct{} func newBasicQuantityPricer() basi...
pkg/rateengine/pricers.go
0.823435
0.617426
pricers.go
starcoder
package unary import ( "fmt" "github.com/matrixorigin/matrixone/pkg/container/nulls" "github.com/matrixorigin/matrixone/pkg/container/types" "github.com/matrixorigin/matrixone/pkg/container/vector" "github.com/matrixorigin/matrixone/pkg/vectorize/space" "github.com/matrixorigin/matrixone/pkg/vm/process" "golan...
pkg/sql/plan2/function/builtin/unary/space.go
0.570451
0.626081
space.go
starcoder
package main import ( "fmt" "log" "os/exec" "strings" "time" "strconv" ) func getNextMonth(t time.Time) string { // Determine the first of the next month after t. firstOfNextMonth := t.AddDate(0,1,-(t.Day()-1)) // Get the string representation of the month number. return strcon...
khal.go
0.649356
0.487429
khal.go
starcoder
package prototests import ( "bytes" ) // deriveEqualSimple returns whether this and that are equal. func deriveEqualSimple(this, that *Simple) bool { return (this == nil && that == nil) || this != nil && that != nil && ((this.Field1 == nil && that.Field1 == nil) || (this.Field1 != nil && that.Field1 != nil &&...
encode/proto/prototests/derived.gen.go
0.622115
0.528047
derived.gen.go
starcoder
package insight import ( "fmt" "time" "github.com/pipe-cd/pipe/pkg/model" ) // deploy frequency // DeployFrequencyChunk represents a chunk of DeployFrequency data points. type DeployFrequencyChunk struct { AccumulatedTo int64 `json:"accumulated_to"` DataPoints DeployFrequencyDataPoint `j...
pkg/insight/chunk.go
0.737725
0.539711
chunk.go
starcoder
package machine import ( "math" "unsafe" ) type Ram struct { Data []byte `json:"data"` } func (ram *Ram) Size() int { return len(ram.Data) } func (ram *Ram) GrowTo(size int) { if size > len(ram.Data) { missing := size - len(ram.Data) new_bytes := make([]byte, missing, missing) ram.Data = append(ram.Data...
src/novmm/machine/ram.go
0.661814
0.453322
ram.go
starcoder
package drawer import ( "fmt" "image" "image/color" "math" "math/rand" "time" proc "github.com/esimov/legoizer/processor" "github.com/fogleman/gg" "github.com/lucasb-eyer/go-colorful" ) const ( _1x1 = iota _2x1 _3x1 _4x1 _6x1 _2x2 _3x2 _4x2 _6x2 ) type point struct { x, y float64 } type lego str...
drawer/drawer.go
0.591015
0.495545
drawer.go
starcoder
package bindings import "strconv" type tFloat64 struct { listeners []Float64Listener value float64 filter Float64Filter } type tFloat64AB struct { tFloat64 parentA Float64 parentB Float64 } type tFloat64BooleanAB struct { tBoolean parentA Float64 parentB Float64 } type tFloat64Divide struct { tFlo...
float64.go
0.764892
0.610686
float64.go
starcoder
package letters import ( "image/color" "github.com/llgcode/draw2d" "github.com/llgcode/draw2d/draw2dimg" ) // CellDrawer represents a type that contains all of the drawing // functions needed by a segment in order to draw within the cell type CellDrawer interface { Fill(paths ...*draw2d.Path) FillStroke(paths ....
pkg/letters/celldraw.go
0.815233
0.478712
celldraw.go
starcoder
package goNixArgParser import "strconv" func getValue(source map[string][]string, key string) (value string, found bool) { var values []string values, found = source[key] if found && len(values) > 0 { value = values[0] } return } func getValues(source map[string][]string, key string) (values []string, found...
util.go
0.504394
0.401952
util.go
starcoder
package dtw import ( "errors" "fmt" "io" "math" "reflect" ) // DistanceFunc is the function used to calculate the distance between x and y type DistanceFunc func(x, y interface{}) float64 // Dtw ... type Dtw struct { s reflect.Value t reflect.Value df DistanceFunc matrix [][]float64 } // New ...
dtw.go
0.617974
0.447279
dtw.go
starcoder
package graph import ( "fmt" "strings" "github.com/heustis/tsp-solver-go/model" ) type GraphVertex struct { id string adjacentVertices map[*GraphVertex]float64 paths map[model.CircuitVertex]*GraphEdge } func NewGraphVertex(id string) *GraphVertex { g := &GraphVertex{ id: ...
graph/graphvertex.go
0.780997
0.554953
graphvertex.go
starcoder
package tester import ( "fmt" "github.com/byorty/contractor/common" validation "github.com/go-ozzo/ozzo-validation/v4" "github.com/pkg/errors" "regexp" "strconv" "strings" "time" ) //go:generate mockgen -source=$GOFILE -package=mocks -destination=mocks/$GOFILE type Assertion struct { Name string Exp...
tester/asserter.go
0.604866
0.48871
asserter.go
starcoder
package main import ( "fmt" "math" ) // location with a latitude, longitude. type location struct { lat, long float64 } // coordinate in degrees, minutes, seconds in a N/S/E/W hemisphere. type coordinate struct { d, m, s float64 h rune } // newLocation from latitude, longitude d/m/s coordinates. func new...
solutions/lesson22/distance/distance.go
0.825062
0.466967
distance.go
starcoder
package skein const ( Key int = 0 Config int = 4 Personalization int = 8 PublicKey int = 12 KeyIdentifier int = 16 Nonce int = 20 Message int = 48 Out int = 63 ) const t1FlagFinal = uint64(1) << 63 const t1FlagFirst = uint64(1)...
vendor/github.com/gxed/hashland/skein/ubiTweak.go
0.678114
0.419113
ubiTweak.go
starcoder
package log // Start is used for the entry into a function. func Start(context interface{}, function string) { Up1.Start(context, function) } // Startf is used for the entry into a function with a formatted message. func Startf(context interface{}, function string, format string, a ...interface{}) { Up1.Startf(cont...
log/log_calls.go
0.50415
0.412589
log_calls.go
starcoder
package ndarray type Array struct { dims *Shape Data []float64 Length int } // --------------------------------------------------------------- func (this *Array) DataCopy() []float64 { d := make([]float64, len(this.Data)) copy(d, this.Data) return d } func (this Array) Dims() (rows, columns int) { return ...
ndarray.go
0.594198
0.543348
ndarray.go
starcoder
package imaging import ( "image" "image/color" "math" "golang.org/x/image/draw" ) // Resize creates a copy of the given image, scaled to the given rectangle. func Resize(i image.Image, width float64) image.Image { scaledSize := int(math.Round(width)) size := image.Rect(0, 0, scaledSize, scaledSize) dst := im...
internal/imaging/imaging.go
0.870212
0.665906
imaging.go
starcoder
package models // Dataset: Earnings by place of work // Dimensions: Sex | Employment status // Variables: gross weekly pay, weekly pay excluding overtime // Table // Observation | Variable (Earnings)| Sex | Employment status // 123 | Gross weekly pay | Male | Full Time // 70 | Gross weekly pay...
models/dataset.go
0.70028
0.592637
dataset.go
starcoder
package te import ( "fmt" "sort" "strings" "time" ) // Expression represents a temporal expression. type Expression interface { IsActive(t time.Time) bool Next(t time.Time) time.Time } type hourExpr int func (expr hourExpr) IsActive(t time.Time) bool { return t.Hour() == int(expr) } func (expr hourExpr) Nex...
expressions.go
0.696371
0.518302
expressions.go
starcoder
package main import ( "os" "bufio" "fmt" "math" "sort" ) type point struct { X int Y int } func distance(p1 point, p2 point) float64 { dx, dy := float64(p2.X - p1.X), float64(p2.Y - p1.Y) return math.Sqrt(math.Pow(dx, 2) + math.Pow(dy, 2)) } func angle(p1 point, p2 point) float64 { dx, dy := float64(p2.X ...
Day 10/main.go
0.732687
0.465691
main.go
starcoder
package mysql_nodejs import ( . "github.com/gocircuit/circuit/gocircuit.org/render" ) func RenderApp() string { return RenderHtml("Write the circuit app", Render(appBody, nil)) } const appBody = ` <h1>Write the circuit app</h1> <p>In this section we are going to write a Go program (the circuit app), which when ex...
gocircuit.org/tutorial/mysql-nodejs/app.go
0.698329
0.612165
app.go
starcoder
package rand import ( "crypto/internal/randutil" "errors" "io" "math/big" ) // Prime returns a number of the given bit length that is prime with high probability. // Prime will return error for any error returned by rand.Read or if bits < 2. func Prime(rand io.Reader, bits int) (*big.Int, error) { if bits < 2 {...
src/crypto/rand/util.go
0.680666
0.46642
util.go
starcoder
package phy import ( "image" "image/color" "image/draw" "math" "math/rand" "time" "github.com/icexin/eggos/app" "github.com/icexin/eggos/drivers/kbd" "github.com/icexin/eggos/drivers/vbe" "github.com/jakecoffman/cp" ) const gravityStrength = 5.0e6 var planetBody *cp.Body func planetGravityVelocity(body ...
app/phy/game.go
0.624179
0.446796
game.go
starcoder
package bisect // Package bisect implements common bisection algorithms // Interface is a type, typically a collection can be // sorted in-place by the routines in this package type Interface interface { // Len is the number of elements in the collection. Len() int // Compares a given item with the element x at in...
bisect.go
0.810704
0.671147
bisect.go
starcoder
package main import ( "fmt" ) // Triangle stores the amount of white and black pieces type Triangle struct { White int Black int } // Board represents the board type Board struct { Tris [24]Triangle Bar Triangle Finished Triangle Turn bool } // NewBoard creates a board func NewBoard() Board { b...
board.go
0.520984
0.418578
board.go
starcoder
package util import ( "github.com/samber/lo" "golang.org/x/exp/slices" ) type List[T comparable] []T func (l List[T]) Has(elements ...T) bool { return Any(elements, func(e T) bool { return slices.Contains(l, e) }) } func (l List[T]) At(i int) *T { if len(l) == 0 || i < 0 || len(l) <= i { return nil } e :...
server/pkg/util/list.go
0.578924
0.471223
list.go
starcoder
package deque // Power of 2 for bitwise modulus: x % n == x & (n - 1). const minSize = 64 // Deque represents a single instance of the data structure. type Deque struct { buffer []interface{} first int last int size int } // Len returns the number of elements in the deque func (q *Deque) Len() int { retur...
deque/deque.go
0.738575
0.523359
deque.go
starcoder
package kpage import ( "container/list" "fmt" "math/rand" "time" "github.com/mohae/deepcopy" ) // Solution represents a solution of a kPage problem type Solution struct { Pages uint Crossings uint Vertex uint Edges []*Edge Order []uint vPosition []uint adj []*list....
kpage/solution.go
0.608361
0.414484
solution.go
starcoder
package binarysearch // BinarySearch binary search // 二分查找,非递归版本 func BinarySearch(a []int, v int) int { if len(a) == 0 { return -1 } low := 0 high := len(a) - 1 for low <= high { mid := low + (high-low)/2 if a[mid] == v { return mid } else if a[mid] > v { high = mid - 1 } else { low = mid + 1...
binarysearch/golang/binarysearch.go
0.572723
0.472988
binarysearch.go
starcoder
package routing import ( "errors" "fmt" ) // Node represents a vertex in the graph. type Node struct { ID string // ID of this node. Endhost bool // Whether it is an end-host (important dst for routing). } func (n Node) String() string { return n.ID } // Key returns the beehive key representing this nod...
examples/routing/graph.go
0.858289
0.451387
graph.go
starcoder
package internal import ( "errors" "fmt" "math" ) // A 2-dimensional point with floating point coordinates. type Point2D struct { X float32 Y float32 } // A 2-dimensional rectangle with floating point coordinates type Rect2D struct { A Point2D B Point2D } // A 3-dimensional point with floating point...
internal/coord.go
0.849535
0.786869
coord.go
starcoder
package backbuf import ( "fmt" ) const minSize = 1 // Buffer implements a circular byte buffer, data is read from left to right // but chucks are read from right to left. Unread data is never overwriten type Buffer struct { buffer []byte wpos int rpos int full bool } // New creates a Buffer with a capacity of...
backbuf/backbuf.go
0.781205
0.492493
backbuf.go
starcoder
package redblack type Tree struct { root *Node nil *Node } type color int const ( colorRed = iota colorBlack ) type Node struct { color color key int left *Node right *Node p *Node } // rotate change pointer's reference to recovery red-black tree's property func (t *Tree) LeftRotate(node *Node) { ...
redblack/red_black_tree.go
0.549641
0.510863
red_black_tree.go
starcoder
package main import ( "bufio" "flag" "fmt" "math" "os" "strconv" "strings" ) // haversin(θ) function func hsin(theta float64) float64 { return math.Pow(math.Sin(theta/2), 2) } // http://en.wikipedia.org/wiki/Haversine_formula func Distance(lat1, lon1, lat2, lon2 float64) float64 { var la1, lo1, la2, lo2, r ...
gmp_compare/gmp_compare.go
0.714628
0.416559
gmp_compare.go
starcoder
package main import ( "fmt" "io/ioutil" "math" "sort" "strings" ) type coordinates struct { x, y float64 } type asteroid struct { visibleAsteroids int tangentsOfObstruction map[string]bool } type distance struct { coordinates value float64 } type byDistance []distance func (d byDistance) Len() int ...
day20/main.go
0.527803
0.415136
main.go
starcoder
package g import ( ) // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // Angular events - http://www.w3schools.com/angular/angular_events.asp // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- func (ele *ELEMENT) NgBlur(expression string) *ELEMENT { return ele.Attr("ng-blur", ex...
markup/angular_events.go
0.541894
0.408513
angular_events.go
starcoder
package core import ( "runtime" . "github.com/gooid/gocv/opencv3/internal/native" ) const _channelsMatOfRect = 4 var _depthMatOfRect = CvTypeCV_32S type MatOfRect struct { *Mat } func NewMatOfRect() (rcvr *MatOfRect) { rcvr = &MatOfRect{} rcvr.Mat = NewMat2() runtime.SetFinalizer(rcvr, func(interface{}) { r...
opencv3/core/MatOfRect.java.go
0.626353
0.405478
MatOfRect.java.go
starcoder
package mat64 import "math" // Float is the main float type for the mat64 package. It is an alias for float64. type Float = float64 const ( // SmallestNonzeroFloat corresponds to math.SmallestNonzeroFloat64. SmallestNonzeroFloat Float = math.SmallestNonzeroFloat64 // Pi mathematical constant. Pi Float = math.Pi...
pkg/mat64/mat.go
0.920781
0.709787
mat.go
starcoder
package circuit type BitVector struct { Nodes []*Node } func NewBitVector(n int) *BitVector { return &BitVector{make([]*Node, n)} } func FillVector(n int, node *Node) *BitVector { r := NewBitVector(n) for i := range(r.Nodes) { r.Nodes[i] = node } return r } func ZeroVector(n int) *BitVector { return FillVe...
bitvector.go
0.678433
0.743959
bitvector.go
starcoder
package measurements import ( "github.com/Debiancc/go-turf/features" "github.com/Debiancc/go-turf/helpers" "github.com/Debiancc/go-turf/types" "math" ) func Destination(origin features.Point, distance float64, bearing float64, units types.Units, properties *features.Properties) *features.Point { lng1 := helpers....
measurements/destination.go
0.790166
0.604195
destination.go
starcoder
package gmgmap import "math/rand" type connectInfo struct { up bool right bool down bool left bool } // NewRogue - generate a new Rogue-like map, with rooms connected with tunnels func NewRogue(width, height, gridWidth, gridHeight, minRoomPct, maxRoomPct int) *Map { m := NewMap(width, height) // Divide ...
gmgmap/rogue.go
0.569613
0.460592
rogue.go
starcoder
package value import "strconv" // UInt holds a single uint64 value. type UInt struct { valPtr *uint64 } // NewUInt makes a new UInt with the given uint64 value. func NewUInt(val uint64) *UInt { valPtr := new(uint64) *valPtr = val return &UInt{valPtr: valPtr} } // NewUIntFromPtr makes a new UInt with the given ...
value/uint.go
0.799599
0.574037
uint.go
starcoder
package avl_tree import ( "math" ) type AVLTree struct { root *Node size int } func (a *AVLTree) GetSize() int { return a.size } func (a *AVLTree) IsEmpty() bool { return a.size == 0 } func (a *AVLTree) isBalanced() bool { return a.root.isBalanced() } func (a *AVLTree) Add(data int) { a.size++ if a.root =...
golang/datastructure/tree/avl-tree/avl_tree.go
0.61231
0.442576
avl_tree.go
starcoder
package internal import ( mgl "github.com/go-gl/mathgl/mgl32" "math" ) type Camera struct { Position, WorldUp mgl.Vec3 Yaw, Pitch, Zoom float32 MovementSpeed, RotationSpeed float32 } func cos(arg float32) float32 { return float32(math.Cos(float64(arg))) } func sin(arg float32) float32 {...
internal/camera.go
0.767429
0.584212
camera.go
starcoder
package ui import ( "bytes" "fmt" ) // DefaultTableColumnSeperator is the default seperater for tabluar columns var DefaultTableColumnSeperator = "\t" // Table is a UI component that renders the data in formatted in a table type Table struct { // Rows is the collection of rows in the table Rows []*Row // MaxCe...
ui/table.go
0.683842
0.498291
table.go
starcoder
package filters import ( "fmt" "math" "strings" flowpb "github.com/cilium/cilium/api/v1/flow" ) type portMap map[uint32]uint32 // FlowContext can carry state from one filter to another. type FlowContext struct { // tcpPorts is filled in when matching a wildcarded source port for a TCP SYN. // Subsequent non-...
connectivity/filters/filters.go
0.687
0.44559
filters.go
starcoder
package coo import ( "math" ) var WebMercator = &System{ toGeographic: func(east, north float64, ell *Ellipsoid) (lon, lat float64) { if ell == nil { ell = DefaultEllipsoid } a := ell.A lon = east / a * toDeg lat = math.Atan(math.Exp(north/a))*toDeg*2 - 90 return }, fromGeographic: func(lon, lat fl...
system.go
0.656658
0.511168
system.go
starcoder
package sliceWrapper const objectTemplate = `{{range .Types}} type {{.NameTitle}}Slice struct { s []{{.Name}} } func New{{.NameTitle}}Slice() *{{.NameTitle}}Slice { return &{{.NameTitle}}Slice{} } func (v *{{.NameTitle}}Slice) Clear() { v.s = v.s[:0] } func (v *{{.NameTitle}}Slice) Equal(rhs *{{.NameTitle}}Slice...
sliceWrapper/objectTemplate.go
0.669096
0.50891
objectTemplate.go
starcoder
package ml import ( "fmt" "math" "math/rand" "strconv" cabiriaMath "github.com/liampulles/cabiria/pkg/math" ) // Split can be used to split training ang test data by a percentage. // The resulting arrays are pseudorandom in composition; not consistent // between runs. func Split(samples []Sample, split float6...
pkg/ml/common.go
0.703957
0.514949
common.go
starcoder
package indexer import ( "github.com/Jragonmiris/mathgl" ) // Note: is_near is implemented in mathgl already as FloatEqual type PackedVertex struct { Position mathgl.Vec3f UV mathgl.Vec2f Norm mathgl.Vec3f } // Only implementing the fast version func IndexVBO(vertices []mathgl.Vec3f, uvs []mathgl.Vec2...
examples/opengl-tutorial/indexer/indexer.go
0.628521
0.501465
indexer.go
starcoder
package sql import ( "fmt" "io" ) // SelectStatement represents a SQL SELECT statement. type SelectStatement struct { Fields []string TableName string } // Parser represents a parser. type Parser struct { s *Scanner buf struct { tok Token // last read token lit string // last read literal n int ...
parser.go
0.70253
0.40869
parser.go
starcoder
package k8sTest import ( "bytes" "context" "fmt" "net" "path/filepath" "time" . "github.com/cilium/cilium/test/ginkgo-ext" "github.com/cilium/cilium/test/helpers" external_ips "github.com/cilium/cilium/test/k8sT/manifests/externalIPs" . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega"...
test/k8sT/external_ips.go
0.574514
0.451629
external_ips.go
starcoder
package ring import ( "math/bits" "unsafe" ) // NTT computes the NTT of p1 and returns the result on p2. func (r *Ring) NTT(p1, p2 *Poly) { r.NumberTheoreticTransformer.Forward(r, p1, p2) } // NTTLvl computes the NTT of p1 and returns the result on p2. // The value level defines the number of moduli of the input ...
ring/ring_ntt.go
0.855791
0.66266
ring_ntt.go
starcoder
package v2 import ( "bytes" "encoding/json" ) // UnstructuredTypesEqual compares two unstructured object. func UnstructuredTypesEqual(a, b *UnstructuredTypedObject) bool { if a == nil && b == nil { return true } if a == nil || b == nil { return false } if a.GetType() != b.GetType() { return false } ra...
vendor/github.com/gardener/component-spec/bindings-go/apis/v2/unstructured.go
0.70416
0.490175
unstructured.go
starcoder
package geogoth // MultiPoint ... type MultiPoint struct { Coords [][]float64 } // NewMultiPoint creates MultiPoint func NewMultiPoint(coords [][]float64) MultiPoint { return MultiPoint{ Coords: coords, } } // Coordinates returns array of longitude, latitude of the MultiPoint func (m MultiPoint) Coordinates() i...
multipoint .go
0.900489
0.713269
multipoint .go
starcoder
package vec import ( "github.com/chewxy/math32" "github.com/itohio/EasyRobot/pkg/core/math" ) type Quaternion [4]float32 func (v *Quaternion) Sum() float32 { var sum float32 for _, val := range v { sum += val } return sum } func (v *Quaternion) Vector() Vector { return v[:] } func (v *Quaternion) Slice(s...
pkg/core/math/vec/quaternion.go
0.807954
0.514644
quaternion.go
starcoder
package a import ( "fmt" "math" ) // Represents a point in 3D space type Vector3 struct { X, Y, Z float32 } func (v Vector3) SetXYZ(x, y, z float32) { v.X = x v.Y = y v.Z = z } func NewVector3(x, y, z float32) Vector3 { return Vector3{ X: x, Y: y, Z: z, } } func (v Vector3) ToMap() SiMap { return ma...
common/a/vector.go
0.867724
0.725794
vector.go
starcoder
package algebra import ( "math" ) //EPSILON for testing floating point equality var EPSILON float64 = 0.0001 type Vector struct { tuple []float64 } //NewPoint creates a tuple with the data and appends a 1.0 to signify it is a point func NewPoint(data ...float64) *Vector { newData := append(data, 1.0) v := &Vect...
pkg/algebra/vector.go
0.826537
0.696094
vector.go
starcoder
package chart import ( "fmt" "time" util "github.com/iesreza/go-chart/util" ) // Interface Assertions. var ( _ Series = (*TimeSeries)(nil) _ FirstValuesProvider = (*TimeSeries)(nil) _ LastValuesProvider = (*TimeSeries)(nil) _ ValueFormatterProvider = (*TimeSeries)(nil) ) // TimeSeries ...
time_series.go
0.825097
0.518485
time_series.go
starcoder
package clock import "time" // Work mirrors the behaviour of Go's time package. var Work Clock func init() { Work = New() } // Now returns the current local time. func Now() time.Time { return Work.Now() } func Since(t time.Time) time.Duration { return Work.Now().Sub(t) } // Sleep pauses the current goroutine ...
clock.go
0.735737
0.423398
clock.go
starcoder
package wad import ( "fmt" "time" ) // Rate is the conversion rate. type Rate struct { // BaseCode is the rate we're converting from BaseCode string // QuoteCode is the rate we're converting to QuoteCode string // RateValue is the conversion rate RateValue float64 // Timestamp is the timestamp of the convers...
moneysocket/wad/rate.go
0.77806
0.50891
rate.go
starcoder
package exiftag const ( // Image width - SHORT or LONG (1) ImageWidth = Tiff | 0x0100 // Image height - SHORT or LONG (1) ImageLength = Tiff | 0x0101 // Number of bits per component - SHORT (3) BitsPerSample = Tiff | 0x0102 // Compression scheme - SHORT (1) Compression = Tiff | 0x0103 // Pixel compositio...
exif/exiftag/name.go
0.543348
0.470858
name.go
starcoder
// Package stat implements facilities for storing distribution sketches and updating them package stat import ( "math" ) // Moment is a streaming sketch data structure. // It keeps track of moment statistics for an incoming stream of floating point numbers. type Moment struct { sum float64 sumAbs float64 sumS...
src/circuit/kit/stat/moment.go
0.873714
0.571348
moment.go
starcoder
package restorable import ( "fmt" "image" "github.com/hajimehoshi/ebiten/v2/internal/graphicscommand" ) type pixelsRecord struct { rect image.Rectangle pix []byte mask []byte } func (p *pixelsRecord) clearIfOverlapped(rect image.Rectangle) { r := p.rect.Intersect(rect) ox := r.Min.X - p.rect.Min.X oy := ...
internal/restorable/rect.go
0.526586
0.469034
rect.go
starcoder
package gintersect // NonEmpty is true if the intersection of lhs and rhs matches a non-empty set of non-empty str1ngs. func NonEmpty(lhs string, rhs string) (bool, error) { g1, err := NewGlob(lhs) if err != nil { return false, err } g2, err := NewGlob(rhs) if err != nil { return false, err } var match bo...
vendor/github.com/yashtewari/glob-intersection/non_empty.go
0.851351
0.44089
non_empty.go
starcoder
package neuralnets import ( "math" "math/rand" log "github.com/sirupsen/logrus" "gonum.org/v1/gonum/floats" "gonum.org/v1/gonum/mat" "libs.altipla.consulting/errors" "code.ia/internal/config" ) type NeuralNetwork struct { Settings NeuralNetworkSettings WeightsHidden *mat.Dense BiasesHidden *mat.Dens...
internal/neuralnets/neural_networks.go
0.648689
0.408454
neural_networks.go
starcoder
package alt import ( "fmt" "github.com/ngjaying/ojg/gen" ) var emptySlice = []interface{}{} // Builder is a basic type builder. It uses a stack model to build where maps // (objects) and slices (arrays) add pushed on the stack and closed with a // pop. type Builder struct { stack []interface{} starts []int } ...
alt/builder.go
0.537041
0.487307
builder.go
starcoder
package p1847 import "sort" func closestRoom(rooms [][]int, queries [][]int) []int { rs := make([]Room, len(rooms)) for i, r := range rooms { rs[i] = Room{r[0], r[1]} } sort.Slice(rs, func(i, j int) bool { return rs[i].size > rs[j].size }) qs := make([]Query, len(queries)) for i, q := range queries { qs...
src/leetcode/set1000/set1000/set1800/set1840/p1847/solution.go
0.647241
0.414188
solution.go
starcoder
package api func init() { Swagger.Add("chef", `{ "swagger": "2.0", "info": { "title": "api/external/ingest/chef.proto", "version": "version not set" }, "schemes": [ "http", "https" ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/i...
components/automate-gateway/api/chef.pb.swagger.go
0.833291
0.422683
chef.pb.swagger.go
starcoder
package noarch import ( "fmt" "time" ) // TimeT is the representation of "time_t". // For historical reasons, it is generally implemented as an integral value // representing the number of seconds elapsed // since 00:00 hours, Jan 1, 1970 UTC (i.e., a unix timestamp). // Although libraries may implement this type u...
noarch/time.go
0.783368
0.544862
time.go
starcoder
package main import ( "container/list" "github.com/go-gl/gl/v4.1-core/gl" "github.com/go-gl/mathgl/mgl32" ) // MatrixStack Maps the stack of rendering matrixes type MatrixStack struct { Current *mgl32.Mat4 Stack *list.List } // MatrixUniforms Maps uniform matrixes type MatrixUniforms struct { Model ...
matrix.go
0.78695
0.402451
matrix.go
starcoder
package core import ( "math" ) // Transform is a 4x4 transformation matrix. type Transform struct { mat [4][4]Float // Matrix entries } // NewTransform returns a pointer of the Transform. func NewTransform(mat [4][4]Float) *Transform { t := new(Transform) t.mat = mat return t } // NewTransformWithElements retu...
src/core/transform.go
0.826782
0.65758
transform.go
starcoder
package disttwoatoms import ( "bufio" "errors" "fmt" "strconv" "strings" ) // readCfgFirst reads the first configuration. It reads the number of atoms, the // columns and performs the usual calculations like in readCfg. This method // saves a lot of runtime because it saves the number of columns. It is // theref...
pkg/disttwoatoms/read.go
0.609757
0.568176
read.go
starcoder
package camera import ( "image/png" "jensmcatanho/raytracer-go/math/color" "jensmcatanho/raytracer-go/math/geometry" "jensmcatanho/raytracer-go/math/sampler" "jensmcatanho/raytracer-go/tracer" "log" "os" ) // Pinhole is a camera that renders a scene with a perspective projection type Pinhole struct { Eye *...
camera/pinhole.go
0.842021
0.603844
pinhole.go
starcoder
package chart import ( "fmt" "math" ) // MinSeries draws a horizontal line at the minimum value of the inner series. type MinSeries struct { Name string Style Style YAxis YAxisType InnerSeries ValuesProvider minValue *float64 } // GetName returns the name of the time series. func (ms MinSe...
vendor/github.com/wcharczuk/go-chart/v2/min_max_series.go
0.883425
0.532425
min_max_series.go
starcoder
package orb import ( "math" ) var emptyBound = Bound{Min: Point{1, 1}, Max: Point{-1, -1}} // A Bound represents a closed box or rectangle. // To create a bound with two points you can do something like: // orb.MultiPoint{p1, p2}.Bound() type Bound struct { Min, Max Point } // GeoJSONType returns the GeoJSON type...
bound.go
0.892533
0.702505
bound.go
starcoder
package sqlparser // CloneAlterOption creates a deep clone of the input. func CloneAlterOption(in AlterOption) AlterOption { if in == nil { return nil } switch in := in.(type) { case *AddColumns: return CloneRefOfAddColumns(in) case *AddConstraintDefinition: return CloneRefOfAddConstraintDefinition(in) ca...
go/vt/sqlparser/clone.go
0.590425
0.406744
clone.go
starcoder
package main import ( "strconv" "strings" ) const ALL_CHARS = "abcdefg" // FindCountOfUniqueNumbers finds the count of unique numbers. // Unique numbers being the keys for 1, 4, 7 and 8. func FindCountOfUniqueNumbers(input []string) int { count := 0 for _, s := range input { split := strings.Split(s, " | ") ...
day8.go
0.633297
0.50653
day8.go
starcoder
package ruler import ( "reflect" "fmt" ) type node struct { // name Label string // Value Value interface{} // operation code op int // kind kind reflect.Kind // chilren node []*node } func nodeFromAny(label string, val interface{}) (r *node) { v := ValueFormat(val) switch v.(type) { case int: ...
node.go
0.553264
0.445107
node.go
starcoder
package array import( "sort" ) /* # https://leetcode.com/explore/interview/card/top-interview-questions-medium/103/array-and-strings/776/ Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solut...
interview/medium/array/3sum.go
0.579638
0.546073
3sum.go
starcoder
package parameters // parameters which define a 1-d impact oscillator system with no damping between impacts import ( "fmt" "math") type Parameters struct { ForcingFrequency float64 CoefficientOfRestitution float64 ObstacleOffset float64 Gamma float64 MaximumPeriods uint // maximum forcing periods to detect i...
dynamics/parameters/parameters.go
0.874761
0.658692
parameters.go
starcoder
package simulations import ( "context" "time" "github.com/matrix/go-matrix/p2p/discover" ) // Simulation provides a framework for running actions in a simulated network // and then waiting for expectations to be met type Simulation struct { network *Network } // NewSimulation returns a new simulation which run...
p2p/simulations/simulation.go
0.705684
0.47244
simulation.go
starcoder
package SetSimilaritySearch import ( "errors" "sort" ) // SearchIndex is a data structure supports set similarity search queries. // The algorithm is a combination of the prefix filter and position filter // techniques. type SearchIndex struct { threshold float64 simFunc function...
search.go
0.599485
0.518729
search.go
starcoder
package shp import ( "fmt" "github.com/golang/geo/r1" "github.com/golang/geo/s1" "github.com/golang/geo/s2" ) // Validator is used to validate shapes inside a shp file. type Validator struct { box s2.Rect } // MakeValidator creates a new Validator based on the constraints of a particular shp file. func MakeVal...
shp/validator.go
0.812904
0.534673
validator.go
starcoder