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 models import ( "fmt" "strconv" "strings" "gorm.io/gorm" ) // InfraStatus is the status that an infrastructure can take type InfraStatus string // The allowed statuses const ( StatusCreating InfraStatus = "creating" StatusCreated InfraStatus = "created" StatusError InfraStatus = "error" St...
internal/models/infra.go
0.564098
0.464173
infra.go
starcoder
package maximum import "container/list" /* 239. 滑动窗口最大值 https://leetcode-cn.com/problems/sliding-window-maximum 给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。 你只可以看到在滑动窗口内的 k 个数字。滑动窗口每次只向右移动一位。 返回滑动窗口中的最大值。 示例: 输入: nums = [1,3,-1,-3,5,3,6,7], 和 k = 3 输出: [3,3,5,5,6,7] 解释: 滑动窗口的位置 最大值 ---------------...
solutions/sliding-window-maximum/d.go
0.572125
0.407333
d.go
starcoder
package number import ( "math" ) // CanTruncate checks if a float (from) can be converted to an int (to) func CanTruncate(from Type, to Type, value interface{}) bool { if from == F32 && to == I32 { if v, ok := value.(float32); ok { return math.MinInt32 <= v && v < math.MaxInt32+1 } panic("Check value must ...
number/conversion.go
0.665084
0.540378
conversion.go
starcoder
package voxel // BuildUnion returns a union of two models a and b translated to (dx,dy,dz) func BuildUnion(a, b BlenderVoxelFormat, dx, dy, dz uint32) (g BlenderVoxelFormat) { return buildResultVM(a, b, dx, dy, dz, maxFloat32) } // BuildIntersection returns an intersection of two models a and b translated to (dx,dy,...
voxel/two-models.go
0.875787
0.550487
two-models.go
starcoder
package typeio import ( "io" "time" ) // ReadUnixTimeUTC32BE reads 4 bytes in big-endian byte order from r, interprets // it as a UNIX time, the number of seconds elapsed since Jan 1, 1970 UTC, and // returns the UTC time it represents. // Note that this data type has the well-known Y2038 problem. func ReadUnixTim...
time.go
0.822902
0.448004
time.go
starcoder
package entities import ( "image/color" "github.com/oakmound/oak/v4/alg/floatgeom" "github.com/oakmound/oak/v4/collision" "github.com/oakmound/oak/v4/dlog" "github.com/oakmound/oak/v4/event" "github.com/oakmound/oak/v4/render" "github.com/oakmound/oak/v4/render/mod" "github.com/oakmound/oak/v4/scene" ) type ...
entities/entity.go
0.596668
0.405037
entity.go
starcoder
package curl // uint256 is a simple 256-bit uint modelled as an array of uint64. type uint256 [4]uint64 // bit returns the value of the i-th bit of z. // If i ≥ 256 the bit a position i % 256 is considered. func (z *uint256) bit(i uint) uint { return uint((z[(i/64)%4] >> (i % 64)) & 1) } // setBit sets the i-th bit...
curl/uint256.go
0.712632
0.545951
uint256.go
starcoder
package lexical // http://www.ncfta.ca/papers/emailforensics.pdf import ( "math" "strings" ) type Analysis struct { corpus string tokenArray []string CharacterCount int RatioOfDigitsToN float64 RatioOfLettersToN float64...
lexical/lexical.go
0.761716
0.513059
lexical.go
starcoder
package prec import ( "math" ) type floatInfo struct { mantbits uint expbits uint bias int } type decimalSlice struct { d []byte nd, dp int neg bool } func formatF64(f float64) string { return string(genericFtoa(make([]byte, 0, 24), f, 'f', -1, 64)) } func formatFloat(f float64, fmt byte, prec...
prec/grisu.go
0.616128
0.41561
grisu.go
starcoder
package pb import ( "sort" ) // ToBurndownSparseMatrix converts a rectangular integer matrix to the corresponding Protobuf object. // It is specific to hercules.BurndownAnalysis. func ToBurndownSparseMatrix(matrix [][]int64, name string) *BurndownSparseMatrix { if len(matrix) == 0 { panic("matrix may not be nil o...
internal/pb/utils.go
0.539954
0.471284
utils.go
starcoder
package year2021 import ( "bytes" "fmt" "os" "strings" "github.com/dhruvmanila/advent-of-code/go/util" ) // foldInstruction contains information regarding a single fold. type foldInstruction struct { // direction is the direction to which to fold to. 'x' and 'y' are the // possible values for folding the pape...
go/year2021/sol13.go
0.698946
0.59796
sol13.go
starcoder
package externalapi import ( "bytes" "encoding/hex" "github.com/pkg/errors" ) // DomainHashSize of array used to store hashes. const DomainHashSize = 32 // DomainHash is the domain representation of a Hash type DomainHash struct { hashArray [DomainHashSize]byte } // NewZeroHash returns a DomainHash that repres...
domain/consensus/model/externalapi/hash.go
0.887923
0.517632
hash.go
starcoder
// A illuminant conversion functions // Standard Illuminant A is, by definition, the same as a blackbody radiator of temperature 2856 K. package white // A_B functions func A_B_Bradford(xs, ys, zs float64) (xd, yd, zd float64) { m := [3][3]float64{ {0.8905163, -0.0829136, 0.2680945}, {-0.0971524, 1.0754262, 0.0...
f64/white/a.go
0.626467
0.551151
a.go
starcoder
package translate // Languages supported by Google Translate API. // https://cloud.google.com/translate/docs/languages var languages = map[string]string{ "af": "Afrikaans", "sq": "Albanian", "am": "Amharic", "ar": "Arabic", "hy": "Armenian", "az": "Azerbaijani", "eu": "Basque", "be...
languages.go
0.619471
0.490968
languages.go
starcoder
package engine // see.go is a simple implementation of a static exchange evaluator. var PieceValues [7]int16 = [7]int16{ 100, 300, 300, 500, 900, Inf, 0, } // Peform a static exchange evaluation on target square of the move given, // and return a score of the move from the perspective of the side to move. fun...
engine/see.go
0.785061
0.506408
see.go
starcoder
package codegentemplates const DocsEvents = `Each and every *Event* additionally has the following common meta data: - Timestamp, in UTC, the event was raised on - ID of the user that caused that event {{range .Module.Events.Events}} {{.Event}} ------- {{if .Changelog}} Changelog: {{range .Changelog}} - {{.}}{{end...
codegen/codegentemplates/docs.go
0.864282
0.80038
docs.go
starcoder
package wkb import ( "bytes" "encoding/binary" "fmt" "io" "github.com/golang/geo/s2" ) func decodeOrder(r io.ByteReader) (binary.ByteOrder, error) { orderByte, err := r.ReadByte() if err != nil { return nil, err } var order binary.ByteOrder switch orderByte { case wkbXDR: order = binary.BigEndian ca...
encoding/wkb/decode.go
0.766031
0.467332
decode.go
starcoder
package chk import ( "fmt" "math" "testing" ) // DerivVecSca checks the derivative of vector w.r.t scalar by comparing with numerical solution // obtained with central differences (5-point rule) // Check: // d{f} │ {f}:vector x:scalar // {g} = ———— │ with {g}:vector // ...
chk/deriv.go
0.680666
0.532668
deriv.go
starcoder
package types import ( "io" "math" "github.com/lyraproj/pcore/px" ) type TupleType struct { size *IntegerType givenOrActualSize *IntegerType types []px.Type } var TupleMetaType px.ObjectType func init() { TupleMetaType = newObjectType(`Pcore::TupleType`, `Pcore::AnyType { attribu...
types/tupletype.go
0.649245
0.494751
tupletype.go
starcoder
package graph import ( i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization" ) // BookingCustomQuestion provides operations to manage the solutionsRoot singleton. type BookingCustomQuestion struct { Entity // The expected answer type. ...
models/microsoft/graph/booking_custom_question.go
0.709724
0.4016
booking_custom_question.go
starcoder
package ann import ( "errors" "log" "math" "math/rand" "time" ) // Activater interface is Activation function that need have two methods. type Activater interface { Apply(float64) float64 Derivative(float64) float64 } // Sigmoid represents sigmoid activation function type Sigmoid struct { } // Apply calculat...
ann/bp.go
0.632616
0.505127
bp.go
starcoder
package benchmark import ( "reflect" "testing" ) func isBoolToUint16FuncCalibrated(supplier func() bool) bool { return isCalibrated(reflect.Bool, reflect.Uint16, reflect.ValueOf(supplier).Pointer()) } func isIntToUint16FuncCalibrated(supplier func() int) bool { return isCalibrated(reflect.Int, reflect.Uint16, re...
common/benchmark/09_to_uint16_func.go
0.707
0.649926
09_to_uint16_func.go
starcoder
package warc import ( "bufio" "compress/bzip2" "compress/gzip" "io" "io/ioutil" ) const ( // CompressionNone represent uncompression CompressionNone CompressionType = iota // CompressionBZIP represent BZIP compression CompressionBZIP // CompressionGZIP represent GZIP compression CompressionGZIP ) // Compr...
compression.go
0.604165
0.495789
compression.go
starcoder
package f32 // A Point is a two dimensional point. type Point struct { X, Y float32 } // A Rectangle contains the points (X, Y) where Min.X <= X < Max.X, // Min.Y <= Y < Max.Y. type Rectangle struct { Min, Max Point } // Add return the point p+p2. func (p Point) Add(p2 Point) Point { return Point{X: p.X + p2.X, Y...
ui/f32/f32.go
0.914267
0.654384
f32.go
starcoder
package main import ( . "github.com/benhoyt/goawk/internal/ast" . "github.com/benhoyt/goawk/lexer" . "github.com/benhoyt/goawk/parser" ) // typer walks the parse tree and builds a mappings of variables and // expressions to their types. type typer struct { globals map[string]valueType scalarRefs map[stri...
awkgo/typer.go
0.523664
0.451931
typer.go
starcoder
package main import ( "fmt" "math" ) // Pos returns the linear index of the coordinates x and y. // x and y need to be cast to uint8 before uint16 so // the value doesn't become incorrect if x or y are // negative. func Pos(x, y int8) uint16 { return (math.MaxUint8+1)*uint16(uint8(y)) + uint16(uint8(x)) } // Cell...
cell.go
0.797162
0.628037
cell.go
starcoder
package exprgraph import ( "gonum.org/v1/gonum/graph" "gorgonia.org/gorgonia/internal/execution" ) // SetWeightedEdge adds a weighted edge from one node to another. // If the nodes do not exist, they are added and are set to the nodes of the edge otherwise. // It will panic if the IDs of the e.From and e.To are equ...
internal/exprgraph/weighted_graph.go
0.737631
0.596404
weighted_graph.go
starcoder
package gtime import ( "github.com/xjh22222228/gosh/ginternal" "github.com/xjh22222228/gosh/gstr" "github.com/xjh22222228/gosh/gtime/glocale" "regexp" "strconv" "strings" "time" ) const ( FormatDate = "YYYY-MM-DD" FormatTime = "HH:mm:ss" FormatYear = "YYYY" FormatDateTime =...
gtime/format.go
0.666171
0.480052
format.go
starcoder
package ast // Block represents a linear sequence of statements, most often the contents // of a {} pair. type Block struct { Statements []Node // The set of statements that make up the block } func (Block) isNode() {} // Branch represents an «"if" condition { trueblock } "else" { falseblock }» structure. type Bra...
gapil/ast/expression.go
0.795221
0.746046
expression.go
starcoder
package serde import ( "errors" ) type DummyVisitor struct { expect string } func (vi DummyVisitor) String() string { if vi.expect == "" { return "dummy" } return vi.expect } func NewDummyVisitor(expect string) DummyVisitor { return DummyVisitor{expect: expect} } type BoolVisitor struct { v *bool } func...
de_primitive.go
0.714728
0.47926
de_primitive.go
starcoder
package ndjson import ( "bytes" "errors" "fmt" "unicode" "unicode/utf8" ) // FindKey accepts a JSON object and returns the value associated with the key specified func FindKey(in []byte, pos int, k []byte) ([]byte, error) { // The start variable will be available to hold our start position for each type // we ...
pkg/json/ndjson/json_query.go
0.724188
0.635138
json_query.go
starcoder
package lib import ( "fmt" "sort" ) // Range encapsulates the min and max values for an interval and allows the user // to specify some sort of metadata. type Range struct { Min int Max int Metadata interface{} } // Contains will establish that the given query falls in the bounds of the // Range, incl...
lib/interval_tree.go
0.799716
0.443661
interval_tree.go
starcoder
package legacydata import ( "strconv" "time" "github.com/timberio/go-datemath" ) type DataTimeRange struct { From string To string Now time.Time } func NewDataTimeRange(from, to string) DataTimeRange { return DataTimeRange{ From: from, To: to, Now: time.Now(), } } func (tr *DataTimeRange) GetFr...
pkg/tsdb/legacydata/time_range.go
0.712232
0.561395
time_range.go
starcoder
package basic import ( "errors" "fmt" "math" "strconv" "github.com/overseven/go-math-expression-parser/funcs" ) var ( // the array of operations sorted by operators // operators[0] - highest operators (unary, functions) // operators[1] - medium operators (*, /, %, ^) // operators[2] - lowest operators (+, -...
funcs/basic/basic.go
0.593256
0.497009
basic.go
starcoder
package pkg import "math" type Mat4x4 struct { m00, m01, m02, m03 float64 m10, m11, m12, m13 float64 m20, m21, m22, m23 float64 m30, m31, m32, m33 float64 } func (M *Mat4x4)setProjectionMatrix(viewAngle float64, nearDistance float64, farDistance float64) { // set the projection matrix scale := 1.0 / math.Tan(v...
pkg/matrix.go
0.736874
0.565119
matrix.go
starcoder
package validation const ( JSONSchemaFixedLengthFileDeclaration = ` { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "github.com/jf-tech/omniparser:fixedlength_file_declaration", "title": "omniparser schema: fixedlength/file_declaration", "type": "object", "properties": { ...
extensions/omniv21/validation/fixedlengthFileDeclaration.go
0.622918
0.406509
fixedlengthFileDeclaration.go
starcoder
package core import ( "gonum.org/v1/gonum/floats" "gonum.org/v1/gonum/stat" "math" ) /* Table */ // DataTable is an array of (userId, itemId, rating). type DataTable struct { Ratings []float64 Users []int Items []int } // NewDataTable creates a new raw data set. func NewDataTable(users, items []int, ratin...
core/table.go
0.663015
0.402011
table.go
starcoder
package graphblas import ( "context" "log" "github.com/rossmerr/graphblas/constraints" ) // DenseVector a vector type DenseVector[T constraints.Number] struct { l int // length of the sparse vector values []T } // NewDenseVector returns a DenseVector func NewDenseVector[T constraints.Number](l int) *Dens...
denseVector.go
0.850748
0.712307
denseVector.go
starcoder
package v1alpha1 // RackAwarenessState stores info about rack awareness status type RackAwarenessState string // State holds info about the state of action type State string // Action step holds info about the action step type ActionStep string // ClusterState holds info about the cluster state type ClusterState s...
pkg/apis/nifi/v1alpha1/common_types.go
0.552057
0.480174
common_types.go
starcoder
package livestatus import ( "reflect" "sort" "time" ) // Record represents a Livestatus response entry. type Record map[string]interface{} // Len returns the number of columns present in the record. func (r Record) Len() int { return len(r) } // Columns returns the list of the record columns. func (r Record) Co...
record.go
0.835416
0.427815
record.go
starcoder
package measurement import ( "fmt" "sync" "sync/atomic" "time" ) const ( sigFigs = 1 defaultMinLatency = 1 * time.Millisecond DefaultMaxLatency = 16 * time.Second ) type Measurement struct { warmUp int32 // use as bool, 1 means in warmup progress, 0 means warmup finished. sync.RWMutex MinLatency...
pkg/measurement/measure.go
0.61173
0.47591
measure.go
starcoder
package rijksdriehoek import "math" type coefficients struct { p float64 q float64 pq float64 } const ( x0 = 155000 y0 = 463000 phi0 = 52.15517440 lam0 = 5.38720621 ) var k = []coefficients{ {p: 0, q: 1, pq: 3235.65389}, {p: 2, q: 0, pq: -32.58297}, {p: 0, q: 2, pq: -0.24750}, {p: 2, q: 1, pq: -0.8497...
rd.go
0.659624
0.652933
rd.go
starcoder
package runes import ( "io" "io/ioutil" "github.com/phR0ze/n/pkg/buf" "github.com/phR0ze/n/pkg/errs" "github.com/pkg/errors" ) // Scanner provides methods for working with documents as runes type Scanner struct { src io.Reader // original source reader runes []rune // runes to work with Pos buf....
pkg/buf/runes/runes.go
0.586286
0.44083
runes.go
starcoder
package ilium import "math" const PDF_COS_THETA_EPSILON float32 = 1e-7 const PDF_R_EPSILON float32 = 1e-7 func uniformSampleDisk(u1, u2 float32) (x, y float32) { // This has a slight bias towards the center. r := sqrtFloat32(u1) theta := 2 * math.Pi * u2 sinTheta, cosTheta := sincosFloat32(theta) x = r * cosTh...
ilium/sampling.go
0.843992
0.400456
sampling.go
starcoder
package main import ( "fmt" "math/rand" "os" ) /* Playground app to rotate a random square matrix by 90 degrees clockwise */ func main() { var size = enterTheMatrix() var matrix = matrixReloaded(size) fmt.Println() fmt.Println("The Matrix Reloaded:") printMatrix(matrix) matrixRevolutions(matrix) fmt.Prin...
src/rotatematrix/rotatematrix.go
0.652463
0.449876
rotatematrix.go
starcoder
package dyno import ( "context" ddb "github.com/aws/aws-sdk-go-v2/service/dynamodb" "sync" ) // RestoreTableToPointInTime executes RestoreTableToPointInTime operation and returns a RestoreTableToPointInTime operation func (s *Session) RestoreTableToPointInTime(input *ddb.RestoreTableToPointInTimeInput, mw ...Resto...
op_RestoreTableToPointInTime.go
0.744471
0.588919
op_RestoreTableToPointInTime.go
starcoder
package convey import ( "github.com/smartystreets/goconvey/assertions" ) var ( ShouldEqual = assertions.ShouldEqual ShouldNotEqual = assertions.ShouldNotEqual ShouldResemble = assertions.ShouldResemble ShouldNotResemble = assertions.ShouldNotResemble ShouldPointTo = assertions.ShouldPointTo Sho...
src/github.com/smartystreets/goconvey/convey/assertions.go
0.622574
0.557725
assertions.go
starcoder
package smoothsurface import ( "math" "github.com/paulmach/go.geo" ) // LazySmoothSurface provides ValueAt and GradientAt function based on // a surface vertically and horizontally smoothed using the given kernel. // The values are smoothed on request and cached. // Note that is takes 3x the memory, but using arra...
utils/smoothsurface/lazy_smooth.go
0.87674
0.685563
lazy_smooth.go
starcoder
package modelselection import ( // "fmt" "runtime" "time" "github.com/pa-m/sklearn/base" "gonum.org/v1/gonum/mat" ) // CrossValidateResult is the struct result of CrossValidate. it includes TestScore,FitTime,ScoreTime,Estimator type CrossValidateResult struct { TestScore []float64 FitTime, ScoreTime ...
model_selection/validation.go
0.563618
0.474144
validation.go
starcoder
package statistics import ( "bytes" "math" "reflect" "sort" "github.com/cznic/mathutil" "github.com/cznic/sortutil" "github.com/pingcap/errors" "github.com/pingcap/tidb/sessionctx/stmtctx" "github.com/pingcap/tidb/tablecodec" "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util/chunk" "github.co...
statistics/cmsketch.go
0.686475
0.401277
cmsketch.go
starcoder
package grammar type repetitiveRuleNode struct { recursiveName string node RuleNode isMultipleMandatory bool isMultipleOptional bool isOptional bool } func createRepetitiveRuleNode(node RuleNode) RepetitiveRuleNode { return createRepetitiveRuleNodeInternally("", node, false, false...
pangolin/domain/lexers/grammar/repetitiverulenode.go
0.769514
0.507019
repetitiverulenode.go
starcoder
package graph import ( i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization" ) // WorkbookWorksheet type WorkbookWorksheet struct { Entity // Returns collection of charts that are part of the worksheet. Read-only. charts []Workboo...
models/microsoft/graph/workbook_worksheet.go
0.664323
0.404155
workbook_worksheet.go
starcoder
package main // simpy example: import ( "fmt" "log" "github.com/bgmerrell/simgo" ) // Python example /* import simpy def nested_condition(env): # Example nested `or` condition t1 = env.timeout(1, value='spam') t2 = env.timeout(2, value='eggs') t3 = env.timeout(3, value='coconut') results = yi...
examples/nested_condition.go
0.563618
0.487368
nested_condition.go
starcoder
package pgsgo import ( "fmt" "strings" pgs "github.com/vchitai/protoc-gen-star" ) func (c context) Type(f pgs.Field) TypeName { ft := f.Type() var t TypeName switch { case ft.IsMap(): key := scalarType(ft.Key().ProtoType()) return TypeName(fmt.Sprintf("map[%s]%s", key, c.elType(ft))) case ft.IsRepeated(...
lang/go/type_name.go
0.717408
0.412353
type_name.go
starcoder
package main import ( "fmt" "container/vector" ) type Sum struct { elements vector.IntVector accumulated int } func (this *Sum) Init(newElements vector.IntVector) { this.elements = newElements.Copy() this.accumulated = 0 for _,v := range this.elements { this.accumulated += v } } func (this *Sum) Init2...
project-euler/76.go
0.597373
0.428771
76.go
starcoder
package card import ( "context" "fmt" "net/http" "github.com/xendit/xendit-go" "github.com/xendit/xendit-go/utils/validator" ) // Client is the client used to invoke ewallet API. type Client struct { Opt *xendit.Option APIRequester xendit.APIRequester } // CreateCharge creates new card charge func (...
card/client.go
0.574395
0.401981
client.go
starcoder
package bufferdecoder import ( "encoding/binary" "fmt" ) type EbpfDecoder struct { buffer []byte cursor int } // New creates and initializes a new EbpfDecoder using rawBuffer as its initial content. // The EbpfDecoder takes ownership of rawBuffer, and the caller should not use rawBuffer after this call. // New i...
pkg/bufferdecoder/decoder.go
0.694717
0.41182
decoder.go
starcoder
package pjson // Bit flags passed to the "info" parameter of the iter function which // provides additional information about the const ( _ = 1 << iota String // the data is a JSON String Number // the data is a JSON Number True // the data is a JSON True False // the data is a JSON False Null /...
pjson.go
0.553505
0.566378
pjson.go
starcoder
package cc import ( "github.com/adamcolton/geom/d3" "github.com/adamcolton/geom/d3/affine" "github.com/adamcolton/geom/d3/solid" "github.com/adamcolton/geom/d3/solid/mesh" ) type ccMesh struct { mesh.Mesh edgeCtr uint32 edge2Idx map[solid.IdxEdge]uint32 pt2edge map[uint32]map[uint32]uint32 // maps ptI...
d3/solid/cc/cc.go
0.52902
0.448487
cc.go
starcoder
package astutil import "go/ast" func InjectAlias(t *ast.FuncType, importedSpecs map[string]*ast.ImportSpec, aliases map[string]string) { ast.Inspect(t, func(node ast.Node) bool { switch node := node.(type) { case *ast.Field: convertAlias(&node.Type, importedSpecs, aliases) case *ast.StarExpr: convertAlia...
vendor/github.com/maxbrunsfeld/counterfeiter/astutil/mutator.go
0.510741
0.45744
mutator.go
starcoder
package sif // A Partition is a portion of a columnar dataset, consisting of multiple Rows. // Partitions are not generally interacted with directly, instead being // manipulated in parallel by DataFrame Tasks. type Partition interface { ID() string // ID retrieves the ID of this Partition GetMaxRows() in...
partition.go
0.628293
0.749958
partition.go
starcoder
package trie // Adapted from the TST implementation in Algorithms, 4th ed., by <NAME> and <NAME>. // https://algs4.cs.princeton.edu/52trie/TST.java.html. // A Trie is a data structure that supports common prefix operations. type Trie[V any] struct { n int root *node[V] } type node[V any] struct { c ...
trie/trie.go
0.807992
0.57069
trie.go
starcoder
package container import ( "fmt" "reflect" "strings" "github.com/pspaces/gospace/function" ) // Template structure used for matching against tuples. // Template is a tuple with type information used for pattern matching. type Template struct { Flds []interface{} `bson:"fields" json:"fields" xml:"fields"` } // ...
container/template.go
0.613584
0.409811
template.go
starcoder
package webrtc // GetConnectionStats is a helper method to return the associated stats for a given PeerConnection func (r StatsReport) GetConnectionStats(conn *PeerConnection) (PeerConnectionStats, bool) { statsID := conn.getStatsID() stats, ok := r[statsID] if !ok { return PeerConnectionStats{}, false } pcSt...
trunk/3rdparty/srs-bench/vendor/github.com/pion/webrtc/v3/stats_go.go
0.681409
0.448487
stats_go.go
starcoder
// Package schulze implements the Schulze method for single winner voting. package schulze import ( "sort" ) // Score represents a total number of wins for a single choice. type Score struct { Choice string Wins int } // VoteMatrix holds number of votes for every pair of choices. type VoteMatrix map[string]map...
schulze.go
0.773559
0.539226
schulze.go
starcoder
package types import ( "io" "github.com/lyraproj/pcore/px" ) type VariantType struct { types []px.Type } var VariantMetaType px.ObjectType func init() { VariantMetaType = newObjectType(`Pcore::VariantType`, `Pcore::AnyType { attributes => { types => Array[Type] } }`, func(ctx px.Context, args []px.Value)...
types/varianttype.go
0.574634
0.492005
varianttype.go
starcoder
package meter import ( "reflect" ) var ( counterType = reflect.TypeOf((*Counter)(nil)) counterMultiType = reflect.TypeOf((*MultiCounter)(nil)) gaugeType = reflect.TypeOf((*Gauge)(nil)) gaugeMultiType = reflect.TypeOf((*MultiGauge)(nil)) histogramType = reflect.TypeOf((*Histogram)(nil)) histog...
meter/utils.go
0.606498
0.514095
utils.go
starcoder
package goiter import ( "io" ) // RunePositionIter tracks the line number and rune position while reading UTF8 runes of an io.Reader. // Tracks the first byte of multi byte runes. // LineNumberIter is an Iterable but not an Iter, since it only iterates runes. // When a CR, LF, or CRLF sequence is read, it is return...
rune_position_iter.go
0.667473
0.445952
rune_position_iter.go
starcoder
package utils import ( "reflect" "strings" "github.com/iancoleman/strcase" ) // IsModelSlice returns true if the given interface is a slice of models func IsModelSlice(model interface{}) bool { value := reflect.ValueOf(model) if value.Kind() == reflect.Ptr { return value.Elem().Kind() == reflect.Slice } re...
utils/models.go
0.700383
0.411939
models.go
starcoder
package trending import ( "errors" "math/rand" trending "github.com/andygrunwald/TrendingGithub/trends" ) // TrendingAPI represents the interface to the github.com/trending website type TrendingAPI interface { GetTrendingLanguages() ([]trending.Language, error) GetProjects(time, language string) ([]trending.Pro...
trending/trending.go
0.621771
0.47025
trending.go
starcoder
package templates // Readme is a default README laid down by s2i create const Readme = ` # Creating a basic S2I builder image ## Getting started ### Files and Directories | File | Required? | Description | |------------------------|-----------|...
pkg/create/templates/readme.go
0.876052
0.82029
readme.go
starcoder
package main import ( "bytes" "fmt" "math/rand" "strconv" "time" "github.com/rivo/tview" ) type cell struct { x int y int alive bool _id int _neighbours int } type grid struct { size int connectedEastWest bool connectedNorthSouth bool population ...
conway/conway.go
0.567337
0.433442
conway.go
starcoder
// +build amd64,!gccgo,!appengine // Package bitwise provides efficient implementations of xor/xnor/and/and-not/nand/or/nor/not. package bitwise // XOR sets each element in according to dst[i] = a[i] XOR b[i] func XOR(dst, a, b []byte) int { n := len(a) if len(b) < n { n = len(b) } if len(dst) < n { n = len(...
vendor/github.com/tmthrgd/go-bitwise/bitwise_amd64.go
0.513425
0.431944
bitwise_amd64.go
starcoder
package science import ( "encoding/json" "net/http" "reflect" "github.com/Clever/http-science/config" ) // cleanupHeaders removes headers that can be different for inconsequential reasons func cleanupHeaders(res *http.Response, cleanup []string) { for _, val := range cleanup { delete(res.Header, val) if val...
science/compare.go
0.575827
0.401072
compare.go
starcoder
package dusk import ( gl "github.com/go-gl/gl/v4.1-core/gl" "github.com/go-gl/mathgl/mgl32" ) // Material represents a collection of settings and textures type Material struct { Ambient mgl32.Vec4 Diffuse mgl32.Vec4 Specular mgl32.Vec4 AmbientMap *Texture DiffuseMap *Texture SpecularMap *Texture NormalM...
dusk/Material.go
0.623721
0.439627
Material.go
starcoder
package generators var DefinitionTemplate = ` {{define "definition.template"}}## {{.Name}} {{.Version}} Group | Version | Kind ------------ | ---------- | ----------- ` + "`{{.GroupDisplayName}}` | `{{.Version}}` | `{{.Name}}`" + ` {{if .OtherVersions}}<aside class="notice">Other api versions of this obje...
vendor/github.com/kubernetes-incubator/reference-docs/gen-apidocs/generators/templates.go
0.702428
0.641914
templates.go
starcoder
package xian import ( "fmt" "strings" ) type bigram struct { a, b rune } func (b *bigram) String() string { return fmt.Sprintf("%c%c", b.a, b.b) } // Biunigrams returns bigram and unigram tokens from s. func Biunigrams(s string) []string { tokens := make([]string, 0, 32) for bigram := range toBigrams(s) { ...
token.go
0.664758
0.403273
token.go
starcoder
package fn import ( "github.com/nlpodyssey/spago/mat" "sort" ) // SparseMax function implementation, based on https://github.com/gokceneraslan/SparseMax.torch type SparseMax[T mat.DType, O Operand[T]] struct { x O y mat.Matrix[T] // initialized during the forward pass, required by the backward pass...
ag/fn/sparsemax.go
0.811116
0.562357
sparsemax.go
starcoder
package cgp import ( "fmt" "math" "math/rand" "runtime" "sync" "time" ) // A Function is a function that is usable in a Genetic Program. It takes // one or more parameters and outputs a single result. For example // a Function could implement binary AND or floating point multiplication. type Function struct { ...
cgp.go
0.684053
0.576184
cgp.go
starcoder
package body import ( "encoding/json" "encoding/xml" "fmt" "github.com/burakkoken/api-master/expect" v "github.com/go-playground/validator/v10" "github.com/stretchr/testify/assert" "net/http" "testing" ) var validator = v.New() const HeaderContentType = "Content-Type" const ( ContentTypeApplicationJson = "...
body/expect.go
0.598312
0.475849
expect.go
starcoder
package draw2d import ( "image" "image/color" ) // GraphicContext describes the interface for the various backends (images, pdf, opengl, ...) type GraphicContext interface { // PathBuilder describes the interface for path drawing PathBuilder // BeginPath creates a new path BeginPath() // GetMatrixTransform re...
vendor/github.com/llgcode/draw2d/gc.go
0.6137
0.58157
gc.go
starcoder
package main import ( "fmt" "log" "os" "github.com/gonum/floats" "github.com/kniren/gota/dataframe" ) type centroid []float64 func main() { // Pull in the CSV file. irisFile, err := os.Open("iris.csv") if err != nil { log.Fatal(err) } defer irisFile.Close() // Create a dataframe from the CSV file. i...
Chapter06/evaluating/example2/myprogram.go
0.632049
0.531027
myprogram.go
starcoder
package display import ( "math" "sync" ) // TriangleRasterInput part of options that is passed to rasterizer workers. type TriangleRasterInput struct { // Pixel buffer. Shader needs to output color to buffer with // boffs offset and value calculated by shader. Buffer can use multiple // bytes for pixel. Multiply...
pkg/display/triangle.go
0.710528
0.51312
triangle.go
starcoder
package blocktype /* From draft-tuexen-opsawg-pcapng November 13, 2017 3.2. Block Types The currently standardized Block Type codes are specified in Section 11.1; they have been grouped in the following four categories: The following MANDATORY block MUST appear at least once in each file: o Sectio...
pcapng/blocktype/block_type.go
0.583322
0.52476
block_type.go
starcoder
// Package fr provides holiday definitions for France. package fr import ( "time" "github.com/Tamh/cal/v2" "github.com/Tamh/cal/v2/aa" ) var ( // NouvelAn represents New Year's Day on 1-Jan NouvelAn = aa.NewYear.Clone(&cal.Holiday{Name: "Nouvel an", Type: cal.ObservancePublic}) // LundiDePâques represents Ea...
v2/fr/fr_holidays.go
0.512205
0.528473
fr_holidays.go
starcoder
package sim import "fmt" // Strategy can select arm or update information type Strategy interface { SelectArm() int Update(arm int, reward float64) Reset() } // Arm simulates a single strategy arm pull with every execution. Returns {0,1}. type Arm func() float64 // MonteCarlo runs a monte carlo experiment with ...
sim/mc.go
0.8067
0.447158
mc.go
starcoder
package gos7 import ( "bytes" "encoding/binary" "fmt" "math" "time" ) const ( bias int64 = 621355968000000000 // "decimicros" between 0001-01-01 00:00:00 and 1970-01-01 00:00:00 ) //Helper the helper to get/set value from/to byte array with difference types type Helper struct{} //SetValueAt set a value at a p...
helper.go
0.589953
0.401277
helper.go
starcoder
package dash import ( "encoding/hex" "errors" "github.com/nfnt/resize" "image" "image/color" "strconv" ) type bitString string func (b bitString) asByteSlice() []byte { var out []byte var str string for i := len(b); i > 0; i -= 8 { if i-8 < 0 { str = string(b[0:i]) } else { str = string(b[i-8 : i...
Dash.go
0.705785
0.405154
Dash.go
starcoder
package interpretations import ( "fmt" "sync" "time" "github.com/spiceai/spiceai/pkg/proto/common_pb" spice_time "github.com/spiceai/spiceai/pkg/time" ) type InterpretationsStore struct { epoch time.Time endTime time.Time period time.Duration granularity time.Duration intervals int64 int...
pkg/interpretations/interpretations.go
0.64646
0.408955
interpretations.go
starcoder
package math32 // Sphere represents a 3D sphere defined by its center point and a radius type Sphere struct { Center Vector3 // center of the sphere Radius float32 // radius of the sphere } // NewSphere creates and returns a pointer to a new sphere with // the specified center and radius. func NewSphere...
math32/sphere.go
0.888384
0.51129
sphere.go
starcoder
package libsvm import ( "fmt" "math" "math/rand" "time" ) /** * This function does classification or regression on a test vector x given a model with probability information. For a classification model with probability information, this function gives nrClass probability estimates in the slice probab...
pkg/libsvm/probability.go
0.620162
0.563558
probability.go
starcoder
package fftw // FFT computes the Fourier transform of src. // It allocates memory in which to return the result. func FFT(src *Array) *Array { dst := NewArray(src.Len()) fftDir(dst, src, Forward) return dst } // IFFT computes the inverse Fourier transform of src. // It allocates memory in which to return the resul...
fftw/fft.go
0.908184
0.663689
fft.go
starcoder
package planner import ( "context" "fmt" "github.com/genjidb/genji/database" "github.com/genjidb/genji/document" "github.com/genjidb/genji/sql/query" "github.com/genjidb/genji/sql/query/expr" ) // An Operation can manipulate and transform a stream of documents. type Operation int const ( // Input is a node f...
sql/planner/tree.go
0.716417
0.419648
tree.go
starcoder
package gft import ( "image" "image/draw" "math" "github.com/infastin/gul/gm32" "github.com/infastin/gul/tools" ) type Interpolation int const ( NearestNeighborInterpolation Interpolation = iota BilinearInterpolation BicubicInterpolation ) type rotateFilter struct { rad float32 interpolation...
gft/rotate.go
0.695028
0.499695
rotate.go
starcoder
package Euler2D import ( "fmt" "math" "github.com/notargets/gocfd/utils" ) type FlowFunction uint16 func (pm FlowFunction) String() string { strings := []string{ "Density", "XMomentum", "YMomentum", "Energy", "Mach", "Static Pressure", "Dynamic Pressure", "Pressure Coefficient", "Sound Speed",...
model_problems/Euler2D/fluids.go
0.636918
0.573798
fluids.go
starcoder
// eqplot plots an equation updating over time in a etable.Table and Plot2D. // This is a good starting point for any plotting to explore specific equations. // This example plots a double exponential (biexponential) model of synaptic currents. package main import ( "math" "strconv" "github.com/emer/etable/eplot"...
examples/eqplot/eqplot.go
0.844953
0.550245
eqplot.go
starcoder
package GoNeuralNetwork import ( "errors" "fmt" "log" "sync" ) /* Represents the neural network. A slice of type layer. */ type network struct { layers []layer } /* Creates and returns a pointer to a new network struct. */ func CreateNetwork() *network { return &network{ layers: make([]layer, 0), } } /* Ad...
Network/network.go
0.655667
0.47244
network.go
starcoder
package pure import ( "fmt" "sort" "strings" "time" "github.com/benthosdev/benthos/v4/internal/bloblang/field" "github.com/benthosdev/benthos/v4/internal/bloblang/mapping" "github.com/benthosdev/benthos/v4/internal/bloblang/query" "github.com/benthosdev/benthos/v4/internal/bundle" "github.com/benthosdev/bent...
internal/impl/pure/processor_log.go
0.707708
0.548311
processor_log.go
starcoder
package template_comparable import ( "github.com/cheekybits/genny/generic" "sort" ) type ValueType generic.Number // ValueTypeSort sorts an array using the provided comparator func ValueTypeSort(a []ValueType) (err error) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) return nil } // ValueTypeBi...
template-comparable/slices.go
0.719975
0.519399
slices.go
starcoder
package gpsabl import ( "fmt" "math" "time" ) // Copyright 2019 by <EMAIL>. All // rights reserved. Use of this source code is governed // by a BSD-style license that can be found in the // LICENSE file. // CorrectionParameter - The "Enum" type the represents the correction mode type CorrectionParameter string c...
src/tobi.backfrak.de/internal/gpsabl/TrackFiller.go
0.717804
0.401629
TrackFiller.go
starcoder