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 primitive import ( "fmt" "strings" "math" "github.com/fogleman/gg" "github.com/golang/freetype/raster" ) type Polygon struct { Worker *Worker Order int Convex bool MinAngle float64 SizeFactor float64 BoundsFactor int X, Y []float64 } // const m = 0 // const minAngle = 15 func NewRandomPolyg...
primitive/polygon.go
0.662141
0.47725
polygon.go
starcoder
package jin import "strconv" // Get returns the value that path has pointed. // It stripes quotation marks from string values. // Path can point anything, a key-value pair, a value, an array, an object. // Path variable can not be null, // otherwise it will provide an error message. func (p *Parser) Get(path ...strin...
parse_get.go
0.667798
0.42931
parse_get.go
starcoder
package operators import ( onnx "github.com/owulveryck/onnx-go" "gorgonia.org/gorgonia" ) // Div operator // https://github.com/onnx/onnx/blob/master/docs/Operators.md#Div type Div struct { name string } // Init of the operator; the operator does not expect any attribute; therefore, any value of attrs is silently...
operators/div.go
0.751192
0.446253
div.go
starcoder
package api func init() { Swagger.Add("iam_v2beta_policy", `{ "swagger": "2.0", "info": { "title": "components/automate-gateway/api/iam/v2beta/policy.proto", "version": "version not set" }, "schemes": [ "http", "https" ], "consumes": [ "application/json" ], "produces": [ "appli...
components/automate-gateway/api/iam_v2beta_policy.pb.swagger.go
0.627152
0.406214
iam_v2beta_policy.pb.swagger.go
starcoder
package boxlayout import "math" type Dimensions struct { X0 int X1 int Y0 int Y1 int } type Direction int const ( ROW Direction = iota COLUMN ) // to give a high-level explanation of what's going on here. We layout our windows by arranging a bunch of boxes in the available space. // If a box has children, it...
pkg/gui/boxlayout/boxlayout.go
0.52074
0.606702
boxlayout.go
starcoder
package serialization import ( "fmt" "math" "math/big" "math/bits" ) const ( maxMagLength = math.MaxInt32/32 + 1 longMask = int64(0xffffffff) ) // BigInt is a port of java.math.BigInteger with only the necessary bits. type BigInt struct { mag []int32 signum int32 } // NewBigInt creates a BigInt from ...
internal/serialization/big_int.go
0.70304
0.471467
big_int.go
starcoder
package geom import ( "reflect" "github.com/ctessum/polyclip-go" ) // A Path is a series of connected points. type Path []Point // Len returns the number of Points in the receiver. func (p Path) Len() int { return len(p) } // XY returns the coordinates of point i. func (p Path) XY(i int) (x, y float64) { retur...
polygon.go
0.821546
0.717903
polygon.go
starcoder
package urlutil import ( "net/http" "reflect" "strconv" ) // Values maps a string key to a list of values. // It is typically used for query parameters and form values. // Unlike in the http.Header map, the keys in a Values map // are case-sensitive. type Values map[string][]string // Query returns query string v...
urlutil/urlutil.go
0.765243
0.496155
urlutil.go
starcoder
package agents import ( "time" "math" "github.com/hajimehoshi/ebiten/v2" "github.com/jtbonhomme/asteboids/internal/physics" "github.com/jtbonhomme/asteboids/internal/sounds" "github.com/jtbonhomme/asteboids/internal/vector" "github.com/sirupsen/logrus" ) const ( bulletThrottle time.Duration = 200 * ti...
internal/agents/starship.go
0.625781
0.42173
starship.go
starcoder
package datum import ( "fmt" "math" "sort" "sync/atomic" "time" ) // Datum is an interface for metric datums, with a type, value and timestamp to be exported. type Datum interface { // // Type returns the Datum type. // Type() metrics.Type // ValueString returns the value of a Datum as a string. ValueStrin...
internal/metrics/datum/datum.go
0.800068
0.593668
datum.go
starcoder
package basic import ( "math" "github.com/starainrt/astro/planet" . "github.com/starainrt/astro/tools" ) func SaturnL(JD float64) float64 { return planet.WherePlanet(5, 0, JD) } func SaturnB(JD float64) float64 { return planet.WherePlanet(5, 1, JD) } func SaturnR(JD float64) float64 { return planet.WherePlane...
basic/saturn.go
0.692538
0.471649
saturn.go
starcoder
package bn256 import ( "math/big" "errors" ) // twistPoint implements the elliptic curve Y²=X³+3/ξ over GF(p²). Points are // kept in Jacobian form and T=Z² when valid. The group G₂ is the set of // n-torsion points of this curve over GF(p²) (where n = Order) type twistPoint struct { X, Y, Z, T gfP2 } var twistB ...
twist.go
0.763219
0.435841
twist.go
starcoder
package decode import ( "fmt" "math" "github.com/docker/go-units" "github.com/vmware/govmomi/vim25/types" "github.com/vmware/vic/lib/apiservers/service/models" ) func FromValueBytesMetric(m *models.ValueBytesMetric) string { v := float64(m.Value.Value) var bytes float64 switch m.Value.Units { case model...
lib/apiservers/service/restapi/handlers/decode/resources.go
0.722135
0.456107
resources.go
starcoder
package profile import "math" const ( carea = 1. // area of profile [m²] ztop = 0. // elevation of top of profile [m] nsl = 50 // number of profile sublayers geom = true // use geometric layering ) // State holds the dynamic state for a profile, that can be subdivided into multiple layers for numerica...
profile/state.go
0.635788
0.480905
state.go
starcoder
package iso20022 // Information about a securities account and its characteristics. type InvestmentAccount52 struct { // Name of the account. It provides an additional means of identification, and is designated by the account servicer in agreement with the account owner. Name *Max35Text `xml:"Nm,omitempty"` // Su...
InvestmentAccount52.go
0.684159
0.411702
InvestmentAccount52.go
starcoder
package bson import ( "fmt" "math" ) type BsonIterator struct { raw []byte length int offset int // current field elementLen int keyLen int value []byte } func bytesToInt32(b []byte) int32 { if len(b) < 4 { panic("bytesToInt32: len([]byte) < 4") } return int32(uint32(b[0]) | (uint32(b[1]...
bson/bsoniterator.go
0.639511
0.44089
bsoniterator.go
starcoder
package plan import ( "io" "reflect" "github.com/opentracing/opentracing-go" "github.com/dolthub/go-mysql-server/sql" ) // An IndexedJoin is a join that uses index lookups for the secondary table. type IndexedJoin struct { // The primary and secondary table nodes. The normal meanings of Left and // Right in ...
sql/plan/indexed_join.go
0.63341
0.466785
indexed_join.go
starcoder
package hole import ( "math" "math/rand" "strconv" "strings" ) type Node struct { op byte value int left, right *Node } func asNode(val int) *Node { return &Node{op: '=', value: val} } func randInt(a, b int) int { return rand.Intn(b-a+1) + a } func expand(node *Node) { val := node.value var...
hole/reverse-polish-notation.go
0.505371
0.443661
reverse-polish-notation.go
starcoder
package blurhash import ( "fmt" "github.com/buckket/go-blurhash/base83" "image" "image/color" "math" ) // An InvalidHashError occurs when the given hash is either too short or the length does not match its size flag. type InvalidHashError string func (e InvalidHashError) Error() string { return fmt.Sprintf("bl...
vendor/github.com/buckket/go-blurhash/decode.go
0.86792
0.453141
decode.go
starcoder
// Package sgu implements the Spatial Gating Unit (SGU). // Reference: `Pay Attention to MLPs` by Liu et al, 2021 (https://arxiv.org/pdf/2105.08050.pdf) package sgu import ( "encoding/gob" "github.com/nlpodyssey/spago/ag" "github.com/nlpodyssey/spago/initializers" "github.com/nlpodyssey/spago/mat/float" "github...
nn/sgu/model.go
0.879276
0.417093
model.go
starcoder
package tvf import ( "context" "fmt" "time" "github.com/pkg/errors" "github.com/cube2222/octosql" "github.com/cube2222/octosql/docs" "github.com/cube2222/octosql/execution" "github.com/cube2222/octosql/storage" ) type MaximumDifferenceWatermarkGenerator struct { source execution.Node timeField octosql....
execution/tvf/maximum_difference_watermark_generator.go
0.769687
0.48499
maximum_difference_watermark_generator.go
starcoder
package plaid import ( "encoding/json" ) // EarningsTotal An object representing both the current pay period and year to date amount for an earning category. type EarningsTotal struct { // Commonly used term to describe the line item. CanonicalDescription NullableString `json:"canonical_description,omitempty"` /...
plaid/model_earnings_total.go
0.816223
0.478651
model_earnings_total.go
starcoder
package main import "fmt" // Coord represents an integral coordinate type Coord struct { x int y int z int } func doDeltas() []Coord { coords := make([]Coord, 0) for x := -1; x <= 1; x++ { for y := -1; y <= 1; y++ { for z := -1; z <= 1; z++ { if x == 0 && y == 0 && z == 0 { continue } coor...
day17/space3.go
0.763924
0.445469
space3.go
starcoder
package battleships import ( "errors" "fmt" "math/rand" "regexp" "strconv" "time" ) const ( // Rows defines number of rows of the game's board Rows = 10 // Cols defines number of cols of the game's board Cols = 10 inputRegex = "^[A-J](10|[1-9])$" horizontalDirection = 0 verticalDirection = 1 ...
game.go
0.743261
0.496887
game.go
starcoder
package pinapi_old import ( _context "context" _ioutil "io/ioutil" _nethttp "net/http" _neturl "net/url" ) // Linger please var ( _ _context.Context ) // GetBetsApiService GetBetsApi service type GetBetsApiService service type apiBetsGetBetsByTypeV3Request struct { ctx _context.Context apiServi...
pinapi_old/api_get_bets.go
0.571408
0.540439
api_get_bets.go
starcoder
package vmath import ( "math" "github.com/go-gl/mathgl/mgl32" ) type Frustum struct { planes [6]fPlane fovy, aspect, near, far float32 tang, nh, nw, fh, fw float32 } type fPlane struct { N, P mgl32.Vec3 D float32 } func (f *fPlane) setPoints(v1, v2, v3 mgl32.Vec3) { aux1 := v1.Sub(v...
type/vmath/frustum.go
0.673621
0.409693
frustum.go
starcoder
package stdlib import ( "fmt" "reflect" "github.com/krotik/ecal/parser" ) /* ECALFunctionAdapter models a bridge adapter between an ECAL function to a Go function. */ type ECALFunctionAdapter struct { funcval reflect.Value docstring string } /* NewECALFunctionAdapter creates a new ECALFunctionAdapter. */ fun...
stdlib/adapter.go
0.671794
0.426083
adapter.go
starcoder
package cache import ( "sync" sharev1alpha1 "github.com/openshift/api/sharedresource/v1alpha1" "github.com/openshift/csi-driver-shared-resource/pkg/client" "k8s.io/apimachinery/pkg/labels" "k8s.io/klog/v2" ) /* Some old fashioned comments that describe what we are doing in this golang file. First, some notes ...
pkg/cache/shares.go
0.601477
0.453867
shares.go
starcoder
package adt import "container/heap" // PriorityQueue represents an ordered collection of elements that can be // accessed in a priority-first manner. Elements with a higher priority are // retrieved before elements with a lower priority. Priority is represented in // a lower-value order; the closer a priority is to z...
priority_queue.go
0.81841
0.483283
priority_queue.go
starcoder
package trank import ( "math" "sort" "github.com/algao1/basically" ) // A WGraph is an undirected graph, with nodes representing words within // a document. Edges represent the connection between words. type WGraph struct { Nodes map[string]float64 Edges map[string]map[string]int } // KWTextRank implements the...
trank/trank.go
0.784113
0.472866
trank.go
starcoder
package birch import ( "fmt" "io" "math" "time" "github.com/tychoish/birch/jsonx" ) // DC is a convenience variable provided for access to the DocumentConstructor methods. var DC DocumentConstructor // DocumentConstructor is used as a namespace for document constructor functions. type DocumentConstructor struc...
x_constructor.go
0.724578
0.41253
x_constructor.go
starcoder
package qrad import ( "math" "math/cmplx" ) type Gate struct { Matrix Matrix Name string // Draw IsBoxed bool Symbol string } func (g Gate) Operands() int { return int(math.Log2(float64(g.Matrix.Height))) } func (g Gate) IsControl() bool { return g.Symbol == "C" && g.Matrix.Height == 0 } var NotGate = ...
gates.go
0.683314
0.564579
gates.go
starcoder
package main import ( blt "bearlibterminal" "errors" ) const ( VectorColorNeutral = "white" VectorColorGood = "green" VectorColorBad = "red" VectorWhyInspect = "inspect" VectorWhyTarget = "target" ) type Vector struct { /* Vector is struct that is supposed to help with creating simple, straig...
vec.go
0.504639
0.572185
vec.go
starcoder
package mesh import ( "fmt" "geGoMetry/r3" "math" ) type helper struct { min, max r3.Vector } //UPDATE : https://stackoverflow.com/questions/18695346/how-to-sort-a-mapstringint-by-its-values type distancePair struct { vector r3.Vector distance float64 } type distancePairList []distancePair func (p distanc...
meshing/helper.go
0.632957
0.646153
helper.go
starcoder
package predicate // Bool represents a function that accepts a bool and returns a bool if the predicate is validated. type Bool func(bool) bool // Int represents a function that accepts a int and returns a bool if the predicate is validated. type Int func(int) bool // Int8 represents a function that accepts a int8 a...
functional/predicate/predicate.go
0.725065
0.899784
predicate.go
starcoder
package main import ( "fmt" "html" "io" "strings" "github.com/dave/dst" ) // GraphNode is a representation of a node in the AST graph. type GraphNode struct { Type string Value string Node dst.Node Edges []*GraphEdge // Used for keeping track of node position during rendering level int seq int } fu...
internal/vendor/github.com/segmentio/golines/graph.go
0.70304
0.417746
graph.go
starcoder
package openapi import ( "encoding/json" ) // TokenBucket Defines a token bucket with a maximum capacity (_size_), an initial burst size (_one_time_burst_) and an interval for refilling purposes (_refill_time_). The refill-rate is derived from _size_ and _refill_time_, and it is the constant rate at which the token...
src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_token_bucket.go
0.782247
0.401394
model_token_bucket.go
starcoder
package twodee import ( "github.com/go-gl/mathgl/mgl32" "image" "image/color" ) type GridItem interface { Passable() bool Opaque() bool } type Grid struct { Width int32 Height int32 BlockSize float32 points []GridItem } func NewGrid(w, h, blocksize int32) *Grid { return &Grid{ points: make...
grid.go
0.731826
0.453504
grid.go
starcoder
package bps import "math/big" // rawValue returns the row value as new big.Int instance func (b *BPS) rawValue() *big.Int { s := nilSafe(b) return new(big.Int).Set(s.value) } // PPBs returns the row value that means PPB. func (b *BPS) PPBs() *big.Int { return b.rawValue() } // PPMs returns the row value that mea...
bps/conv.go
0.885365
0.565719
conv.go
starcoder
package iso20022 // Formal document used to record a fact and used as proof of the fact that goods have been insured under an insurance policy. type InsuranceDataSet1 struct { // Identifies the insurancedata set DataSetIdentification *DocumentIdentification1 `xml:"DataSetId"` // Issuer of the certificate, typical...
InsuranceDataSet1.go
0.737631
0.404331
InsuranceDataSet1.go
starcoder
package gm32 import "fmt" type Vec2 [2]float32 func (v Vec2) Len() float32 { return Hypot(v[0], v[1]) } func (v Vec2) Normalize() Vec2 { l := 1.0 / v.Len() return Vec2{v[0] * l, v[1] * l} } func (v1 Vec2) Dot(v2 Vec2) float32 { return v1[0]*v2[0] + v1[1]*v2[1] } func (v1 Vec2) Cross(v2 Vec2) float32 { return...
gm32/vec.go
0.738386
0.582135
vec.go
starcoder
package alchemist import ( "fmt" "log" "strings" "unicode" "unicode/utf8" ) // Atom is an interface that declares certain types as atoms. type Atom interface { Parser Run(Universe) } // SimpleAtom represents a simple atom in the universe. type SimpleAtom string // Parse parses a SimpleAtom. func (a *SimpleAt...
atom.go
0.699254
0.420719
atom.go
starcoder
package reflect // This file contains a set of debugging functions that are used // by tests of reflect and some other packages. import ( "fmt" "path/filepath" r "reflect" "sort" ) // AssertEqualType gets two *Type arguments and returns nil in case they // are equal to each other and an error otherwise. func Ass...
internal/reflect/equal.go
0.67104
0.549036
equal.go
starcoder
package graphtweets import "github.com/dghubble/go-twitter/twitter" // Edges a list of edges and their occurrences type Edges struct { Source []string `json:"source"` Target []string `json:"target"` Number []int `json:"weight"` } // Nodes a list of nodes and their occurrences type Nodes struct { Name []stri...
graphtweets/utils.go
0.650911
0.45538
utils.go
starcoder
package musictheory import ( "fmt" "math" ) // Quality types const ( PerfectType QualityType = iota MajorType MinorType AugmentedType DiminishedType ) // IntervalFunc creates an interval at as specific step/degree type IntervalFunc func(int) Interval // Perfect interval func Perfect(step int) Interval { ret...
interval.go
0.7237
0.533033
interval.go
starcoder
package hexit import ( "math" "math/rand" tf "github.com/tensorflow/tensorflow/tensorflow/go" "gonum.org/v1/gonum/stat/distuv" ) // SearchNode is a node in a search tree type SearchNode struct { // Move that led to this node move Move // Total number of visits n uint32 // Value estimate from NN v float32 ...
src/search.go
0.773216
0.544499
search.go
starcoder
package tree import ( "fmt" ) // Tree is the basic struct for any tree hierarchy type Tree struct { Id string `json:"id"` Root *Node `json:"root"` } // SubordinatesResponse is the base // response for the GET subordinates route type SubordinatesResponse struct { Subordinates SubordinatesInfo `json:"subordinat...
tree/tree.go
0.754192
0.457258
tree.go
starcoder
package main import ( "sort" . "github.com/9d77v/leetcode/pkg/algorithm/unionfind" ) /* 题目:水位上升的泳池中游泳 在一个 N x N 的坐标方格 grid 中,每一个方格的值 grid[i][j] 表示在位置 (i,j) 的平台高度。 现在开始下雨了。当时间为 t 时,此时雨水导致水池中任意位置的水位为 t 。你可以从一个平台游向四周相邻的任意一个平台,但是前提是此时水位必须同时淹没这两个平台。假定你可以瞬间移动无限距离,也就是默认在方格内部游动是不耗时的。当然,在你游泳的时候你必须待在坐标方格里面。 你从坐标方格的左上平台 (0...
internal/leetcode/778.swim-in-rising-water/main.go
0.535827
0.448004
main.go
starcoder
package sqlbuilder import ( "reflect" "strconv" ) type Builder struct { //The query value bindings bindings //The Columns that should be return columns []string //The table which the query is targeting table string //Update columns update []interface{} //Insert columns ...
builder.go
0.626238
0.543166
builder.go
starcoder
package raster import ( "fmt" "strings" ) type Raster struct { Data []float64 Xsize int Ysize int Size int CellXSize float64 CellYSize float64 Nodata float64 } type Cell struct { Value *float64 Xindex int Yindex int } type Direction int const ( None Direction = 0 Right ...
raster/raster.go
0.66356
0.464659
raster.go
starcoder
package mock var example1DayForecast string = ` { "DailyForecasts": [ { "AirAndPollen": [ { "Category": "Good", "CategoryValue": 1, "Name": "AirQuality", "Type": "Ozone", "Value": 38 }, { "Category":...
mock/examples_day_forecast.go
0.687105
0.59355
examples_day_forecast.go
starcoder
Package webauthn provides server-side registration and authentication for clients using FIDO2 keys, FIDO U2F keys, tpm, etc. and is decoupled from `net/http` for easy integration with existing projects. It's modular so projects only import what is needed. Five attestation packages are available: fidou2f, androidkeysto...
webauthn.go
0.659844
0.407216
webauthn.go
starcoder
package lit import ( "bytes" "fmt" "reflect" "strconv" "xelf.org/xelf/ast" "xelf.org/xelf/bfr" "xelf.org/xelf/knd" "xelf.org/xelf/typ" ) type proxy struct { Reg *Reg typ typ.Type val reflect.Value } func newProxy(reg *Reg, t typ.Type, ptr reflect.Value) proxy { x := proxy{reg, t, ptr} if x.isptr() { ...
lit/prx.go
0.589244
0.458227
prx.go
starcoder
package pager // This package provides mapping functions to work with slices of uint // types. It allows the getting, setting and transforming of various // uint types such as uint, uint16, uint32 and uint64. Right now, this // set of functions uses the LittleEndian encoding format, but future // versions of this will...
pkg/pager/bin.go
0.896693
0.551755
bin.go
starcoder
package gollections // A Collection is a grouping of elements. type Collection interface { // Add appends new elements to the end of the collection. Add(values ...interface{}) // Clear removes all elements from the collection. Clear() // Contains checks if the collection contains all specified values. Contains(v...
interface.go
0.575707
0.529628
interface.go
starcoder
package mage import ( "image" ) const ( FLIP_X = 0 FLIP_Y = 1 ROTATE_90 = 2 ROTATE_270 = 3 ) // Crop() returns the portion of the image selected by the argument values. func (i *Image) Crop(xi, yi, xf, yf int) *Image { area := image.Rect(xi, yi, xf, yf) ...
transforms.go
0.662032
0.548855
transforms.go
starcoder
package QRMaker import ( //入力データに対してモードを識別するためにインポート "regexp" //数値から2進数文字列に変換するためにインポート "strconv" "unicode/utf8" ) func getStrLen (src string) int { return utf8.RuneCountInString(src) } func searchIntArray (array []int, value int) (index int) { for i, r := range array { if r == va...
utils.go
0.502441
0.537709
utils.go
starcoder
package scene import ( "sort" "github.com/m110/yatzy/internal/entity" ) type scoringFunc func([]entity.Die) uint func ones(dice []entity.Die) uint { return sumOfDice(dice, 1) } func twos(dice []entity.Die) uint { return sumOfDice(dice, 2) } func threes(dice []entity.Die) uint { return sumOfDice(dice, 3) } f...
internal/scene/scoring.go
0.628977
0.450782
scoring.go
starcoder
package optimizer import ( "errors" "fmt" "log" "os" "path" "strings" ) /* This file implements FlatZincModel: a class to hold a constraint problem, based on the FlatZinc format. The class can dump the constraint program to a file, using the FlatZinc specification. The class can also read solver solutions, wri...
pkg/optimizer/flatzinc_model.go
0.778565
0.403567
flatzinc_model.go
starcoder
//Package reflect contains an implementation of a parser for a reflected go structure. package reflect import ( "github.com/katydid/katydid/parser" "io" "reflect" ) type state struct { parent reflect.Value typ reflect.StructField value reflect.Value field int maxField int isLeaf bool isArray...
parser/reflect/reflect.go
0.661048
0.504761
reflect.go
starcoder
package main import ( "context" "fmt" pb "fzkprac/prac_grpc/learn_20210724/grpc_demo/route" "google.golang.org/grpc" "google.golang.org/protobuf/proto" "io" "log" "math" "net" "time" ) type routeGuideServer struct { features []*pb.Feature // 相当于假db pb.UnimplementedRouteGuidServer } // check if a point i...
prac_grpc/learn_20210724/grpc_demo/route-server/server.go
0.578567
0.430686
server.go
starcoder
package pipe import ( "fmt" "time" ) // Pipe struct represents a pipeline through which data flows type Pipe struct { Description string // a Description/name of the pipeline, used for monitoring input map[string][]float64 // data that the pipe will apply the op to sin...
pipe/pipe.go
0.708515
0.557966
pipe.go
starcoder
package stream import ( "github.com/mariomac/gostream/item" ) // Of creates an Stream from a variable number of elements that are passed as // arguments. func Of[T any](elems ...T) Stream[T] { return OfSlice(elems) } // OfSlice creates a Stream from a slice. func OfSlice[T any](elems []T) Stream[T] { return &iter...
stream/instantiate.go
0.671686
0.708792
instantiate.go
starcoder
package types import ( "errors" "fmt" gotime "time" ) // CoreTime is the internal struct type for Time. type CoreTime uint64 // ZeroCoreTime is the zero value for TimeInternal type. var ZeroCoreTime = CoreTime(0) // IsLeapYear returns if it's leap year. func (t CoreTime) IsLeapYear() bool { return isLeapYear(t....
kvsql/types/core_time.go
0.828766
0.469399
core_time.go
starcoder
package geomfn import ( "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/errors" "github.com/twpayne/go-geom" ) // Orientation defines an orientation of a shape. type Orientation int const ( // OrientationCW denotes a clockwise orientation. OrientationCW Orientation = iota // OrientationCCW ...
pkg/geo/geomfn/orientation.go
0.761361
0.440289
orientation.go
starcoder
package parse import ( "fmt" "io" "strings" yaml "gopkg.in/yaml.v3" ) type YAMLTransformer interface { Transform(node *yaml.Node) (bool, error) } type YAMLDataTransformer struct{} func (YAMLDataTransformer) Transform(node *yaml.Node) (bool, error) { if node.Tag != "!Data" { return false, nil } var query...
pkg/expr/parse/yaml.go
0.663887
0.4081
yaml.go
starcoder
package graph import ( "errors" "sync" ) type Graph struct { mu sync.RWMutex nodes map[string]*Node // A map of all the nodes in this graph, indexed by their key. } // Initializes a new graph. func New() *Graph { return &Graph{nodes: map[string]*Node{}} } // Returns the amount of nodes contained in the grap...
graph.go
0.746416
0.432243
graph.go
starcoder
package trie // Node represents each node in Trie. type Node struct { children map[rune]*Node // map children nodes isLeaf bool // current node value } // NewNode creates a new Trie node with initialized // children map. func NewNode() *Node { n := &Node{} n.children = make(map[rune]*Node) n.isLeaf =...
structure/trie/trie.go
0.759671
0.46041
trie.go
starcoder
package ast type expr struct{} func (e expr) Expr() {} // The different AST nodes available to parse. type ( // An Identifier represents a name in the variable store; evaluates to the // value of that variable. Identifier struct { expr Value string } // A Number represents a number literal. Number struct ...
ast/expressions.go
0.710929
0.587144
expressions.go
starcoder
package physics import "github.com/mokiat/gomath/sprec" const driftCorrectionAmount = float32(0.01) // TODO: Configurable? type Jacobian struct { SlopeVelocity sprec.Vec3 SlopeAngularVelocity sprec.Vec3 } func (j Jacobian) EffectiveVelocity(body *Body) float32 { return sprec.Vec3Dot(j.SlopeVelocity, body....
game/physics/jacobian.go
0.659953
0.65506
jacobian.go
starcoder
package bullet // #cgo pkg-config: bullet // #cgo windows LDFLAGS: -Wl,--allow-multiple-definition // #include "bulletglue.h" import "C" import ( "github.com/go-gl/mathgl/mgl32" "unsafe" ) type BulletPhysicsIndice C.int type BulletPhysicsSDKHandle C.plPhysicsSdkHandle type BulletDynamicWorldHandle C.plDynamicsWorld...
framework/physics/collision/bullet/bullet.go
0.69285
0.517754
bullet.go
starcoder
package metric import "time" // Recorder record rate. type Recorder struct { Runner *Runner LogType LogType Key } // MakeRecorder creates a Recorder. func MakeRecorder(logType LogType, keys []string) Recorder { return DefaultRunner.MakeRecorder(logType, keys) } // MakeRecorder creates a Recorder. func (r *Runn...
metric/metric.go
0.790045
0.559771
metric.go
starcoder
package mcp import ( "fmt" "strings" "sync" ) // UniqueKey is the data structure describing a unique key. type UniqueKey struct { // It inherits a RWMutex, which is used to modify the metadata inside the UK struct. sync.RWMutex // rowID is an integer describing the row ID of the unique key. // The row ID is a...
dm/simulator/internal/mcp/uk.go
0.590425
0.436982
uk.go
starcoder
package main type number interface { ~int | ~int32 | ~int64 | ~float32 | ~float64 | ~uint } func MaxOfType0[T number](a, b T) T { if a > b { return a } return b } func MaxOfType1[T number](a, b T) T { if a > b { return a } return b } func MaxOfType2[T number](a, b T) T { if a > b { return a } ...
generated/generics.go
0.777596
0.715958
generics.go
starcoder
package timefn import "time" // StartOfSecond returns the start of the second. func StartOfSecond(t time.Time) time.Time { return time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), 0, t.Location()) } // EndOfSecond returns the end of the second. func EndOfSecond(t time.Time) time.Time { retu...
timefn.go
0.874614
0.767516
timefn.go
starcoder
package riddles import ( "fmt" "math" "strconv" "strings" "unicode" ) // https://www.geeksforgeeks.org/string-data-structure/ // sumAllNumbers // Given a string containing alphanumeric characters, // calculate sum of all numbers present in the string. func sumAllNumbers(str string) int { if len(str) == 0 { r...
riddles/strings.go
0.742422
0.404684
strings.go
starcoder
package tree /** ** Approach: Use the feature of heap ** - Make a heap with all items in the array. According to heap's feature, the root item is the biggest. ** - Swap the root with the last item i in the heap. Then consider item i as being removed from the heap. ** - Make the rest of i - 1 items to be a heap again. ...
basic/tree/Heap.go
0.752104
0.656486
Heap.go
starcoder
package bit import ( "math/big" ) // A bit array. type Array struct { *big.Int } // NewArray allocates and returns a new Bits set to x. func NewArray(x int64) *Array { return &Array{big.NewInt(x)} } // Count counts the number of set bits in b. func (b *Array) Count() (c int) { for _, v := range b.Bits() { c +...
bit/bit.go
0.762866
0.479565
bit.go
starcoder
package forGraphBLASGo import ( "github.com/intel/forGoParallel/parallel" "github.com/intel/forGoParallel/pipeline" "github.com/intel/forGoParallel/psort" "sort" "sync" ) type vectorAssign[D any] struct { u *vectorReference[D] indices []int index func(j int) (i int, ok bool) } func vectorIndexLookup(...
functional_Vector_ComputedAssign.go
0.54698
0.439146
functional_Vector_ComputedAssign.go
starcoder
package openapi import ( "encoding/json" ) // Status The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error messag...
internal/openapi/model_status.go
0.793986
0.479016
model_status.go
starcoder
package codewords var adjectives = []string{ "abactinal", "abandoned", "abashed", "abasic", "abatable", "abatic", "abaxial", "abbatial", "abbreviated", "abdicable", "abdominal", "abdominous", "abdominovesical", "abducent", "abducting", "abecedarian", ...
adjectives.go
0.501465
0.571587
adjectives.go
starcoder
package services type InstanceTypeBody struct { InstanceTypes []InstanceType } type InstanceType struct { InstanceType string VCpuInfo VcpuInfo MemoryInfo MemoryInfo } type VcpuInfo struct { DefaultVCpus int64 } type MemoryInfo struct { SizeInMiB int64 } func GetInstanceTypesJson() []byte { return []byte(` ...
services/InstanceTypes.go
0.521227
0.439386
InstanceTypes.go
starcoder
package main import ( "image" "image/color" "math" "sync" ) // A Vec3 represents three-component vector. type Vec3 [3]float64 // Length returns length (magnitude) of x. func (x *Vec3) Length() float64 { return math.Sqrt(x.Length2()) } // Length2 returns squared length of x. func (x *Vec3) Length2() float64 { ...
2018/2018090701/main.go
0.747708
0.547646
main.go
starcoder
package riksbank import ( "time" "github.com/zeeraw/riksbank/currency" "github.com/zeeraw/riksbank/period" ) // RateGroup represents a group for a rate type RateGroup struct { ID string Name string } // RateSeries represents a series for a rate type RateSeries struct { ID string Name string } // Rate re...
types.go
0.581778
0.674339
types.go
starcoder
package compiler import ( "fmt" "ok/ast" "ok/instruction" "ok/lexer" "strings" ) func getBinaryInstruction(op string, left, right, result string) (instruction.Instruction, string) { switch op { case "data + data": return &instruction.Combine{Left: left, Right: right, Result: result}, "data" case "data += d...
compiler/binary.go
0.5794
0.582075
binary.go
starcoder
package main import ( "fmt" "math" "strings" "time" ) const Tau = 2 * math.Pi func DegToRad(deg float64) float64 { return deg * Tau / 360 } func RadToDeg(rad float64) float64 { return rad * 360 / Tau } // func DegToRad(deg float64) float64 { // return deg * math.Pi / 180 // } // func RadToDeg(rad float64) ...
doublepend/util.go
0.692954
0.479321
util.go
starcoder
package bitops import "fmt" // real implementation for Extract32 and GetField32 func extract32(value uint32, start uint, length uint) (uint32, error) { return (value >> start) & ( ^uint32(0) >> (32 - length)), nil } // real implementation for Extract64 and GetField64 func extract64(value uint64, start uint, leng...
bitops.go
0.636918
0.542984
bitops.go
starcoder
// In some languages it's idiomatic to use [generic](http://en.wikipedia.org/wiki/Generic_programming) // data structures and algorithms. Go does not support // generics; in Go it's common to provide collection // functions if and when they are specifically needed for // your program and data types. // Here are some ...
collection-function.go
0.823612
0.578002
collection-function.go
starcoder
// Interface to ws2811 chip (neopixel driver). Make sure that you have // ws2811.h and pwm.h in a GCC include path (e.g. /usr/local/include) and // libws2811.a in a GCC library path (e.g. /usr/local/lib). // See https://github.com/jgarff/rpi_ws281x for instructions package ws2811 import "github.com/pkg/errors" cons...
ws2811.go
0.575588
0.410402
ws2811.go
starcoder
package assert import ( "fmt" "testing" "github.com/slcjordan/poc" ) type ListGames struct { assertion *Assertion cursorLimitCheckers []Int32Checker cursorOffsetCheckers []Int32Checker Games SavedGameSummaryArray1D } func newListGames(assertion *Assertion) ListGames { return ListGames{ asser...
test/assert/service.go
0.658308
0.639117
service.go
starcoder
package mapval import ( "fmt" "strings" "time" "github.com/stretchr/testify/assert" ) // KeyPresent checks that the given key is in the map, even if it has a nil value. var KeyPresent = IsDef{name: "check key present"} // KeyMissing checks that the given key is not present defined. var KeyMissing = IsDef{name:...
libbeat/common/mapval/is_defs.go
0.710226
0.468791
is_defs.go
starcoder
package main import ( "bufio" "fmt" "math/rand" "os" "strconv" "strings" "time" ) // Piece is encoded as an int. type Piece int // Board is a slice of Pieces. type Board []Piece // Standard board dimensions 7x6. const ( boardWidth = 7 boardHeight = 6 numSimulations = 1000 ) // Map names to Piece e...
main.go
0.731922
0.546194
main.go
starcoder
package gocudnn /* #include <cudnn.h> */ import "C" import ( "unsafe" "github.com/dereklstinson/cutil" ) //FindRNNForwardInferenceAlgorithmEx finds the inference algorithmEx func (r *RNND) FindRNNForwardInferenceAlgorithmEx( handle *Handle, xD []*TensorD, //Input. An array of fully packed tensor descriptors desc...
cudnnRNN_algofindfw.go
0.623262
0.438364
cudnnRNN_algofindfw.go
starcoder
package dinerogo import ( "errors" "fmt" "math" ) // GetAmount : Get the amount of the dinero object func (d *dinero) GetAmount() int64 { return d.amount } // GetCurrency : Get currency of the Dinero Obj func (d *dinero) GetCurrency() string { return d.currency } // GetPrecision : Get the decimal precision of ...
methods.go
0.747616
0.474083
methods.go
starcoder
package processor import ( "encoding/json" "strconv" "time" "github.com/Jeffail/benthos/v3/lib/condition" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/message/tracing" "github.com/Jeffail/benthos/v3/lib/metrics" "github.com/Jeffail/benthos/v3/lib/types" olog "github.com/opentrac...
lib/processor/switch.go
0.731346
0.591841
switch.go
starcoder
package line import ( "bufio" "io" "strings" "github.com/influxdata/flux" "github.com/influxdata/flux/execute" "github.com/influxdata/flux/memory" "github.com/influxdata/flux/values" ) // ResultDecoder decodes raw input strings from a reader into a flux.Result. // It uses a separator to split the input into t...
line/result.go
0.797517
0.405625
result.go
starcoder
package mxplatformgo import ( "encoding/json" ) // ChallengesResponseBody struct for ChallengesResponseBody type ChallengesResponseBody struct { Challenges []ChallengeResponse `json:"challenges,omitempty"` Pagination *PaginationResponse `json:"pagination,omitempty"` } // NewChallengesResponseBody instantiates a ...
model_challenges_response_body.go
0.741861
0.486941
model_challenges_response_body.go
starcoder
package assertlog import ( "strings" "time" "github.com/stretchr/testify/assert" ) type Source interface { Logs() string } type TestingT interface { Errorf(format string, args ...interface{}) FailNow() } type Service struct { test TestingT source func() string curr func() string ticker *time.Ticker }...
test/pkg/assertlog/assertlog.go
0.589362
0.432603
assertlog.go
starcoder
package jce import ( "reflect" "strconv" "github.com/elap5e/penguin/pkg/bytes" "github.com/elap5e/penguin/pkg/log" ) func Marshal(v any, opts ...bool) ([]byte, error) { simple := false if len(opts) > 0 { simple = opts[0] } e := &encoder{Buffer: bytes.NewBuffer([]byte{})} err := e.marshal(v, simple) if ...
pkg/encoding/jce/encode.go
0.532425
0.474692
encode.go
starcoder
package xydata import ( "github.com/Akkurate/utils/numf" "github.com/Akkurate/utils/numi" ) // Length of data func (xy *XY) Len() int { xy.Error = "" return len(xy.Map) } // Replaces XY pair from given index. func (xy *XY) ReplaceXY(x, y float64, i int) { if xy.isBadindexing(i) { return } xy.data[xy.Map[i...
xydata/basic.go
0.679817
0.507873
basic.go
starcoder