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 sipparser // Imports from the go standard library import ( "errors" "fmt" ) // pAssertedIdStateFn is just a fn type type pAssertedIdStateFn func(p *PAssertedId) pAssertedIdStateFn // PAssertedId is a struct that holds: // -- Error is just an os.Error // -- Val is the raw value // -- Name is the name value...
passertedid.go
0.507812
0.42185
passertedid.go
starcoder
package ensure import ( "fmt" "reflect" "strings" "testing" ) // Testable respresents a value to test. type Testable struct { Test *testing.T Error error String string Value interface{} ReturnValue *interface{} } // shortcut var s = fmt.Sprintf // Fatal stops with fatal error. func ...
ensure.go
0.694821
0.49646
ensure.go
starcoder
package scatter import ( "math" "strconv" "github.com/knightjdr/prohits-viz-analysis/pkg/float" customMath "github.com/knightjdr/prohits-viz-analysis/pkg/math" "github.com/knightjdr/prohits-viz-analysis/pkg/types" ) func formatData(scatter *Scatter, axisLength float64) { axisBoundaries := defineAxisBoundaries(...
pkg/svg/scatter/data.go
0.732496
0.410225
data.go
starcoder
package main import ( "flag" "fmt" "log" "os" "path/filepath" "strconv" "strings" "github.com/sensorable/lblconv" ) var ( convertFrom format // The source format. convertTo format // The target format. imageDirPath string // The input directory with the labeled images. imageOutDirPath ...
cmd/lblconv/main.go
0.577734
0.410225
main.go
starcoder
package mlpack /* #cgo CFLAGS: -I./capi -Wall #cgo LDFLAGS: -L. -lmlpack_go_decision_tree #include <capi/decision_tree.h> #include <stdlib.h> */ import "C" import "gonum.org/v1/gonum/mat" type DecisionTreeOptionalParam struct { InputModel *decisionTreeModel Labels *mat.Dense MaximumDepth int Minimu...
decision_tree.go
0.715325
0.593963
decision_tree.go
starcoder
package index import ( "time" "github.com/pkg/errors" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/labels" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/querier/astmapper" "github.com/grafana/loki/pkg/storage/config" ) type periodIndex struct { time.Time...
pkg/ingester/index/multi.go
0.653901
0.40539
multi.go
starcoder
package secp256k1 import ( "crypto/elliptic" "math/big" "sync" ) type CurveParams struct { P *big.Int N *big.Int B *big.Int Gx, Gy *big.Int BitSize int Name string } func (curve *CurveParams) Params() *elliptic.CurveParams { return &elliptic.CurveParams{ P: curve.P, N: ...
secp256k1.go
0.609175
0.612455
secp256k1.go
starcoder
package network import ( "errors" "fmt" neatmath "github.com/yaricom/goNEAT/v2/neat/math" "math" ) var ( // ErrNetExceededMaxActivationAttempts The error to be raised when maximal number of network activation attempts exceeded ErrNetExceededMaxActivationAttempts = errors.New("maximal network activation attempts...
neat/network/common.go
0.701713
0.473718
common.go
starcoder
package cdk // Point2I and Rectangle combined import ( "fmt" "regexp" "strconv" ) type Region struct { Point2I Rectangle } func NewRegion(x, y, w, h int) *Region { r := MakeRegion(x, y, w, h) return &r } func MakeRegion(x, y, w, h int) Region { return Region{ Point2I{X: x, Y: y}, Rectangle{W: w, H: h}...
region.go
0.684053
0.478407
region.go
starcoder
package notes import ( "math" "time" ) const ( // C is middle C frequency C = 261.63 // Cs is middle C sharp frequency Cs = 277.18 // D is middle D frequency D = 293.66 // Ds is middle D sharp frequency Ds = 311.13 // E is middle E frequency E = 329.63 // F is middle F frequency F = 349.23 // Fs is mid...
notes/single.go
0.729327
0.434401
single.go
starcoder
package biguint // An exercise to help me to learn the basics of Go. // The arithmetic uses the algorithms I learned in primary school - long division etc. // I resisted the urge to call it "bigunit" with great difficulty. import ( "strconv" ) // biguints are implemnted as slices of ints. type biguint []int // Str...
biguint.go
0.586168
0.47171
biguint.go
starcoder
package query import ( "encoding/json" "fmt" "strconv" "strings" ) // isNumber takes an interface as input, and returns a float64 if the type is // compatible (int* or float*). func isNumber(n interface{}) (float64, bool) { switch n := n.(type) { case int: return float64(n), true case int8: return float64(...
schema/query/utils.go
0.666822
0.429908
utils.go
starcoder
package pufferpanel import ( "errors" "fmt" "github.com/spf13/cast" "reflect" "time" ) //Converts the val parameter to the same type as the target func Convert(val interface{}, target interface{}) (interface{}, error) { switch target.(type) { case string: if val == nil { return "", nil } return cast.T...
conversion.go
0.507324
0.402069
conversion.go
starcoder
package intersect import "math" // Line A line is infinate in length, and is defined by any two points type Line struct { slope float64 yInt float64 xVal float64 // only used if slope is inf } // ToLine returns the line, it is only used to fill the edge interface func (l1 Line) ToLine() Line { return l1 } // ...
line.go
0.853593
0.489626
line.go
starcoder
package rivescript import "fmt" /* Topic inheritance functions. These are helper functions to assist with topic inheritance and includes. */ /* getTopicTriggers recursively scans topics and collects triggers therein. This function scans through a topic and collects its triggers, along with the triggers belonging t...
inheritance.go
0.78316
0.500854
inheritance.go
starcoder
package timeseries import ( "math" "sort" "time" ) // Aligns point's time stamps according to provided interval. func (ts TimeSeries) Align(interval time.Duration) TimeSeries { if interval <= 0 || ts.Len() < 2 { return ts } alignedTs := NewTimeSeries() var frameTs = ts[0].GetTimeFrame(interval) var pointFr...
pkg/timeseries/align.go
0.785309
0.589539
align.go
starcoder
package main import ( "math" "github.com/unixpickle/model3d/model2d" "github.com/unixpickle/model3d/model3d" "github.com/unixpickle/model3d/render3d" "github.com/unixpickle/model3d/toolbox3d" ) func main() { solid := model3d.JoinedSolid{ BaseSolid(), HouseSolid(), } mesh := model3d.MarchingCubesSearch(so...
examples/romantic/my_home/main.go
0.618665
0.438605
main.go
starcoder
package types import ( "encoding/json" "math/big" "github.com/filecoin-project/go-filecoin/internal/pkg/encoding" "github.com/filecoin-project/go-leb128" "github.com/polydawn/refmt/obj/atlas" ) func init() { encoding.RegisterIpldCborType(blockHeightAtlasEntry) } var blockHeightAtlasEntry = atlas.BuildEntry(Bl...
internal/pkg/types/block_height.go
0.601125
0.50177
block_height.go
starcoder
package util import ( "strconv" "log" "net" "strings" "os" "bufio" "dsgd/Math" "fmt" ) // data point encapsulates the data features stored in the data vector // label correpsonds to the class of the datapoint type Data_point struct { Data Math.Vector Label float64 } // a tuple used to write output of each...
util/utils.go
0.512205
0.527438
utils.go
starcoder
package f5api // This describes a message sent to or received from some operations type LtmMonitorWap struct { // The application service to which the object belongs. AppService string `json:"appService,omitempty"` // Specifies the IP address and service port of the resource that is the destination of this monito...
ltm_monitor_wap.go
0.859767
0.464659
ltm_monitor_wap.go
starcoder
package money import ( "strconv" "strings" ) // Currency represents the currency information for formatting type Currency struct { code string decimalDelimiter string thousandDelimiter string exponent int symbol string template string } // https://en.wikipedia.org/w...
currency.go
0.805556
0.458167
currency.go
starcoder
In chess, a queen can attack horizontally, vertically, and diagonally */ // 1 "Q" per row // moment we have no available spaces we backtrack func solveNQueens(n int) [][]string { var res [][]string if n == 1 { res = append(res, []string{"Q"}) return res } board := buildBaseBoard(n) ...
n-queens/n-queens.go
0.626353
0.488771
n-queens.go
starcoder
package asciitable import ( "bytes" "fmt" "os" "strings" "text/tabwriter" "golang.org/x/term" ) // Column represents a column in the table. type Column struct { Title string MaxCellLength int FootnoteLabel string width int } // Table holds tabular values in a rows and columns format. type ...
lib/asciitable/table.go
0.640074
0.461077
table.go
starcoder
package assertion import ( "fmt" "reflect" ) const ( cmpOpEqual = iota cmpOpNotEqual cmpOpGreater cmpOpLowerEqual cmpOpLower cmpOpGreaterEqual ) var errMsgByOp = map[int]string{ cmpOpEqual: errMsgNotEqual, cmpOpNotEqual: errMsgNotDifferent, cmpOpGreater: errMsgNotGreater, cmpOpLowerEqual:...
compare.go
0.710025
0.401013
compare.go
starcoder
package game // State is a current game state as percieved by the current turn. type State struct { // Turn is a current turn number. // Note that turn number starts with one, not zero. Turn int // Round is a number of the current encounter. // Note that round number starts with one, not zero. Round int // Ro...
game/game.go
0.707607
0.404919
game.go
starcoder
package workflow import ( "fmt" "reflect" "sync" "time" ) type OpType int const ( CALL OpType = iota AND APPLY COMBINE ) type step struct { targetFunc interface{} paramsPassed []interface{} funcReturned []interface{} voidReturn bool op OpType future *Future } type Flow struct { s...
flow_services.go
0.622345
0.460471
flow_services.go
starcoder
package utils import ( "net" "regexp" "strings" ) // ResolvesToIp resolves a given DNS name and checks whether the result matches the expected IP address. func ResolvesToIp(hostname string, expectedIp string) bool { // Return false if expected IP is invalid if len(expectedIp) == 0 || net.ParseIP(expectedIp) == ...
utils/network.go
0.829596
0.451327
network.go
starcoder
package evop import "fmt" type ( gene struct { key string weight int } // operator should return a genome and information if passed genome was modified. operator func([]*gene) ([]*gene, bool) // constraint is kind of a filter which let us eliminate incorrecty encoded trees. constraint func([]*gene) boo...
evop.go
0.766992
0.475118
evop.go
starcoder
package godag // DAG represents a directed acyclic graph. type DAG struct { nodes map[string]*Node weights map[string]int } // New returns a new DAG instance. func New() *DAG { return &DAG{nodes: make(map[string]*Node)} } // Insert creates a new node with the specified label and list of dependency labels. func ...
godag.go
0.808067
0.511046
godag.go
starcoder
package forGraphBLASGo import ( "github.com/intel/forGoParallel/pipeline" "runtime" "sync/atomic" ) type transposedMatrix[T any] struct { nrows, ncols int base *matrixReference[T] } func newTransposedMatrix[T any](ref *matrixReference[T]) *matrixReference[T] { if baseReferent, ok := ref.get().(transpos...
functional_MatrixTransposed.go
0.587943
0.402392
functional_MatrixTransposed.go
starcoder
package indns import ( "net" ) type RecordType uint16 // Types of DNS records. The values must match the standard ones. const ( TypeA RecordType = 1 TypeNS = 2 TypeTXT = 16 TypeAAAA = 28 TypeANY = 255 // Only for matching against actual resource types. ) type Record i...
record.go
0.607314
0.486392
record.go
starcoder
package header /** * The To header field first and foremost specifies the desired "logical" * recipient of the request, or the address-of-record of the user or resource * that is the target of this request. This may or may not be the ultimate * recipient of the request. Requests and Responses must contain a ToHea...
sip/header/ToHeader.go
0.898872
0.588594
ToHeader.go
starcoder
package shape import ( "fmt" "gioui.org/f32" "gioui.org/op" orderedmap "github.com/wk8/go-ordered-map" "github.com/wrnrlr/wonderwall/wonder/colornames" "github.com/wrnrlr/wonderwall/wonder/rtree" ) // A two-dimensional surface that extends infinitely far type Plane struct { Elements *orderedmap.OrderedMap Ind...
wonder/shape/plane.go
0.555073
0.413655
plane.go
starcoder
package main import ( "flag" "fmt" "math" ) func main() { input := flag.Int("i", 1, "Define input to compute steps") version := flag.Int("v", 1, "Define a version") flag.Parse() switch *version { case 1: x, y := getUlamSpiralCoordinates(*input) steps := int(math.Abs(x) + math.Abs(y)) fmt.Printf("Steps:...
day3/spiral.go
0.565059
0.469338
spiral.go
starcoder
package main import ( "bufio" "fmt" "io" "os" "regexp" "strconv" "strings" ) // Command represents a single stage in the pipeline of commands. It processes // `data` between `start` and `end` and if it finds a match calls `match` with the // start and end of the match. type Command interface { Do(data io.Read...
commands.go
0.637482
0.462776
commands.go
starcoder
package signatures // SimpleSignature ... type SimpleSignature struct { part string match string description string comment string } // Match checks if given file matches with signature func (s SimpleSignature) Match(file MatchFile) []*MatchResult { var haystack *string switch s.part { case Pa...
scanner/signatures/simple.go
0.677154
0.417212
simple.go
starcoder
package lengconv func CmToFt(c Centimeter) Foot { return Foot(c / FootC) // преобразование типа Centimeter в Foot } func CmToM(c Centimeter) Meter { return Meter(c / 100) // преобразование типа Centimeter в Meter } func CmToMm(c Centimeter) Millimeter { return Millimeter(c * 10) // преобразование типа Centimeter ...
conv.go
0.550607
0.571348
conv.go
starcoder
package playbook type ospot struct { o O spot HalfCourtPos } func oMoved(o ospot, to HalfCourtPos) ospot { return ospot{ o: o.o, spot: to, } } //Setting represents the setting of the Os on the court during the play type Setting struct { os map[ONum]ospot ball ONum } //Ball gets the ball handler fu...
playbook/setting.go
0.682045
0.504028
setting.go
starcoder
package stepper import ( . "github.com/conclave/pcduino/core" ) type Stepper struct { direction int speed uint steps uint delay uint pins []byte count uint timestamp int64 } func New(steps uint, pins ...byte) *Stepper { l := len(pins) if l != 2 && l != 4 { return nil } stepper := S...
lib/stepper/stepper.go
0.516108
0.509398
stepper.go
starcoder
package rti import ( "encoding/binary" "math" ) // EarthVelocityDataSet will contain all the Earth Velocity Data set values. // These values describe water profile data in m/s. // The data will be stored in array. The array size will be based off the // base data set. // Bin x Beam type EarthVelocityDataSet struct...
EarthVelocityDataSet.go
0.671471
0.73029
EarthVelocityDataSet.go
starcoder
package matrix import "fmt" type InsightsVector struct { _m int _data []float64 _valid bool } func NewInsightVector(m int, value float64) InsightsVector { vector := InsightsVector{ _m: -1, _data: nil, _valid: false, } if m <= 0 { panic("[InsightsVector] invalid size") } else { vector._data...
arima/matrix/insight_vector.go
0.580233
0.578835
insight_vector.go
starcoder
package goment import ( "fmt" "strconv" "strings" "time" "github.com/nleeper/goment/locales" "github.com/nleeper/goment/regexps" "github.com/tkuchiki/go-timezone" ) type formatReplacementFunc func(*Goment) string type formatPadding struct { token string targetLength int forceSign bool } var for...
format.go
0.569733
0.513607
format.go
starcoder
package trees import ( "fmt" "math" ) /* Binary Search Tree Implementation */ type BinarySearchTreeNode struct { value int Left, Right *BinarySearchTreeNode } func NewBinarySearchTreeNode(value int) *BinarySearchTreeNode { return &BinarySearchTreeNode{ value: value, Left: nil, Right: nil, } } type Bin...
trees/BinarySearchTree.go
0.672869
0.437163
BinarySearchTree.go
starcoder
package memeduck import ( "github.com/MakeNowJust/memefish/pkg/ast" "github.com/pkg/errors" "github.com/genkami/memeduck/internal" ) // WhereCond is a conditional expression that appears in WHERE clauses. type WhereCond interface { ToASTWhere() (*ast.Where, error) } // ExprCond is a boolean expression to filter...
where.go
0.779406
0.441553
where.go
starcoder
package glmatrix import ( "fmt" "math" "math/rand" ) // NewVec2 creates a new, empty vec2 func NewVec2() []float64 { return []float64{0., 0.} } // Vec2Create creates a new vec2 initialized with values from an existing vector func Vec2Create() []float64 { return NewVec2() } // Vec2Clone creates a new vec2 initi...
vec2.go
0.899472
0.669448
vec2.go
starcoder
package aes import ( "bytes" "fmt" ) // 0 padding mode,Use 0 padding when the data length is not aligned, otherwise no padding, // When padding with ZeroPadding, there is no way to distinguish between real data and // padding data, so it is only suitable for encryption and decryption of strings ending with \0. fun...
crypto/aes/padding.go
0.773473
0.435962
padding.go
starcoder
package level2 import ( "fmt" "github.com/sfomuseum/go-edtf" "github.com/sfomuseum/go-edtf/common" "github.com/sfomuseum/go-edtf/re" "strconv" "strings" ) /* Significant digits A year (expressed in any of the three allowable forms: four-digit, 'Y' prefix, or exponential) may be followed by 'S', followed by a ...
vendor/github.com/sfomuseum/go-edtf/level2/significant_digits.go
0.685529
0.418935
significant_digits.go
starcoder
package models import ( i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time" i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // Process type Process struct { // User account identifier (user account context...
models/process.go
0.620392
0.410638
process.go
starcoder
package ext import ( "fmt" "xelf.org/xelf/cor" "xelf.org/xelf/exp" "xelf.org/xelf/lit" "xelf.org/xelf/typ" ) // Rule is a configurable helper for assigning tags to nodes. type Rule struct { Prepper KeyPrepper Setter KeySetter } // KeyPrepper resolves el and returns a value to be assigned to key or an error....
ext/node_rules.go
0.608594
0.406803
node_rules.go
starcoder
package checker import ( "fmt" "github.com/twtiger/gosecco/tree" ) type typeChecker struct { result error expectBoolean bool } func typeCheckExpectingBoolean(x tree.Expression) error { tc := &typeChecker{result: nil, expectBoolean: true} x.Accept(tc) return tc.result } func typeCheckExpectingNumeric(...
vendor/github.com/twtiger/gosecco/checker/type_checker.go
0.716119
0.442516
type_checker.go
starcoder
package typedefs // SceneItemTransform represents the complex type for SceneItemTransform. type SceneItemTransform struct { Bounds struct { // Alignment of the bounding box. Alignment int `json:"alignment"` // Type of bounding box. Can be "OBS_BOUNDS_STRETCH", "OBS_BOUNDS_SCALE_INNER", "OBS_BOUNDS_SCALE_OUTER...
api/typedefs/xx_generated.sceneitemtransform.go
0.830216
0.475057
xx_generated.sceneitemtransform.go
starcoder
package regression import ( "errors" "fmt" "math" "github.com/jung-kurt/etc/go/util" "gonum.org/v1/gonum/optimize" "gonum.org/v1/gonum/stat" ) // LinearFitType groups together the slope, intercept, coefficient of // determination, and root-mean-square average deviation of a regression line. type LinearFitType ...
go/regression/mth.go
0.819063
0.576661
mth.go
starcoder
package chess import ( "fmt" "strings" ) type ChessBoard struct { board [][]*Figure graveYard []*Figure } func NewCleanChessBoard() *ChessBoard { board := make([][]*Figure, 8) for i := 0; i < len(board); i++ { board[i] = make([]*Figure, 8) } return &ChessBoard{ board: board, graveYard: make([]*...
chess/chessboard.go
0.767777
0.441733
chessboard.go
starcoder
package instrumentation import "time" // MultiInstrumentation satisfies the Instrumentation interface by demuxing // each call to multiple instrumentation targets. type MultiInstrumentation struct { instrs []Instrumentation } // Satisfaction guaranteed. var _ Instrumentation = MultiInstrumentation{} // NewMultiIns...
instrumentation/multi_instrumentation.go
0.757884
0.410461
multi_instrumentation.go
starcoder
package schema import ( "math" "strconv" "github.com/ccbrown/api-fu/graphql/ast" ) func coerceInt(v interface{}) interface{} { switch v := v.(type) { case bool: if v { return 1 } return 0 case int8: return int(v) case uint8: return int(v) case int16: return int(v) case uint16: return int(v)...
graphql/schema/builtins.go
0.630116
0.442094
builtins.go
starcoder
package scroll import ( "image" "image/color" "gioui.org/f32" "gioui.org/gesture" "gioui.org/io/pointer" "gioui.org/layout" "gioui.org/op" "gioui.org/op/clip" "gioui.org/op/paint" "gioui.org/unit" "gioui.org/widget" ) type ( C = layout.Context D = layout.Dimensions ) // Scrollable holds state of a scro...
scroll/scroll.go
0.637482
0.423756
scroll.go
starcoder
package fmp4parser import ( "errors" "sync/atomic" ) // bufferCache is a simple queue for mp4Buffer used for fmp4parser const SlotEntry = 1024 const SlotSize = 4096 // internal mp4Buffer size is 4M == SlotEntry*SlotSize bytes // bufferCache.b is a consecutive bytes // How it works: Slice b is divided into 1024 su...
buffer_cache.go
0.614972
0.427516
buffer_cache.go
starcoder
package algorithm import "fmt" type BinarySearchTree struct { value int leftChild *BinarySearchTree rightChild *BinarySearchTree } //递归添加 func (tree *BinarySearchTree) RecursionAdd(value int) { if tree.value == 0 { tree.value = value tree.leftChild = &BinarySearchTree{} tree.rightChild = &BinarySearc...
algorithm/binarysearchtree.go
0.54577
0.413951
binarysearchtree.go
starcoder
package reflectutil import ( "fmt" "reflect" "strings" ) // T represents any type T. type T struct { // The underlying non-pointer type T. reflect.Type // Counts how many times the given type was pointing on an underlying non-pointer type T. ptrCount int } func (t T) String() string { return strings.Repeat("...
internal/reflectutil/t.go
0.756807
0.50177
t.go
starcoder
package kalman // See https://en.wikipedia.org/wiki/Kalman_filter import ( "fmt" "gonum.org/v1/gonum/mat" ) const ( _N = 6 // Size of the matrixes and vectors. // Symbolic names for rows/columns. _X = 0 _Y = 1 _Z = 2 _VX = 3 _VY = 4 _VZ = 5 ) // ErrInvalidProcNoise is returned when we can't compute p...
filter.go
0.795301
0.564098
filter.go
starcoder
package assertjson import ( "math" "github.com/stretchr/testify/assert" ) // IsInteger asserts that the JSON node has an integer value. func (node *AssertNode) IsInteger(msgAndArgs ...interface{}) { node.t.Helper() if node.exists() { float, ok := node.value.(float64) if !ok { assert.Failf( node.t, ...
assertjson/numeric.go
0.734786
0.710716
numeric.go
starcoder
package behaviors //-------------------- // IMPORTS //-------------------- import ( "time" "github.com/tideland/gocells/cells" ) //-------------------- // CONSTANTS //-------------------- const ( // TopicPair signals a detected pair of events. TopicPair = "pair" // TopicPairTimeout signals a timeout during ...
behaviors/pair.go
0.6488
0.400632
pair.go
starcoder
package ray import ( "image" "math" ) // Camera is the canonical camera object, tracing rays and writing to an image type Camera struct { Transform f float64 dx float64 dy float64 Width int Height int Image *image.RGBA } // NewCamera creates a camera with a focal length, camera width, camera ...
camera.go
0.88623
0.611092
camera.go
starcoder
package renderer import ( "image" "image/color" "math" "github.com/schollz/progressbar/v3" "gonum.org/v1/gonum/mat" ) func constrain(x, min, max float64) float64 { if x < min { return min } else if x > max { return max } else { return x } } func normalization(v *mat.VecDense) { v.ScaleVec(1/math.Sqr...
renderer/render.go
0.605099
0.401013
render.go
starcoder
package fnv type ( // 64-bit FNV-1 hash. Fnv64 uint64 // 64-bit FNV-1a hash. Fnv64a uint64 ) const ( offset64 = 14695981039346656037 prime64 = 1099511628211 ) // New64 returns a new 64-bit FNV-1 hash. func New64() *Fnv64 { var s Fnv64 = offset64 return &s } // Reset resets the Hash to its initial state. f...
internal/hash/fnv/fnv.go
0.825343
0.404802
fnv.go
starcoder
package dcel import "github.com/gonum/graph" // Node is a graph node in the DCEL data structure. type Node interface { graph.Node // Halfedge returns the outgoing halfedge from the node. When the node is // isolated, the returned halfedge is nil. When the node is at a boundary, // the halfedge's Face is nil. Ha...
interfaces.go
0.719581
0.631438
interfaces.go
starcoder
package quadtreego import ( "fmt" "errors" ) type Point struct { X float64 Y float64 Weight interface{} } type Node struct { Left float64 Top float64 Width float64 Height float64 Parent *Node NW *Node NE *Node SW *Node SE *Node Point Point NodeType...
quadtree.go
0.657428
0.484441
quadtree.go
starcoder
package cryptotest import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/inklabs/rangedb/pkg/crypto" "github.com/inklabs/rangedb/pkg/shortuuid" ) func VerifyKeyStore(t *testing.T, newStore func(t *testing.T) crypto.KeyStore) { t.Helper() t.Run("get", func(...
pkg/crypto/cryptotest/verify_key_store.go
0.538498
0.615781
verify_key_store.go
starcoder
package maps import ( "bytes" "io" ) // Polyline represents a list of lat,lng points encoded as a byte array. // See: https://developers.google.com/maps/documentation/utilities/polylinealgorithm type Polyline struct { Points string `json:"points"` } // DecodePolyline converts a polyline encoded string to an arra...
polyline.go
0.855006
0.500244
polyline.go
starcoder
package storagetests import ( "testing" "github.com/anothermemory/storage" "github.com/anothermemory/unit" "github.com/stretchr/testify/assert" ) // CreateFunc represents function which must return created storage object type CreateFunc func() storage.Storage // Func represents test function for single test-cas...
storagetests.go
0.524151
0.560493
storagetests.go
starcoder
package day10 import ( "math" "sort" ) // Asteroid is a single asteroid on the map. An Asteroid knows its location in Cartesian coordinates, // and it also knows the location of all other asteroids in polar coordinates, relative to itself. type Asteroid struct { X int Y int angles map[int][]*AsteroidEd...
day10/asteroid.go
0.824885
0.57821
asteroid.go
starcoder
package ast import "fmt" // Exec carries out node-specific logic, which may include evaluation of subnodes and primitive operations depending on the nodes type. func (n *IntegerLiteral) Exec(context *ExecContext) *Variant { return &Variant{ Type: PrimitiveTypeInt, Int: n.Val, } } // Exec carries out node-spec...
ast/exec.go
0.708717
0.534795
exec.go
starcoder
/** * An extended form of Bram Cohen's patience diff algorithm. * <p> * This implementation was derived by using the 4 rules that are outlined in * Bram Cohen's <a href="http://bramcohen.livejournal.com/73318.html">blog</a>, * and then was further extended to support low-occurrence common elements. * <p> * The b...
src/diff/histogramdiff/histogramdiff.go
0.805211
0.577734
histogramdiff.go
starcoder
package graphblas import ( "context" "log" "reflect" "github.com/rossmerr/graphblas/constraints" ) func init() { RegisterMatrix(reflect.TypeOf((*CSRMatrix[float64])(nil)).Elem()) } // CSRMatrix compressed storage by rows (CSR) type CSRMatrix[T constraints.Number] struct { r int // number of rows in th...
csrMatrix.go
0.761184
0.519278
csrMatrix.go
starcoder
package il import ( "fmt" "strconv" ) func coerceLiteral(lit *BoundLiteral, from, to Type) (*BoundLiteral, bool) { var str string switch from { case TypeBool: str = strconv.FormatBool(lit.Value.(bool)) case TypeNumber: str = strconv.FormatFloat(lit.Value.(float64), 'g', -1, 64) case TypeString: str = li...
pkg/tf2pulumi/il/coercions.go
0.52829
0.487856
coercions.go
starcoder
package financial import ( "errors" "math" ) // Fv Returns a float specifying the future value of an annuity based on // periodic, fixed payments and a fixed interest rate. func Fv(rate, periods, pmt, principal float64) (float64, error) { if periods < 0 { return 0, errors.New("Invalid payment period") } t := ...
time_based.go
0.871939
0.685334
time_based.go
starcoder
package wordchainsresolver // GreedyWordTreeNode struct represents words tidy in a tree type GreedyWordTreeNode struct { Word string ScoreToGoal int PreviousElement *GreedyWordTreeNode NextElements []*GreedyWordTreeNode } // NewGreedyWordTreeElement is GreedyWordTreeNode constructor // input : a...
internal/app/wordchainsresolver/greedySolver.go
0.675978
0.412353
greedySolver.go
starcoder
package main /* Day 13, Part A Given a list of inputs in a file in the format `layer number: depth`, each on a new line, which represent the number of firewall layers in position. If there is no layer specified, it has no depth. Each cycle a "scanner" will progress down in depth of each layer. When the "scan" reache...
2017/day13.go
0.60964
0.491639
day13.go
starcoder
package cheapruler import ( "errors" "math" ) // A collection of very fast approximations to common geodesic measurements. // Useful for performance-sensitive code that measures things on a city scale. type CheapRuler struct { Kx float64 Ky float64 } // The closest point on the line from the given point and // i...
cheapruler.go
0.883142
0.738221
cheapruler.go
starcoder
package light import ( "github.com/g3n/engine/core" "github.com/g3n/engine/gls" "github.com/g3n/engine/math32" ) // Point is an omnidirectional light source type Point struct { core.Node // Embedded node color math32.Color // Light color intensity float32 // Light intensity uni gls...
light/point.go
0.889694
0.547162
point.go
starcoder
package solver import "fmt" // yWing removes candidates. If a cell has two candidates (AB) and in the same column as AB is a cell containing AC and in the same row as AB is a cell containing BC, then if AB evaluates to A, then AC must be C, and similarly, if AB evaluates to B, then BC must be B. Therefore, the cell a...
solver/ywing.go
0.70791
0.497925
ywing.go
starcoder
package slice import ( "reflect" ) // UnionGeneric returns union set of left and right, with right follows left. // The duplicate members in left are kept. func UnionGeneric(left, right interface{}) interface{} { if left == nil && right == nil { return nil } return UnionValue(reflect.ValueOf(left), reflect.Valu...
union.go
0.854536
0.562477
union.go
starcoder
package tlv import ( "bytes" "fmt" "io" "sort" "github.com/eacsuite/eacd/btcec" ) // Type is an 64-bit identifier for a TLV Record. type Type uint64 // TypeMap is a map of parsed Types. The map values are byte slices. If the byte // slice is nil, the type was successfully parsed. Otherwise the value is byte //...
tlv/record.go
0.796411
0.403949
record.go
starcoder
package continuous import ( "math" "sort" pb "gopkg.in/cheggaaa/pb.v1" ) // KraskovStoegbauerGrassberger1 is an implementation of the first // algorithm presented in // <NAME>, <NAME>, and <NAME>. // Estimating mutual information. Phys. Rev. E, 69:066138, Jun 2004. // The function assumes that the data xyz is nor...
continuous/KraskovStoegbauerGrassberger.go
0.657978
0.529932
KraskovStoegbauerGrassberger.go
starcoder
package entity import ( "github.com/df-mc/dragonfly/server/entity/damage" "github.com/df-mc/dragonfly/server/entity/healing" "github.com/df-mc/dragonfly/server/world" "github.com/go-gl/mathgl/mgl64" ) // Living represents an entity that is alive and that has health. It is able to take damage and will die upon // ...
server/entity/living.go
0.620507
0.411673
living.go
starcoder
package vm import ( "fmt" "math/big" "github.com/tenderly/solidity-hmr/ethereum/common/math" ) // Memory implements a simple memory model for the ethereum virtual machine. type Memory struct { store []byte lastGasCost uint64 } // NewMemory returns a new memory model. func NewMemory() *Memory { return &...
ethereum/core/vm/memory.go
0.687
0.466299
memory.go
starcoder
A chart repository is an HTTP server that provides information on charts. A local repository cache is an on-disk representation of a chart repository. There are two important file formats for chart repositories. The first is the 'index.yaml' format, which is expressed like this: apiVersion: v1 entries: frobnit...
src/vendor/k8s.io/helm/pkg/repo/doc.go
0.713432
0.532121
doc.go
starcoder
package main import ( "github.com/guanyilun/go-sampling/sampling" "fmt" ) type Automata struct { limit int actions int probs []float64 active bool sampling *sampling.Sampling // May not be necessary counter int delta int reward float64 penalize float64 threshold float64...
go/automata.go
0.574634
0.428831
automata.go
starcoder
package output import ( "fmt" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/message/batch" "github.com/Jeffail/benthos/v3/lib/metrics" "github.com/Jeffail/benthos/v3/lib/output/writer" "github.com/Jeffail/benthos/v3/lib/types" ) //---------------------------------------------------...
lib/output/kinesis.go
0.73412
0.456168
kinesis.go
starcoder
package pipeline import ( "fmt" "strings" "github.com/observiq/stanza/errors" "github.com/observiq/stanza/operator" "gonum.org/v1/gonum/graph/encoding/dot" "gonum.org/v1/gonum/graph/simple" "gonum.org/v1/gonum/graph/topo" ) var _ Pipeline = (*DirectedPipeline)(nil) // DirectedPipeline is a pipeline backed by...
pipeline/directed.go
0.823151
0.409103
directed.go
starcoder
package main import ( "fmt" "strings" ) func visualiseMatrix(given [][]uint8, width, height int) { fmt.Print(matricesToString(given, nil, width, height)) } func (c1 cell) in(slice []cell) bool { for _, c2 := range slice { if c1 == c2 { return true } } return false } func aliveCellsToString(given, expec...
visualise.go
0.516839
0.424114
visualise.go
starcoder
package trie import ( "github.com/DgamesFoundation/subchain/fabric/core/ledger/statemgmt" ) type levelDeltaMap map[string]*trieNode type trieDelta struct { lowestLevel int deltaMap map[int]levelDeltaMap } func newLevelDeltaMap() levelDeltaMap { return levelDeltaMap(make(map[string]*trieNode)) } func newTrie...
fabric/core/ledger/statemgmt/trie/trie_delta.go
0.620852
0.630088
trie_delta.go
starcoder
package analyzers import ( summarypb "github.com/GoogleCloudPlatform/testgrid/pb/summary" "github.com/GoogleCloudPlatform/testgrid/pkg/summarizer/common" "github.com/golang/protobuf/ptypes/timestamp" ) // IntString is for sorting, primarily intended for map[string]int as implemented below type IntString struct { ...
pkg/summarizer/analyzers/baseanalyzer.go
0.63114
0.406509
baseanalyzer.go
starcoder
package mipmap import ( "fmt" "math" "github.com/MattSwanson/ebiten/v2/internal/affine" "github.com/MattSwanson/ebiten/v2/internal/buffered" "github.com/MattSwanson/ebiten/v2/internal/driver" "github.com/MattSwanson/ebiten/v2/internal/graphics" "github.com/MattSwanson/ebiten/v2/internal/shaderir" ) func Begi...
internal/mipmap/mipmap.go
0.501709
0.453806
mipmap.go
starcoder
package types //------------------------------------------------------------------------------ // Message is a struct containing any relevant fields of a benthos message and // helper functions. type Message struct { Parts [][]byte `json:"parts"` } // NewMessage initializes an empty message. func NewMessage() Mess...
plugin/benthos/lib/types/message.go
0.643665
0.555013
message.go
starcoder
package hoff import ( "errors" "github.com/google/go-cmp/cmp" ) // Computation take a NodeSystem and compute a Context against it. type Computation struct { System *NodeSystem Context *Context Status bool Report map[Node]ComputeState } // NewComputation create a computation based on a valid, and activated ...
computation.go
0.693265
0.462898
computation.go
starcoder
package circuit import ( "fmt" "math" "math/cmplx" "math/rand" "time" "github.com/Quant-Team/qvm/pkg/circuit/gates" m "github.com/Quant-Team/qvm/pkg/math/matrix" v "github.com/Quant-Team/qvm/pkg/math/vector" ) var _ Qubiter = Zero() var _ Qubiter = One() type Gate m.Matrix // Qubiter - abstractio interface...
pkg/circuit/qubit.go
0.724091
0.404713
qubit.go
starcoder
package msgp import ( "encoding/binary" "errors" "fmt" "io" "math" "reflect" "strconv" ) // Unpack reads a value from the io.Reader. And assigns it to the value pointed by 'ptr'. // Because Unpack depends on the type of 'ptr' to extract a value, 'ptr' should be // an address of specific type variable. // If po...
decode.go
0.539711
0.4436
decode.go
starcoder
package imaging import ( "image" "image/color" "math" ) // FlipH flips the image horizontally (from left to right) and returns the transformed image. func FlipH(img image.Image) *image.NRGBA { src := newScanner(img) dstW := src.w dstH := src.h rowSize := dstW * 4 dst := image.NewNRGBA(image.Rect(0, 0, dstW, d...
vendor/github.com/disintegration/imaging/transform.go
0.890091
0.462534
transform.go
starcoder
package bloombits import ( "sync" ) // request represents a bloom retrieval task to prioritize and pull from the local // database or remotely from the network. type request struct { section uint64 // Section index to retrieve the a bit-vector from bit uint // Bit index within the section to retrieve the ve...
core/bloombits/scheduler.go
0.661486
0.480905
scheduler.go
starcoder