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" "strings" ) type matrix map[string]map[string]int func (m *Model) BuildMatrix(expected, predicted []string) (matrix, []string, error) { if len(expected) != len(predicted) { return nil, nil, fmt.Errorf("Input slices are not equal length; expected length: %v, predicted length: %v", l...
models/confuse.go
0.513425
0.491944
confuse.go
starcoder
package processor import ( "fmt" "strconv" "strings" "time" "github.com/Jeffail/benthos/v3/internal/docs" "github.com/Jeffail/benthos/v3/internal/interop" "github.com/Jeffail/benthos/v3/internal/tracing" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/message" "github.com/Jeffail/...
lib/processor/process_field.go
0.719384
0.663819
process_field.go
starcoder
package unityai type PathCorridorState uint8 const ( kPathCorridorValid PathCorridorState = 1 << 0 kPathCorridorPartial PathCorridorState = 1 << 1 kPathCorridorInterrupted PathCorridorState = 1 << 2 ) type PathCorridor struct { m_pos Vector3f m_target Vector3f m_path []NavMeshPolyRef...
path_corridor.go
0.669745
0.545225
path_corridor.go
starcoder
package petstore import ( "encoding/json" ) // ReadOnlyFirst struct for ReadOnlyFirst type ReadOnlyFirst struct { Bar *string `json:"bar,omitempty"` Baz *string `json:"baz,omitempty"` } // NewReadOnlyFirst instantiates a new ReadOnlyFirst object // This constructor will assign default values to properties that ha...
samples/openapi3/client/petstore/go-experimental/go-petstore/model_read_only_first.go
0.736211
0.50061
model_read_only_first.go
starcoder
package runeutil // InRange : check min <= c <= max func InRange(c rune, min, max int) bool { return rune(min) <= c && c <= rune(max) } // IsLower : Is rune lower case? func IsLower(c rune) bool { return rune('a') <= c && c <= rune('z') } // IsUpper : Is rune upper case? func IsUpper(c rune) bool { return rune('A...
runeutil/runeutil.go
0.535341
0.61832
runeutil.go
starcoder
package fake import ( "github.com/stretchr/testify/mock" dem "github.com/markus-wa/demoinfocs-golang" "github.com/markus-wa/demoinfocs-golang/common" st "github.com/markus-wa/demoinfocs-golang/sendtables" ) var _ dem.IGameState = new(GameState) // GameState is a mock for of demoinfocs.IGameState. type GameState...
fake/game_state.go
0.660282
0.408218
game_state.go
starcoder
package main import ( "fmt" ) var ( //% is repaced with the "from" or "to" depot name pathTransform = Transform{ From: "^//%s/", To: "//%s/", } identTransform = Transform{ From: "^%s$", To: "%s", } //Transforms are indexed by the <db name>:<field index> where field index enumerates from 0 //fields...
transforms.go
0.512449
0.400017
transforms.go
starcoder
package node import ( "fmt" "github.com/bazo-blockchain/lazo/lexer/token" "math/big" ) // Node is the interface that wraps the basic Node functions. type Node interface { // Pos returns the position of the node in the source code. // It is also the position of the first token. Pos() token.Position // String re...
parser/node/nodes.go
0.738386
0.486941
nodes.go
starcoder
package problems import "math" /** * Definition for a binary tree node. */ type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func InorderTraversal(root *TreeNode) []int { res := []int{} stack := []*TreeNode{} for root != nil || len(stack) > 0 { for root != nil { stack = append(stack, ro...
problems/binary_tree.go
0.630344
0.48121
binary_tree.go
starcoder
Package ntp implementns ntp packet and basic functions to work with. It provides quick and transparent translation between 48 bytes and simply accessible struct in the most efficient way. */ package ntp import ( "net" "time" ) // NanosecondsToUnix is the difference between NTP and Unix epoch in NS const Nanoseconds...
protocol/ntp/ntp.go
0.748904
0.607721
ntp.go
starcoder
package pdp // Expression abstracts any PDP expression. // The GetResultType method returns type of particular expression. // The Calculate method returns calculated value for particular expression. type Expression interface { GetResultType() Type Calculate(ctx *Context) (AttributeValue, error) } type functionMaker...
pdp/expression.go
0.585931
0.532729
expression.go
starcoder
package validator import "fmt" // DigitsBetweenFloat64 returns true if value lies between left and right border func DigitsBetweenFloat64(value, left, right float64) bool { if left > right { left, right = right, left } return value >= left && value <= right } // MaxFloat64 is the validation function for validat...
validator_float.go
0.819026
0.728024
validator_float.go
starcoder
package ffi import ( "reflect" "github.com/kode4food/ale/data" ) type ( floatWrapper reflect.Kind intWrapper reflect.Kind stringWrapper reflect.Kind boolWrapper bool ) var ( _stringWrapper stringWrapper _boolWrapper boolWrapper float32zero = reflect.ValueOf(float32(0)) float64zero = reflect.Value...
ffi/primitive.go
0.540924
0.421254
primitive.go
starcoder
package snowball import ( "fmt" "github.com/ava-labs/avalanchego/ids" ) // Consensus represents a general snow instance that can be used directly to // process the results of network queries. type Consensus interface { fmt.Stringer // Takes in alpha, beta1, beta2, and the initial choice Initialize(params Para...
snow/consensus/snowball/consensus.go
0.760384
0.440168
consensus.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // OptionalClaims type OptionalClaims struct { // The optional claims returned in the JWT access token. accessToken []OptionalClaimable // Stores addi...
models/optional_claims.go
0.742515
0.407805
optional_claims.go
starcoder
package duration import ( "errors" "time" ) // Duration is a standard unit of time. type Duration time.Duration // String returns a string representing the duration in the form "3d1h3m". // Leading zero units are omitted. As a special case, durations less than one // second format use a smaller unit (milli-, micro...
duration.go
0.796965
0.414188
duration.go
starcoder
// Package shaderir offers intermediate representation for shader programs. package shaderir import ( "go/constant" "go/token" "strings" ) type Program struct { UniformNames []string Uniforms []Type TextureNum int Attributes []Type Varyings []Type Funcs []Func VertexFunc VertexFunc Fr...
internal/shaderir/program.go
0.622115
0.404802
program.go
starcoder
package txpool import ( "fmt" "github.com/ledgerwatch/erigon-lib/rlp" ) type NewPooledTransactionHashesPacket [][32]byte // ParseHashesCount looks at the RLP length Prefix for list of 32-byte hashes // and returns number of hashes in the list to expect func ParseHashesCount(payload Hashes, pos int) (count int, da...
txpool/packets.go
0.648689
0.422326
packets.go
starcoder
package copypasta import ( "math/rand" "time" ) /* k-d tree: k-dimensional tree; k 维树 https://en.wikipedia.org/wiki/K-d_tree 推荐 https://www.luogu.com.cn/blog/command-block/kdt-xiao-ji https://www.luogu.com.cn/blog/lc-2018-Canton/solution-p4148 https://oi-wiki.org/ds/kdt/ todo 题单 https://www.luogu.com.cn/training/...
copypasta/kd_tree.go
0.612078
0.546496
kd_tree.go
starcoder
package kubelet import metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" func cumulativeInt(metricName string, units string, value *uint64) *metricspb.Metric { if value == nil { return nil } return &metricspb.Metric{ MetricDescriptor: &metricspb.MetricDescriptor{ Name: metric...
receiver/kubeletstatsreceiver/kubelet/pb.go
0.659405
0.40869
pb.go
starcoder
package gerber import ( "fmt" "io" "math" ) const ( sf = 1e6 // scale factor ) // Shape represents the type of shape the apertures use. type Shape string const ( // RectShape uses rectangles for the aperture. RectShape Shape = "R" // CircleShape uses circles for the aperture. CircleShape Shape = "C" ) // P...
gerber/primitives.go
0.844633
0.627038
primitives.go
starcoder
package main import ( "fmt" "github.com/MarinX/keylogger" "github.com/nsf/termbox-go" "periph.io/x/periph/conn/gpio" "periph.io/x/periph/host" "periph.io/x/periph/host/bcm283x" ) // https://github.com/MarinX/keylogger/blob/master/keymapper.go // https://www.usb.org/sites/default/files/documents/hut1_12v2....
src/misc/spi-keyboard/main.go
0.500244
0.409457
main.go
starcoder
package triangulate3 import ( "geGoMetry/r3" "geGoMetry/shape" "math" ) func constructEnglobingTetra(Vectors []r3.Vector) shape.Mesh { offset := 1.0 minExtremity, maxExtremity := computeBoundingBoxForVectors(Vectors) minExtremity.Add(r3.Vector{-offset, -offset, -offset}) maxExtremity.Add(r3.Vector{offset, of...
triangulate3/englober.go
0.743447
0.545467
englober.go
starcoder
package search import ( "github.com/christat/gost/queue" "time" "fmt" ) // Best First Search underpins several algorithms, such as Greedy BFS or A*. // The main difference comes in the enqueuing logic, which is specific to the algorithm itself. func BestFirst(origin, target HeuristicState, callback BFSEnqueuingCal...
best_first_helper.go
0.797793
0.425307
best_first_helper.go
starcoder
package mimic import ( "encoding/binary" "fmt" "github.com/cilium/ebpf/asm" ) var _ VMMem = (*PlainMemory)(nil) // PlainMemory is the simplest implementation of VMMem possible, it is just a []byte with no additional information // about its contents. The ByteOrder is used when Load'in or Store'ing scalar values....
memory_plain.go
0.623033
0.423041
memory_plain.go
starcoder
package grid import ( "math/rand" ) // dungeon is a level comprised of square rooms connected by corridors. type dungeon struct { grid // superclass grid } // Generate a dungeon by partioning the given space into randomly sized // non-overlapping blocks. Reuse the definition of a room from room.go. func (d *dunge...
grid/dungeon.go
0.621656
0.448547
dungeon.go
starcoder
package main import ( "fmt" "reflect" ) func isBool(in reflect.Type) bool { return in.Kind() == reflect.Bool } func isInt(in reflect.Type) bool { switch in.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.U...
hack/gen-tf-code/reflect.go
0.529993
0.556038
reflect.go
starcoder
package list // Clone returns a new List with the same contents as this one. func (l *List[T]) Clone() *List[T] { nl := New[T]() if l == nil { return nil } if l.Count() == 0 { return nil } tail := &node[T]{ value: l.head.value, prev: nil, next: nil, } nl.head = tail for n := l.head; n != nil; n ...
collections/list/methods.go
0.785267
0.403097
methods.go
starcoder
* Implementation of the AES-GCM Encryption/Authentication * * Some restrictions.. * 1. Only for use with AES * 2. Returned tag is always 128-bits. Truncate at your own risk. * 3. The order of function calls must follow some rules * * Typical sequence of calls.. * 1. call GCM_init * 2. call GCM_add_header any number of ...
vendor/github.com/hyperledger/fabric-amcl/core/GCM.go
0.715026
0.447883
GCM.go
starcoder
package icinga import ( "errors" "fmt" "math" "strconv" "strings" ) type ( // Range is a combination of a lower boundary, an upper boundary // and a flag for inverted (@) range semantics. See [0] for more // details. Range interface { Check(float64) bool CheckInt(int) bool CheckInt32(int32) bool } r...
range.go
0.773644
0.440469
range.go
starcoder
package geo import ( "bytes" "encoding/binary" "encoding/json" "fmt" "log" "math" ) // Represents a Physical Point in geographic notation [lat, lng]. type Point struct { lat float64 lng float64 } const ( // According to Wikipedia, the Earth's radius is about 6,371km EARTH_RADIUS = 6371 ) // Returns a new ...
vendor/github.com/kellydunn/golang-geo/point.go
0.80406
0.510192
point.go
starcoder
package schemas import ( "encoding/json" ) // ObjectTypeDefinitionLabels Singular and plural labels for the object. Used in CRM display. type ObjectTypeDefinitionLabels struct { // The word for one object. (There’s no way to change this later.) Singular *string `json:"singular,omitempty"` // The word for multipl...
generated/schemas/model_object_type_definition_labels.go
0.635336
0.439807
model_object_type_definition_labels.go
starcoder
package forGraphBLASGo import ( "github.com/intel/forGoParallel/pipeline" ) type vxM[Dw, Du, DA any] struct { op Semiring[Dw, Du, DA] u *vectorReference[Du] A *matrixReference[DA] } func newVxM[Dw, Du, DA any]( op Semiring[Dw, Du, DA], u *vectorReference[Du], A *matrixReference[DA], ) computeVectorT[Dw] { ...
functional_Vector_ComputedVxM.go
0.538012
0.507873
functional_Vector_ComputedVxM.go
starcoder
package helpers import "sort" type ArrayTypes interface { int | int32 | int64 | float32 | float64 | ~string } // Permutations generates all possible combinations from the input data func Permutations(xs []int16) (permuts [][]int16) { // Taken from: https://www.golangprograms.com/golang-program-to-generate-slice-pe...
pkg/helpers/manipulations.go
0.754282
0.509581
manipulations.go
starcoder
package packet import "encoding/json" const biomeRegistryJSON = ` { "value": [ { "name": "minecraft:ocean", "id": 0, "element": { "temperature": 0.5, "scale": 0.1, "precipitation": "rain", "effects": { "water_fog_color": 329011, "water_color"...
pkg/edition/java/proto/packet/biome.go
0.615666
0.41253
biome.go
starcoder
package mongo import ( "fmt" ) // Price is a structure that holds a price and gives information about the // amount of tax applied to that price. type Price struct { gross Money // The gross. net Money // The net which is equal to the gross minus tax. tax Money // The amount of tax subtra...
price.go
0.795022
0.676133
price.go
starcoder
<tutorial> Getting started example of using 51Degrees device detection match metrics information. The example shows how to: <ol> <li>Instantiate the 51Degrees device detection provider. <p><pre class="prettyprint lang-go"> var provider = FiftyOneDegreesPatternV3.NewProvider(dataFile) </pre></p> <li>Produce a match for ...
MatchMetrics.go
0.628179
0.654398
MatchMetrics.go
starcoder
package r3 import ( "math" ) // Vector data structure type Vector struct { X, Y, Z float64 } // Zero Vector var Zero = Vector{} func createVector(a, b Vector) Vector { return Vector{ a.X - b.X, a.Y - b.Y, a.Z - b.Z, } } // Norm returns the vector's norm. func (v Vector) Norm() float64 { return math.Sqrt(...
r3/vector.go
0.921684
0.798423
vector.go
starcoder
package xmath import "math" type Vector struct { X float64 `json:"x"` Y float64 `json:"y"` Z float64 `json:"z"` } func Vect(x, y, z float64) Vector { return Vector{x, y, z} } func (v Vector) Length() float64 { return math.Sqrt(v.X*v.X + v.Y*v.Y + v.Z*v.Z) } func (v Vector) LengthSq() float64 { return v.X*v.X...
xmath/math.go
0.866712
0.644197
math.go
starcoder
package gocw import ( "math" "math/rand" "sort" ) // Edge represents an edge in a directed graph type Edge struct { // identifies indices of the samples at the ends of an edge. Idx1, Idx2 uint64 // can be used for any purpose Distance float64 } type Edges []Edge func (e Edges) Len() int { return len(e) } fu...
chinesewhispers.go
0.703346
0.505188
chinesewhispers.go
starcoder
package types import ( "database/sql/driver" "fmt" "github.com/shopspring/decimal" ) const surgePrecision = 2 var ( // DefaultSurge represents the base of surges DefaultSurge = NewSurgeFromFloat(1) zero = NewSurgeFromFloat(0.) decimal100 = decimal.NewFromFloat(100.0) coeff = decimal.NewFromFloat...
vendor/junolab.net/ms_core/types/surge.go
0.799912
0.557604
surge.go
starcoder
package iso20022 // Description of the financial instrument. type FinancialInstrumentAttributes3 struct { // Identifies the financial instrument. SecurityIdentification *SecurityIdentification11 `xml:"SctyId"` // Quantity of entitled intermediate securities based on the balance of underlying securities. Quantity...
data/train/go/93e617a40fcc77c55a5385592f43ac0e16ea5a17FinancialInstrumentAttributes3.go
0.852537
0.416737
93e617a40fcc77c55a5385592f43ac0e16ea5a17FinancialInstrumentAttributes3.go
starcoder
package drw import ( "math" "github.com/jakubDoka/mlok/ggl" "github.com/jakubDoka/mlok/mat" "github.com/jakubDoka/mlok/mat/angle" ) // AutoResolutionSpacing is size of fraction of the circle that has Auto resolution var AutoResolutionSpacing float64 = 1 // Auto is constant that if you pass as resolution to Circ...
ggl/drw/circle.go
0.74158
0.557604
circle.go
starcoder
package asig import "github.com/bloeys/gglm/gglm" const ( MaxColorSets = 8 MaxTexCoords = 8 ) type Mesh struct { //Bitwise combination of PrimitiveType enum PrimitiveTypes PrimitiveType Vertices []gglm.Vec3 Normals []gglm.Vec3 Tangents []gglm.Vec3 BitTangents []gglm.Vec3 //ColorSets ...
asig/mesh.go
0.649134
0.42316
mesh.go
starcoder
package ot import ( "crypto/rand" "crypto/rsa" "encoding/binary" "fmt" "io" "math/big" "github.com/markkurossi/mpc/ot/mpint" "github.com/markkurossi/mpc/pkcs1" ) // RandomData creates size bytes of random data. func RandomData(size int) ([]byte, error) { m := make([]byte, size) _, err := rand.Read(m) if ...
ot/rsa.go
0.857171
0.416856
rsa.go
starcoder
package main import ( "bufio" "fmt" "log" "os" ) func main() { fmt.Println("Starting day11") // Part one result1 := GetCountOfOccupiedSeatsPartOne("input.txt") fmt.Printf("Part one: the number of occupied seats after the grid stabalizes is %v\n", result1) // Part two result2 := GetCountOfOccupiedSeatsPart...
2020/day11/day11.go
0.610221
0.427935
day11.go
starcoder
// Mounts template-attack on ECDH power traces, and proves zero-coordinate // point operations are discernible from power traces. // This can be used to mount Goubin's "Refined Power-Analysis Attack". // https://wiki.newae.com/Template_Attacks // $ go run cmd/ecdh_zero_point_template_attack.go -logtostderr \ // ...
cmd/ecdh_zero_point_template_attack.go
0.723212
0.584597
ecdh_zero_point_template_attack.go
starcoder
package shape import ( "gioui.org/f32" "gioui.org/layout" "gioui.org/op" "gioui.org/op/clip" "gioui.org/op/paint" "image/color" ) const c = 0.55228475 // 4*(sqrt(2)-1)/3 type Circle struct { Center f32.Point Radius float32 FillColor *color.NRGBA StrokeColor *color.NRGBA StrokeWidth float32 } ...
wonder/shape/circle.go
0.688259
0.419113
circle.go
starcoder
package parse import "fmt" // Expr represents a special type of Node that represents an expression. type Expr interface { Node } // NameExpr represents an identifier, such as a variable. type NameExpr struct { Pos Name string // Name of the identifier. } // NewNameExpr returns a NameExpr. func NewNameExpr(name s...
parse/expr.go
0.813535
0.615261
expr.go
starcoder
package clang // #include <stdlib.h> // #include "go-clang.h" import "C" /** * \brief Flags that control the creation of translation units. * * The enumerators in this enumeration type are meant to be bitwise * ORed together to specify which options should be used when * constructing the translation unit. */ ty...
translationunitflags.go
0.53048
0.428413
translationunitflags.go
starcoder
package draw2d import ( "image" "image/color" ) // GraphicContext describes the interface for the various backends (images, pdf, opengl, ...) type GraphicContext interface { PathBuilder // BeginPath creates a new path BeginPath() // GetMatrixTransform returns the current transformation matrix GetMatrixTransfo...
vendor/github.com/llgcode/draw2d/gc.go
0.619471
0.547646
gc.go
starcoder
package m2c import ( "fmt" "math/cmplx" ) var ( conj = cmplx.Conj ) // Matrix with two rows, two columns and Complex numbers as values. type Matrix struct { A, B, C, D complex128 } // Matrix contructor. func NewMatrix(a, b, c, d complex128) Matrix { return Matrix{A: a, B: b, C: c, D: d} } // CannotInvertMatri...
matrix.go
0.892899
0.715561
matrix.go
starcoder
package trie //Trie -> datastructure type type Trie struct { letter rune children []*Trie meta map[string]interface{} isLeaf bool } //Inserting a node in trie /* 1. set a current node as root node 2. set the current letter as the first letter of the word 3. if current node has reference to the current let...
Data Structures/Trie/trie.go
0.564339
0.478285
trie.go
starcoder
package nagios import ( "github.com/hashicorp/terraform/helper/schema" ) func dataSourceHost() *schema.Resource { return &schema.Resource{ Read: dataSourceHostRead, Schema: map[string]*schema.Schema{ "host_name": { Type: schema.TypeString, Required: true, }, "address": { Type: s...
nagios/data_source_host.go
0.616012
0.470007
data_source_host.go
starcoder
package continuous import ( "fmt" "math" "os" "sort" pb "gopkg.in/cheggaaa/pb.v1" ) // FrenzelPompe is an implementation of // <NAME> and <NAME>. // Partial mutual information for coupling analysis of multivariate time series. // Phys. Rev. Lett., 99:204101, Nov 2007. // The function assumes that the data xyz i...
continuous/FrenzelPompe.go
0.592195
0.540742
FrenzelPompe.go
starcoder
// Package csv provides methods for easily validating the rows and columns of a // CSV file. package csv import ( "context" "io/ioutil" "os" "regexp" "strconv" "strings" "chromiumos/tast/errors" "chromiumos/tast/local/crosconfig" ) // validator represents a function validator that takes in as input an eleme...
src/chromiumos/tast/local/bundles/cros/platform/csv/valid.go
0.69181
0.469642
valid.go
starcoder
package polygo /* This file contains polynomial type defintions and general operations. */ import ( "errors" "fmt" ) // A RealPolynomial is represented as a slice of coefficients ordered increasingly by degree. // For example, one can imagine: 5x^0 + 4x^1 + (-2)x^2 + ... type RealPolynomial struct { ...
polynomial.go
0.869049
0.533519
polynomial.go
starcoder
package lit import ( "fmt" "github.com/mb0/diff" "xelf.org/xelf/cor" "xelf.org/xelf/knd" ) // Delta is a list of path edits that describe a transformation fromn one value to another. type Delta []KeyVal // Diff returns delta between values a and b or an error. The result can be applied to a to get b. // The sim...
lit/delta.go
0.609292
0.506836
delta.go
starcoder
package azure import ( "context" "encoding/json" "errors" "fmt" "net/http" "strings" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/data/aztables" "github.com/benthosdev/benthos/v4/internal/batch/policy" "github.com/benthosdev/benthos/v4/internal/bloblang/fiel...
internal/impl/azure/output_table_storage.go
0.669529
0.562898
output_table_storage.go
starcoder
package gofun // Zippable is the interface for zipping. type Zippable interface { // Zip creates Unzippable of pairs where the pair from Unzippable contains // two elements from two Zippables which have same position. Fail must be a // failure Unzippable. Zip(ys Zippable, fail Unzippable) Unzippable ...
zippable.go
0.640523
0.484319
zippable.go
starcoder
package main import ( "github.com/faiface/pixel" "github.com/faiface/pixel/pixelgl" ) // chunk handles triangle data and batch drawing type chunk struct { dirty bool batch *pixel.Batch triangles *pixel.TrianglesData bounds *Bounds cType chunkType sprite *pixel.Sprite } // Impl. the Entity i...
chunk.go
0.68679
0.409398
chunk.go
starcoder
package cruzbit import ( "golang.org/x/crypto/ed25519" ) // BranchType indicates the type of branch a particular block resides on. // Only blocks currently on the main branch are considered confirmed and only // transactions in those blocks affect public key balances. // Values are: MAIN, SIDE, ORPHAN or UNKNOWN. t...
ledger.go
0.547222
0.55652
ledger.go
starcoder
package pgo type RigidbodyFlags uint32 const ( /** \brief Enables kinematic mode for the actor. Kinematic actors are special dynamic actors that are not influenced by forces (such as gravity), and have no momentum. They are considered to have infinite mass and can be moved around the world using the setKinemati...
pgo/rigidbodyflags.go
0.719088
0.600393
rigidbodyflags.go
starcoder
package sliceutil import ( "reflect" ) // Compare will check if two slices are equal // even if they aren't in the same order // Inspired by github.com/stephanbaker white board sudo code func Compare(s1, s2 interface{}) bool { if s1 == nil || s2 == nil { return false } // Convert slices to correct type slice1...
sliceutil.go
0.644225
0.406155
sliceutil.go
starcoder
package sim import ( "github.com/quells/LennardJonesGo/vector" "math" "math/rand" ) // InitPositionCubic initializes particle positions in a simple cubic configuration. func InitPositionCubic(N int, L float64) [][3]float64 { R := make([][3]float64, N) Ncube := 1 for N > Ncube*Ncube*Ncube { Ncube++ } rs := L...
sim/initialize.go
0.695131
0.497315
initialize.go
starcoder
package data import ( "fmt" "strconv" "strings" ) // A Value represents a dynamically typed piece of data. type Value struct { Type Type Word string Number float64 Proc Procedure Str string Quotation []Value Bool bool } // Type describes the internal type of a Value. type Type ...
data/value.go
0.635336
0.432363
value.go
starcoder
package conv import "time" // NewBool returns ref to v. func NewBool(v bool) *bool { return &v } // ValueBool returns dereference of v or zero value if nil. func ValueBool(v *bool) bool { if v == nil { return false } return *v } // NewInt returns ref to v. func NewInt(v int) *int { return &v } // ValueInt ret...
new_native.go
0.784773
0.405419
new_native.go
starcoder
package rbtree import ( "log" ) type color bool const ( red color = true black color = false ) var ( nilNode = &RBTree{0, 0, black, nil, nil, nil} ) // RBTree ... type RBTree struct { key uint32 value interface{} color color // true - red, false - black left *RBTree right *RBTree parent *RBTree }...
rbtree/rbtree.go
0.532911
0.411525
rbtree.go
starcoder
package keeper import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" hardtypes "github.com/kava-labs/kava/x/hard/types" "github.com/kava-labs/kava/x/incentive/types" ) // AccumulateHardBorrowRewards updates the rewards accumulated for the input reward period func (k Keeper) AccumulateHardBorrowRewards(ctx sdk...
x/incentive/keeper/rewards_borrow.go
0.726426
0.458106
rewards_borrow.go
starcoder
package model type ( // Type is the data structure for storing the parsed values of schema string Type map[string]Collection // key is database name // Collection is a data structure for storing fields of schema Collection map[string]Fields // key is collection name // Fields is a data structure for storing the ...
gateway/model/schema_type.go
0.566858
0.444022
schema_type.go
starcoder
package bitio import ( "bufio" "io" ) // Reader is the bit reader interface. type Reader interface { // Reader is an io.Reader io.Reader // Reader is also an io.ByteReader. // ReadByte reads the next 8 bits and returns them as a byte. io.ByteReader // ReadBits reads n bits and returns them as the lowest n b...
vendor/github.com/icza/bitio/reader.go
0.637257
0.403949
reader.go
starcoder
package screen2d import ( "fmt" "time" "github.com/veandco/go-sdl2/sdl" ) // Color meets the color.Color interface required for CreateRGBSurface type Color struct { R, G, B, A uint32 } // RGBA meets the color.Color interface required for CreateRGBSurface func (c Color) RGBA() (r, g, b, a uint32) { return c.R, ...
screen2d.go
0.835114
0.519887
screen2d.go
starcoder
package protocol import ( "sync" ) /*This datastructe maintains a map of the form [32]byte - *Block. It stores the blcoks received from the shards. This datastructure will be queried after every epoch block to check if we can continue to the next epoch. Because we need to remove the first element of this datastructur...
protocol/received_block_stash.go
0.510985
0.440229
received_block_stash.go
starcoder
package reducer // Reduce is a generic reduction function that processes the input from left to right. // Initially, the state is equal to start. // Then, combine is called for each input together with the current state. // Finally, the state is returned. func Reduce[A, B any](start B, combine func(B, A) B) Reducer[A,...
reducer/aggregates.go
0.785925
0.737442
aggregates.go
starcoder
package set const predicatedFunctions = ` // Filter returns a new {{.TName}}Set whose elements return true for func. func (set {{.TName}}Set) Filter(fn func({{.PName}}) bool) {{.TName}}Collection { result := make(map[{{.PName}}]struct{}) for v := range set { if fn(v) { result[v] = struct{}{} } } return {{.T...
internal/set/predicated.go
0.813757
0.601945
predicated.go
starcoder
package tonacity import ( "fmt" "sort" ) // Interval The type to use when specifying an interval in a key. type Interval uint8 const ( // These are intervals in the context of a key, which is made up of seven notes. // First For specifying the root tone. Here for completeness, not actually useful. First Inter...
chords.go
0.88178
0.61659
chords.go
starcoder
package signal //go:generate go run gen.go import ( "math" "reflect" "time" ) type ( // Signal is a buffer that contains a digital representation of a // physical signal that is a sampled and quantized. // Signal types have semantics of go slices. They can be sliced // and appended to each other. Signal inte...
signal.go
0.729327
0.525795
signal.go
starcoder
package indicators import ( "fmt" ) // A collection of indicators and derived FSMs. type FsmCollection struct { // Array of all FSMs Fsms []*FsmMap // Map from FSM to Indicator Indicators map[*FsmMap]*Indicator // Map from activator tokens to array of FSMs. The tokens include // all tokens which lead out o...
collection.go
0.600657
0.421195
collection.go
starcoder
package feedforward import ( "fmt" "math" ) // Represents a type which holds information about the current Iteration of an iterative algorithm. // GetIteration returns the current Iteration number. // GetScore returns a loss function score (lower is better). type IterationStatistic interface { GetIteration() int ...
observers.go
0.86164
0.591989
observers.go
starcoder
package skillz type Operator struct { Column string `json:"column"` Operation Operation `json:"operation"` Value OpValue `json:"value"` } type OpValue interface{} type Operation int const ( EqualOp Operation = iota NotEqualOp GreaterThanOp GreaterThanEqualToOp LessThanOp LessThanEqualToOp InOp...
operator.go
0.766031
0.436202
operator.go
starcoder
package books import ( "database/sql" "fmt" _ "github.com/mattn/go-sqlite3" // Used with sql package. ) const titleSearch = true // Used as a parameter when func query is called. // Book represents a searchable book object. type Book struct { ID int // A different number for each book. Title ...
pkg/books/books.go
0.633183
0.444384
books.go
starcoder
package numbers import ( "log" "math" //DEBUG: "fmt" ) //LogIntegrate evaluates log(int_a^b f(x)dx) in cases where f returns log(f(x)). Uses the rectangle rule. func LogIntegrate(f func(float64) float64, a float64, b float64, n int) float64 { if a >= b { log.Fatalf("logIntegrate failed, left bound must be small...
numbers/integrate.go
0.696784
0.557785
integrate.go
starcoder
package collections import ( "reflect" ) // IndexOf Returns the index of the first occurrence of the specified element in the slice, or -1 if the specified element is not contained in the slice. func IndexOf[T any](slice []*T, element *T) int { for index, value := range slice { if reflect.DeepEqual(value, element...
collections/collections.go
0.883575
0.734453
collections.go
starcoder
package storagehostmanager import ( "time" "github.com/DxChainNetwork/godx/common/unit" "github.com/DxChainNetwork/godx/storage" ) // StorageHostManager related constant const ( saveFrequency = 2 * time.Minute PersistStorageHostManagerHeader = "Storage Host Manager Settings" PersistStorage...
storage/storageclient/storagehostmanager/defaults.go
0.594904
0.406744
defaults.go
starcoder
package dataframe import ( "fmt" "time" ) // Vector represents a collection of Elements. type Vector interface { Set(idx int, i interface{}) Append(i interface{}) At(i int) interface{} Len() int PrimitiveType() VectorPType } func newVector(t interface{}, n int) (v Vector) { switch t.(type) { case []int64: ...
vendor/github.com/grafana/grafana-plugin-sdk-go/dataframe/vector.go
0.659186
0.517327
vector.go
starcoder
package interpreter import ( "fmt" "github.com/smackem/ylang/internal/lang" "reflect" ) type Nilval lang.Nil func (n Nilval) Compare(other Value) (Value, error) { if _, ok := other.(Nilval); ok { return Number(0), nil } return nil, nil } func (n Nilval) greaterThan(other Value) (Value, error) { return nil,...
internal/interpreter/nilval.go
0.78785
0.433382
nilval.go
starcoder
package packets // This packet contains lap times and tyre usage for the session. This packet works slightly differently to other packets. To reduce CPU and bandwidth, each packet relates to a specific vehicle and is sent every 1/20 s, and the vehicle being sent is cycled through. Therefore in a 20 car race you should...
pkg/packets/session_history.go
0.546496
0.487612
session_history.go
starcoder
package day9 import ( "strconv" "strings" ) // isSumOfNumberPair checks whether a number is the sum // of any two distinct numbers in a list func isSumOfNumberPair(num int64, numbers []int64) bool { if len(numbers) < 2 { return false } for i := 0; i < len(numbers)-1; i++ { for o := 1; o < len(numbers); o++ ...
2020/day9/day9.go
0.529507
0.446374
day9.go
starcoder
package main import ( "encoding/json" "fmt" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclsyntax" "github.com/zclconf/go-cty/cty" ctyjson "github.com/zclconf/go-cty/cty/json" ) // Value represent a value to serialize into JSON type Value struct { Value interface{} } func singleToValue(v inter...
packages/@ts-terraform/hcl/parse.go
0.729134
0.415788
parse.go
starcoder
// Package lgs handles input and output of Longer Orange 10 print files package lgs import ( "fmt" "image" "image/color" ) func Rle4Encode(pic *image.Gray) (data []byte, err error) { bounds := pic.Bounds() addSpan := func(color uint8, span uint) (out []byte) { for ; span > 0; span >>= 4 { datum := uint8(s...
lgs/rle.go
0.694406
0.416915
rle.go
starcoder
package tda import ( "image" "image/color" "image/jpeg" "image/png" "os" "strings" "github.com/kettek/apng" "gonum.org/v1/gonum/floats" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/vg" ) // GetImage returns the pixel levels of a jpeg or png file as greyscale // values, along with the...
image_utils.go
0.668988
0.407893
image_utils.go
starcoder
package dsu; /* A disjoint-set—also called union-find—data structure keeps track of nonoverlapping partitions of a collection of data elements. Initially, each data element belongs to its own, singleton, set. The following operations can then be performed on these sets: • Union merges two sets into a single set cont...
data_structures/Disjoint_Set_Union/Golang/DSU_Path_Compression.go
0.868896
0.627366
DSU_Path_Compression.go
starcoder
package camera import ( "github.com/faiface/pixel" "gotracer/vmath" "math" ) // CameraDefocus object describes how the objects are projected into the screen. // The camera object is used to get the rays that need to be casted for each screen UV coordinate. type Camera struct { // Aspect ratio of the camera viewpo...
camera/camera.go
0.831725
0.634812
camera.go
starcoder
package aoc2021 import ( "fmt" "strconv" "strings" utils "github.com/simonski/aoc/utils" ) /* --- Day 3: Binary Diagnostic --- The submarine has been making some odd creaking noises, so you ask it to produce a diagnostic report just in case. The diagnostic report (your puzzle input) consists of a list of binary...
app/aoc2021/aoc2021_03.go
0.791338
0.798108
aoc2021_03.go
starcoder
package integration import ( "context" "fmt" "strconv" "testing" "time" "github.com/m3db/m3/src/dbnode/client" "github.com/m3db/m3/src/dbnode/encoding" "github.com/m3db/m3/src/dbnode/storage/index" "github.com/m3db/m3/src/m3ninx/idx" "github.com/m3db/m3/src/x/ident" xtime "github.com/m3db/m3/src/x/time" ...
src/dbnode/integration/index_helpers.go
0.620277
0.443962
index_helpers.go
starcoder
package sqlparser // EqualsSQLNode does deep equals between the two objects. func EqualsSQLNode(inA, inB SQLNode) bool { if inA == nil && inB == nil { return true } if inA == nil || inB == nil { return false } switch a := inA.(type) { case AccessMode: b, ok := inB.(AccessMode) if !ok { return false ...
go/vt/sqlparser/ast_equals.go
0.511717
0.479565
ast_equals.go
starcoder
package fork import "math/big" // CompactToBig converts a compact representation of a whole number N to an unsigned 32-bit number. The representation is similar to IEEE754 floating point numbers. // Like IEEE754 floating point, there are three basic components: the sign, the exponent, and the mantissa. They are bro...
pkg/chain/fork/bits.go
0.679604
0.564279
bits.go
starcoder
package op // This defines how we do projected gradient. type ProjectedGradient struct { projector *Projection beta, sigma, alpha float32 } type vgpair struct { value float32 gradient Parameter } func NewProjectedGradient(projector *Projection, beta, sigma, alpha float32) *ProjectedGradient { return...
op/projected_gradient.go
0.867822
0.562898
projected_gradient.go
starcoder
package gameutils import ( "github.com/hajimehoshi/ebiten/v2" "image" ) // Interfaz básica de Entidad type BaseEntity interface { Update() error Draw(screen *ebiten.Image) CheckPosition(x int, y int) bool GetPosition() (float64, float64) SetPosition(x float64, y float64) Move(x float64...
castlecleanup/gameutils/entities.go
0.5083
0.576214
entities.go
starcoder
package seq import ( "fmt" "strings" util "github.com/leesjensen/go-chart/util" ) const ( bufferMinimumGrow = 4 bufferShrinkThreshold = 32 bufferGrowFactor = 200 bufferDefaultCapacity = 4 ) var ( emptyArray = make([]float64, 0) ) // NewBuffer creates a new value buffer with an optional set of valu...
seq/buffer.go
0.767167
0.459986
buffer.go
starcoder