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 // Handles doing predictions for a potential phase permutation of a week once the phase // pattern is finalized type weekPredictor struct { Ticker *PriceTicker Pattern PricePattern PatternPhases []PatternPhase // Value cache // The probability weight of the price pattern given last we...
models/predictorWeek.go
0.842345
0.672264
predictorWeek.go
starcoder
package emu import ( "log" "gitlab.com/akita/mgpusim/insts" "gitlab.com/akita/mgpusim/kernels" "gitlab.com/akita/util/ca" ) // A Wavefront in the emu package is a wrapper for the kernels.Wavefront type Wavefront struct { *kernels.Wavefront pid ca.PID Completed bool AtBarrier bool inst *insts.Inst ...
emu/wavefront.go
0.595493
0.414543
wavefront.go
starcoder
package jps type Node struct { row int col int } //GetCol returns column value for a node. in terms of x and y this is x func (node *Node) GetCol() int { return node.col } //GetRow returns row value for a node . in terms of x and y this is y func (node *Node) GetRow() int { return node.row } //GetNode returns n...
jumpPoint.go
0.723505
0.603026
jumpPoint.go
starcoder
package require import ( "reflect" "strconv" ) //Int converts the given number or string value to int. //If conversion is not possible returns the given default value or 0 if no default value is specified. func Int(num interface{}, defaultValue ...int) int { def := 0 if len(defaultValue) > 0 { def = defaultValu...
common/require/requireNumber.go
0.729616
0.496887
requireNumber.go
starcoder
package dst // Gaussian ratio distribution. import ( "math" ) //GearyHinkleyTransformation transforms the ratio of two normally distributed variables to the transformed variable T would approximately have a standard Gaussian distribution. See Hinkley(1969). func GearyHinkleyTransformation(z, μX, σX, μY, σY, ρ fl...
dst/ratio_gaussian.go
0.906911
0.70791
ratio_gaussian.go
starcoder
package tarantula import ( "bytes" "crypto/aes" "crypto/cipher" "crypto/hmac" "crypto/rand" "crypto/sha256" "encoding/binary" "errors" "time" ) /* Seal Structure: |---- mac ----| |------| |--------- aes-ctr -------| [ iv ] [ exp ] [ mac ] [ data ] 0 16 24 ...
vendor/github.com/swdunlop/tarantula-go/seal.go
0.709221
0.441553
seal.go
starcoder
package tuner // tuner.go is a texel tuning implementation for Blunder. import ( "blunder/engine" "bufio" "fmt" "math" "os" "strings" ) const ( DataFile = "" NumCores = 4 NumWeights = 786 KPrecision = 10 Draw float64 = 0.5 WhiteWin float64 = 1.0 BlackWin float64 = 0.0 NumPositions ...
tuner/tuner.go
0.720565
0.460107
tuner.go
starcoder
package c import ( "image/color" "math/big" ) type ComplexBigFloat struct { Real *big.Float Imag *big.Float } func (lhs *ComplexBigFloat) Add(rhs *ComplexBigFloat) *ComplexBigFloat { return &ComplexBigFloat{ Real: new(big.Float).Add( lhs.Real, rhs.Real, ), Imag: new(big.Float).Add( lhs.Imag, r...
ch03/ex08/c/float.go
0.610221
0.416915
float.go
starcoder
package main import ( "container/heap" "fmt" "math" ) // ComputeTNR Compute Transit Node Routing func (graph *Graph) ComputeTNR(transitCnt int) { if !graph.contracted { fmt.Println("The graph has not contracted, run ComputeContractions first.") return } if graph.TNRed { fmt.Println("The graph has already ...
tnr.go
0.591959
0.407687
tnr.go
starcoder
package heap import "github.com/lxzan/dao" func MinHeap[T dao.Comparable[T]](a, b T) dao.Ordering { if a > b { return dao.Greater } else if a < b { return dao.Less } else { return dao.Equal } } func MaxHeap[T dao.Comparable[T]](a, b T) dao.Ordering { return -1 * MinHeap(a, b) } func New[T any](cap int, c...
heap/heap.go
0.561215
0.413359
heap.go
starcoder
package board import ( "fmt" "math" "math/rand" "time" "github.com/pkg/errors" ) var r *rand.Rand // Board is the representation of the game's // playing field type Board [][]string type positions struct { gx int gy int hx int hy int } // New returns a new board to the user based on // an input dimension...
board/board.go
0.746971
0.406155
board.go
starcoder
package layout import ( "fmt" "sort" "strings" ) // LayeredGraph is graph with dummy nodes such that there is no long edges. // Short edge is between nodes in Layers next to each other. // Long edge is between nodes in 1+ Layers between each other. // Segment is either a short edge or a long edge. // Top layer has...
layout/layered_graph.go
0.658198
0.590336
layered_graph.go
starcoder
package policyv1 import ( hash "hash" ) // HashPB computes a hash of the message using the given hash function // The ignore set must contain fully-qualified field names (pkg.msg.field) that should be ignored from the hash func (m *Policy) HashPB(hasher hash.Hash, ignore map[string]struct{}) { if m != nil { cerb...
api/genpb/cerbos/policy/v1/policy_hashpb.pb.go
0.817356
0.444746
policy_hashpb.pb.go
starcoder
package application /* TX RULES 1. The sum of value in vout MUST be equal to the sum of value in vin with deposit discounts applied. 2. The txHash MUST be correct for the transaction 3. All signatures must be valid 4. No conflicting transaction hashes are allowed 5. No conflicting UTXO IDs are all...
application/doc.go
0.519765
0.51312
doc.go
starcoder
package accessionnumbers // type Defintion provides a struct containing accession number patterns and URIs for an organization. type Definition struct { // The name of the organization associated with this definition. OrganizationName string `json:"organization_name"` // The URL of the organization associated with ...
cmd/vendor/github.com/sfomuseum/go-accession-numbers/accessionnumbers.go
0.628749
0.40592
accessionnumbers.go
starcoder
package summarizer import ( "context" "regexp" "github.com/GoogleCloudPlatform/testgrid/internal/result" "github.com/GoogleCloudPlatform/testgrid/pb/state" summarypb "github.com/GoogleCloudPlatform/testgrid/pb/summary" "github.com/GoogleCloudPlatform/testgrid/pkg/summarizer/common" ) const ( minRuns = 0 ) va...
pkg/summarizer/flakiness.go
0.664867
0.472379
flakiness.go
starcoder
Karplus Strong Oscillator Module KS generally has a delay line buffer size that determines the fundamental frequency of the sound. That has some practical problems. The delay line buffer is too large for low frequencies and it makes it hard to provide fine resolution control over the frequency. This implementation us...
module/osc/ks.go
0.822225
0.659515
ks.go
starcoder
package assert import ( http "net/http" url "net/url" time "time" ) func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool { return Condition(a.t, comp, msgAndArgs...) } func (a *Assertions) Conditionf(comp Comparison, msg string, args ...interface{}) bool { return Conditionf(a.t, comp,...
assertion_forward.go
0.785555
0.400486
assertion_forward.go
starcoder
package httptest import ( "encoding/json" "fmt" "io/ioutil" "net/http" "testing" "github.com/sasalatart/batcoms/domain/battles" "github.com/sasalatart/batcoms/domain/commanders" "github.com/sasalatart/batcoms/domain/factions" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // A...
http/httptest/httptest.go
0.653127
0.499146
httptest.go
starcoder
// Author: <EMAIL> package main import ( "math" "math/rand" "time" "github.com/go-daq/crc8" ) // DefaultSampleRate is the sample rate of our simulation const DefaultSampleRate = 150.0 * 1000.0 // IOTBaudRate is the Baud rate of our protocol const IOTBaudRate = 1.785 * 1000.0 // CarrierFreq is the carrier fre...
2019/quals/hardware-remotecontrol/app/simulator.go
0.752286
0.584064
simulator.go
starcoder
package indicators import ( "github.com/jaybutera/gotrade" ) // A Time Series Forecast Indicator (Tsf) type Tsf struct { *LinRegWithoutStorage selectData gotrade.DOHLCVDataSelectionFunc // public variables Data []float64 } // NewTsf creates a Time Series Forecast Indicator (Tsf) for online usage func NewTsf(ti...
indicators/tsf.go
0.717309
0.438845
tsf.go
starcoder
package util import ( "math/rand" "reflect" "time" ) func InSlice(val interface{}, slice interface{}) (exist bool, index int) { exist = false index = -1 if slice == nil || reflect.TypeOf(slice).Kind() != reflect.Slice { return } s := reflect.ValueOf(slice) for i := 0; i < s.Len(); i++ { if reflect.DeepE...
slice.go
0.507568
0.434941
slice.go
starcoder
package vmath import ( "unsafe" ) func (result *Quaternion) MakeFromM3(tfrm *Matrix3) { xx := tfrm[t3col0+x] yx := tfrm[t3col0+y] zx := tfrm[t3col0+z] xy := tfrm[t3col1+x] yy := tfrm[t3col1+y] zy := tfrm[t3col1+z] xz := tfrm[t3col2+x] yz := tfrm[t3col2+y] zz := tfrm[t3col2+z] trace := ((xx + yy) + zz) ...
quaternion.go
0.516108
0.402744
quaternion.go
starcoder
package shapes import ( "fmt" "reflect" "github.com/pkg/errors" ) // solver.go implements the constraint solvers // there are two kinds of constraints to solve: variable constraints and SubjectTo constraints. // exprConstraint says that A must be equal to B type exprConstraint struct { a, b Expr } func (c expr...
solver.go
0.61555
0.481332
solver.go
starcoder
package kv import ( "bytes" "context" bolt "go.etcd.io/bbolt" "go.opencensus.io/trace" ) // lookupValuesForIndices takes in a list of indices and looks up // their corresponding values in the DB, returning a list of // roots which can then be used for batch lookups of their corresponding // objects from the DB. ...
.docker/Prysm/prysm-spike/beacon-chain/db/kv/utils.go
0.633977
0.538255
utils.go
starcoder
package lox func (p *Parser) expression() Expr { return p.assignment() } func (p *Parser) assignment() Expr { expr := p.equality() if p.match(TokenTypeEqual) { equals := p.previous() value := p.assignment() exprVar, ok := value.(*ExprVar) if ok { return &ExprAssign{exprVar.Name, value} } pan...
lox/parserExprs.go
0.522689
0.519338
parserExprs.go
starcoder
package labels import ( "fmt" "github.com/janelia-flyem/dvid/datatype/imageblk" "github.com/janelia-flyem/dvid/dvid" ) // MergeOp represents the merging of a set of labels into a target label. type MergeOp struct { Target uint64 Merged Set } // MergeTuple represents a merge of labels. Its first element is the...
datatype/common/labels/events.go
0.677047
0.558387
events.go
starcoder
package rx import ( "sync" "sync/atomic" ) //jig:template Merge<Foo> //jig:needs Observable<Foo> Merge // MergeFoo combines multiple Observables into one by merging their emissions. // An error from any of the observables will terminate the merged observables. func MergeFoo(observables ...ObservableFoo) Observable...
generic/merging.go
0.716913
0.438665
merging.go
starcoder
package mission import ( "encoding/json" "fmt" "math/big" "time" "git.sr.ht/~kisom/proxima/physics" "git.sr.ht/~kisom/proxima/rat" ) const ( proximaLY = 4.247 ) var ( Heliopause = physics.AstronomicalUnit(120.0) MarsDistance = physics.AstronomicalUnit(0.52) JupiterDistance = physics.Astronomica...
mission/mission.go
0.750553
0.508422
mission.go
starcoder
package patgen import ( "math/rand" "github.com/emer/emergent/erand" "github.com/emer/etable/etensor" ) // PermutedBinary sets the given tensor to contain nOn onVal values and the // remainder are offVal values, using a permuted order of tensor elements (i.e., // randomly shuffled or permuted). func PermutedBina...
patgen/permuted.go
0.564819
0.485234
permuted.go
starcoder
package intervals import ( "math" ) const ( defaultMinLow = 0 defaultMaxHigh = math.MaxInt64 defaultLowInclusive = true defaultHighInclusive = true defaultSelfAdjustMinLow = false defaultSelfAdjustMaxHigh = true ) // Intervals is an interface to handle Interval structures discov...
intervals.go
0.814459
0.427158
intervals.go
starcoder
package wparams // ParamStorer is a type that stores safe and unsafe parameters. Keys should be unique across both SafeParams and // UnsafeParams (that is, if a key occurs in one map, it should not occur in the other). type ParamStorer interface { SafeParams() map[string]interface{} UnsafeParams() map[string]interfa...
vendor/github.com/palantir/witchcraft-go-params/paramstorer.go
0.657758
0.514034
paramstorer.go
starcoder
package common import ( "math" "math/rand" "gorgonia.org/tensor" ) func AddVector(dense, vec *tensor.Dense) { imax, _ := dense.Info().Shape().DimSize(0) jmax, _ := dense.Info().Shape().DimSize(1) for i := 0; i < imax; i++ { for j := 0; j < jmax; j++ { aij, _ := dense.At(i, j) vj, _ := vec.At(j) de...
common/common.go
0.611034
0.459986
common.go
starcoder
package main import "math" // A camera represents a view into a world. type Camera struct { // The width of the camera's view in pixels. Width int // The height of the camera's view in pixels. Height int // The angular width of what the camera sees specified in radians. FieldOfView float64 // A matrix indica...
camera.go
0.917108
0.744958
camera.go
starcoder
package rj32 import "fmt" func reg(r int) string { switch r { case 0: return "ra" case 15: return "sp" case 14: return "gp" default: if r < 4 { return fmt.Sprintf("a%d", r-1) } if r < 7 { return fmt.Sprintf("s%d", r-4) } return fmt.Sprintf("t%d", r-8) } } // String returns the disassemble...
emurj/rj32/trace.go
0.509276
0.469095
trace.go
starcoder
package mathlib import ( "errors" "math" ) // PI Returns the constant value of pi func PI() float64 { return 3.14159265358979 } // SqrtPI Returns the square root of a supplied number multiplied by pi // Returns the square root of (number * pi). func SqrtPI(number float64) (float64, error) { // Validate Number -...
math/trigonometry.go
0.910356
0.555194
trigonometry.go
starcoder
package detour import ( "unsafe" ) type DtNodeFlags uint8 const ( DT_NODE_OPEN DtNodeFlags = 0x01 DT_NODE_CLOSED DtNodeFlags = 0x02 DT_NODE_PARENT_DETACHED DtNodeFlags = 0x04 // parent of the node is not adjacent. Found using raycast. ) type DtNodeIndex uint16 const DT_NULL_IDX DtNodeIndex...
server/game/nav/NavNode.go
0.589007
0.492493
NavNode.go
starcoder
package generator import ( "github.com/pkg/errors" "gopkg.in/yaml.v2" "io/ioutil" ) // Inventory acts as a collection of categorized Tokens which can be queried for both randomized // and parameterized selection. type Inventory struct { dictionary map[string][]Token selectRange map[string]float64 } // CreateIn...
generator/inventory.go
0.689096
0.401658
inventory.go
starcoder
package set const SetMapToParamFunctions = ` // Set:MapTo[{{.TypeParameter}}] {{if .TypeParameter.IsBasic}} // MapTo{{.TypeParameter.LongName}} transforms {{.TName}}Set to []{{.TypeParameter.Name}}. func (set {{.TName}}Set) MapTo{{.TypeParameter.LongName}}(fn func({{.PName}}) {{.TypeParameter}}) []{{.TypeParameter.Na...
internal/set/mapToT.go
0.762778
0.626895
mapToT.go
starcoder
package envoy import ( "fmt" "net" "time" "github.com/openservicemesh/osm/pkg/certificate" ) // Proxy is a representation of an Envoy proxy connected to the xDS server. // This should at some point have a 1:1 match to an Endpoint (which is a member of a meshed service). type Proxy struct { certificate.CommonNam...
pkg/envoy/proxy.go
0.619126
0.406479
proxy.go
starcoder
package types import ( "bytes" "encoding/hex" "fmt" "github.com/noah-blockchain/noah-go-node/hexutil" "math/big" "math/rand" "reflect" ) const ( HashLength = 32 AddressLength = 20 CoinSymbolLength = 10 ) var ( hashT = reflect.TypeOf(Hash{}) addressT = reflect.TypeOf(Address{}) ) func Replac...
core/types/types.go
0.775605
0.404096
types.go
starcoder
package scene import "math" // The is a copy of fogleman/fauxl/matrix.go type Matrix struct { X00, X01, X02, X03 float64 X10, X11, X12, X13 float64 X20, X21, X22, X23 float64 X30, X31, X32, X33 float64 } func Identity() Matrix { return Matrix{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1} } func Tra...
scene/matrix.go
0.875734
0.624508
matrix.go
starcoder
// This file implements the compressed encoding of source // positions using a lookup table. package src // XPos is a more compact representation of Pos. type XPos struct { index int32 lico } // NoXPos is a valid unknown position. var NoXPos XPos // IsKnown reports whether the position p is known. // XPos.IsKnow...
src/cmd/internal/src/xpos.go
0.803521
0.597138
xpos.go
starcoder
package main import "sort" /***************************************************************************************************** * * You are given a series of video clips from a sporting event that lasted T seconds. These video * clips can be overlapping with each other and have varied lengths. * * Each video ...
basic/Algorithm/dynamic_programming/1024.video_stitching/1024.VideoStitching_zhangsl.go
0.551091
0.504455
1024.VideoStitching_zhangsl.go
starcoder
package main import ( "flag" "fmt" "math" "os" "sync" "time" "github.com/ChristopherRabotin/gokalman" "github.com/ChristopherRabotin/smd" "github.com/gonum/matrix/mat64" ) const ( ekfTrigger = -15 // Number of measurements prior to switching to EKF mode. ekfDisableTime = 1200 // Seconds between mea...
examples/statOD/hwmain/main.go
0.592195
0.403684
main.go
starcoder
package misc // LinkCutTree represents a Link-Cut tree. type LinkCutTree struct { nodes []*linkCutNode } // NewLinkCutTree instantiates a new Link-Cut tree. func NewLinkCutTree(size int) *LinkCutTree { t := &LinkCutTree{ nodes: make([]*linkCutNode, size), } for i := range t.nodes { t.nodes[i].id = i t.nodes...
misc/linkcut.go
0.837254
0.502258
linkcut.go
starcoder
package inboundmiddleware import ( "context" "go.uber.org/yarpc/api/middleware" "go.uber.org/yarpc/api/transport" ) // UnaryChain combines a series of `UnaryInbound`s into a single `InboundMiddleware`. func UnaryChain(mw ...middleware.UnaryInbound) middleware.UnaryInbound { unchained := make([]middleware.UnaryI...
internal/inboundmiddleware/chain.go
0.765506
0.471102
chain.go
starcoder
package graphics import ( "errors" "image" "image/draw" "math" "github.com/Lealen/graphics-go/graphics/interp" ) // I is the identity Affine transform matrix. var I = Affine{ 1, 0, 0, 0, 1, 0, 0, 0, 1, } // Affine is a 3x3 2D affine transform matrix. // M(i,j) is Affine[i*3+j]. type Affine [9]float64 // M...
graphics/affine.go
0.776496
0.566978
affine.go
starcoder
package test import ( "testing" "github.com/muecoin/multiwallet/model" ) func ValidateTransaction(tx, expectedTx model.Transaction, t *testing.T) { if tx.Txid != expectedTx.Txid { t.Error("Returned invalid transaction") } if tx.Version != expectedTx.Version { t.Error("Returned invalid transaction") } if t...
test/helper.go
0.570331
0.439266
helper.go
starcoder
package utils // NextIndex returns the index of the element that comes after the given number func NextIndex(numbers []int, currentNumber int) int { for index, number := range numbers { if number > currentNumber { return index } } return len(numbers) - 1 } // PrevIndex returns the index that comes before th...
pkg/utils/slice.go
0.768212
0.50891
slice.go
starcoder
package wineregdiff import ( "encoding/hex" "fmt" "regexp" "strconv" "strings" ) type DataType int const ( // https://github.com/wine-mirror/wine/blob/e909986e6ea5ecd49b2b847f321ad89b2ae4f6f1/include/winnt.h#L5571 DataTypeRegNone DataType = 0 DataTypeRegSZ DataType = 1 DataTypeRegExpan...
data.go
0.635336
0.543833
data.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // AssignmentFilterSupportedProperty represents the information about the property which is supported in crafting the rule of AssignmentFilter. type AssignmentFilt...
models/assignment_filter_supported_property.go
0.705075
0.501404
assignment_filter_supported_property.go
starcoder
package pgmodel import ( "fmt" "github.com/prometheus/prometheus/prompb" ) const ( metricNameLabelName = "__name__" ) var ( errNoMetricName = fmt.Errorf("metric name missing") ) // SeriesID represents a globally unique id for the series. This should be equivalent // to the PostgreSQL type in the series table ...
pkg/pgmodel/ingestor.go
0.705379
0.474753
ingestor.go
starcoder
package stdutil import ( "fmt" "regexp" "strconv" "strings" "time" ) // AnyToString - convert any variable to string func AnyToString(value interface{}) string { var b string if value == nil { return "" } switch t := value.(type) { case string: b = t case int: b = strconv.FormatInt(int64(t), 10) c...
stdutil.go
0.677367
0.453141
stdutil.go
starcoder
package validation const ( JSONSchemaTransformDeclarations = ` { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "github.com/jf-tech/omniparser:transform_declarations", "title": "omniparser schema: transform_declarations", "type": "object", "properties": { "transform_decla...
extensions/omniv21/validation/transformDeclarations.go
0.586878
0.493775
transformDeclarations.go
starcoder
package tables import ( "fmt" "github.com/sudachen/go-ml/fu" "github.com/sudachen/go-ml/fu/lazy" "reflect" ) func equalf(c interface{}) func(v reflect.Value) bool { vc := reflect.ValueOf(c) switch vc.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: vv := vc.Int() return...
tables/ifxx.go
0.565779
0.457682
ifxx.go
starcoder
package scenarios import ( . "github.com/onsi/ginkgo" ) var _ = PDescribe("[Dataplane] Adding existing network policy to newly added cluster", func() { PContext("Registering cluster 3 with kubefed and then creating a pod", func() { PIt("Should implement existing namespace selector based network policy in newly ad...
test/e2e/scenarios/add_cluster.go
0.566618
0.747339
add_cluster.go
starcoder
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "log" "os" "path/filepath" "time" ) type Flags struct { ConfigFile string DbPath string ReuseDatabase bool MinPeriod time.Duration MaxPeriod time.Duration } /* Config contains the configuration information used by the appli...
config.go
0.649467
0.417628
config.go
starcoder
package pagination import ( "math" ) // Paginator manages pagination of a data set. type Paginator struct { perPage int // The number of items per page. page int // Which page are we on? offset int // The current offset to pass to the query. total int // The total number of items lastPage int // The n...
pagination/paginator.go
0.742795
0.409929
paginator.go
starcoder
package main import "fmt" type Item struct { Name string Weight int Value int } // Knapsack problem: // You are a thief with a knapsick that can carry 4 kilos of goods // In the store you are about to rob, there are 4 items with different values and weights (see items below) // Question: What items should you ...
ch9/knapsack.go
0.634996
0.446374
knapsack.go
starcoder
package conf // IntVar defines an int flag and environment variable with specified name, default value, and usage string. // The argument p points to an int variable in which to store the value of the flag and/or environment variable. func (c *Configurator) IntVar(p *int, name string, value int, usage string) { c.env...
value_int.go
0.772788
0.621713
value_int.go
starcoder
package vile // Intern - internalize the name into the global symbol table func Intern(name string) *Object { sym, ok := symtab[name] if !ok { sym = new(Object) sym.text = name if IsValidKeywordName(name) { sym.Type = KeywordType } else if IsValidTypeName(name) { sym.Type = TypeType } else if IsValid...
src/symbol.go
0.58166
0.433202
symbol.go
starcoder
package rootfs import ( "path/filepath" "sort" "strings" ) // tree is a way to store directory paths for whiteouts. // It is semi-optimized for reads and non-optimized for writes; // See Merge() and HasPrefix for trade-offs. type tree struct { name string children []*tree end bool } // newTree creates...
rootfs/tree.go
0.750004
0.425725
tree.go
starcoder
package vm // Halt sets the running flag to false. // The machine will shutdown after the current operation. func (machine *Machine) Halt() { machine.keepRunning = false } // PerformPush pushes an argument value onto the stack. func (machine *Machine) PerformPush() error { var value uint16 var err error switch ma...
vm/operations.go
0.564579
0.431584
operations.go
starcoder
package direction import ( "fmt" "github.com/go-gl/mathgl/mgl32" ) // Type is a direction in the minecraft world. type Type uint // Possible direction values. const ( Up Type = iota Down North South West East Invalid ) // Values is all valid directions. var Values = []Type{ Up, Down, North, South, W...
type/direction/direction.go
0.759136
0.437763
direction.go
starcoder
package periodic import ( "fmt" "reflect" "sort" "time" ) const ( // HoursInDay is the number of hours in a single day HoursInDay = 24 // DaysInWeek is the number of days in a week DaysInWeek = 7 ) // Period defines a block of time bounded by a start and end. type Period struct { Start time.Time `json:"sta...
periodic.go
0.846578
0.624165
periodic.go
starcoder
package trivium // Trivium represents the 288-bit state of the Trivium cipher. type Trivium struct { state [5]uint64 } const ( // KeyLength bytes in the key and IV, 10 bytes = 80 bits KeyLength = 10 lgWordSize = 6 // using uint64 = 2^6 as the backing array // the indices in the array for the given cells that a...
trivium.go
0.631253
0.444866
trivium.go
starcoder
package log //index defines our index file, which comprises a persisted file and a memory- mapped file. //The size tells us the size of the index and where to write the next entry appended to the index. import ( "io" "os" "github.com/tysontate/gommap" ) var ( offWidth uint64 = 4 posWidth uint64 = 8 //entWidth...
internal/log/wal-index-functions.go
0.633183
0.610453
wal-index-functions.go
starcoder
package grid // Range represents a grid with the first point being inclusive and the second // point exclusive. type Range [2]Pt // Contains checks if the point is in the Range with the first point being // inclusive and the second point being exclusive. func (r Range) Contains(pt Pt) bool { if r[0].X < r[1].X { i...
d2/grid/range.go
0.8119
0.782995
range.go
starcoder
package iso20022 // Account between an investor(s) and a fund manager or a fund. The account can contain holdings in any investment fund or investment fund class managed (or distributed) by the fund manager, within the same fund family. type InvestmentAccount58 struct { // Unique and unambiguous identification for t...
InvestmentAccount58.go
0.706596
0.433622
InvestmentAccount58.go
starcoder
package gfmatrix import ( "fmt" ) // Matrix represents a GF(2^8)-matrix. type Matrix []Row // Mul right-multiplies a matrix by a row. func (e Matrix) Mul(f Row) Row { out, in := e.Size() if in != f.Size() { panic("Can't multiply by row that is wrong size!") } res := NewRow(out) for i := 0; i < out; i++ { ...
gfmatrix/gfmatrix.go
0.842798
0.459197
gfmatrix.go
starcoder
package ts import ( "fmt" "time" ) // TimeSpan is a period of time with a beginning and an end. type TimeSpan struct { Start time.Time End time.Time // I use the convoluted "NotStartInclusive" so that the zero value for TimeSpan's // bounds is a sensible default, and callers can just use ts.TimeSpan{Start: f...
ts.go
0.796055
0.582016
ts.go
starcoder
package tmo import ( "image" "image/color" "math" "github.com/mdouchement/hdr" "github.com/mdouchement/hdr/filter" "github.com/mdouchement/hdr/xmath" "github.com/mdouchement/hdr/parallel" ) // A CustomReinhard05 is a custom Reinhard05 TMO implementation. // It looks like a JPEG photo taken with a smartphone. ...
tmo/custom_reinhard05.go
0.747063
0.425784
custom_reinhard05.go
starcoder
package main import ( "bytes" "fmt" "github.com/olekukonko/tablewriter" "github.com/pkg/errors" "github.com/redhat-developer/odo/pkg/odo/cli" "github.com/spf13/cobra" "github.com/spf13/pflag" "os" ) /* This "script" generates markdown that can be interpreted by the Slate (https://github.com/lord/slate) forma...
cmd/cli-doc/cli-doc.go
0.503174
0.424054
cli-doc.go
starcoder
package parser import ( "sync" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/scanner" ) // PositionBuilder provide functions to constuct positions type PositionBuilder struct { Positions *Positions PositionPool *sync.Pool } type startPos struct { ...
stage2/vendor/github.com/z7zmey/php-parser/parser/position_builder.go
0.582254
0.439627
position_builder.go
starcoder
package day11 import "fmt" type ( CountNeighbours func(*SeatMap, int, int) int ) type SeatMap struct { seats [][]rune occupied int } // Parses the input list of seat string into a seat map func ParseSeatStrings(seatStrings []string) (*SeatMap, error) { seatMap := &SeatMap{ seats: make([][]rune, len(seatStr...
day11/day11.go
0.723895
0.432003
day11.go
starcoder
package heisenberg import ( "fmt" "math" "math/cmplx" "math/rand" "sort" ) // Qubit is a qubit type Qubit uint64 // GateType is a type of gate type GateType int const ( // GateTypeControlledNot controlled not gate GateTypeControlledNot GateType = iota // GateTypeI multiply by identity GateTypeI // GateTy...
heisenberg.go
0.667798
0.662469
heisenberg.go
starcoder
package linkedlist // LinkedList represents abstract data structure type LinkedList struct { Head *Node Tail *Node isEqual func(a, b interface{}) bool } // NewList is a function that creates a new "instance" of linked list func NewList(compare func(a, b interface{}) bool) LinkedList { return LinkedList{nil,...
linkedlist/list.go
0.735357
0.409457
list.go
starcoder
package embd import "time" // The Direction type indicates the direction of a GPIO pin. type Direction int // The Edge trigger for the GPIO Interrupt type Edge string const ( // In represents read mode. In Direction = iota // Out represents write mode. Out ) const ( // Low represents 0. Low int = iota //...
gpio.go
0.760828
0.425187
gpio.go
starcoder
package common import ( "regexp" "regexp/syntax" ) // MergeREs merges together a list of regexps (this will match any pattern that matches at least one of // the input regexps). // the good news is that '^(^value$)$' will match 'value', so we can use the output of this function and give // it to the collectors of w...
prometheus/exporter/common/common.go
0.672869
0.416619
common.go
starcoder
package faker import ( "math" ) // IntInRange will build a random int between min and max included. func IntInRange(min, max int) int { if min >= max { return min } return random.Intn(max-min+1) + min } // Int will build a random int. func Int() int { return IntInRange(math.MinInt32, math.MaxInt32) } // Int6...
number.go
0.712232
0.551574
number.go
starcoder
package orbdata import ( "github.com/emilyselwood/orbcalc/orbcore" ) // This file will contain orbital information for standard objects. Major planets, moons and so on. // MercuryOrbit defines the standard mercury orbit var MercuryOrbit = orbcore.Orbit{ ID: "Mercury", ParentGrav: ...
orbdata/orbits.go
0.536799
0.498779
orbits.go
starcoder
package spreadsheet import ( "fmt" "baliance.com/gooxml" "baliance.com/gooxml/measurement" "baliance.com/gooxml/schema/soo/sml" "baliance.com/gooxml/spreadsheet/reference" ) // Row is a row within a spreadsheet. type Row struct { w *Workbook s *sml.Worksheet x *sml.CT_Row } // X returns the inner wrapped X...
spreadsheet/row.go
0.75183
0.42471
row.go
starcoder
package chunks import "io" // bstream is a stream of bits type bstream struct { stream []byte // the data stream count uint8 // how many bits are valid in current byte } func newBReader(b []byte) *bstream { return &bstream{stream: b, count: 8} } func newBWriter(size int) *bstream { return &bstream{stream: mak...
vendor/github.com/prometheus/tsdb/chunks/bstream.go
0.593374
0.427695
bstream.go
starcoder
package util import ( "fmt" "strings" "time" vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2" ) const ( // MaxCheckpointWeight is the maximum weight that can be stored in // HistogramCheckpoint in a single bucket MaxCheckpointWeight uint32 = 10000 ) // Histogram repre...
vertical-pod-autoscaler/pkg/recommender/util/histogram.go
0.861844
0.493164
histogram.go
starcoder
package encoder // circle.go assists in calculation of points and angles on a circle. import ( "image" "math" "github.com/mum4k/termdash/private/canvas/braille" ) // startEndAngles given progress indicators and the desired start angle and // direction, returns the starting and the ending angle of the partial ci...
internal/encoder/circle.go
0.859059
0.594198
circle.go
starcoder
package solar import ( "image/color" "math" "github.com/golang/geo/r2" ) // DrawRotatingLine renders a line that moves back and forth type DrawRotatingLine struct { // where line starts startPosition r2.Point // end of the line, updated after call to Animate endPosition r2.Point // where line neds length...
solar/drawRotatingLine.go
0.896891
0.485112
drawRotatingLine.go
starcoder
package plaid import ( "encoding/json" ) // RecipientBACS An object containing a BACS account number and sort code. If an IBAN is not provided or if this recipient needs to accept domestic GBP-denominated payments, BACS data is required. type RecipientBACS struct { // The account number of the account. Maximum of ...
plaid/model_recipient_bacs.go
0.771413
0.58353
model_recipient_bacs.go
starcoder
package qrcode import ( "errors" "image/color" "github.com/ajstarks/svgo" "github.com/boombuler/barcode" ) // QrSVG holds the data related to the size, location, // and block size of the QR Code. Holds unexported fields. type QrSVG struct { qr barcode.Barcode qrWidth int blockSize int startingX int ...
internal/qrcode/qr_svg.go
0.648021
0.507202
qr_svg.go
starcoder
package gosql import ( "reflect" "sort" "time" ) //inSlice func inSlice(k string, s []string) bool { for _, v := range s { if k == v { return true } } return false } //IsZero assert value is zero value func IsZero(val reflect.Value) bool { if !val.IsValid() { return true } kind := val.Kind() swit...
util.go
0.596433
0.478955
util.go
starcoder
package ring import ( "math/bits" "unsafe" "github.com/tuneinsight/lattigo/v3/utils" ) // GenGaloisParams generates the generators for the Galois endomorphisms. func GenGaloisParams(n, gen uint64) (galElRotCol []uint64) { var m, mask uint64 m = n << 1 mask = m - 1 galElRotCol = make([]uint64, n>>1) galE...
ring/ring_automorphism.go
0.636805
0.512815
ring_automorphism.go
starcoder
package gocuke import ( "github.com/cockroachdb/apd/v3" "github.com/cucumber/common/messages/go/v17" "math/big" "reflect" ) // DataTable wraps a data table step argument type DataTable struct { t TestingT table *messages.PickleTable } // NumRows returns the number of rows in the data table. func (d DataTab...
datatable.go
0.868576
0.652823
datatable.go
starcoder
package tuple // Couple is a 2-tuple struct. type Couple[T1, T2 any] struct { V1 T1 V2 T2 } // NewCouple returns a new Couple containing v1 and v2. func NewCouple[T1, T2 any](v1 T1, v2 T2) Couple[T1, T2] { return Couple[T1, T2]{v1, v2} } // Pair is a alternative name of Couple. type Pair[T1, T2 any] Couple[T1, T2...
tuple.go
0.843315
0.529324
tuple.go
starcoder
package parser import "fmt" // NewPos creates a new initialized Pos with the values supplied. func NewPos(filename string, line int) *Pos { return &Pos{ Filename: filename, Line: line, } } // Pos defines a position in a B++ program, commonly used in debug prints type Pos struct { Filename string Line ...
old/parser/types.go
0.720467
0.4856
types.go
starcoder
package fastxml import ( "bytes" "errors" "io" ) // Allocate the errors once and return the same structs var ( errCDATASuffix = errors.New("expected Token to end with ']]>'") errElementSuffix = errors.New("expected Token to end with '>'") ) // Allocate these once instead of on each bytes.Index/HasPrefix/HasSu...
scanner.go
0.562898
0.421909
scanner.go
starcoder
package geojson import "github.com/tidwall/tile38/pkg/geojson/geohash" // LineString is a geojson object with the type "LineString" type LineString struct { Coordinates []Position BBox *BBox bboxDefined bool } func fillLineString(coordinates []Position, bbox *BBox, err error) (LineString, error) { if err ...
pkg/geojson/linestring.go
0.80502
0.508117
linestring.go
starcoder
package mino import ( "sort" ) // Filter is a set of parameters for the Players.Take function. type Filter struct { // Indices indicates the indexes of the elements that must be included. This // list if updated based on the filter that we apply. For example, [0,3] // tells that this filter keeps 2 elements from...
mino/option.go
0.727492
0.54359
option.go
starcoder
package bls12381 import ( "fmt" "math" "math/big" ) // PointG1 is type for point in G1. // PointG1 is both used for Affine and Jacobian point representation. // If z is equal to one the point is accounted as in affine form. type PointG1 [3]fe func (p *PointG1) Set(p2 *PointG1) *PointG1 { p[0].set(&p2[0]) p[1].s...
g1.go
0.760917
0.54462
g1.go
starcoder
package cli import ( "fmt" "os" "strconv" "strings" "time" ) // EnvAttribute describes expected environmental attributes associated with the cli app. // It also provides the default value of the environmental attribute if missing from the environment. type EnvAttribute struct { // Name is the environment variab...
cli/env.go
0.543348
0.410106
env.go
starcoder
package expr import ( "fmt" "math" "strings" "github.com/jesperkha/Fizz/env" "github.com/jesperkha/Fizz/lexer" "github.com/jesperkha/Fizz/util" ) // Evaluates expression tree. Hands off to helper methods which can also recursively call to // resolve nested expressions. Returned value is result of expression an...
expr/evaluate.go
0.736495
0.45538
evaluate.go
starcoder