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 main import ( "fmt" "io/ioutil" "math" "regexp" "strconv" "strings" ) type Particle struct { x int64 y int64 z int64 vx int64 vy int64 vz int64 ax int64 ay int64 az int64 annihilated bool } func (p Particle) Distance() float64 { dist := math.Pow(float64(p.x), 2) dist += math.Pow(float64(...
Day20-25/20.go
0.514644
0.414069
20.go
starcoder
package netfilter import ( "encoding/binary" "fmt" "github.com/mdlayher/netlink" "github.com/pkg/errors" "golang.org/x/sys/unix" ) // An Attribute is a copy of a netlink.Attribute that can be nested. type Attribute struct { // The type of this Attribute, typically matched to a constant. Type uint16 // An a...
attribute.go
0.686895
0.41745
attribute.go
starcoder
// Print a binary tree in an m*n 2D string array following these rules: // 1. The row number m should be equal to the height of the given binary tree. // 2. The column number n should always be an odd number. // 3. The root node's value (in string format) should be put in the exactly middle of the first row it can be ...
0655/code.go
0.715325
0.674583
code.go
starcoder
package any // Ok determines whether Value is not the zero Value. // This is useful to check before using the underlying value. // Consider using Default over Ok. func (v Value) Ok() bool { return v.i != nil } // BoolOk returns the value as a bool type and a bool whether the Value is of type bool. func (v Value) Boo...
ok.go
0.79653
0.57687
ok.go
starcoder
package constellation import ( "fmt" "io" "strings" "github.com/awalterschulze/gographviz" ) // GenerateGraph - function to take a dagconfigService structure and create a graph object that contains the // representation of the graph. Also outputs a string representation (GraphViz dot notation) of the resulting g...
internal/platform/constellation/graph.go
0.698741
0.436202
graph.go
starcoder
package indicators import ( "container/list" "errors" "github.com/thetruetrade/gotrade" ) // An Average Directional Index Rating (Adxr), no storage type AdxrWithoutStorage struct { *baseIndicatorWithFloatBounds // private variables periodCounter int periodHistory *list.List adx *AdxWithoutStorage ...
indicators/adxr.go
0.700383
0.435541
adxr.go
starcoder
package web import "fmt" // Table holds the HTML table of pricing information for a resource. type Table struct { Index int Type string Header [2]string GeneralRows [][2]string PricingInfo [][8]string Total [3]string } // PricingTypeTables holds the HTML tables of hourly, monthly and ye...
io/web/table.go
0.575707
0.488222
table.go
starcoder
package sqlparser // CloneSQLNode creates a deep clone of the input. func CloneSQLNode(in SQLNode) SQLNode { if in == nil { return nil } switch in := in.(type) { case AccessMode: return in case *AddColumns: return CloneRefOfAddColumns(in) case *AddConstraintDefinition: return CloneRefOfAddConstraintDefi...
go/vt/sqlparser/ast_clone.go
0.509276
0.533458
ast_clone.go
starcoder
package repository import ( "api/entity" "api/model" "context" "log" "reflect" "golang.org/x/xerrors" ) type WorldMock struct { expect *WorldExpect } func (r *WorldMock) EXPECT() *WorldExpect { return r.expect } func NewWorldMock() *WorldMock { return &WorldMock{expect: NewWorldExpect()} } type WorldToM...
_example/03_api/mock/repository/world.go
0.512449
0.447883
world.go
starcoder
package reward import ( abi "github.com/filecoin-project/specs-actors/actors/abi" big "github.com/filecoin-project/specs-actors/actors/abi/big" ) // A quantity of space * time (in byte-epochs) representing power committed to the network for some duration. type Spacetime = big.Int type State struct { // CumsumBase...
actors/builtin/reward/reward_state.go
0.797083
0.503662
reward_state.go
starcoder
package goyolov5 import ( "fmt" "image" "image/color" "image/draw" "log" "unsafe" ) // From https://github.com/pixiv/go-libjpeg/blob/master/rgb/rgb.go // Tensor represent image data which has RGB colors. // Tensor is compatible with image.RGBA, but does not have alpha channel to reduce using memory. type Tenso...
tensor.go
0.864081
0.529263
tensor.go
starcoder
package stdlib type Type_bool bool type Type_uint256 int type Type_address int type Type_uint256arr []Type_uint256 type Txn struct { Balance Type_uint256 Value Type_uint256 DidTimeout bool From Type_address Data Msg } var Txn0 = Txn{ Balance: 0, Value: 0 } func Ite_uint256(c Type_bool, x T...
go/src/reach-sh/stdlib/stdlib.go
0.635222
0.526586
stdlib.go
starcoder
package utils import ( "context" "encoding/json" "fmt" "strings" "time" "github.com/prometheus/common/model" ) type Selector string // Range represents a sliced time range with increments. type Range struct { // Start and End are the boundaries of the time range. Start, End model.Time // Step is the maximu...
pkg/utils/prometheus.go
0.67822
0.408926
prometheus.go
starcoder
package tween import ( "github.com/Dethrail/Tamagotchi/engine" //"math" //"time" ) func Scale(t *Tween, arr []float32) []float32 { scale := t.Target.Transform().Scale() if arr == nil || len(arr) == 0 { return []float32{scale.X, scale.Y, scale.Z} } scale = VectorFmt(scale, arr, t.Format) t.Target.Transform(...
server/components/tween/Type.go
0.521715
0.530115
Type.go
starcoder
package geometry import ( "math" ) func CalculateMovementDistance(elapsedTimeInMs int64, distancePerMs float64, maxDistance *float64) float64 { var distance = float64(elapsedTimeInMs) * distancePerMs if nil != maxDistance { return math.Min(*maxDistance, distance) } return distance } type movementCallbackFunc ...
src/engine/geometry/movement.go
0.760384
0.753829
movement.go
starcoder
package organizr import ( "sort" "github.com/Viking2012/goraynor/src/structs" ) // implementation basics from https://pkg.go.dev/sort#example-package-SortKeys // lessFunc is the type of a "less" function that defines the ordering of its PurchaseRecord arguments. type lessFunc func(p1, p2 *structs.PriceRecord) bool...
src/organizr/organizr.go
0.735926
0.560674
organizr.go
starcoder
package number import ( "github.com/shopspring/decimal" ) const ( presentDecimals = 8 persistentDecimals = 32 ) type Decimal struct { decimal.Decimal } func Zero() Decimal { return Decimal{} } func NewDecimal(value int64, decimals int32) Decimal { return Decimal{decimal.New(value, -decimals).Round(persist...
decimal.go
0.866683
0.400339
decimal.go
starcoder
package nn import ( "math" ) type OutputLayer struct { *Layer biasNeuron *BiasNeuron prevLayer ILayer withBias bool weights [][]float64 biasWeights []float64 activationDerivativeFunction ActivationDerivativeFunction...
src/nn/layer_output.go
0.702632
0.544499
layer_output.go
starcoder
package iso20022 // Specifies periods related to a corporate action option. type CorporateActionPeriod5 struct { // Period during which the price of a security is determined. PriceCalculationPeriod *Period1Choice `xml:"PricClctnPrd,omitempty"` // Period during which both old and new equity may be traded simultane...
CorporateActionPeriod5.go
0.858763
0.508666
CorporateActionPeriod5.go
starcoder
package wildcat import ( "unicode/utf8" ) type calculator interface { calculate(data []byte) int64 } // Counter shows type Counter interface { IsType(ct CounterType) bool Type() CounterType update(data []byte) Count(ct CounterType) int64 } // CounterType represents the types of counting. type CounterType int ...
counter.go
0.60871
0.502441
counter.go
starcoder
package eve import ( "bits" ) // GE provides a convenient way to write Graphics Engine commands. type GE struct { DL } // GE retuns Graphics Engine command writer. Special addr -1 means that GE // writes commands to the Graphics Engine co-processor. func (d *Driver) GE(addr int) GE { d.end() w := Writer{d: d} s...
egpath/src/display/eve/ge.go
0.626467
0.489686
ge.go
starcoder
// hstepper contains a horizontal stepper component. package hstepper import ( . "github.com/golangee/forms" "github.com/golangee/forms/theme/material/icon" "strconv" ) // Step is the model for the internal step view. type Step struct { ico icon.Icon numberOnly bool title string } // NewStep creat...
views/hstepper/stepper.go
0.694303
0.553023
stepper.go
starcoder
package core import ( "runtime" . "github.com/gooid/gocv/opencv3/internal/native" ) const _channelsMatOfPoint2f = 2 var _depthMatOfPoint2f = CvTypeCV_32F type MatOfPoint2f struct { *Mat } func NewMatOfPoint2f() (rcvr *MatOfPoint2f) { rcvr = &MatOfPoint2f{} rcvr.Mat = NewMat2() runtime.SetFinalizer(rcvr, fun...
opencv3/core/MatOfPoint2f.java.go
0.613237
0.423637
MatOfPoint2f.java.go
starcoder
package graph import ( "github.com/puppetlabs/leg/datastructure" ) type intrusiveEdge struct { Source, Target Vertex Edge Edge Weight float64 } type baseGraphOps interface { EdgesBetween(source, target Vertex) EdgeSet EdgeBetween(source, target Vertex) (Edge, error) EdgesOf(vertex Vertex) E...
graph/base.go
0.727298
0.465752
base.go
starcoder
package policy import ( "sort" mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1" "github.com/kumahq/kuma/pkg/core/resources/apis/mesh" ) // SelectDataplanePolicy given a Dataplane definition and a list of DataplanePolicy returns the "best matching" DataplanePolicy. // A DataplanePolicy is considered a match i...
pkg/core/policy/dataplane_matcher.go
0.69946
0.565359
dataplane_matcher.go
starcoder
package randelbrot import ( "math" ) // A Renderer maintains state and provides functions for rendering Mandelbrot Set images type Renderer struct { xCoordinates, yCoordinates []float64 } func (r *Renderer) initializeCoordinateMap(sizeX int, sizeY int, set *MandelbrotSet, maxCount int) { r.xCoordinates = make([]f...
randelbrot/renderer.go
0.606964
0.509337
renderer.go
starcoder
package elogo import ( "math" ) const ( // K is the default K-Factor K = 32 // D is the default deviation D = 400 ) // Elo calculates Elo rating changes based on the configured factors. type Elo struct { K int D int } // Outcome is a match result data for a single player. type Outcome struct { Delta int Ra...
elogo.go
0.785061
0.622502
elogo.go
starcoder
package gogeom //y^2 = 4*a*x type Parabola struct { A float64 IsYAxis bool } //(y - k)^2 = 4*a*(x - h) type ParabolaWithOrigin struct { A float64 H float64 K float64 IsYAxis bool } //Length of latus ration func (p *Parabola) LenghtOfLatusRation() float64 { return (p.A * 4) } //Length ...
parabola.go
0.727395
0.569015
parabola.go
starcoder
package sunspec // Point defines the generic behavior all sunspec types have in common. type Point interface { // Index defines the locality of the point in a modbus address space. Index // Name returns the point´s identifier. Name() string // Valid specifies whether the underlying value is implemented by the dev...
point.go
0.889313
0.517144
point.go
starcoder
package docs import "github.com/swaggo/swag" const docTemplate = `{ "schemes": {{ marshal .Schemes }}, "swagger": "2.0", "info": { "description": "{{escape .Description}}", "title": "{{.Title}}", "termsOfService": "http://estuary.tech", "contact": { "name": "API...
docs/docs.go
0.766031
0.406921
docs.go
starcoder
package bitmap import ( "errors" "image" "image/color" "github.com/pzduniak/unipdf/common" "github.com/pzduniak/unipdf/internal/jbig2/writer" ) // ErrIndexOutOfRange is the error that returns if the bitmap byte index is out of range. var ErrIndexOutOfRange = errors.New("bitmap byte index out of range") // Bit...
bot/vendor/github.com/pzduniak/unipdf/internal/jbig2/bitmap/bitmap.go
0.819749
0.55429
bitmap.go
starcoder
package polynomial import ( "log" "math" ) type dataFrame struct { c float64 d float64 e float64 f float64 } // legendre.recurrences in R.cran.orthopolynom // GPL 3.0 // https://github.com/cran/orthopolynom/blob/master/R/legendre.recurrences.R func recurrences(n int, normalize ...bool) (relations []dataFrame) ...
polynomial/legendre.go
0.762998
0.620507
legendre.go
starcoder
package packed // Efficient sequential read/write of packed integers. type BulkOperationPacked9 struct { *BulkOperationPacked } func newBulkOperationPacked9() BulkOperation { return &BulkOperationPacked9{newBulkOperationPacked(9)} } func (op *BulkOperationPacked9) decodeLongToInt(blocks []int64, values []int3...
vendor/github.com/balzaczyy/golucene/core/util/packed/bulkOperation9.go
0.55254
0.710302
bulkOperation9.go
starcoder
package models import ( "github.com/is8ac/tfutils" "github.com/is8ac/tfutils/descend" tf "github.com/tensorflow/tensorflow/tensorflow/go" "github.com/tensorflow/tensorflow/tensorflow/go/op" ) // MakeSingleLayerNN create a modelDef for a single layer nn. func MakeSingleLayerNN(inputs, targets tf.Output) ( paramDe...
descend/models/models.go
0.724578
0.439567
models.go
starcoder
package util import ( "bytes" "fmt" "math" "text/tabwriter" e2e "k8s.io/kubernetes/test/e2e/framework" "github.com/golang/glog" ) // MetricKey is used to identify a metric uniquely. type MetricKey struct { TestName string // Name of the test ("Load Capacity", "Density", etc) Verb string // "GET","LI...
benchmark/pkg/util/util.go
0.668447
0.439146
util.go
starcoder
package algorithm import ( "basic/datatrans" "fmt" "sync" "time" ) var SaveDataFlag bool = false /* @note:this function uses concurrent calculation to boost the comparision between 3 different kinds of algorithm. Basically gorotine, semaphore and message quene(channel) are used in this example. It serves as a...
src/models/algorithm/searchmethod/compare.go
0.538498
0.475971
compare.go
starcoder
package flatten_nested_list_iterator // https://leetcode-cn.com/problems/flatten-nested-list-iterator type NestedInteger struct { value int isInteger bool sub []*NestedInteger } func (this NestedInteger) IsInteger() bool { return this.isInteger } func (this NestedInteger) GetInteger() int { return thi...
data_structure/binary_tree/flatten_nested_list_iterator/flatten_nested_list_iterator.go
0.767733
0.446917
flatten_nested_list_iterator.go
starcoder
package providers import ( "encoding/json" "fmt" "log" "github.com/StackExchange/dnscontrol/v2/models" ) // Registrar is an interface for a domain registrar. It can return a list of needed corrections to be applied in the future. Implement this only if the provider is a "registrar" (i.e. can update the NS record...
providers/providers.go
0.66356
0.467271
providers.go
starcoder
package xgraphics /* xgraphics/new.go contains a few additional constructors for creating an xgraphics.Image. */ import ( "bytes" "fmt" "image" _ "image/gif" _ "image/jpeg" _ "image/png" "os" "github.com/jezek/xgb/xproto" "github.com/alex11br/xgbutil" "github.com/alex11br/xgbutil/ewmh" "github.com/alex11...
xgraphics/new.go
0.688573
0.519338
new.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // AccessReviewSettings type AccessReviewSettings struct { // Indicates whether showing recommendations to reviewers is enabled. accessRecommendationsEnab...
models/access_review_settings.go
0.620852
0.418816
access_review_settings.go
starcoder
package sequtil import ( "fmt" "strings" ) // Maps nucleotide byte value to its int value. var ntoi []int func init() { // Initialize ntoi values. ntoi = make([]int, 256) for i := range ntoi { ntoi[i] = -1 } ntoi['a'], ntoi['A'] = 0, 0 ntoi['c'], ntoi['C'] = 1, 1 ntoi['g'], ntoi['G'] = 2, 2 ntoi['t'], nt...
sequtil/sequtil.go
0.619817
0.458834
sequtil.go
starcoder
package natural import ( "fmt" ) var naturalA Natural var naturalsNames []string var naturals map[string]Natural type Natural struct { name string } func (n Natural) Name() string { return n.name } func (n Natural) Next() Natural { for pos, name := range naturalsNames { if n.name == name { nextPos := (pos...
theory/natural/natural.go
0.525856
0.431944
natural.go
starcoder
package core import ( "fmt" "path" "reflect" "strings" ) // Path represents an on-disk path that is either an input to or an output from a BuildStep (or both). type Path interface { Absolute() string Relative() string String() string WithExt(ext string) OutPath WithPrefix(prefix string) OutPath WithSuffix(s...
RULES/core/path.go
0.841663
0.437583
path.go
starcoder
package events func MakeInitialData() []Event { var christmasOnsite2020 *OnsiteEvent { christmasOnsite2020 = NewOnsiteEvent() christmasOnsite2020.BaseEvent.active = true christmasOnsite2020.BaseEvent.id = "christmas-onsite-2020" christmasOnsite2020.BaseEvent.name = "Christmas Onsite 2020" christmasOnsite20...
pkg/server/models/events/types/data.go
0.520253
0.427815
data.go
starcoder
package gojas import ( "encoding/json" "strings" // "log" ) //JsonAssertion is the struct we use to organize our walking of the JSON doc. The decoder is // created by the Maker only. At the moment, the assertions are walking the JSON doc each time. // Consider an extended method set that can reuse a single JsonAsse...
gojas.go
0.610221
0.59461
gojas.go
starcoder
package otkafka import ( "time" "github.com/go-kit/kit/metrics" "github.com/segmentio/kafka-go" ) type readerCollector struct { factory ReaderFactory stats *ReaderStats interval time.Duration } // AggStats is a gauge group struct. type AggStats struct { Min metrics.Gauge Max metrics.Gauge Avg metrics.G...
otkafka/reader_metrics.go
0.633524
0.485722
reader_metrics.go
starcoder
package iso20022 // Net position of a segregated holding, in a single security, within the overall position held in a securities account at a specified place of safekeeping. type AggregateBalancePerSafekeepingPlace29 struct { // Place where the securities are safe-kept, physically or notionally. This place can be, ...
AggregateBalancePerSafekeepingPlace29.go
0.87864
0.419172
AggregateBalancePerSafekeepingPlace29.go
starcoder
package day04 import ( "fmt" "strconv" "strings" ) type passwordRange struct { from, to int } type password int type criterion func(password password) bool // Day holds the data needed to solve part one and part two type Day struct { passwordRange passwordRange } // NewDay returns a new Day that solves part ...
day04/day04.go
0.736495
0.458167
day04.go
starcoder
type OpTree struct { L *OpTree R *OpTree Op string IsNum bool Num int } func NewNum(num int) *OpTree { return &OpTree { IsNum: true, Num: num, } } func (t *OpTree) Calc() int { if t == nil { return 0 } if t.IsNum { return t...
leetcode/224/224.go
0.508544
0.41117
224.go
starcoder
package satellite import ( "log" "math" "strconv" "strings" ) // Constants const TWOPI float64 = math.Pi * 2.0 const DEG2RAD float64 = math.Pi / 180.0 const RAD2DEG float64 = 180.0 / math.Pi const XPDOTP float64 = 1440.0 / (2.0 * math.Pi) // Holds latitude and Longitude in either degrees or radians type LatLong ...
helpers.go
0.575588
0.564759
helpers.go
starcoder
package mergesort func Sort(initialArray []int) []int { if len(initialArray) <= 1 { return initialArray } middle := len(initialArray) / 2 leftPartSorted := Sort(initialArray[:middle]) rightPartSorted := Sort(initialArray[middle:]) return merge2(leftPartSorted, rightPartSorted) } /* As long as both arrays ...
sorting/mergesort/Mergesort.go
0.59843
0.541045
Mergesort.go
starcoder
package api import ( "encoding/json" ) // BeamStatsResponse struct for BeamStatsResponse type BeamStatsResponse struct { BeamStatsMap *map[string]SoracomBeamStats `json:"beamStatsMap,omitempty"` Date *string `json:"date,omitempty"` Unixtime *int64 `json:"unixtime,omitempty"` } // NewBeamStatsResponse instantiat...
openapi/api/model_beam_stats_response.go
0.761095
0.428652
model_beam_stats_response.go
starcoder
package filter import ( "math" "github.com/mdouchement/hdr" "github.com/mdouchement/hdr/hdrcolor" ) // fast gaussian blur based on http://blog.ivank.net/fastest-gaussian-blur.html // and Golang implementation https://github.com/tajtiattila/blur // FastGaussian blurs im using a fast approximation of gaussian blur...
filter/fast_gaussian.go
0.664976
0.490907
fast_gaussian.go
starcoder
package layout import ( "image" "image/color" "image/draw" "log" "github.com/faiface/gui" ) var _ Layout = Grid{} // Grid represents a grid with rows and columns in each row. // Each row can be a different length. type Grid struct { // Rows represents the number of childs of each row. Rows []int // Backgrou...
layout/grid.go
0.67822
0.508117
grid.go
starcoder
package value import ( "bytes" "encoding/binary" "math" "github.com/caravan/essentials/id" ) type ( // Value is a placeholder for what will eventually be a generic Value interface { Compare(Value) Comparison Bytes() []byte } // Comparison represents the result of an equality comparison Comparison int ...
value/value.go
0.769427
0.464416
value.go
starcoder
package tile import ( "math" "sync" ) type costFn = func(Tile) uint16 // Edge represents an edge of the path type edge struct { Point Cost uint32 } // Around performs a breadth first search around a point. func (m *Grid) Around(from Point, distance uint32, costOf costFn, fn Iterator) { start, ok := m.At(from....
path.go
0.801159
0.465509
path.go
starcoder
package ring import ( "math/big" "math/bits" ) // MForm switches a to the Montgomery domain by computing // a*2^64 mod q. func MForm(a, q uint64, u []uint64) (r uint64) { mhi, _ := bits.Mul64(a, u[1]) r = -(a*u[0] + mhi) * q if r >= q { r -= q } return } // MFormConstant switches a to the Montgomery domain ...
ring/modular_reduction.go
0.764188
0.508117
modular_reduction.go
starcoder
package geodist import ( "errors" "math" ) // these constants are used for vincentyDistance() const a = 6378137 const b = 6356752.3142 const f = 1 / 298.257223563 // WGS-84 ellipsiod /* VincentyDistance computes the distances between two georgaphic coordinates Args: p1: the 'starting' point, given in latitude, l...
vincenty.go
0.833358
0.577912
vincenty.go
starcoder
package stack // This JSON document lays out the basic structure of the CloudFormation // template for our pool stacks. The Resources here will be transfered to the // Pool.*Template attributes. // Make certain that the appropriate Pool structures are modified when changing // the structure of this template. var poolT...
stack/pool_template.go
0.533641
0.443721
pool_template.go
starcoder
package fsm import ( "sync" "github.com/pkg/errors" ) var ( // ErrBuild represents the error of building an FSM. ErrBuild = errors.New("error when building an FSM") // ErrTransitionNotFound indicates that there doesn't exist a transition defined on the source state and the event. ErrTransitionNotFound = error...
vendor/github.com/iotexproject/go-fsm/fsm.go
0.671471
0.468061
fsm.go
starcoder
package sqlparser type SQLAstVisitor interface { Visit(SQLNode) error } func (node *AccessMode) Accept(vis SQLAstVisitor) error { return vis.Visit(node) } func (node *AliasedExpr) Accept(vis SQLAstVisitor) error { return vis.Visit(node) } func (node *AliasedTableExpr) Accept(vis SQLAstVisitor) err...
go/vt/sqlparser/external_visitor.go
0.699254
0.471527
external_visitor.go
starcoder
package ratelimit import ( "context" "time" "github.com/tikv/pd/pkg/syncutil" "golang.org/x/time/rate" ) // RateLimiter is a rate limiter based on `golang.org/x/time/rate`. // It implements `Available` function which is not included in `golang.org/x/time/rate`. // Note: AvailableN will increase the wait time of...
pkg/ratelimit/ratelimiter.go
0.81604
0.413092
ratelimiter.go
starcoder
package siec import ( "math/big" ) func (curve *SIEC255Params) affineToProjective(x, y *big.Int) (X, Y, Z *big.Int) { X, Y, Z = new(big.Int), new(big.Int), new(big.Int) X.Set(x) X.Mod(X, curve.P) Y.Set(y) Y.Mod(Y, curve.P) Z.SetInt64(1) return } func (curve *SIEC255Params) projectiveToAffine(X, Y, Z *big.Int...
projective.go
0.710327
0.438905
projective.go
starcoder
package natlab import ( "fmt" "sync" "time" "inet.af/netaddr" ) // FirewallType is the type of filtering a stateful firewall // does. Values express different modes defined by RFC 4787. type FirewallType int const ( // AddressAndPortDependentFirewall specifies a destination // address-and-port dependent fire...
tstest/natlab/firewall.go
0.564339
0.455744
firewall.go
starcoder
package quickunion import ( "fmt" "github.com/ivanlemeshev/algorithms-go/unionfind" ) // QuickUnion is an implementation of union–find data type. This implementation // uses quick union. The constructor takes O(n) time, where n is the number of // sites. The union and find operations take O(n) time in the worst ca...
unionfind/quickunion/quickunion.go
0.804214
0.462473
quickunion.go
starcoder
package nakamura import ( "errors" "reflect" "strconv" "strings" "time" ) type Months struct { January, February, March, April, May, June, July, August, September, October, November, December int } func IsDateValid(input, format string) bool { if len(input) == 0 { return false } date, dateForma...
diem.go
0.549641
0.433742
diem.go
starcoder
package sqlow // DataType is SQL DataType type DataType struct { TypeName string Type string UNSIGNED bool UndignedType string ZEROFILL bool MaxLength int DefaultPropaty string AutoIncrement bool PrimaryKey bool } var ( // TINYINT is the one that exists in SQL and can...
datatypes.go
0.583559
0.441854
datatypes.go
starcoder
package math const ( E = 2.71828182845904523536028747135266249775724709369995957496696763 // A001113 Pi = 3.14159265358979323846264338327950288419716939937510582097494459 // A000796 Phi = 1.61803398874989484820458683436563811772030917980576286213544862 // A001622 Sqrt2 = 1.41421356237309504880168872420969807...
go/src/math/math.go
0.602997
0.502258
math.go
starcoder
package compare // Int compares two int values. // It returns -1 if value1 is LESS THAN value2. // It returns 0 if value1 is EQUAL TO value2. // It returns 1 if value1 is GREATER THAN value2. func Int(value1 int, value2 int) int { switch { case value1 > value2: return 1 case value1 == value2: return 0 defaul...
int.go
0.776962
0.496643
int.go
starcoder
package tuplecodec import "bytes" // Less decides the key is less than another key func (tk TupleKey) Less(another TupleKey) bool { return bytes.Compare(tk,another) < 0 } // Compare compares the key with another key func (tk TupleKey) Compare(another TupleKey) int { return bytes.Compare(tk,another) } // Equal de...
pkg/vm/engine/tpe/tuplecodec/key.go
0.739046
0.522994
key.go
starcoder
package ease import ( "math" ) const backS float32 = 1.70158 var pi = float32(math.Pi) // TweenFunc provides an interface used for the easing equation. You can use // one of the provided easing functions or provide your own. type TweenFunc func(t, b, c, d float32) float32 func Linear(t, b, c, d float32) float32 {...
ease/easing_functions.go
0.818809
0.628863
easing_functions.go
starcoder
package dsp import ( "math" "math/rand" ) // RandRange returns random values between a specified range func RandRange(min, max float64) float64 { return rand.Float64()*(max-min) + min } // ExpRatio produces an (inverse-)exponential curve that's inflection can be controlled by a specific ratio func ExpRatio(ratio,...
dsp/math.go
0.842669
0.542742
math.go
starcoder
package travel import ( "strconv" "time" ) func (t *Travel) AddCentury() *Travel { t.t = t.t.AddDate(100, 0, 0) return t } func (t *Travel) AddCenturies(centuries int) *Travel { t.t = t.t.AddDate(centuries*100, 0, 0) return t } func (t *Travel) SubCentury() *Travel { t.t = t.t.AddDate(-100, 0, 0) return t } f...
calculation.go
0.692226
0.582907
calculation.go
starcoder
package main import ( "image/jpeg" "image/png" "image" "bufio" "flag" "math" "fmt" "log" "os" ) const ImageChannels = 3 func GetSSIMChannel(inputImage *image.Image, outputImage *image.Image, index int) float64 { imageWidth := (*inputImage).Bounds().Max.X imageHeight := (*inputImage).Bounds().Max.Y iSum ...
scripts/encoder/encoder-intra.go
0.58261
0.496582
encoder-intra.go
starcoder
package fixed import ( "math/bits" ) // 72/56 fixed-point value type Fixed struct { lo, hi uint64 } var fixedRawval1 = rawfixed(1) var fixedOne = rawfixed(oneValue) const unsignMask = uint64(1)<<63 - 1 const signMask = uint64(1) << 63 func sign_(x int64) uint64 { return uint64(x) & signMask } func abs_(x int64...
fixednat.go
0.567218
0.412057
fixednat.go
starcoder
package main import ( "github.com/fogleman/gg" "fmt" "math" ) const width, height int = 1920, 1080 func main() { base := Axes{ xmin: -50, xmax: 50, ymin: -200, ymax: 500, xscale: 5, yscale: 50, GraphicalObject: GraphicalObject{ width...
main.go
0.830216
0.462898
main.go
starcoder
package gollection func LinkedListOf[T any](elements ...T) LinkedList[T] { var inner = &linkedList[T]{0, nil, nil} var list = LinkedList[T]{inner} for _, v := range elements { list.Append(v) } return list } func LinkedListFrom[T any](collection Collection[T]) LinkedList[T] { var list = LinkedListOf[T]() list...
linked_list.go
0.654453
0.513607
linked_list.go
starcoder
package asstags // Mov Set the position and Movement of the line (incremental) func Mov(args ...interface{}) string { lenARGS := len(args) if lenARGS > 6 || lenARGS%2 != 0 { panic("Wrong parameter count.") } if lenARGS == 2 { x, ok := args[0].(float64) if !ok { panic("1st parameter not type float64.") }...
asstags/extra.go
0.528533
0.451085
extra.go
starcoder
package decredmaterial import ( "image" "image/color" "gioui.org/f32" "gioui.org/layout" "gioui.org/op/clip" "gioui.org/op/paint" ) // ProgressBar indicates the progress of a process. Height defines the thickness of the progressbar, // BackgroundColor defines the color of the track, ProgressColor defines the c...
ui/decredmaterial/progressbar.go
0.674479
0.457016
progressbar.go
starcoder
package system import ( "fmt" ) // Renderer is responsible for rendering pixels and handling user input type Renderer interface { Start(vm *VirtualMachine) } // OpCode represents an instruction for the virtual machine type OpCode uint16 func (o OpCode) String() string { return fmt.Sprintf("%04X", uint16(o)) } /...
system/machine.go
0.776411
0.446977
machine.go
starcoder
package common import ( "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/types_go_proto" "sync" ) // EmbeddingTable struct type EmbeddingTable struct { Dim int64 Initializer string EmbeddingVectors map[int64]*Tensor Dtype types_go_proto.DataType lock sync....
elasticdl/pkg/common/embedding_table.go
0.571169
0.407098
embedding_table.go
starcoder
package executetest import ( "fmt" "github.com/apache/arrow/go/arrow/array" "github.com/influxdata/flux" "github.com/influxdata/flux/arrow" "github.com/influxdata/flux/execute" "github.com/influxdata/flux/semantic" "github.com/influxdata/flux/values" ) // Table is an implementation of execute.Table // It is d...
execute/executetest/table.go
0.689724
0.447823
table.go
starcoder
package run import ( "regexp" "strings" log "github.com/sirupsen/logrus" ) // mapNodesToLabelSpecs maps nodes to labelSpecs func mapNodesToLabelSpecs(specs []string, createdNodes []string) (map[string][]string, error) { // check node-specifier possibilitites possibleNodeSpecifiers := []string{"all", "workers", ...
cli/label.go
0.645232
0.415077
label.go
starcoder
package collector // see https://www.tinkerforge.com/en/doc/Software/Device_Identifier.html func DeviceName(id uint16) string { return deviceMap[id] } var deviceMap = map[uint16]string{ 11: "DC Brick", 13: "Master Brick", 14: "Servo Brick", 15: "Stepper Brick", 16: "IMU Brick", 17: "RED Brick", 1...
collector/devices.go
0.653569
0.64848
devices.go
starcoder
package libdconf import ( "strconv" "strings" ) // NewSchemaType will attempt to convert the provided key/val into a SchemaType func NewSchemaType(rawVal string) (sT *SchemaType, parseErr error) { sT = &SchemaType{Val: rawVal} // Ensure we always set the raw value if (rawVal == "false") || (rawVal == "true") { /...
schemaType.go
0.58261
0.489076
schemaType.go
starcoder
package metadata var ( // NullPath means no path NullPath = Path([]string{}) ) // Path is used to identify a particle of metadata. The path can be strings separated by / as in a URL. type Path []string // Clean scrubs the path to remove any empty string or . or .. and collapse the path into a concise form. // It'...
vendor/github.com/docker/infrakit/pkg/spi/metadata/path.go
0.625667
0.410461
path.go
starcoder
package raytracer import ( "container/heap" "fmt" "gonum.org/v1/gonum/spatial/r3" "math" "math/rand" ) type boundingVolumeHierarchyNode struct { nodeId int pMin r3.Vec pMax r3.Vec leaf bool shape *Shape children []*boundingVolumeHierarchyNode } type boundingVolumeHierarchy struct { root ...
raytracer/accelerationstructures.go
0.753739
0.415551
accelerationstructures.go
starcoder
package spritesystem import ( "image" "math" "sort" c "github.com/x-hgg-x/goecsengine/components" m "github.com/x-hgg-x/goecsengine/math" w "github.com/x-hgg-x/goecsengine/world" "github.com/hajimehoshi/ebiten/v2" ecs "github.com/x-hgg-x/goecs/v2" ) type spriteDepth struct { sprite *c.SpriteRender depth ...
systems/sprite/render.go
0.680135
0.427875
render.go
starcoder
package util import ( "fmt" ) // BitSet is the interface wraps method for BitSet data structure implementation. type BitSet interface { // Clear used for set the bit specified by the index to false. Clear(index int) // Set used for set the bit at the specified index to true. Set(index int) // Get returns the v...
util/bitset.go
0.74382
0.432842
bitset.go
starcoder
package adaptablepq import ( "fmt" ) type AdaptablePQ[K, V any] struct { heap []*Entry[K, V] comparator Comparator[K] } // New constructs and returns an empty adaptable pq based on a min-heap. func New[K, V any](comparator Comparator[K]) *AdaptablePQ[K, V] { return &AdaptablePQ[K, V]{heap: []*Entry[K, V]{}...
priorityqueue/adaptablepq/adaptable_heap_pq.go
0.835852
0.412294
adaptable_heap_pq.go
starcoder
package main import ( "fmt" "math" "github.com/leekchan/accounting" "golang.org/x/exp/rand" "gonum.org/v1/gonum/floats" "gonum.org/v1/gonum/mat" "gonum.org/v1/gonum/stat" ) // CashProcess contains the assumptions of the cash flow simulation type CashProcess struct { AnnualCashFlow float64 Drift ...
main.go
0.708616
0.619615
main.go
starcoder
package prng import ( "math/bits" "math" "unsafe" ) // A Xosh with a xoshiro256 prng implements a 64-bit generator with 256-bit state. type Xosh struct { s0, s1, s2, s3 uint64 } // NewXosh returns a new xoshiro256 generator seeded by the seed. func NewXosh(seed uint64) Xosh { x := Xosh{} x.Seed...
xosh.go
0.719384
0.427695
xosh.go
starcoder
package level /* level Copyright (c) 2019 beito This software is released under the MIT License. http://opensource.org/licenses/mit-license.php */ import ( "github.com/beito123/nbt" ) // Level is a simple level loader type Level struct { } // Format is a simple interface for level formats // This needs to be...
level.go
0.681197
0.400955
level.go
starcoder
package block const hashAir = 0 const hashAncientDebris = 1 const hashAndesite = 2 const hashBarrier = 3 const hashBasalt = 4 const hashBeacon = 5 const hashBedrock = 6 const hashBeetrootSeeds = 7 const hashBlueIce = 8 const hashBoneBlock = 9 const hashBricks = 10 const hashCake = 11 const hashCarpet = 12 const hashC...
server/block/hash.go
0.570331
0.50061
hash.go
starcoder
package targets import ( "fmt" "strconv" "strings" ) const MinDelegationHashPrefixBitLen = 1 const MaxDelegationHashPrefixBitLen = 32 // hexEncode formats x as a hex string. The hex string is left padded with // zeros to padWidth, if necessary. func hexEncode(x uint64, padWidth int) string { // Benchmarked to be...
internal/targets/hash_bins.go
0.833325
0.549399
hash_bins.go
starcoder
package common import "math" // Schedule is a means of transforming values based on timesteps. type Schedule interface { // Value for the given step. Value() float32 // Initial value Initial() float32 } // ConstantSchedule just returns a constant value. type ConstantSchedule struct { value float32 } // NewCon...
pkg/v1/common/schedule.go
0.875973
0.630372
schedule.go
starcoder
package byteio import ( "bytes" ) // Scanner defines an interface for scanning line-based data type Scanner interface { Scan() bool Bytes() []byte Error() error Position() int Length() int Seek(int) Filename() string } // ByteSliceScanner defines a structure for reading lines from a byte slice type ByteSlice...
byteio/byteslicescanner.go
0.657209
0.409457
byteslicescanner.go
starcoder
package draw2dAnimation import ( "image/color" "math" ) // An abstract figure type. Represents a base struct for all figures. type Figure struct { subClass Figurer id int depth int startPoint Point rotationDegrees float64 fillColor c...
draw2dAnimation/figure.go
0.911859
0.594581
figure.go
starcoder
package forGraphBLASGo func MxM[DC, DA, DB any](C *Matrix[DC], mask *Matrix[bool], accum BinaryOp[DC, DC, DC], op Semiring[DC, DA, DB], A *Matrix[DA], B *Matrix[DB], desc Descriptor) error { nrows, ncols, err := C.Size() if err != nil { return err } Anrows, Ancols, err := A.Size() if err != nil { return err ...
api_Mult.go
0.638497
0.454896
api_Mult.go
starcoder
package matrix import ( "strconv" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) // Combinations is a slice of combinations of Parameters from a Matrix. type Combinations []*Combination // Combination is a specific combination of Parameters from a Matrix. type Combination struct { // MatrixID is an i...
pkg/matrix/matrix_types.go
0.74008
0.400075
matrix_types.go
starcoder