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 ast // TypeKind is implemented by all Types which are represented in the AST. // BaseType returns the underlying array/slice type if applicable, otherwise it returns the same value as Kind(). // Kind returns a value with represents the kind of value it is: ie int/string/slice/array. type TypeKind interface { ...
ast/type_interface.go
0.861887
0.705379
type_interface.go
starcoder
package main type IntIntMapEntry struct { K int V int } type IntIntMap struct { IntIntMapEntry IntIntMapEntry h int len int children [2]*IntIntMap } func (node *IntIntMap) Height() int { if node == nil { return 0 } return node.h } // suffix IntIntMap is needed because this w...
examples/gen/int_int_map.go
0.516839
0.468608
int_int_map.go
starcoder
package bezier import ( "bytes" "fmt" "math" "github.com/toukii/goutils" ) type IPoint interface { GetX() int GetY() int } type Point struct { X, Y int Z int64 } var ( ShortenTh = 0.75 ) func NewPoint(x, y int) *Point { return &Point{ X: x, Y: y, } } func ParsePoint(p IPoint) *Point { return N...
bezier.go
0.661814
0.424889
bezier.go
starcoder
package alchemist import ( "errors" "math" "github.com/TemirkhanN/alchemist/pkg/alchemy/ingredient" ) type Slot struct { value uint8 } type Alchemist struct { luckLevel int alchemyLevel int mortar *Mortar currentlyUsedIngredients []*ingredient.Ingredient } func NewAlchemist(level int,...
pkg/alchemy/alchemist/alchemist.go
0.520253
0.547585
alchemist.go
starcoder
package prefixtree import ( "strings" "bytes" ) // PrefixTree represents a prefix tree for a set of strings. The first level of // the tree represents all characters that appear at index 0 in the set of // strings, the second level all characters at index 1, and so on down the tree. type PrefixTree struct { ...
prefixtree/prefix_tree.go
0.832169
0.452415
prefix_tree.go
starcoder
package period import ( "fmt" "math" "strconv" "strings" ) func (p32 *Period32) Parse(isoPeriod string) error { if isoPeriod == "" { return fmt.Errorf(`cannot parse a blank string as a period`) } *p32 = Period32{} if isoPeriod == "P0" { return nil // special case } remaining := isoPeriod if remainin...
parse.go
0.722723
0.487673
parse.go
starcoder
package humanizex var CommonUnits = struct{ None Unit Second Unit Meter Unit Byte Unit Bit Unit BitsPerSecond Unit }{ None: Unit{"", ""}, Second: Unit{"s", "s"}, Meter: Unit{"m", "m"}, Byte: Unit{"...
humanizex/common.go
0.715126
0.503052
common.go
starcoder
package gosmparse import "github.com/thomersch/gosmparse/OSMPBF" // Node is an OSM data element with a position and tags (key/value pairs). type Node struct { ID int64 Lat float64 Lon float64 Tags map[string]string } // Way is an OSM data element that consists of Nodes and tags (key/value pairs). // Ways can...
cmd/spatialize/vendor/github.com/thomersch/gosmparse/elements.go
0.513668
0.548976
elements.go
starcoder
package op import "fmt" // Decode decodes the 16 bit representation of an instruction and returns it. func Decode(buf uint16) (inst interface{}, err error) { code := Code(buf & 0xF000 >> 12) switch code { case CodeNop: // operand: 000 // padding. pad := buf & 0x0FFF if pad != 0 { return nil, fmt.Errorf...
archive/cs/risc/op/decode.go
0.66072
0.586108
decode.go
starcoder
package migration func (m *MigrationTable) TinyInteger(field string) *MigrationAttributes { m.table.result = append(m.table.result,&MigrationAttribute{ field: field, fieldType: "TINYINT", }) return m.table } func (m *MigrationTable) SmallInteger(field string) *MigrationAttributes { m.table.res...
migration/migration_field_digital.go
0.676406
0.4856
migration_field_digital.go
starcoder
package math3d import ( "fmt" "math" "unsafe" ) type Matrix struct { values [16]float32 } var indexes = [4][4]int { [4]int{ 0, 4, 8, 12 }, [4]int{ 1, 5, 9, 13 }, [4]int{ 2, 6, 10, 14 }, [4]int{ 3, 7, 11, 15 }, } func NewMatrix(values [16]float32) *Matrix { r := new(Matrix) r.values = values return r } ...
matrix.go
0.564579
0.734941
matrix.go
starcoder
package objects import ( "log" "math" ) type TimingPoint struct { Time int64 BaseBpm, Bpm float64 SampleSet int SampleIndex int SampleVolume float64 } func (t TimingPoint) GetRatio() float64 { return t.Bpm / t.BaseBpm } type Timings struct { Points []TimingPoint queue []Ti...
beatmap/objects/timing.go
0.758779
0.47384
timing.go
starcoder
package matrix import ( "errors" "fmt" ) // ScanDirection scan matrix direction type ScanDirection uint const ( // ROW for row first ROW ScanDirection = 1 // COLUMN for column first COLUMN ScanDirection = 2 ) // State value of matrix map[][] type State uint16 const ( // StateInit represents the initial blo...
matrix/matrix.go
0.687
0.525308
matrix.go
starcoder
package math type Box2 struct { min Vector2 max Vector2 } // Equivalent to makeEmpty func NewDefaultBox2() *Box2 { return NewBox2( NewVector2Inf(1), NewVector2Inf(-1), ) } func NewBox2(min *Vector2, max *Vector2) *Box2 { return &Box2{ min: Vector2{X: min.X, Y: min.Y}, max: Vector2{X: max.X, Y: max.Y}, ...
box2.go
0.843122
0.594551
box2.go
starcoder
package epoch import ( "errors" "fmt" "os" "strconv" "strings" "time" ) // TimeUnit represents a time unit. type TimeUnit byte const ( // UnitSeconds represents seconds. UnitSeconds TimeUnit = iota // UnitMilliseconds represents milliseconds. UnitMilliseconds // UnitMicroseconds represents microseconds. ...
epoch.go
0.786336
0.510435
epoch.go
starcoder
package density import ( "fmt" "math/big" "sort" ) // ValueRing represents a ring values. type ValueRing struct { ids *SortedArrayBigInts max *big.Int // The maximum value of any value in the ring. wordSize int64 // size in bytes dhtSpan int64 } // NewValueRing i...
internal/density/value_ring.go
0.627951
0.531757
value_ring.go
starcoder
package primitives import ( "math" "math/cmplx" ) // InfinitePoint for representing a non-valid point var InfinitePoint = Point{1e20, 1e20, 1e20} // Lambda is to prevent const lambda = 1e6 func solveQuadratic(floats [3]float64) (x1, x2 float64, ret bool) { a, b, c := complex(floats[0], 0.0), complex(floats[1], 0...
pkg/primitives/Objects.go
0.849285
0.694827
Objects.go
starcoder
package timeago import ( "fmt" "reflect" "time" ) // Precision define the minimun amount of time to be considered. type Precision uint const ( // SecondPrecision is the second precision. SecondPrecision Precision = iota // MinutePrecision is the minute precision. MinutePrecision // HourPrecision is the hou...
timea.go
0.645679
0.464234
timea.go
starcoder
package pure import ( "context" "errors" "fmt" "time" "github.com/benthosdev/benthos/v4/internal/bloblang/field" "github.com/benthosdev/benthos/v4/internal/bundle" "github.com/benthosdev/benthos/v4/internal/component" "github.com/benthosdev/benthos/v4/internal/component/cache" "github.com/benthosdev/benthos/...
internal/impl/pure/processor_cache.go
0.683736
0.440108
processor_cache.go
starcoder
Package controller provides libraries for building Controllers. Controllers implement Kubernetes APIs and are central to building Operators, Workload APIs, Configuration APIs, Autoscalers, and more. Controllers Controllers are work queues that enqueue work in response to source.Source events (e.g. Pod Create, Update...
pkg/controller/doc.go
0.856092
0.573858
doc.go
starcoder
package tree import ( "fmt" ) // Btree represents an AVL tree type Btree struct { root *Node values []Val len int } // Val interface to define the compare method used to insert and find values type Val interface { Comp(val Val) int8 } // Node represents a node in the tree with a value, left and right chil...
btree.go
0.768907
0.604983
btree.go
starcoder
package delaunay import ( "fmt" "math" "sort" ) const eps = 1e-6 type Point struct { X float64 Y float64 } func NewPoint(x, y float64) Point { return Point{X: x, Y: y} } func (p Point) String() string { return fmt.Sprintf("(%3.1f, %3.1f)", p.X, p.Y) } func (p Point) CompareTo(other Point) int { if p == ot...
delaunay/delaunay.go
0.793186
0.548794
delaunay.go
starcoder
package optimizer import ( "encoding/json" . "github.com/antonmedv/expr/ast" "math" "reflect" ) type inArray struct{} type fold struct { applied bool } type inRange struct{} type constRange struct{} func Optimize(node *Node) { Walk(node, &inArray{}) limit := 1000 for { fold := &fold{} Walk(node, fold) ...
optimizer/optimizer.go
0.519765
0.407127
optimizer.go
starcoder
package compliance import ( "fmt" "github.com/golang/glog" "github.com/turbonomic/kubeturbo/pkg/discovery/repository" "github.com/turbonomic/turbo-go-sdk/pkg/builder/group" "github.com/turbonomic/turbo-go-sdk/pkg/proto" ) // In Turbo, Schedulable nodes are marked with an access commodity 'schedulable'. Pods are ...
pkg/discovery/worker/compliance/unschedulable_node_anti_affinity_group_dto_builder.go
0.588534
0.435601
unschedulable_node_anti_affinity_group_dto_builder.go
starcoder
package bayes // Simulation from Bayesian normal sampling model. // Ref.: Albert (2009) import ( "code.google.com/p/probab/dst" ) func rigamma(shape, rate float64) float64 { return (1 / dst.GammaNext(shape, 1/rate)) } // NormPostSim returns a simulated sample from the joint posterior distribution of the mean and...
bayes/normpostsim.go
0.912728
0.775605
normpostsim.go
starcoder
package qrss import ( "crypto/rand" "io" //"log" "math" "math/big" ) type Volt float64 type ToneGen struct { SampleRate float64 // Samples per second (Hz) ToneLen float64 // Length in seconds RampLen float64 // ramp-up, ramp-down in seconds BaseHz float64 StepHz float64 } // How many ticks (...
qrss/tones.go
0.673299
0.509337
tones.go
starcoder
// A completely customizable Random Number Generator package main; // sets the value at the given index from an array to negative 1 and returns a new array func setMinusOne(array []int, size, index int) []int { var ret []int; for i := 0; i < size; i++ { if i != index { ret = append(ret, array[i]); ...
programs/benchmark/dijkstra.go
0.792103
0.509398
dijkstra.go
starcoder
package lib import ( "math/rand" ) // A Map represents a level in the game. type Map struct { // Depth determines the level of this map in the game. Depth int // Tiles stores the tiles in a 2d matrix. Tiles [][]Tile } // Width returns the width of the map func (m *Map) Width() int { return len(m.Tiles[0]) } ...
lib/map.go
0.820037
0.622431
map.go
starcoder
package spine import ( "math" ) type Attachment interface { Name() string } type RegionAttachment struct { name string X float32 Y float32 Rotation float32 ScaleX float32 ScaleY float32 Width float32 Height float32 RendererObject interface{} RegionOffsetX float32 ...
anim/spine/attachment.go
0.638385
0.411347
attachment.go
starcoder
package primitives import ( "github.com/alexandreLamarre/Golang-Ray-Tracing-Renderer/pkg/algebra" ) //Intersections data type keeps track of t values of the intersections of rays with a sphere type Intersections struct { hits *MinHeap // hits on contours of objects ref *MinHeap // used in ray reflections/refracti...
pkg/geometry/primitives/intersections.go
0.819063
0.57075
intersections.go
starcoder
package main import ( "fmt" "math/rand" "sync/atomic" "time" ) // In the previous example we used explicit locking with Mutexes to synchronize access to shared state across // multiple Goroutines. Another option is to use the built-in synchronization features of Goroutines and channels // to achieve the same resu...
cmd/concurrency/stateful-goroutines/stateful-goroutines.go
0.644896
0.478773
stateful-goroutines.go
starcoder
package rbytree import ( "bytes" ) // Tree holds red-black tree. // It is not goroutine-safe, make sure that // the access to the instance of the tree is always synchronized. type Tree struct { root *node size int } type color byte const ( red color = iota black ) // node represents the node in the tree. type...
tree.go
0.787646
0.419945
tree.go
starcoder
package lcs // Basic returns the length of the largest common subsequence func Basic(a, b []int64) int { if len(a) == 0 || len(b) == 0 { return 0 } curr := make([]int, len(b)) prev := make([]int, len(b)) max := 0 for ai, ax := range a { for bi, bx := range b { if ax != bx { curr[bi] = 0 } else {...
lcs/lcs.go
0.681409
0.499329
lcs.go
starcoder
package rbtree type color uint8 const ( kRed color = 0 kBlack color = 1 ) type Node struct { left *Node right *Node parent *Node color color Item } type Item interface { Less(than Item) bool } type Rbtree struct { root *Node count uint } func New() *Rbtree { return &Rbtree{ root: nil, coun...
rbtree/rbtree.go
0.676727
0.490663
rbtree.go
starcoder
package retry import ( "math" "time" ) // Exponential performs retries and waits according to an exponential equation: f(x) = a*B^x + y where B is the base, x is the number of retries (starting at 0) and y is the offset time (cannot be less than 0) type Exponential struct { // Times is the maximum number of times...
max_exponential.go
0.850127
0.510863
max_exponential.go
starcoder
package gmi import ( "fmt" "strings" ) var ( _ Line = (*TextLine)(nil) _ Line = (*LinkLine)(nil) _ Line = (*PreformatToggleLine)(nil) _ Line = (*PreformatLine)(nil) _ Line = (*HeadingLine)(nil) _ Line = (*UnorderedListLine)(nil) _ Line = (*QuoteLine)(nil) ) // Line represents a Line in text/gemini in a logi...
ast.go
0.72952
0.729628
ast.go
starcoder
package iso20022 // Set of elements used to identify the underlying transaction. type TransactionReferences2 struct { // Point to point reference, as assigned by the instructing party of the underlying message. MessageIdentification *Max35Text `xml:"MsgId,omitempty"` // Unique reference, as assigned by the accoun...
TransactionReferences2.go
0.88779
0.477006
TransactionReferences2.go
starcoder
package mf2 import ( "fmt" "reflect" ) // Flatten takes a Microformats map and flattens all arrays with // a single value to one element. func Flatten(data map[string][]interface{}) map[string]interface{} { return flatten(data).(map[string]interface{}) } func flatten(data interface{}) interface{} { value := refl...
entry/mf2/mf2.go
0.696887
0.445047
mf2.go
starcoder
package salsa import ( "time" "github.com/asimpleidea/salsa/sauces" ) type result struct { Header *resultHeader `json:"header"` Data resultData `json:"data"` } func (r *result) deviantArt() *sauces.DeviantArt { return &sauces.DeviantArt{ SauceHeader: r.Header.toSauceHeader(), ExternalURLs: r.Data.toS...
result_data.go
0.539711
0.415195
result_data.go
starcoder
package axon import ( "fmt" "reflect" "unsafe" ) // axon.Synapse holds state for the synaptic connection between neurons type Synapse struct { Wt float32 `desc:"effective synaptic weight value, determining how much conductance one spike drives on the receiving neuron. Wt = SWt * WtSig(LWt), where WtSig produc...
axon/synapse.go
0.706899
0.563918
synapse.go
starcoder
package cron import ( "strings" "fmt" "regexp" "strconv" "github.com/pengzj/swift/bitmap" "time" ) type CronSchedule struct { Minute *bitmap.Bitmap Hour *bitmap.Bitmap Day *bitmap.Bitmap Month *bitmap.Bitmap Week *bitmap.Bitmap Year *bitmap.Bitmap Deadline time.Time } func (schedule *CronSchedule) CanTr...
cron/parse.go
0.530236
0.473109
parse.go
starcoder
package stringset import ( "fmt" "reflect" "strings" ) const testVersion = 3 // Set represents a set of unique strings. type Set map[string]bool // New creates an empty Set. func New() Set { return make(Set) } // NewFromSlice creates a Set from the contents of the slice. // If a string exists multiple times in...
solutions/go/custom-set/custom_set.go
0.872822
0.422147
custom_set.go
starcoder
package merge import ( "fmt" "github.com/attic-labs/noms/go/d" "github.com/attic-labs/noms/go/types" ) type applyFunc func(candidate, types.ValueChanged, types.Value) candidate func (m *merger) threeWayOrderedSequenceMerge(a, b, parent candidate, apply applyFunc, path types.Path) (types.Value, error) { aChange...
go/merge/three_way_ordered_sequence.go
0.533641
0.55652
three_way_ordered_sequence.go
starcoder
package infer // Gradient ascent algorithms. import ( "bitbucket.org/dtolpin/infergo/model" "math" ) // Grad is the interface of gradient-based // optimizers. Step makes a single step over // parameters in the gradient direction. type Grad interface { Step(m model.Model, x []float64) (ll float64, grad []float64) ...
infer/grad.go
0.780955
0.616907
grad.go
starcoder
package ast import ( "bytes" "fmt" "io" "strconv" "strings" ) const ( EPSILON RealNum = 0.00000001 ) type Number interface { Add(Number) Number Sub(Number) Number Mul(Number) Number Div(Number) Number Expr } type IntNum int type RealNum float64 type RatNum struct { Numerator Number Denominator Numb...
ast/number.go
0.511229
0.418935
number.go
starcoder
package newstorage import ( "errors" "testing" "github.com/google/uuid" "github.com/stretchr/testify/require" "github.com/Universal-Health-Chain/aries-framework-go/pkg/newstorage" ) // TestAll tests common storage functionality. // These tests demonstrate behaviour that is expected to be consistent across stor...
test/newstorage/newstore.go
0.652574
0.571587
newstore.go
starcoder
package btree import "github.com/jmgilman/kv" // node represents a node in a Tree type node struct { pair kv.KVPair left *node right *node } // get searches for the given key in the tree node and returns its associated // KVPair or ErrorNoSuchKey if the key was not found. func (n *node) get(key string) (*kv.KVP...
btree/node.go
0.833223
0.462352
node.go
starcoder
package iso20022 // Information needed to process a currency exchange or conversion. type ForeignExchangeTerms4 struct { // Currency and amount bought in a foreign exchange trade. The buy amount is received by the buyer. BuyAmount *ActiveCurrencyAnd13DecimalAmount `xml:"BuyAmt,omitempty"` // Currency and amount s...
ForeignExchangeTerms4.go
0.821689
0.52683
ForeignExchangeTerms4.go
starcoder
Two main functions are provided: - GetLatestBy to get the latest event for each group. A group is defined by one or more columns. - GroupBy to group events by one or more columns and perform an aggregation for each group, like count(), sum() or max(). It is possible to use a single aggregation when calling GroupBy or...
aggregation/aggregate.go
0.816004
0.559651
aggregate.go
starcoder
package phonetics import ( "math/rand" ) func RandomSound() Sound { sound := Sound{} sound.randomiseSound() for !sound.IsValid() { sound.randomiseSound() } sound.Standardise() return sound } func (sound *Sound) randomiseSound() { sound.Point = ArticulationPoint(rand.Intn(int(ArticulationPointCount))) soun...
phonetics/Sound.go
0.505371
0.424173
Sound.go
starcoder
package advent2021 import ( "fmt" "log" "strconv" "strings" ) // VentMap is the 2d int array that represents the location of the heat vents type VentMap [1000][1000]int // Note: Generally the above should be dynamic and have more error checking on exceeding the limits // coordinates represents the X,Y coordinat...
internal/pkg/advent2021/day5.go
0.659186
0.541712
day5.go
starcoder
package asstime import ( "fmt" "math" "regexp" "github.com/Alquimista/eyecandy/utils" ) const ( // FpsNtscFilm Frame per second rate NTSC film standard (23.976) FpsNtscFilm float64 = float64(24000) / float64(1001) // FpsNtsc Frame per second rate NTSC standard (30) FpsNtsc float64 = float64(30000) / float64(...
asstime/asstime.go
0.648578
0.451689
asstime.go
starcoder
package main import ( "fmt" "math" ) // Describe2Der describes 2D shapes type Describe2Der interface { area() float64 perim() float64 } // Describe3Der describes 3D shapes type Describe3Der interface { volume() float64 surface() float64 } // Circle description type Circle struct { radius float64 } // Rectan...
software/development/languages/go-cheat-sheet/src/function-method-interface-package-example/interface/interfaces2.go
0.878314
0.440168
interfaces2.go
starcoder
package collect import ( "errors" "fmt" "reflect" "strconv" ) func AnyGet[V, K any](item any, key K) (zero V, _ error) { var result any ref := reflect.ValueOf(item) switch ref.Kind() { case reflect.Map: if r := ref.MapIndex(reflect.ValueOf(key)); r.IsValid() { result = r.Interface() } else { return...
helpers.go
0.52975
0.440108
helpers.go
starcoder
package bsonkit import ( "math" "github.com/shopspring/decimal" "go.mongodb.org/mongo-driver/bson/primitive" ) func d128ToDec(d primitive.Decimal128) decimal.Decimal { big, exp, _ := d.BigInt() return decimal.NewFromBigInt(big, int32(exp)) } func decTod128(d decimal.Decimal) primitive.Decimal128 { dd, _ := pr...
bsonkit/math.go
0.706292
0.478529
math.go
starcoder
package wid import ( "image/color" "gioui.org/unit" ) // Some default colors var ( Red = RGB(0xFF0000) Yellow = RGB(0xFFFF00) Green = RGB(0x00FF00) Blue = RGB(0x0000FF) White = RGB(0xFFFFFF) Black = RGB(0x000000) ) // Zv is a zero unit.Value. Just saving a few keystrokes var Zv = unit.Value{} // D...
wid/rgba.go
0.797596
0.406332
rgba.go
starcoder
package fflogs import ( "context" ) type ReportTablesOptions struct { //view string `path:"view"` // The type of data requested. Supported values are 'summary', 'damage-done', 'damage-taken', 'healing', 'casts', 'summons', 'buffs', 'debuffs', 'deaths', 'survivability', 'resources' and '...
api_Report_Tables_raw.go
0.834272
0.479077
api_Report_Tables_raw.go
starcoder
package ansicsi import ( "bytes" "io" "strconv" ) // Command represents a parsed ANSI control function. type Command interface { // Encode writes the ANSI CSI and control sequence for the command to the given Writer. Encode(w io.Writer) (int, error) decodeParameters(params []int) bool } // ControlSequence rep...
csi.go
0.619241
0.452717
csi.go
starcoder
package main type Scanner struct { inputStream string // Keep it simple } func (scanner Scanner) Scan() Token { return Token{} } type Token struct { } type Parser struct { } func (parser Parser) parse(scanner Scanner, ProgramNodeBuilder ProgramNodeBuilder) { } type ProgramNodeBuilder struct { node ProgramNode...
structural/facade/facade.go
0.621656
0.403861
facade.go
starcoder
package trie import ( "github.com/howz97/algorithm/basic/queue" "github.com/howz97/algorithm/strings/alphabet" ) func NewTrie[T any](alp alphabet.IAlp) *Trie[T] { return &Trie[T]{ alp: alp, root: newNode[T](alp.R()), } } type Trie[T any] struct { alp alphabet.IAlp root *node[T] } func (t *Trie[T]) Find(...
strings/trie/trie.go
0.512693
0.453322
trie.go
starcoder
package gobang /** * |B| | | | | | | | | | * | |B| | | | | | | | | * | | |B| | | | | | | | * | | | |B| | | | | | | * | | | | |B| | | | | | * | | | |B| | | | | | | * | | | | |B| | | | | | * | | | | | |B| | | | | * | | | | | | |B| | | | * | | | | | | | |B| | | */ func NewTopLeftDiagonalCellMatcher(stone Stone...
gobang/top_left_diagonal_cell_matcher.go
0.811825
0.492981
top_left_diagonal_cell_matcher.go
starcoder
package main import ( "fmt" "math" "math/rand" "time" "github.com/hajimehoshi/ebiten/v2" ) type Player struct { x float64 // Player position x y float64 // Player position y cellX int cellY int angle float64 // Facing angle in radians health int mana int playingFootsteps bool // These ...
src/player.go
0.604516
0.424114
player.go
starcoder
package util import "github.com/samber/lo" type Element[T any] struct { Index int Element T } // Enumerate returns a new slice with each element and its index. func Enumerate[T any](collection []T) []Element[T] { if collection == nil { return nil } return lo.Map(collection, func(e T, i int) Element[T] { ...
server/pkg/util/slice.go
0.770378
0.461866
slice.go
starcoder
package types import ( DaoPrediction "github.com/containers-ai/alameda/datahub/pkg/dao/prediction" Metric "github.com/containers-ai/alameda/datahub/pkg/metric" DatahubV1alpha1 "github.com/containers-ai/api/alameda_api/v1alpha1/datahub" ) type PodPredictionExtended struct { *DaoPrediction.PodPrediction } func (p ...
datahub/pkg/formatextension/types/predictions.go
0.664649
0.4133
predictions.go
starcoder
package apksign import ( "encoding/binary" ) /* This idiom is very common in the v2 Android signing scheme: val := binary.LittleEndian.Uint32(buf) // parse 4 bytes into a uint32 buf = buf[4:] // advance the buffer past the "consumed" bytes ...and same for uint64 values. It's not a lot of code...
pkg/playground-android/apksign/pushpop.go
0.761716
0.572723
pushpop.go
starcoder
package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" cdptypes "github.com/lcnem/eurx/x/cdp/types" "github.com/lcnem/eurx/x/estmdist/types" ) // MintPeriodInflation mints new tokens according to the inflation schedule specified in the parameters func (k Keeper) MintPeriodInflation(ctx sdk.Context) erro...
x/estmdist/keeper/mint.go
0.745584
0.411998
mint.go
starcoder
package dull import ( "bytes" "fmt" "github.com/stretchr/testify/assert" "image" "image/png" "os" "path" "testing" ) func normaliseImageIfRequired(img image.Image) { if img == nil { return } switch img2 := img.(type) { case *image.RGBA: pixels := img2.Pix for p := 0; p < len(pixels); p += 4 { r...
visual-test.go
0.626581
0.411702
visual-test.go
starcoder
package game // Room holds the directions and entities within the room. type Room struct { Name string Description string Doors []Door Items []Item } // Door holds the metadata required to journey to a different room. type Door struct { RoomID uint Direction string IsLocked bool // IsVisible ...
internal/game/room.go
0.5144
0.425963
room.go
starcoder
package equitocube import ( "errors" "image/color" "math" ) //Cubemap save cubemap data type Cubemap struct { Ratio Vector2 TileSize Vector2 TileMap [2][3]string FaceMap map[string]VectorArray3 SquareTileSize int } //Vector2 save vector2 data type Vector2 struct { X int Y int ...
cubemap.go
0.792304
0.688449
cubemap.go
starcoder
package printer /* © 2021 B1 Digital User : ICI Name : <NAME> Date : 28.05.2021 15:34 Notes : . */ import ( "fmt" "image" ) func closestNDivisibleBy8(n int) int { q := n / 8 n1 := q * 8 return n1 } func printImage(img image.Image) (xL byte, xH byte, yL byte, yH byte, da...
bitimage.go
0.734024
0.422862
bitimage.go
starcoder
package transforms import ( "math" "github.com/calbim/ray-tracer/src/matrix" "github.com/calbim/ray-tracer/src/tuple" ) //Translation returns a matrix representing a translation operation func Translation(x, y, z float64) *matrix.Matrix { return matrix.New([]float64{1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1...
src/transforms/transforms.go
0.918462
0.791821
transforms.go
starcoder
package ml import ( "errors" "fmt" "strings" ) // Common erros. var ( ErrBadDim = errors.New("dimension of the two matrix differs") ErrInconsistentData = errors.New("matrix has different y dimension per x") ErrUninitialized = errors.New("matrix not initialized") ErrNotAVector = errors.New("t...
week1/matrix.go
0.734501
0.456834
matrix.go
starcoder
package context import ( "github.com/pkg/errors" "github.com/zoncoen/scenarigo/assert" ) var assertions = map[string]interface{}{ "and": listArgsLeftArrowFunc(listArgsAssertion(assert.And)), "or": listArgsLeftArrowFunc(listArgsAssertion(assert.Or)), "notZero": assert.No...
context/assert.go
0.623492
0.517022
assert.go
starcoder
// Compare the proportions of certain attribute in two populations. The true proportions are pi1 and pi2, unknown. // We take a random sample from each of the populations and observe y1, y2 ... number of instances having the attribute. // The distribution y1|pi1 is binomial(n1, pi1), similarly for y2|pi2, and they are...
bayes/binom_p_diff.go
0.789923
0.862352
binom_p_diff.go
starcoder
// Package termutil provides structures and helper functions to work with // terminal (state, sizes). Taken from docker-ce source code. package termutil import ( "errors" "fmt" "os" "os/signal" "golang.org/x/sys/unix" ) var ( // ErrInvalidState is returned if the state of the terminal is invalid. ErrInvalidS...
pkg/termutil/term.go
0.533884
0.427875
term.go
starcoder
package iso20022 // Provides information about the rates related to securities movement. type RateDetails23 struct { // Rate used for additional tax that cannot be categorised. AdditionalTax *RateAndAmountFormat39Choice `xml:"AddtlTax,omitempty"` // Rate used to calculate the amount of the charges/fees that canno...
RateDetails23.go
0.832951
0.695354
RateDetails23.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // IdentityUserFlowAttribute type IdentityUserFlowAttribute struct { Entity // The data type of the user flow attribute. This cannot be modified after the...
models/identity_user_flow_attribute.go
0.679604
0.403626
identity_user_flow_attribute.go
starcoder
package unityai import "sort" type Vertex2Array []Vector2f func (this Vertex2Array) Len() int { return len(this) } func (this Vertex2Array) Less(i, j int) bool { a := this[i] b := this[j] return a.x < b.x || (a.x == b.x && a.y < b.y) } func (this Vertex2Array) Swap(i, j int) { this[i], this[j] = this[j], this...
hull_avoidance.go
0.519521
0.571527
hull_avoidance.go
starcoder
package geojson import ( "encoding/json" "go.mongodb.org/mongo-driver/bson" ) // A Feature corresponds to GeoJSON feature object type Feature struct { ID interface{} `json:"id,omitempty" bson:",omitempty"` Type string `json:"type"` BoundingBox []float64 `j...
feature.go
0.826747
0.520314
feature.go
starcoder
package onshape import ( "encoding/json" ) // BTPStatementLoopForIn279 struct for BTPStatementLoopForIn279 type BTPStatementLoopForIn279 struct { BTPStatementLoop277 BtType *string `json:"btType,omitempty"` Container *BTPExpression9 `json:"container,omitempty"` IsVarDeclaredHere *bool `json:"isVarDeclaredHere,om...
onshape/model_btp_statement_loop_for_in_279.go
0.672654
0.483405
model_btp_statement_loop_for_in_279.go
starcoder
package indicators import ( "container/list" "errors" "github.com/thetruetrade/gotrade" "math" ) // A Lowest Low Value Bars Indicator (LlvBars), no storage, for use in other indicators type LlvBarsWithoutStorage struct { *baseIndicatorWithIntBounds // private variables periodHistory *list.List currentLow ...
indicators/llvbars.go
0.589362
0.405714
llvbars.go
starcoder
package hector import( "strconv" "math/rand" "math" "fmt" ) type NeuralNetworkParams struct { LearningRate float64 LearningRateDiscount float64 Regularization float64 Hidden int64 Steps int Verbose int } type TwoLayerWeights struct { L1 *Matrix L2 *Matrix } /* Please...
neural_network.go
0.610337
0.484197
neural_network.go
starcoder
package kdtree import ( "geo" "graph" ) type Location struct { Graph *graph.GraphFile EC uint64 Cluster int } func (l Location) Vertex() graph.Vertex { return graph.Vertex(l.EC >> (EdgeOffsetBits + StepOffsetBits)) } func (l Location) EdgeOffset() uint32 { return uint32((l.EC >> StepOffsetBits) & MaxE...
src/kdtree/location.go
0.670716
0.480052
location.go
starcoder
package symbol import ( "strings" "github.com/gojek/merlin/pkg/transformer/symbol/function" ) // Geohash calculates geohash of latitude and longitude with the given character precision // latitude and longitude can be: // - Json path string // - Slice / gota.Series // - float64 value func (sr Registry) Geohash(lat...
api/pkg/transformer/symbol/geospatial.go
0.782538
0.432423
geospatial.go
starcoder
package nb2 import ( "errors" "math" "sort" "github.com/schollz/find4/server/main/src/database" "github.com/schollz/find4/server/main/src/models" ) // Algorithm defines the basic structure type Algorithm struct { Data map[string]map[string]float64 isLoaded bool } // New returns new algorithm func New() *...
findapi/lib/ai/_old/learning/nb2/nb2.go
0.551574
0.415492
nb2.go
starcoder
package dtstruct // InstancesSorterByExec sorts instances by executed binlog coordinates type InstancesSorterByExec struct { instances [](*MysqlInstance) dataCenter string } func NewInstancesSorterByExec(instances [](*MysqlInstance), dataCenter string) *InstancesSorterByExec { return &InstancesSorterByExec{ ins...
go/adaptor/mysql/dtstruct/instance_sorter.go
0.625667
0.411998
instance_sorter.go
starcoder
package validation import ( "context" "errors" "reflect" "strconv" ) // Each returns a validation rule that loops through an iterable (map, slice or array) // and validates each value inside with the provided rules. // An empty iterable is considered valid. Use the Required rule to make sure the iterable is not ...
each.go
0.788054
0.458955
each.go
starcoder
package kubernetes import ( "fmt" "time" ) type resolver interface { Resolve(string) (*Schema, error) Version() string } // Validator knows enough to be able to validate a YAML document. type Validator struct { resolver resolver } // NewValidator returns an instantiated validator. func NewValidator(resolver re...
internal/kubernetes/validations.go
0.525125
0.401043
validations.go
starcoder
package types import ( "bytes" "<KEY>" ) // Tip is what expected consensus needs from a Block. For now it *is* a // Block. type Tip = Block // TipSet is a set of Tips, blocks at the same height with the same parent set, // keyed by Cid string. type TipSet map[string]*Tip var ( // ErrEmptyTipSet is returned when...
types/tipset.go
0.659734
0.429609
tipset.go
starcoder
package interpreter import ( "github.com/google/cel-go/common/types/ref" ) // EvalState tracks the values associated with expression ids during execution. type EvalState interface { // GetRuntimeExpressionID returns the runtime id corresponding to the // expression id from the AST. GetRuntimeExpressionID(exprID ...
interpreter/evalstate.go
0.641984
0.522629
evalstate.go
starcoder
package circbuf import ( "fmt" ) // Buffer implements a circular buffer. It is a fixed size, // and new writes overwrite older data, such that for a buffer // of size N, for any amount of writes, only the last N bytes // are retained. type Buffer struct { data []byte out []byte size int64 w...
vendor/github.com/balena-os/circbuf/circbuf.go
0.770206
0.469034
circbuf.go
starcoder
package parser import ( "github.com/magic003/liza/ast" "github.com/magic003/liza/lexer" "github.com/magic003/liza/token" ) // New returns a new instance of parser. func New(filename string, src []byte) *Parser { parser := &Parser{} lexer := lexer.New(filename, src, parser.handleErr, lexer.ScanComments) parser....
parser/parser.go
0.603815
0.487002
parser.go
starcoder
package p384 import ( "crypto/subtle" "math/big" "github.com/cloudflare/circl/math" ) type curve struct{} // P384 returns a Curve which implements P-384 (see FIPS 186-3, section D.2.4). func P384() Curve { return curve{} } // IsOnCurve reports whether the given (x,y) lies on the curve. func (c curve) IsOnCurve...
vendor/github.com/cloudflare/circl/ecc/p384/p384opt.go
0.883632
0.58818
p384opt.go
starcoder
If a certain value can not be directly converted to another, the zero value of the destination type is returned instead. */ package to import ( "fmt" "reflect" "regexp" "strconv" "time" ) var ( durationType = reflect.TypeOf(time.Duration(0)) timeType = reflect.TypeOf(time.Time{}) ) const ( digits = ...
backend/vendor/src/github.com/mgutz/to/to.go
0.553988
0.427636
to.go
starcoder
package thnow import ( "strconv" "strings" "time" ) // ToString Convet time.Time To Date String format func (date DateNow) ToString(optional ...string) string { var defaultFormat = "02 Jan 2006 15:04:05" var result = time.Now().Format(defaultFormat) day := date.Day() weekday := int(date.Weekday()) month := in...
thnow.go
0.503418
0.414958
thnow.go
starcoder
package minheighttree /* * @lc app=leetcode id=310 lang=golang * * [310] Minimum Height Trees * * https://leetcode.com/problems/minimum-height-trees/description/ * * algorithms * Medium (29.94%) * Total Accepted: 64.1K * Total Submissions: 213K * Testcase Example: '4\n[[1,0],[1,2],[1,3]]' * * For an u...
310-min-height-tree/310.minimum-height-trees.go
0.895408
0.65426
310.minimum-height-trees.go
starcoder
package function import ( "fmt" "strconv" "strings" "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" ) // AsWKT is a function that converts a spatial type into WKT format (alias for AsText) type AsWKT struct { expression.UnaryExpression } var _ sql.FunctionExpressi...
sql/expression/function/wkt.go
0.670932
0.529081
wkt.go
starcoder
package ns /** * Configuration for assignment resource. */ type Nsassignment struct { /** * Name for the assignment. Must begin with a letter, number, or the underscore character (_), and must contain only letters, numbers, and the hyphen (-), period (.) hash (#), space ( ), at (@), equals (=), colon (:), and unders...
resource/config/ns/nsassignment.go
0.71423
0.542257
nsassignment.go
starcoder
package rbtree import "github.com/fanyang01/tree/common" // BLACK and RED is the color of nodes const ( BLACK = false RED = true ) // Node is the node in a tree type Node struct { left, right, p *Node color bool v interface{} } // Tree is a red-black tree type Tree struct { size int...
rbtree/tree.go
0.76625
0.450359
tree.go
starcoder
package analysis import ( "time" "infra/appengine/luci-migration/storage" ) const ( // lowSpeed is the lower speed threshold. If speed drops below this, // the builder is not WAI lowSpeed = 0.8 // highSpeed is the target speed. If speed is high or more, the builder is // WAI. highSpeed = 0.9 // targetHealt...
go/src/infra/appengine/luci-migration/analysis/compare.go
0.649579
0.421552
compare.go
starcoder