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 main import ( "fmt" "math" "os" ) const ( MarsGravity = -3.711 MaxHSpeed = 20 MaxVSpeed = 40 ) func main() { defer func() { if r := recover(); r != nil { d("ERROR: %v", r) } }() (&lander{}).Land() } func d(format string, a ...interface{}) { fmt.Fprintln(os.Stderr, fmt.Sprintf(format, a...))...
very_hard/Mars_Lander_Ep_3/mars.go
0.577257
0.513485
mars.go
starcoder
package cache import ( "time" ) // Cache is a representation of any cache store that has keys and values type Cache interface { // Purge is used to completely clear the cache. Purge() // Add adds the given key and value to the store without an expiry. Add(key, value interface{}) // AddWithDefaultExpires adds...
services/cache/cache.go
0.701304
0.473779
cache.go
starcoder
package snomed import ( "sync" ) // NaiveCache is an fairly naive in-memory cache used for development. // It is designed to store arbitrary SNOMED-CT entities such as Concepts, Descriptions and Relationships. // To make it easier to use, there are convenience methods to do the type-casting to put and get objects of...
snomed/cache.go
0.527803
0.419886
cache.go
starcoder
package validation import ( "fmt" "reflect" "time" ) var ( // ErrMinGreaterEqualThanRequired is the error that returns when a value is less than a specified threshold. ErrMinGreaterEqualThanRequired = NewError("validation_min_greater_equal_than_required", "must be no less than {{.threshold}}") // ErrMaxLessEqu...
vendor/github.com/go-ozzo/ozzo-validation/v4/minmax.go
0.814643
0.520131
minmax.go
starcoder
package xyml import ( "encoding/base64" "strconv" "time" "gopkg.in/yaml.v3" ) // NewBinaryNode returns a new binary typed YAML node with the given content. func NewBinaryNode(v []byte) *yaml.Node { return &yaml.Node{ Kind: yaml.ScalarNode, Tag: TagBinary, Value: base64.StdEncoding.EncodeToString(v), }...
v1/pkg/xyml/make.go
0.814348
0.597197
make.go
starcoder
package function import ( "fmt" "github.com/dolthub/go-mysql-server/sql" ) // Explode is a function that generates a row for each value of its child. // It is a placeholder expression node. type Explode struct { Child sql.Expression } var _ sql.FunctionExpression = (*Explode)(nil) // NewExplode creates a new E...
sql/expression/function/explode.go
0.762424
0.538741
explode.go
starcoder
package onshape import ( "encoding/json" ) // BTBodyTypeFilter112AllOf struct for BTBodyTypeFilter112AllOf type BTBodyTypeFilter112AllOf struct { BodyType *string `json:"bodyType,omitempty"` BtType *string `json:"btType,omitempty"` } // NewBTBodyTypeFilter112AllOf instantiates a new BTBodyTypeFilter112AllOf objec...
onshape/model_bt_body_type_filter_112_all_of.go
0.680348
0.521471
model_bt_body_type_filter_112_all_of.go
starcoder
package rbtree import ( "constraints" "github.com/modern-dev/gtl/utility" ) const ( red color = iota black ) type ( RBTree[T comparable] struct { root *nodeHandle[T] nilNode *nodeHandle[T] cmpInst utility.Compare[T] size int dupl bool } nodeHandle[T any] struct { col color left *...
containers/rbtree/redblacktree.go
0.795062
0.59749
redblacktree.go
starcoder
package model import ( "github.com/hashicorp/hcl/v2" "github.com/pulumi/pulumi/sdk/go/common/util/contract" "github.com/zclconf/go-cty/cty" ) // Traversable represents an entity that can be traversed by an HCL2 traverser. type Traversable interface { // Traverse attempts to traverse the receiver using the given ...
pkg/codegen/hcl2/model/traversable.go
0.735452
0.431464
traversable.go
starcoder
package formats import "errors" type Z80 struct { cpu CpuState ula UlaState mem [48 * 1024]byte samRom bool issue2_emulation bool doubleInterruptFrequency bool videoSynchronization byte // 0..3 joystick byte // 0..3 } const ( _Z80_V1_HEADER_SIZE = 30 _Z80_V2_...
formats/Z80.go
0.590189
0.475118
Z80.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // ReferencedObject type ReferencedObject struct { // Stores additional data not described in the OpenAPI description found when deserializing. Can be used fo...
models/referenced_object.go
0.694303
0.407098
referenced_object.go
starcoder
package graph import ( i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization" ) // WorkbookChartDataLabels type WorkbookChartDataLabels struct { Entity // Represents the format of chart data labels, which includes fill and font formatt...
models/microsoft/graph/workbook_chart_data_labels.go
0.694095
0.531696
workbook_chart_data_labels.go
starcoder
// Command custommetric creates a custom metric and writes TimeSeries value // to it. It writes a GAUGE measurement, which is a measure of value at a // specific point in time. This means the startTime and endTime of the interval // are the same. To make it easier to see the output, a random value is written. // When ...
monitoring/custommetric/custommetric.go
0.782746
0.461381
custommetric.go
starcoder
package linear import ( "fmt" "math" ) const ( sgn_mask_float = 0x80000000 ) var ( positive_zero_float64 float64 = 0.0 negative_zero_float64 float64 = -positive_zero_float64 positive_zero_float64_bits = math.Float64bits(positive_zero_float64) negative_zero_float64_bits = math.Float64...
utils.go
0.710327
0.519704
utils.go
starcoder
package viz import ( "image/color" "github.com/anki/goverdrive/phys" "github.com/anki/goverdrive/robo/track" ) const ( // Supported GameShape types // Note that a thick line works as a rectangle. Boo-yeah! shapeLine = 0 shapeCirc = 1 numShapes = 2 ) // GameShape defines a flexible container for specifying ...
goverdrive/viz/gameshape.go
0.752468
0.439988
gameshape.go
starcoder
package systems import ( "github.com/emctague/go-loopy/ecs" "log" ) // Transform is a component which represents the position of some entity. type Transform struct { X float64 Y float64 Rotation float64 Width float64 Height float64 ParentID uint64 // This transform will follow all the same ...
systems/transform.go
0.620047
0.526099
transform.go
starcoder
package pgdialect import ( "database/sql/driver" "encoding/hex" "fmt" "reflect" "strconv" "time" "unicode/utf8" "github.com/uptrace/bun/dialect" "github.com/uptrace/bun/schema" ) var ( driverValuerType = reflect.TypeOf((*driver.Valuer)(nil)).Elem() stringType = reflect.TypeOf((*string)(nil)).Elem() ...
dialect/pgdialect/append.go
0.517571
0.411939
append.go
starcoder
package ec import ( "encoding/hex" "fmt" "math/big" ) // p is a prime number of secp256k1. // http://www.secg.org/sec2-v2.pdf var p, _ = new(big.Int).SetString("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16) // Point is a coordinate of elliptic curve. type Point struct { X *big.Int Y *bi...
ec/ec.go
0.728265
0.500793
ec.go
starcoder
package chart import "fmt" // Interface Assertions. var ( _ Series = (*ContinuousSeries)(nil) _ FirstValuesProvider = (*ContinuousSeries)(nil) _ LastValuesProvider = (*ContinuousSeries)(nil) ) // ContinuousSeries represents a line on a chart. type ContinuousSeries struct { Name string Style Style...
continuous_series.go
0.831827
0.554953
continuous_series.go
starcoder
package dataframe // ColumnHeader helps you manipulate column names type ColumnHeader struct { columns map[string]bool } // Columns create a ColumnHeader from a list of column names. func Columns(names ...string) ColumnHeader { result := make(map[string]bool) for _, col := range names { result[col] = true ...
dataframe/column_header.go
0.875694
0.511839
column_header.go
starcoder
package datadog import ( "encoding/json" "time" ) // UsageLambdaHour Number of lambda functions and sum of the invocations of all lambda functions for each hour for a given organization. type UsageLambdaHour struct { // Contains the number of different functions for each region and AWS account. FuncCount *int64 ...
api/v1/datadog/model_usage_lambda_hour.go
0.738009
0.430626
model_usage_lambda_hour.go
starcoder
package sshutil // Variables used to hold template data. const ( TypeKey = "Type" KeyIDKey = "KeyID" PrincipalsKey = "Principals" ExtensionsKey = "Extensions" CriticalOptionsKey = "CriticalOptions" TokenKey = "Token" InsecureKey = "Insecure" ...
vendor/go.step.sm/crypto/sshutil/templates.go
0.702938
0.426322
templates.go
starcoder
package asm import ( "fmt" "github.com/llir/ll/ast" "github.com/llir/llvm/ir" "github.com/llir/llvm/ir/types" "github.com/pkg/errors" ) // === [ Create IR ] =========================================================== // newExtractElementInst returns a new IR extractelement instruction (without // body but with...
asm/inst_vector.go
0.578567
0.413714
inst_vector.go
starcoder
package mpa // A reservoirReader is an intermediate buffer for the main data stream in Layer // III. Before the decoder starts reading the main data for a frame, it makes // sure all main data between the byte pointed by main_data_begin and the last // byte of the frame being decoded is in the reservoir. Thus, the re...
vendor/github.com/korandiz/mpa/reservoirreader.go
0.628977
0.611643
reservoirreader.go
starcoder
package promql import ( "math" ) // Function represents a function of the expression language and is // used by function nodes. type Function struct { Name string ArgTypes []ValueType Variadic int ReturnType ValueType } // Calculate the trend value at the given index i in raw data d. // This is somew...
vendor/github.com/influxdata/promql/v2/functions.go
0.747155
0.781247
functions.go
starcoder
package mercator import ( "math" ) const ( tileSize = 256.0 initialResolution = 2 * math.Pi * 6378137 / tileSize originShift = 2 * math.Pi * 6378137 / 2 ) func round(a float64) float64 { if a < 0 { return math.Ceil(a - 0.5) } return math.Floor(a + 0.5) } // Resolution calculates the resoluti...
mercator.go
0.890853
0.587085
mercator.go
starcoder
package utils import "fmt" /* A frequency distribution for the outcomes of an experiment. A frequency distribution records the number of times each outcome of an experiment has occurred. For example, a frequency distribution could be used to record the frequency of each word type in a document. Formally, a frequen...
utils/frequency_dist.go
0.88397
0.72227
frequency_dist.go
starcoder
package main type PlayerState struct { score int position int moving string // Can be "no", "up" or "down" } type BallState struct { position struct { x int y int } direction struct { x bool y bool } } type GameState struct { inProgress bool player1 PlayerState player2 PlayerState ball ...
backend/state.go
0.602062
0.422147
state.go
starcoder
package internal type TrapezoidSet map[*Trapezoid]struct{} // Use a query graph to split a set of polygons into monotone polygons. func ConvertToMonotones(list PolygonList) PolygonList { // TODO: QueryGraph should natively support adding all of the polygons at once graph := &QueryGraph{} for _, polygon := range li...
internal/split_monotones.go
0.550849
0.706912
split_monotones.go
starcoder
Minimum Phase Bandwidth Limited Steps See: https://www.experimentalscene.com/articles/minbleps.php https://www.cs.cmu.edu/~eli/papers/icmc01-hardsync.pdf */ //----------------------------------------------------------------------------- package core import ( "math" "math/cmplx" ) //-----------------------------...
core/minblep.go
0.803482
0.554772
minblep.go
starcoder
package geometry import ( "math" "github.com/go-gl/mathgl/mgl32" ) type ArcSegment struct { center mgl32.Vec2 radius float32 angleStart float32 angleEnd float32 } // Solves the quadratic equation, assuming that a != 0 // Returns the listing of real results (0 to 2) func solveQuadraticReals(a, b, c f...
voxelli/geometry/arcSegment.go
0.865863
0.684149
arcSegment.go
starcoder
package codegen import "strings" type goFuncValue struct { name string args []Value } // Len creates a new function call of the Go built-in function `len()` func Len(val Value) *goFuncValue { return newGoFunc("len", val) } // MakeSlice creates a new function call of the Go built-in function `make()` for an empty...
value_goFunc.go
0.833087
0.455683
value_goFunc.go
starcoder
package internal import ( "errors" "time" ) //TimeOfDay represents the time of day type TimeOfDay struct { hour, minute, second int d time.Duration } const shortForm = "15:04:05" var errParseTime = errors.New("Time must be in the format HH:MM:SS") //NewTimeOfDay returns a newly initialized T...
vendor/github.com/quickfixgo/quickfix/internal/time_range.go
0.839208
0.664173
time_range.go
starcoder
package constraints import ( "github.com/zimmski/tavor/token" ) // Optional implements a constraint and optional token which references another token which can be de(activated) type Optional struct { token token.Token value bool reducing bool reducingOriginalValue bool } // NewOptional returns a n...
token/constraints/optional.go
0.900666
0.534552
optional.go
starcoder
package stats import ( "math" "math/rand" "strings" "time" ) // NormPpfRvs generates random variates using the Point Percentile Function. // For more information please visit: https://demonstrations.wolfram.com/TheMethodOfInverseTransforms/ func NormPpfRvs(loc float64, scale float64, size int) []float64 { var to...
norm.go
0.767777
0.67882
norm.go
starcoder
package operator import ( "bytes" "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/encoding" "github.com/matrixorigin/matrixone/pkg/vm/process" ) var r...
pkg/sql/plan2/function/operator/ne.go
0.576423
0.417746
ne.go
starcoder
package fil import "github.com/rannoch/cldr" var calendar = cldr.Calendar{ Formats: cldr.CalendarFormats{ Date: cldr.CalendarDateFormat{Full: "EEEE, MMMM d, y", Long: "MMMM d, y", Medium: "MMM d, y", Short: "M/d/yy"}, Time: cldr.CalendarDateFormat{Full: "h:mm:ss a zzzz", Long: "h:mm:ss a z", Medium: "h:m...
resources/locales/fil/calendar.go
0.550366
0.441553
calendar.go
starcoder
package gabi import ( "crypto/rand" "math/big" ) // CLSignature is a data structure for holding a Camenisch-Lysyanskaya signature. type CLSignature struct { A *big.Int E *big.Int `json:"e"` V *big.Int `json:"v"` KeyshareP *big.Int `json:"KeyshareP"` // R_0^{keysharesecret}, necessary fo...
clsignature.go
0.628863
0.467028
clsignature.go
starcoder
package geoutil import ( "errors" "github.com/hiendv/geojson/pkg/util" "github.com/paulmach/orb" "github.com/paulmach/orb/geojson" ) const ( geometryMultiPolygon = "MultiPolygon" geometryPolygon = "Polygon" ) // RewindFeatureCollection rewinds a GeoJSON feature collection. // The second parameter is the ...
pkg/geoutil/rewind.go
0.774583
0.421492
rewind.go
starcoder
package continuous import ( "github.com/jtejido/ggsl/specfunc" "github.com/jtejido/linear" "github.com/jtejido/stats" "github.com/jtejido/stats/err" smath "github.com/jtejido/stats/math" "math" "math/rand" ) // Gamma distribution // https://en.wikipedia.org/wiki/Gamma_distribution type Gamma struct { baseCont...
dist/continuous/gamma.go
0.798344
0.478894
gamma.go
starcoder
// D50 illuminant conversion functions package white // D50_A functions func D50_A_Bradford(xs, ys, zs float64) (xd, yd, zd float64) { m := [3][3]float64{ {1.1573713, 0.0872411, -0.1268788}, {0.1199410, 0.9219445, -0.0455568}, {-0.0200278, 0.0303599, 0.4178345}} xd = m[0][0]*xs + m[0][1]*ys + m[0][2]*zs yd ...
f64/white/d50.go
0.5083
0.578597
d50.go
starcoder
package golgi import ( "github.com/pkg/errors" G "gorgonia.org/gorgonia" "gorgonia.org/tensor" ) var ( _ Layer = (*layerNorm)(nil) ) // layerNorm performs layer normalization as per https://arxiv.org/abs/1607.06450 type layerNorm struct { FC epsNode *G.Node eps float64 flops int computeFLOPs boo...
norm.go
0.727492
0.442155
norm.go
starcoder
package graphite import ( "fmt" "strconv" ) // Metric is an interface to be able to create new metric types easily. // Each metric must have some methods to be able to be used by the Aggregator. type Metric interface { // Update receives a generic value through interface{} to update its internal value. Update(in...
metrics.go
0.848894
0.417093
metrics.go
starcoder
package chromath // RGBTransformer allows tranforms from a user-defined RGB color space to XYZ with optional scaling and adaptation type RGBTransformer struct { ws *RGBSpace compander Compander transform, transformInv Matrix inScaler Scaler outScale ...
vendor/github.com/jkl1337/go-chromath/rgb.go
0.91323
0.547646
rgb.go
starcoder
package matcher import ( "fmt" "log" "math" ) //A Pair is the basic thing that makes up a match type Pair struct { a string b string } //NewPair creates a new pairing between to items func NewPair(a, b string) Pair { return Pair{a: a, b: b} } //Eql returns true if the two pairs are the same //A Pair is the s...
matcher/matches.go
0.696887
0.444203
matches.go
starcoder
package dsa type BSTNode struct { Elem int left *BSTNode right *BSTNode } type BinarySearchTree struct { root *BSTNode } func (bst *BinarySearchTree) replace(oldNode, newNode, parent *BSTNode) { if parent == nil { bst.root = newNode } else { if parent.left == oldNode { parent.left = newNode } else {...
data-structure/golang/binary_search_tree.go
0.59796
0.447158
binary_search_tree.go
starcoder
package fbe import "math" // Fast Binary Encoding buffer based on dynamic byte array type Buffer struct { // Bytes memory buffer data []byte // Bytes memory buffer size size int // Bytes memory buffer offset offset int } // Create an empty buffer func NewEmptyBuffer() *Buffer { return &B...
projects/Go/proto/fbe/Buffer.go
0.857112
0.599749
Buffer.go
starcoder
package main var schemas = ` { "API": { "createAsset": { "description": "Create an asset. One argument, a JSON encoded event. AssetID is required with zero or more writable properties. Establishes an initial asset state.", "properties": { "args": { ...
contracts/industry/building/building_sensor_hyperledger/schemas.go
0.849441
0.600452
schemas.go
starcoder
package configifytest import ( "time" "github.com/robsignorelli/configify" "github.com/stretchr/testify/suite" ) // SourceSuite is a testify suite that adds some helpers for asserting whether or not the // source you're testing has a specific value in it. type SourceSuite struct { suite.Suite Source configify.S...
configifytest/source_suite.go
0.694406
0.626767
source_suite.go
starcoder
package brotli /* Lookup table to map the previous two bytes to a context id. There are four different context modeling modes defined here: contextLSB6: context id is the least significant 6 bits of the last byte, contextMSB6: context id is the most significant 6 bits of the last byte, contextUTF8: second-order...
vendor/github.com/andybalholm/brotli/context.go
0.536556
0.585753
context.go
starcoder
package util import ( "fmt" "sort" ) func LessIntSlice(l, r []int) bool { return Ints(l).Less(r) } func SortIntSlice(intSlices [][]int) { IntsArray(intSlices).Sort() } type Int int func (in Int) Compare(with int) int { switch { case int(in) < with: return -1 case int(in) > with: return -1 } return 0 }...
util/intslice.go
0.529507
0.446012
intslice.go
starcoder
package curl import ( "math" "github.com/iotaledger/iota.go/consts" ) const rotationOffset = 364 // stateRotations stores the chunk offset and the bit shift of the state after each round. // Since the modulo operations are rather costly, they are pre-computed. var stateRotations [NumRounds]struct { offset, shift...
curl/transform.go
0.726329
0.622287
transform.go
starcoder
package imageoutput import "math" // MappedCoordinate stores the journey of an individual coordinate. type MappedCoordinate struct { inputImageX int inputImageY int patternViewportX float64 patternViewportY float64 transformedX float64 transformedY float64 satisfiedFilter bool hasMappedCoordinates boo...
entities/imageoutput/mappedcoordinate.go
0.943686
0.588712
mappedcoordinate.go
starcoder
package bits import ( "fmt" ) // A new Gate is defined by a truth table, or by a choicetable type ( Bit int // bit, as integer Bits []Bit // input bits, or output bits // Multiple possible outputs, with equal probability Choices []Bits // A logic gate with multiple inputs and one output OneToManyGate func...
gate.go
0.691706
0.503235
gate.go
starcoder
package sweetiebot import ( "fmt" "strconv" "strings" "github.com/bwmarrin/discordgo" ) type PollModule struct { } func (w *PollModule) Name() string { return "Polls" } func (w *PollModule) Register(info *GuildInfo) {} func (w *PollModule) Commands() []Command { return []Command{ &PollCommand{}, &Create...
sweetiebot/poll_command.go
0.708313
0.420659
poll_command.go
starcoder
package main import ( "fmt" "github.com/Ullaakut/aoc19/pkg/aocutils" "github.com/fatih/color" ) type Cell struct { wireID int r rune } type Grid struct { g map[aocutils.Vector2D]Cell formats map[rune]func(string, ...interface{}) string } func NewGrid(formats map[rune]func(string, ...interface{}) strin...
Day03/Part1/grid.go
0.763836
0.501526
grid.go
starcoder
package utils /** * These utilities format output in a variety of ways. * * The goal is to have multiple methods of output so that it's easy to script the CLI * in whatever way a user wants. Currently we just implement JSON output, but we plan * to implement a subset of the JSONPath spec so that we can implement...
photon/utils/formatting.go
0.718594
0.469946
formatting.go
starcoder
package coinharness import ( "fmt" "github.com/jfixby/coin" "github.com/jfixby/pin" "reflect" "testing" "time" ) // JoinType is an enum representing a particular type of "node join". A node // join is a synchronization tool used to wait until a subset of nodes have a // consistent state with respect to an attri...
helpers.go
0.66454
0.426381
helpers.go
starcoder
package minimalisp // Expression is the interface all types of expressions must fulfil. type Expression interface { Accept(visitor visitor) (interface{}, error) } // Visitor is the interface which an interpreter has to fulfil. type visitor interface { visitLiteralExpr(literalExpr *LiteralExpr) (interface{}, error) ...
ast.go
0.71423
0.42185
ast.go
starcoder
package rui import ( "fmt" "strings" ) const ( // Radius is the SizeUnit view property that determines the corners rounding radius // of an element's outer border edge. Radius = "radius" // RadiusX is the SizeUnit view property that determines the x-axis corners elliptic rounding // radius of an element's oute...
radius.go
0.713531
0.549882
radius.go
starcoder
package processor import ( "time" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/message" "github.com/Jeffail/benthos/v3/lib/metrics" "github.com/Jeffail/benthos/v3/lib/response" "github.com/Jeffail/benthos/v3/lib/types" ) //---------------------------------------------------------...
lib/processor/split.go
0.781205
0.440469
split.go
starcoder
package fixture import ( "testing" "strconv" "reflect" ) type Test func(t *testing.T) type F func(p Param) interface{} type Ft struct { *testing.T params ParamReader fixture F data []interface{} results *Results } func New(t *testing.T, f F, p ParamReader, r *Results) *Ft { return &Ft{ T: t, para...
fixture/fixture.go
0.670069
0.602851
fixture.go
starcoder
package edges import ( "image" "image/color" "image/draw" ) /* * the four dials / knobs you can play with * to control the results from this algorithm */ const ( WindowSize = 7 Ratio = 0.80 SmoothingFactor = 0.94 ThinningFactor = 0 ) type Detector struct { original ...
edges.go
0.710327
0.438364
edges.go
starcoder
package schemes import "image/color" // PGAitch is a gradient color scheme from a dismal dark to a bright // yellow. var PGAitch []color.Color func init() { PGAitch = []color.Color{ color.RGBA{R: 0xff, G: 0xfe, B: 0xa5, A: 0xff}, color.RGBA{R: 0xff, G: 0xfe, B: 0xa4, A: 0xff}, color.RGBA{R: 0xff, G: 0xfd, B: ...
schemes/pgaitch.go
0.550607
0.639229
pgaitch.go
starcoder
package main // Rate Limiting is an important mechanism for controlling resource utilization and maintaining // quality of service. Go elegantlt supports rate limiting with Goroutines, channels and tickers import ( "fmt" "time" ) func main() { // First we'll look at basic rate limiting. // Suppose we want to li...
cmd/concurrency/rate-limiting/rate-limiting.go
0.617628
0.414603
rate-limiting.go
starcoder
package tree_node import ( "fmt" "os" ) // Postcondition: Return value is the tree node with target value, if it cannot // find any node with matching value then return NULL. func TreeSearch(root *TreeNode, target int) *TreeNode { if root == nil { // Base case return root } if root.item == target { // Fo...
pkg/tree_node/tree_functions.go
0.80112
0.57687
tree_functions.go
starcoder
package pos import ( "bytes" "fmt" ) // Pos contains the position of a lexical Item type Pos struct { stack []int } // New returns a new position before the first symbol func New() *Pos { p := &Pos{ stack: make([]int, 0, 8), } return p.Push(0) } // From returns a Pos derived from the position stack, `stack`...
lex/item/pos/pos.go
0.75183
0.618176
pos.go
starcoder
package openapi // Paths Object // Holds the relative paths to the individual endpoints and their operations. // The path is appended to the URL from the Server Object in order to construct // the full URL. The Paths MAY be empty, due to ACL constraints. type Paths struct { // A relative path to an individual endpoi...
paths.go
0.647352
0.528716
paths.go
starcoder
package nasType // IntegrityProtectionMaximumDataRate 9.11.4.7 // MaximumDataRatePerUEForUserPlaneIntegrityProtectionForUpLink Row, sBit, len = [0, 0], 8 , 8 // MaximumDataRatePerUEForUserPlaneIntegrityProtectionForDownLink Row, sBit, len = [1, 1], 8 , 8 type IntegrityProtectionMaximumDataRate struct { Iei uint8 ...
lib/nas/nasType/NAS_IntegrityProtectionMaximumDataRate.go
0.585575
0.402686
NAS_IntegrityProtectionMaximumDataRate.go
starcoder
package graphReconstruct import ( "github.com/vertgenlab/gonomics/dna" "github.com/vertgenlab/gonomics/dnaTwoBit" "github.com/vertgenlab/gonomics/expandedTree" "github.com/vertgenlab/gonomics/genomeGraph" "log" ) type graphColumn struct { AlignId int AlignNodes map[string][]*genomeGraph.Node //string keys r...
graphReconstruct/graphReconstruct.go
0.628521
0.661971
graphReconstruct.go
starcoder
package expect import ( "errors" "fmt" "reflect" ) type Be struct { Else *Else And *Be t T actual interface{} assert bool } func newBe(t T, e *Else, actual interface{}, assert bool) *Be { be := &Be{ Else: e, t: t, actual: actual, assert: assert, } be.And = be return be } // Asse...
be.go
0.613584
0.522141
be.go
starcoder
package common import ( "context" "github.com/DataDog/datadog-go/statsd" ) // ContextKey is key to be used to store values to context type ContextKey string // Extras are extra information to be added into context type Extras map[string]interface{} // Basics are basics information to be added into context type Ba...
common/context.go
0.661814
0.463141
context.go
starcoder
package metrics import ( "time" ) /* Package metrics wants to help us to know what's going on. We'll try to keep it simple. */ // Data has all the metrics data in memory. It has counters and loggers. // The formers can only be incremented or decreased, while the latter // can used to get time differences. type Dat...
metrics/metrics.go
0.649245
0.418994
metrics.go
starcoder
package van import ( "context" "fmt" "reflect" ) var ( typeVan = reflect.TypeOf((*Van)(nil)).Elem() typeError = reflect.TypeOf((*error)(nil)).Elem() typeContext = reflect.TypeOf((*context.Context)(nil)).Elem() ) func isStructPtr(t reflect.Type) bool { return t.Kind() == reflect.Ptr && t.Elem().Kind() ==...
types.go
0.521471
0.42322
types.go
starcoder
package bird_data_guessing import ( "sort" "testing" "github.com/gbdubs/inference" ) // string type testStringCase struct { name string expected string } type testStringBehavior func(englishOrLatinName string) *inference.String func stringCase(englishOrLatinName string, expectedResult string) testStringC...
testing_string.go
0.517327
0.445409
testing_string.go
starcoder
package vectormodel import ( "errors" "fmt" "sort" "gonum.org/v1/gonum/mat" ) type ( // VectorModel is a struct to handle document vector space models. VectorModel struct { confidence float64 regularization float64 docIDs []int docIndexes map[int]int nFacto...
vectormodel/vector_model.go
0.717012
0.487124
vector_model.go
starcoder
package validation import ( "encoding/json" "errors" "math" "strconv" "sync" "github.com/PaddlePaddle/PaddleDTX/crypto/core/machine_learning/evaluation/metrics" ) // BinClassValidation performs validation of Binary Classfication case type BinClassValidation interface { // Splitter divides data set into sever...
crypto/core/machine_learning/evaluation/validation/validation.go
0.818193
0.488161
validation.go
starcoder
package money import ( "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "regexp" ) // parseNumber expects the string to contain a single // floating point number and returns the same. If the // string doesn't contain exactly one number, it returns an error. func parseNumber(s string) (float64, error) { va...
money.go
0.799521
0.472927
money.go
starcoder
package unimap import "fmt" // Composite is an interface to a collection, indexed by namespace, of consistent mappings from string to string. The // mappings are consistent in the sense that no two mappings map a given pair to distinct results. type Composite interface { // Add updates the composite mapping by addin...
pkg/unimap/composite.go
0.721056
0.504639
composite.go
starcoder
package src import ( "encoding/binary" "math" "reflect" ) type IEncoder interface { countByteLen(data interface{}) (error, uint64) SetByteOrder(order ByteOrder) Encode(data interface{}) (error, []byte) encodeUint8(stream []byte, pos uint64, value uint8) ([]byte, uint64) encodeUint16(stream []byte, pos uint6...
src/Encoder.go
0.69368
0.41941
Encoder.go
starcoder
package mcutils type ValueType interface { string | int64 | float64 | bool } type Number interface { int64 | float64 } func Index[T ValueType](arr []T, val T) int { // types - string, int, float, bool for i, value := range arr { if value == val { return i } } return -1 } func ArrayContains[T ValueType]...
collections.go
0.628065
0.422803
collections.go
starcoder
package fuzzymatcher import ( "unicode/utf8" ) type wordEntry struct { // wordIdx contains one bit sifted to the left for each word in the sentence // So wordIdx will be 1, 2, 4, 8, 16, 32, ... // This also means the wordIdx can be a maximum of 64 words WordIdx uint64 Letters []rune len int all...
matcher.go
0.511717
0.413122
matcher.go
starcoder
package dax import ( "github.com/dlespiau/dax/math" ) type Node struct { // Grapher parent Grapher children []Grapher transformValid bool worldTransformValid bool position math.Vec3 rotation math.Quaternion scale math.Vec3 transform math.Transform // worldTransform is the local space to world ...
node.go
0.758958
0.438304
node.go
starcoder
// Package assert contains wrapper on top of go's testing library // to make tests easier. package assert import ( "fmt" "math" "reflect" "regexp" "runtime" "testing" ) // used to strip out the long filename. var fileRegex = regexp.MustCompile("([^/]*/){0,2}[^/]*$") // Assert is a helper struct for testing me...
testing_support/assert/assert.go
0.720467
0.69937
assert.go
starcoder
package los import "math" // Map is a map of a roguelike level. Make sure all functions are // linear time type Map interface { OOB(int, int) bool // Is the point x, y out of bounds? Activate(int, int) // Activate x, y Discover(int, int) // Mark x, y discovered Lit(int, int) ...
los.go
0.7237
0.531574
los.go
starcoder
package vo import ( "sort" "strings" "github.com/unknwon/com" ) var TwoToneSphereRuleMap = map[int]map[int]int{ 6: {1: 1, 0: 2}, 5: {1: 3, 0: 4}, 4: {1: 4, 0: 5}, 3: {1: 5, 0: 0}, 2: {1: 6, 0: 0}, 1: {1: 6, 0: 0}, 0: {1: 6, 0: 0}, } var TwoToneSpherePriceMap = map[int]int{ 1: 5000000, 2: 200000, 3: 300...
internal/domain/lottery/vo/two_tone_sphere_calculator.go
0.547222
0.441854
two_tone_sphere_calculator.go
starcoder
package repository import ( "context" "cloud.google.com/go/bigtable" "github.com/sendinblue/bigtable-access-layer/data" "github.com/sendinblue/bigtable-access-layer/mapping" ) const defaultMaxRows = 100 type Repository struct { adapter Adapter mapper *mapping.Mapper maxRows int } // NewRepository creates a...
repository/repository.go
0.69233
0.440951
repository.go
starcoder
package types import ( "io" "reflect" "strings" "github.com/lyraproj/pcore/px" "github.com/lyraproj/pcore/utils" ) type EnumType struct { caseInsensitive bool values []string } var EnumMetaType px.ObjectType func init() { EnumMetaType = newObjectType(`Pcore::EnumType`, `Pcore::ScalarDataType { ...
types/enumtype.go
0.533397
0.404684
enumtype.go
starcoder
package bookingclient import ( "encoding/json" ) // RateRestrictionsModel struct for RateRestrictionsModel type RateRestrictionsModel struct { // The minimum length of stay in order to book the rate. If at least this number of time slices are covered by the stay duration the rate will be offered. MinLengthOfStay...
api/clients/bookingclient/model_rate_restrictions_model.go
0.754192
0.504639
model_rate_restrictions_model.go
starcoder
package nune import ( "math" "reflect" "github.com/vorduin/slices" ) // From returns a Tensor from the given backing - be it a numeric type, // a sequence, or nested sequences - with the corresponding shape. func From[T Number](b any) Tensor[T] { switch k := reflect.TypeOf(b).Kind(); k { case reflect.String: ...
factory.go
0.779657
0.642643
factory.go
starcoder
package chart import "math" // BollingerBandsSeries draws bollinger bands for an inner series. // Bollinger bands are defined by two lines, one at SMA+k*stddev, one at SMA-k*stdev. type BollingerBandsSeries struct { Name string Style Style YAxis YAxisType Period int K float64 InnerSeries ValueP...
vendor/github.com/nicholasjackson/bench/vendor/github.com/wcharczuk/go-chart/bollinger_band_series.go
0.859325
0.591989
bollinger_band_series.go
starcoder
package matrix import ( "fmt" "math" "strings" ) type Shape struct { Row int Col int } func (s Shape) Size() int { return s.Row * s.Col } func (s Shape) String() string { return fmt.Sprintf("(%d, %d)", s.Row, s.Col) } func ShapeNotEqual(a, b Shape) bool { return a.Row != b.Row || a.Col != b.Col } // Matri...
matrix.go
0.651466
0.466603
matrix.go
starcoder
package turbot import ( "context" "fmt" "regexp" "strconv" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/plugin" "github.com/turbot/steampipe-plugin-sdk/plugin/transform" ) func tableTurbotPolicySetting(ctx context.Context) *plugin.Table { return &plugin.Table{ ...
turbot/table_turbot_policy_setting.go
0.622459
0.407982
table_turbot_policy_setting.go
starcoder
package xlsx import ( "fmt" "strconv" "time" "github.com/tealeg/xlsx" "github.com/varshaprasad96/operator-sdk-data-collector/pkg/fields" ) func GetOutput(data fields.OperatorData, outputFilePath string) error { output := xlsx.NewFile() if err := createSheetAnfFillOverallData(output, data.SDKVersionCount, dat...
pkg/output/xlsx/xlsx.go
0.518546
0.438966
xlsx.go
starcoder
package items import ( "fmt" "strings" "github.com/goccmack/gocc/internal/ast" ) type itemPos struct { stack []stackElement } type stackElement struct { node ast.LexNTNode pos int } func newItemPos(lexPattern *ast.LexPattern) (pos *itemPos) { pos = &itemPos{ stack: make([]stackElement, 0, 8), } pos.pu...
internal/lexer/items/itempos.go
0.6137
0.441673
itempos.go
starcoder
package nn import ( "encoding/json" tsr "../tensor" ) // FlattenLayer is a layer that flattens data into a single frame with a single row. type FlattenLayer struct { inputShape LayerShape outputShape LayerShape inputs *tsr.Tensor outputs *tsr.Tensor } // NewFlattenLayer creates a new instance of a f...
nn/flattenLayer.go
0.872822
0.599016
flattenLayer.go
starcoder
package plan import ( "fmt" "strconv" "strings" "github.com/XiaoMi/Gaea/mysql" "github.com/XiaoMi/Gaea/parser/ast" "github.com/XiaoMi/Gaea/util/hack" "github.com/XiaoMi/Gaea/util/math" ) // ResultRow is one Row in Result type ResultRow []interface{} // GetInt get int value from column // copy from Resultset...
proxy/plan/merge_result.go
0.573917
0.432303
merge_result.go
starcoder
package universe import ( "math" "sort" "github.com/influxdata/flux" "github.com/influxdata/flux/codes" "github.com/influxdata/flux/execute" "github.com/influxdata/flux/internal/errors" "github.com/influxdata/flux/plan" "github.com/influxdata/flux/runtime" ) const HistogramQuantileKind = "histogramQuantile" ...
stdlib/universe/histogram_quantile.go
0.670285
0.419945
histogram_quantile.go
starcoder
package pvss import ( "math/big" logging "github.com/sirupsen/logrus" "github.com/torusresearch/torus-common/common" "github.com/torusresearch/torus-common/secp256k1" "github.com/torusresearch/torus-node/pkcs7" ) func pad(b []byte) []byte { byt, err := pkcs7.Pad(b, 64) if err != nil { logging.Error("Could n...
pvss/nizkpk.go
0.676727
0.467757
nizkpk.go
starcoder
package dlx // Matrix is a 2D representation of the exact cover problem consisting of 1s and 0s type Matrix interface { // AddRow allows the puzzle to be built up by adding one row at a time. // A row is an int slice of column indeces for the "1" elements in the matrix AddRow([]int) int // Solve attempts to find ...
dlx.go
0.688887
0.74958
dlx.go
starcoder