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 model import "fmt" // Threshold defines how close two values can be and still be considered identical (e.g. for de-duplicating points). const Threshold = 0.0000001 // Circuit provides an abstract representation of a set of points (locations, vertices) for the TSP solver to interact with. // This allows it to...
model/circuit.go
0.849035
0.867261
circuit.go
starcoder
package main import ( "bufio" "fmt" "math" "os" "strconv" "strings" ) // Add all the values in an []int. func sum(numbers []int) (value int) { for _, number := range numbers { value += number } return value } // Finds the index of the needle in the haystack. func indexOf(needle int, haystack []int) int {...
aoc4.go
0.63273
0.44746
aoc4.go
starcoder
package cryptderivekey import ( "crypto/md5" "crypto/sha1" "fmt" "strings" ) func md5HashSlice(data []byte) []byte { md5Hash := md5.Sum(data) return md5Hash[:] } func sha1HashSlice(data []byte) []byte { sha1Hash := sha1.Sum(data) return sha1Hash[:] } func CryptDeriveKey(key []byte, hashType string) ([]byt...
cryptderivekey.go
0.627837
0.472988
cryptderivekey.go
starcoder
package lcs // Myers represents an implementation of Myer's longest common subsequence // and shortest edit script algorithm as as documented in: // An O(ND) Difference Algorithm and Its Variations, 1986. type Myers[T comparable] struct { a, b []T /* na, nb int slicer func(v interface{}, from, to int32) interface...
algo/lcs/myers.go
0.639961
0.533276
myers.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // ParseExpressionResponse type ParseExpressionResponse struct { // Stores additional data not described in the OpenAPI description found when deserializing. ...
models/parse_expression_response.go
0.67854
0.41947
parse_expression_response.go
starcoder
package quadtree const ( MinLongitude float32 = -180.0 MaxLongitude float32 = 180.0 MinLatitude float32 = -90.0 MaxLatitude float32 = 90.0 Capacity = 8 MaxDepth = 8 ) type ( Node struct { bounds *Rectangle depth int points []*Point parent *Node childs [4]*Node } ) // NewQuadTree creates QuadTre...
node.go
0.847763
0.546859
node.go
starcoder
package data import ( "fmt" "regexp" ) type Entry[T any] struct { Label string Val T } type LabelMap[T any] struct { labels []Entry[T] } func EmptyLabelMap[T any]() LabelMap[T] { return LabelMap[T]{labels: []Entry[T]{}} } func LabelMapFrom[T any](labels ...Entry[T]) LabelMap[T] { return LabelMap[T]{labels...
data/label_map.go
0.591015
0.5425
label_map.go
starcoder
package isc func ListAll[T any](list []T, f func(T) bool) bool { for _, e := range list { if !f(e) { return false } } return true } func ListAny[T any](list []T, f func(T) bool) bool { for _, e := range list { if f(e) { return true } } return false } func ListNone[T any](list []T, f func(T) bool)...
isc/match.go
0.506591
0.421433
match.go
starcoder
package main import ( "machine" "time" "tinygo.org/x/drivers/dht" ) var ( // RGB LED 1 (Temp) pins {R,G,B} pinsTemp = [3]machine.Pin{machine.GP0, machine.GP1, machine.GP2} // RGB LED 2 (Humidity) pins {R,G,B} pinsHumidity = [3]machine.Pin{machine.GP3, machine.GP4, machine.GP5} // DHT 11 pinDHT = machine.GP1...
elegoo_most_complete_starter_kit/12_temperature_humidity_sensor/main.go
0.583085
0.430447
main.go
starcoder
package main // Given a robot cleaner in a room modeled as a grid. // Each cell in the grid can be empty or blocked. // The robot cleaner with 4 given APIs can move forward, // turn left or turn right. Each turn it made is 90 degrees. // When it tries to move into a blocked cell, its bumper sensor // detects the obsta...
robotroomcleaner/main.go
0.811863
0.7242
main.go
starcoder
package main import ( "encoding/csv" "errors" "fmt" "io" "os" ) /* Problem taken from: https://www.fluentcpp.com/2017/10/23/results-expressive-cpp17-coding-challenge/ The task proposed in the challenge was to write a command line tool that takes in a CSV file, overwrites all the data of a given column by a g...
csv/main.go
0.549157
0.405979
main.go
starcoder
package optimizer import ( "strconv" "github.com/rhwilr/lemur/ast" "github.com/rhwilr/lemur/token" ) type Optimizer struct { program *ast.Program optimized *ast.Program } func New(program *ast.Program) *Optimizer { return &Optimizer{ program: program, optimized: &ast.Program{}, } } func (o *Optimizer) O...
optimizer/optimizer.go
0.720958
0.410166
optimizer.go
starcoder
package three // NewSphericalHarmonics3 : // Primary reference: // https://graphics.stanford.edu/papers/envmap/envmap.pdf // Secondary reference: // https://www.ppsloan.org/publications/StupidSH36.pdf // 3-band SH defined by 9 coefficients func NewSphericalHarmonics3() *SphericalHarmonics3 { coefficients := [9]V...
server/three/sphericalharmonics3.go
0.760828
0.697525
sphericalharmonics3.go
starcoder
package inject import ( "fmt" "reflect" "sort" ) // Graph describes a dependency graph that resolves nodes using well defined relationships. // These relationships are defined with node pointers and Providers. type Graph interface { Finalizable Add(Definition) Define(ptr interface{}, provider Provider) Definiti...
vendor/github.com/karlkfi/inject/graph.go
0.628863
0.422922
graph.go
starcoder
package graph import ( "github.com/DmitryBogomolov/algorithms/graph/internal/utils" ) // In a DFS tree edge "u-v" is bridge if "v" subtree has no back edges to ancestors of "u". func findCutEdgesCore( gr Graph, // original vertex distances distances []int, // updated vertex distances updatedDistances []int, cu...
graph/graph/cut_edges.go
0.680348
0.434881
cut_edges.go
starcoder
package ch5 var maxCompare = func(a, b int) bool { return a > b } var minCompare = func(a, b int) bool { return a < b } type heap struct { arr []int compare func(a1, a2 int) bool } func NewHeap(com func(a1, a2 int) bool) *heap { return &heap{ compare: com, } } func (h *heap) Clear() { h.arr = nil } func...
adt/ch5/part6.go
0.587825
0.400515
part6.go
starcoder
package iso20022 // Chain of parties involved in the settlement of a transaction, including receipts and deliveries, book transfers, treasury deals, or other activities, resulting in the movement of a security or amount of money from one account to another. type SettlementParties5 struct { // First party in the sett...
SettlementParties5.go
0.682468
0.512693
SettlementParties5.go
starcoder
package numbers import ( "log" "math" "math/rand" //DEBUG: "fmt" ) //Sample InverseNormal returns a simulated value from a normal distribution. func SampleInverseNormal(mu float64, sigma float64) float64 { return rand.NormFloat64()*sigma + mu } //InitializeFastRejectionSampler takes in the parameters of a rejec...
numbers/monteCarlo.go
0.772273
0.588032
monteCarlo.go
starcoder
package main import ( "bufio" "flag" "fmt" "os" "strconv" "strings" ) func main() { // Use Flags to run a part methodP := flag.String("method", "p1", "The method/part that should be run, valid are p1,p2 and test") flag.Parse() switch *methodP { case "p1": partOne() break case "p2": partTwo() brea...
2019/3-CrossedWires/main.go
0.600071
0.446434
main.go
starcoder
package leetcode import ( "github.com/halfrost/LeetCode-Go/structures" ) // Interval define type Interval = structures.Interval // SummaryRanges define type SummaryRanges struct { intervals []Interval } // Constructor352 define func Constructor352() SummaryRanges { return SummaryRanges{} } // AddNum define func...
leetcode/9990352.Data-Stream-as-Disjoint-Intervals/352. Data Stream as Disjoint Intervals.go
0.686265
0.419767
352. Data Stream as Disjoint Intervals.go
starcoder
package statsgod import ( "errors" "math" "sort" ) // ValueSlice provides a storage for float64 values. type ValueSlice []float64 // Get is a getter for internal values. func (values ValueSlice) Get(i int) float64 { return values[i] } // Len gets the length of the internal values. func (values ValueSlice) Len() ...
statsgod/statistics.go
0.789112
0.654122
statistics.go
starcoder
package math // Represents the specific planes/sides of the frustum. const ( NEAR byte = iota FAR byte = iota TOP byte = iota RIGHT byte = iota BOTTOM byte = iota LEFT byte = iota SIDE_TOTAL byte = iota ) // Represents the possible intersection attributes of a sphere or other...
math/frustum.go
0.839405
0.589775
frustum.go
starcoder
package main import ( "errors" "math" "time" ) const ( // Gravitational constant G float64 = 6.67430e-11 // Mass of Earth M_E float64 = 5.97219e+24 // Mean radius of Earth R_E float64 = 6.371008e+6 ) // Error returned if eccentric anomaly solution does not converge after 100 iterations. var errNoConverg...
src/calc.go
0.861101
0.640327
calc.go
starcoder
package validator import ( "context" "strconv" "github.com/mitchellh/mapstructure" "github.com/alibaba/ilogtail/pkg/doc" "github.com/alibaba/ilogtail/pkg/logger" "github.com/alibaba/ilogtail/pkg/protocol" ) const counterSysValidatorName = "sys_counter" type counterSystemValidator struct { ExpectReceivedMin...
test/engine/validator/sys_counter.go
0.567697
0.450118
sys_counter.go
starcoder
package flagger import ( "fmt" "math" //"strings" ) func BuildDecTree( leafCount, spareLevels uint32, traits *TraitMatrix, tm TraitMap, splitPercTolerance float32) DecTree { dt := GetEmptyDecTree(leafCount, spareLevels) tags := make([]string, len(tm)...
pkg/flagger/dtbuilder.go
0.629205
0.42471
dtbuilder.go
starcoder
package goop2 // Var represnts a variable in a optimization problem. The variable is // identified with an uint64. type Var struct { ID uint64 Lower float64 Upper float64 Vtype VarType } // NumVars returns the number of variables in the expression. For a variable, it // always returns one. func (v *Var) NumVar...
vars.go
0.851243
0.669387
vars.go
starcoder
package problem6 /** * Sum square difference * * https://projecteuler.net/problem=6 * The sum of the squares of the first ten natural numbers is, * 1^2 + 2^2 + ... + 10^2 = 385 * The square of the sum of the first ten natural numbers is, * (1 + 2 + ... + 10)^2 = 55^2 = 3025 * Hence the difference between t...
problem-6/answer.go
0.833257
0.74519
answer.go
starcoder
package query import ( "fmt" "strings" "github.com/pkg/errors" "github.com/spoke-d/thermionic/internal/db/database" ) // SelectStrings executes a statement which must yield rows with a single string // column. It returns the list of column values. func SelectStrings(tx database.Tx, query string, args ...interfac...
internal/db/query/slices.go
0.730578
0.466056
slices.go
starcoder
package main import ( "fmt" ) // Cell is a "one" in our sparse matrix, it's an element of a 2D doubly linked list type Cell struct { Left, Right, Up, Down *Cell Row, Column *Cell data interface{} } func (cell Cell) String() string { return fmt.Sprintf("%v", cell.data) } // Matrix de...
main.go
0.587707
0.676889
main.go
starcoder
package proto import ( "math" "github.com/go-faster/errors" ) // Compile-time assertions for ColLowCardinalityOf. var ( _ ColInput = ColLowCardinalityOf[string]{} _ ColResult = (*ColLowCardinalityOf[string])(nil) _ Column = (*ColLowCardinalityOf[string])(nil) ) // DecodeState implements StateDecoder, ensur...
proto/col_low_cardinality_of.go
0.515864
0.421909
col_low_cardinality_of.go
starcoder
package tempAll import ( "fmt" "math" "reflect" ) import ( "github.com/tflovorn/scExplorer/bzone" "github.com/tflovorn/scExplorer/serialize" vec "github.com/tflovorn/scExplorer/vector" ) // Container for variables relevant at all temperatures. type Environment struct { // Program parameters: PointsPerSide int...
tempAll/environment.go
0.585812
0.509215
environment.go
starcoder
package pigo import ( "bytes" "encoding/binary" "math" "math/rand" "sort" "unsafe" ) // Puploc contains all the information resulted from the pupil detection // needed for accessing from a global scope. type Puploc struct { Row int Col int Scale float32 Perturbs int } // PuplocCascade is a gen...
vendor/github.com/esimov/pigo/core/puploc.go
0.567218
0.504516
puploc.go
starcoder
package game import ( "image/color" "math" "github.com/hajimehoshi/ebiten/v2" "github.com/lucasb-eyer/go-colorful" ) // Bresenham algorithm for rasterizing a circle // Draw a circle that fills given image // Before drawing, ensure that the image has odd width and height for best // results: // if width%2 == 0 ...
game/circle.go
0.691081
0.47317
circle.go
starcoder
// card.go contains the Suit and Face types, as well as the Card struct. // Card contains basic card variables, including both logic and UI information. package card import ( "golang.org/x/mobile/exp/f32" "golang.org/x/mobile/exp/sprite" "hearts/img/coords" ) type Suit int const ( Club Suit = iota Diamond S...
go/src/hearts/logic/card/card.go
0.68342
0.457621
card.go
starcoder
package im2a import ( "errors" "fmt" "image" "image/color" "io" "math" "net/http" "os" "strings" _ "image/gif" _ "image/jpeg" _ "image/png" "github.com/disintegration/imaging" "golang.org/x/image/draw" ) // Pixel ... type Pixel struct { Color int Rune rune Transparent bool } // Asciif...
asciifier.go
0.617974
0.458834
asciifier.go
starcoder
package coordinate import ( "fmt" "math" "strings" ) func EuclideanDistance(c1, c2 Coordinate) float64 { d := c1.Subtract(c2) d = d.Multiply(d) distance := float64(0) for i := 0; i < d.Cardinality(); i++ { distance += d.Get(i) } return math.Sqrt(float64(distance)) } func ManhattanDistance(c1, c2 Coordinat...
coordinate/coordinate.go
0.854854
0.497253
coordinate.go
starcoder
package output import ( "github.com/Jeffail/benthos/v3/internal/docs" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/metrics" "github.com/Jeffail/benthos/v3/lib/output/writer" "github.com/Jeffail/benthos/v3/lib/types" ) //--------------------------------------------------------------...
lib/output/zmq4.go
0.621541
0.635618
zmq4.go
starcoder
package gohome import ( "github.com/PucklaMotzer09/mathgl/mgl32" ) func toLine3D(pos1 mgl32.Vec3, pos2 mgl32.Vec3) (line Line3D) { vecCol := ColorToVec4(DrawColor) line[0][0] = pos1[0] line[0][1] = pos1[1] line[0][2] = pos1[2] line[0][3] = vecCol[0] line[0][4] = vecCol[1] line[0][5] = vecCol[2] line[0][6] ...
src/gohome/drawutils.go
0.675122
0.446857
drawutils.go
starcoder
package svg import ( "github.com/goki/gi/gi" "github.com/goki/ki/ki" "github.com/goki/ki/kit" "github.com/goki/mat32" ) // Circle is a SVG circle type Circle struct { NodeBase Pos mat32.Vec2 `xml:"{cx,cy}" desc:"position of the center of the circle"` Radius float32 `xml:"r" desc:"radius of the circle"` ...
svg/circle.go
0.798187
0.467149
circle.go
starcoder
package interpolation import ( "github.com/edwardbrowncross/naturalneighbour/delaunay" "github.com/edwardbrowncross/naturalneighbour/voronoi" ) // Interpolator provides natural neighbour interpolation within a set of points. type Interpolator struct { t *delaunay.Triangulation areaCache map[*del...
interpolation/interpolator.go
0.738952
0.441854
interpolator.go
starcoder
package routerrpc import ( "time" "github.com/Actinium-project/acmutil" ) // RoutingConfig contains the configurable parameters that control routing. type RoutingConfig struct { // MinRouteProbability is the minimum required route success probability // to attempt the payment. MinRouteProbability float64 `long:...
.history/lnrpc/routerrpc/config_20200302203542.go
0.675336
0.468912
config_20200302203542.go
starcoder
package lib import ( "errors" "fmt" "strconv" "strings" "github.com/dunelang/dune" ) func init() { dune.RegisterLib(Assert, ` declare namespace assert { export function contains(search: string, value: string): void export function equal(a: any, b: any, errorMessage?: string): void export function ...
lib/assert.go
0.590779
0.594021
assert.go
starcoder
package plantest import ( "context" "testing" "github.com/google/go-cmp/cmp" "github.com/influxdata/flux/plan" "github.com/influxdata/flux/stdlib/universe" ) // SimpleRule is a simple rule whose pattern matches any plan node and // just stores the NodeIDs of nodes it has visited in SeenNodes. type SimpleRule st...
plan/plantest/rules.go
0.696268
0.418697
rules.go
starcoder
package schema import ( "github.com/elastic/beats/libbeat/common" ) // Schema describes how a map[string]interface{} object can be parsed and converted into // an event. The conversions can be described using an (optionally nested) common.MapStr // that contains Conv objects. type Schema map[string]Mapper // Mapper...
vendor/github.com/elastic/beats/libbeat/common/schema/schema.go
0.85318
0.633906
schema.go
starcoder
package schema import ( errors_ "errors" "fmt" "strings" "github.com/semi-technologies/weaviate/entities/models" ) type schemaProperties struct { Schema *models.Schema } // WeaviateSchema represents the used schema's type WeaviateSchema struct { ActionSchema schemaProperties ThingSchema schemaProperties } ...
entities/schema/backward_compat.go
0.673943
0.416322
backward_compat.go
starcoder
package tsm1 import ( "github.com/influxdata/influxdb/v2/tsdb" ) // ReadFloatBlockAt returns the float values corresponding to the given index entry. func (t *TSMReader) ReadFloatBlockAt(entry *IndexEntry, vals *[]FloatValue) ([]FloatValue, error) { t.mu.RLock() v, err := t.accessor.readFloatBlock(entry, vals) t...
tsdb/engine/tsm1/reader.gen.go
0.747339
0.477676
reader.gen.go
starcoder
package condition import ( "fmt" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/metrics" "github.com/Jeffail/benthos/v3/lib/types" jmespath "github.com/jmespath/go-jmespath" ) //------------------------------------------------------------------------------ func init() { Constructor...
lib/condition/jmespath.go
0.66454
0.788787
jmespath.go
starcoder
package channels import ( logging "github.com/ipfs/go-log/v2" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-statemachine/fsm" datatransfer "github.com/filecoin-project/go-data-transfer" "github.com/filecoin-project/go-data-transfer/channels/internal" ) var log = logging.Logger("data-t...
channels/channels_fsm.go
0.546496
0.412471
channels_fsm.go
starcoder
package parser import ( "fmt" "regexp" "strconv" ) // Result is a struct which holds the result from parsing a string type Result struct { Match string Rest string } // NewResult creates a new Result struct to hold the result from a Parser func NewResult(m, r string) *Result { return &Result{ Match: m, Re...
parser/parser.go
0.691497
0.400661
parser.go
starcoder
package angular import ( "time" ) // Units for Velocity values. Always multiply with a unit when setting the initial value like you would for // time.Time. This prevents you from having to worry about the internal storage format. const ( MilliradianPerSecond Velocity = Velocity(Milliradian) / Velocity(time.Second)...
angular/velocity_generated.go
0.930062
0.636254
velocity_generated.go
starcoder
package statemachine import ( "strconv" ) /** The StateMachine allows to build a LCG (Life Cycle Graph) to represent the multiple states an aplication will go through. At each state, an action can be executed through a Hook Caller. **/ type LCGState int func (s LCGState) String() string { return strconv.Ito...
tools/statemachine/sm.go
0.647575
0.544438
sm.go
starcoder
package cbr /*---FILE DESCRIPTION--- The parameter file contains structs with parameters that changes how the CBR AI interprets or works with the gamestate and its cases. This file alo contains the aiData struct which is where general CBRAI data is stored. ---FILE DESCRIPTION---*/ var cbrParameters = CBRParameters{ ...
src/cbr/parameters.go
0.630344
0.700088
parameters.go
starcoder
package main import ( "math" "time" ) // CompendiumFactory generates data structures for any page of the compendium. type CompendiumFactory struct { NbTop uint // Number of most downvoted comments Timezone *time.Location // Timezone of the dates } // NewCompendiumFactory returns a new CompendiumFact...
compendium.go
0.692018
0.454593
compendium.go
starcoder
package main import ( "bufio" "fmt" "log" "math" "os" "sort" "strings" ) const Reset = "\033[0m" const Red = "\033[31m" const Green = "\033[32m" const Yellow = "\033[33m" func main() { patterns, outputs, err := Loader("input.txt") if err != nil { log.Fatal(err) } _ = patterns _ = outputs fmt.Printf(...
day8/day8.go
0.522446
0.420778
day8.go
starcoder
package sql import ( "fmt" "strings" ) type Data interface { Append(other Data) Data AppendWithSpace(other Data) Data SurroundAppend(l, r string, other Data) Data String() string Values() []interface{} } // Empty can be used before a for loop to initialize your Data func Empty() Data { return empty } var em...
sql/data.go
0.609873
0.599866
data.go
starcoder
package tiff import ( "encoding/json" "fmt" ) /* Entry structure For IFD/Entry: Each 12-byte IFD entry has the following format: Bytes 0-1: The Tag that identifies the entry. Bytes 2-3: The entry Type. Bytes 4-7: The number of values, Count of the indicated Type. Bytes 8-11: The Value Offset, the file of...
entry.go
0.578686
0.460592
entry.go
starcoder
package pipe import ( "fmt" "time" "github.com/dudk/phono" ) type ( // measurable identifies an entity with measurable metrics. // Each measurable can have multiple counters. // If custom metrics will be needed, it can be exposed in the future. measurable interface { Reset() Measure() Measure FinishMeas...
pipe/metric.go
0.794664
0.412885
metric.go
starcoder
package cmd import ( "github.com/pkg/errors" "github.com/spf13/cobra" ) var ( // queryCreateCmd represents the lql create command queryCreateCmd = &cobra.Command{ Use: "create", Short: "Create a query", Long: ` There are multiple ways you can create a query: * Typing the query into your default editor...
cli/cmd/lql_create.go
0.827654
0.40987
lql_create.go
starcoder
package keras import ( "fmt" "time" ) //Model architecure to implement neural network. type Model struct { ConvLayers []Layer Name string Optimizer Optimizer LossFunc func([]float64, []float64) float64 LossValues []float64 Duration time.Duration Settings []Metrics TrainDataX []f...
keras/keras.go
0.809728
0.408808
keras.go
starcoder
package domain import ( "encoding/json" "fmt" "net/url" "strconv" "strings" "time" ) // ShortDate represents a date without a time, i.e. the time is always zero. type ShortDate struct { time.Time } // NewShortDate creates a ShortDate from a given time func NewShortDate(date time.Time) ShortDate { return Date...
domain/time.go
0.848062
0.421254
time.go
starcoder
package deepcopy import () func DeepCopyJsonData(dataFrom interface{}) interface{} { switch dataFrom.(type) { case map[string]interface{}: dataTo := make(map[string]interface{}) DeepOverwriteJsonMap(dataFrom.(map[string]interface{}), dataTo) return dataTo case []interface{}: fromJsonSlice := dataFrom.([]i...
deepcopy/json.go
0.52342
0.40157
json.go
starcoder
package impl import ( "errors" "github.com/xichen2020/eventdb/document/field" "github.com/xichen2020/eventdb/filter" "github.com/xichen2020/eventdb/values" "github.com/xichen2020/eventdb/values/iterator" iterimpl "github.com/xichen2020/eventdb/values/iterator/impl" "github.com/xichen2020/eventdb/x/pool" ) var...
values/impl/array_based_double_values.go
0.561696
0.412648
array_based_double_values.go
starcoder
package flatmap import ( "fmt" "reflect" ) // Flatten takes an object and returns a flat map of the object. The keys of the // map is the path of the field names until a primitive field is reached and the // value is a string representation of the terminal field. func Flatten(obj interface{}, filter []string, primi...
vendor/github.com/hashicorp/nomad/helper/flatmap/flatmap.go
0.670177
0.475179
flatmap.go
starcoder
package wire import ( "fmt" "io" ) // defaultInvListAlloc is the default size used for the backing array for an inventory list. The array will dynamically grow as needed, but this figure is intended to provide enough space for the max number of inventory vectors in a *typical* inventory message without needing to ...
pkg/chain/wire/msginv.go
0.672977
0.451931
msginv.go
starcoder
package vert import ( "fmt" "reflect" "syscall/js" ) var zero = reflect.ValueOf(nil) // AssignTo assigns a JS value to a Go pointer. // Returns an error on invalid assignments. func (v Value) AssignTo(i interface{}) error { rv := reflect.ValueOf(i) if k := rv.Kind(); k != reflect.Ptr || rv.IsNil() { return &...
assign.go
0.6488
0.427456
assign.go
starcoder
package base import ( "github.com/scylladb/go-set/iset" "math/rand" ) // RandomGenerator is the random generator for gorse. type RandomGenerator struct { *rand.Rand } // NewRandomGenerator creates a RandomGenerator. func NewRandomGenerator(seed int64) RandomGenerator { return RandomGenerator{rand.New(rand.NewSo...
base/random.go
0.717408
0.480479
random.go
starcoder
package eval import ( "bytes" "fmt" "io" "reflect" ) type ( RDetect map[interface{}]bool Value interface { fmt.Stringer Equality ToString(bld io.Writer, format FormatContext, g RDetect) PType() Type } // Comparator returns true when a is less than b. Comparator func(a, b Value) bool Object interf...
eval/values.go
0.74512
0.412767
values.go
starcoder
package decimal import ( "math/big" ) // BigDecimal real value is // d = (value + numerator / denominator) * 10 ^ (-scale) // We have: // denominator = 0 as initial => numerator / 0 = 0 // it means numerator / denominator only valid if denominator != 0 // Simple type of BigDecimal: // - The numerator shouble be l...
decimal.go
0.688678
0.437643
decimal.go
starcoder
package g2d import ( "fmt" "math" "github.com/angelsolaorbaiceta/inkgeom/nums" ) var ( IVersor = MakeVersor(1, 0) JVersor = MakeVersor(0, 1) ) /* Vector is an entity with projections both in the X and Y axis. Used to represent both points and vectors in two dimensions. */ type Vector struct { x, y float64 } ...
g2d/vector.go
0.910394
0.675353
vector.go
starcoder
package s2 import ( "github.com/golang/geo/r2" ) // Cell is an S2 region object that represents a cell. Unlike CellIDs, // it supports efficient containment and intersection tests. However, it is // also a more expensive representation. type Cell struct { face int8 level int8 orientation int8 id ...
Godeps/_workspace/src/github.com/golang/geo/s2/cell.go
0.801004
0.525856
cell.go
starcoder
package costmodel import ( "fmt" "math" "strconv" costAnalyzerCloud "github.com/kubecost/cost-model/cloud" ) // NetworkUsageVNetworkUsageDataector contains the network usage values for egress network traffic type NetworkUsageData struct { PodName string Namespace string NetworkZoneEg...
costmodel/networkcosts.go
0.658088
0.566498
networkcosts.go
starcoder
package levels import ( "image" "image/color" "github.com/Nyarum/img/channel" "github.com/Nyarum/img/utils" ) // linearScale scales the value given so that the range min to max is scaled to // 0 to 1. func linearScale(value, min, max float64) float64 { return (value - min) * (1 / (max - min)) } // http://en.wi...
levels/levels.go
0.868004
0.401834
levels.go
starcoder
package gen import ( "fmt" "math/big" "reflect" "sort" "strings" "unicode" "github.com/gocql/gocql" "gopkg.in/inf.v0" ) func (g *Generator) getDecoderName(t reflect.Type) string { return g.functionName("decode", t) } // decoderGen is a function that generates unmarshaller code. // It unmarshals t from byte...
gen/decoder.go
0.500732
0.507812
decoder.go
starcoder
package tensor import "github.com/pkg/errors" func (e StdEng) Argmax(t Tensor, axis int) (retVal Tensor, err error) { switch tt := t.(type) { case DenseTensor: return e.argmaxDenseTensor(tt, axis) default: return nil, errors.Errorf(typeNYI, "StdEng.Argmax", t) } } func (e StdEng) argmaxDenseTensor(t DenseTe...
vendor/gorgonia.org/tensor/defaultengine_argmethods.go
0.603815
0.459986
defaultengine_argmethods.go
starcoder
package pqt const ( // FunctionBehaviourVolatile indicates that the function value can change even within a single table scan, // so no optimizations can be made. // Relatively few database functions are volatile in this sense; some examples are random(), currval(), timeofday(). // But note that any function that ...
function.go
0.577972
0.575051
function.go
starcoder
package cios import ( "fmt" "math" "reflect" "sort" ) type NullableMultipleSeriesImageStream []NullableMultipleSeriesImage func NullableMultipleSeriesImageStreamOf(arg ...NullableMultipleSeriesImage) NullableMultipleSeriesImageStream { return arg } func NullableMultipleSeriesImageStreamFrom(arg []NullableMultip...
cios/stream_nullablemultipleseriesimage.go
0.564579
0.476458
stream_nullablemultipleseriesimage.go
starcoder
package gafit import ( "math" "sort" "gonum.org/v1/gonum/mat" ) // OrthogonalMatchingPursuit optimizes the cost function by selecting the model that leads to the // largest decrease in the cost function func OrthogonalMatchingPursuit(dataset Dataset, cost CostFunction, maxFeatures int) OptimizeResult { X := data...
gafit/greedy.go
0.691706
0.421135
greedy.go
starcoder
package chart const ( // DefaultChartHeight is the default chart height. DefaultChartHeight = 400 // DefaultChartWidth is the default chart width. DefaultChartWidth = 1024 // DefaultStrokeWidth is the default chart stroke width. DefaultStrokeWidth = 0.0 // DefaultDotWidth is the default chart dot width. Defaul...
defaults.go
0.604866
0.406096
defaults.go
starcoder
package forGraphBLASGo func ScalarApply[Dt, Df any](t *Scalar[Dt], accum BinaryOp[Dt, Dt, Dt], op UnaryOp[Dt, Df], f *Scalar[Df], _ Descriptor) error { if t == nil || t.ref == nil || f == nil || f.ref == nil { return UninitializedObject } t.ref = newScalarReference[Dt](newComputedScalar[Dt](t.ref, accum, newScala...
api_Apply.go
0.690455
0.764188
api_Apply.go
starcoder
package ui import ( "math" "github.com/thinkofdeath/steven/render" ) // Text is a drawable that draws a string. type Text struct { baseElement x, y float64 r, g, b, a int value string Width float64 scaleX, scaleY float64 rotation float64 } // NewText creates a new Tex...
ui/text.go
0.740456
0.447581
text.go
starcoder
package intersection_of_two_arrays import "sort" /* 给定两个数组,编写一个函数来计算它们的交集。 示例 1: 输入: nums1 = [1,2,2,1], nums2 = [2,2] 输出: [2] 示例 2: 输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] 输出: [9,4] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/intersection-of-two-arrays 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 */ /* 1。借助一个set解决...
solutions/intersection-of-two-arrays/d.go
0.518546
0.583856
d.go
starcoder
package kneedle import ( "math" "github.com/pkg/errors" ) //gaussian calculates the gaussian of an input //where height is the height of the center of the curve (sometimes called 'a'), //center is the center of the curve (sometimes called 'b'), //and width is the standard deviation, i.e ~68% of the data will be con...
maths.go
0.609989
0.681275
maths.go
starcoder
// Package index provides constants and functions for reading // a spreadsheet that lists other spreadsheets: each one a budget // covering a particular date range. The app uses these functions // to look up the budget spreadsheets and determine which one(s) // a transaction should be added to. package index import (...
index/index.go
0.745584
0.699126
index.go
starcoder
package types import "github.com/attic-labs/noms/go/hash" type SkipValueCallback func(v Value) bool // WalkValues loads prolly trees progressively by walking down the tree. We don't wants to invoke // the value callback on internal sub-trees (which are valid values) because they are not logical // values in the gra...
go/types/walk.go
0.563378
0.412234
walk.go
starcoder
package util import ( "context" "fmt" "time" ) // Unit is a type alias representing the standard functional programming Unit type type Unit = struct{} // ErrorOf is a type that wraps an arbitrary value to turn the value into an error instance type ErrorOf struct { Value interface{} } // Error implements the err...
util/util.go
0.768863
0.420243
util.go
starcoder
package canvas // Polyline defines a list of points in 2D space that form a polyline. If the last coordinate equals the first coordinate, we assume the polyline to close itself. type Polyline struct { coords []Point } // PolylineFromPath returns a polyline from the given path by approximating it by linear line segme...
polyline.go
0.84572
0.833528
polyline.go
starcoder
package pdfjet import ( "fmt" "io" "strconv" ) // insertStringAt inserts the string s1 into a1 at the specified index func insertStringAt(a1 []string, s1 string, index int) []string { a2 := make([]string, 0) a2 = append(a2, a1[:index]...) a2 = append(a2, s1) a2 = append(a2, a1[index:]...) return a2 } // inse...
src/pdfjet/helperfunctions.go
0.60778
0.497559
helperfunctions.go
starcoder
package dfl import ( "fmt" "reflect" "github.com/pkg/errors" ) // CompareNumbers compares parameter a and parameter b. // The parameters may be of type uint8, int, int64, or float64. // If a > b, then returns 1. If a < b, then returns -1. If a == b, then return 0. func CompareNumbers(a interface{}, b interface...
pkg/dfl/CompareNumbers.go
0.539954
0.415314
CompareNumbers.go
starcoder
package common import ( "crypto/rand" "crypto/sha256" "encoding/hex" "fmt" "io" "math/big" "github.com/33cn/chain33/common/crypto/sha3" "golang.org/x/crypto/ripemd160" ) const ( hashLength = 32 ) //Hash hash type Hash [hashLength]byte //BytesToHash []byte -> hash func BytesToHash(b []byte) Hash { var h ...
vendor/github.com/33cn/chain33/common/hash.go
0.634543
0.431464
hash.go
starcoder
package syntaxtree import ( "bytes" "strings" "github.com/manishmeganathan/tunalang/lexer" ) // A structure that represents an Identifier literal type Identifier struct { // Represents the lexological token 'IDENT' Token lexer.Token // Represents the identifier name Value string } // A method of Identifier ...
syntaxtree/literals.go
0.832373
0.428054
literals.go
starcoder
package openapi import ( "time" "encoding/json" ) // NullableClass struct for NullableClass type NullableClass struct { IntegerProp *int32 `json:"integer_prop,omitempty"` isExplicitNullIntegerProp bool `json:"-"` NumberProp *float32 `json:"number_prop,omitempty"` isExplicitNullNumberProp bool `json:"-"` BooleanP...
samples/openapi3/client/petstore/go-experimental/go-petstore/model_nullable_class.go
0.776962
0.428473
model_nullable_class.go
starcoder
package helper import ( "encoding/json" "fmt" "math" "math/rand" "strings" "time" ) func init() { rand.Seed(time.Now().UnixNano()) } // RandomGenerator is delegated to generate random without call seed every time type RandomGenerator struct { randomizer *rand.Rand } // InitRandomizer initialize a new Random...
helper/helper.go
0.706494
0.547585
helper.go
starcoder
package lib import ( "gopkg.in/dedis/crypto.v0/abstract" "gopkg.in/dedis/crypto.v0/cipher" "gopkg.in/dedis/onet.v1/network" "strconv" "strings" "sync" ) // Objects //______________________________________________________________________________________________________________________ // GroupingKey is an ID co...
lib/structs.go
0.518546
0.413832
structs.go
starcoder
package v1alpha1 // AuthorizationRuleListerExpansion allows custom methods to be added to // AuthorizationRuleLister. type AuthorizationRuleListerExpansion interface{} // AuthorizationRuleNamespaceListerExpansion allows custom methods to be added to // AuthorizationRuleNamespaceLister. type AuthorizationRuleNamespac...
client/listers/eventhub/v1alpha1/expansion_generated.go
0.596786
0.439807
expansion_generated.go
starcoder
package iso20022 // Specifies the payment terms of the underlying transaction. type PaymentTerms6 struct { // Due date specified for the payment terms. DueDate *ISODate `xml:"DueDt,omitempty"` // Payment period specified for these payment terms. PaymentPeriod *PaymentPeriod1 `xml:"PmtPrd,omitempty"` // Textual...
PaymentTerms6.go
0.854111
0.436622
PaymentTerms6.go
starcoder
package enigma import ( "fmt" "strings" ) // ReflectorConfig contains full configuration of a reflector type ReflectorConfig struct { Model ReflectorModel WheelPosition byte Wiring string } func (r ReflectorConfig) isEmpty() bool { return r.Model == "" && r.WheelPosition == 0 && r.Wiring == "" }...
reflector.go
0.649245
0.458046
reflector.go
starcoder
package main import ( "bufio" "fmt" "log" "os" "strings" ) type pos struct { x, y int } func (p pos) add(o pos) pos { return pos{p.x + o.x, p.y + o.y} } type maze struct { grid map[pos]string w, h int } func (m *maze) print() { for y := 0; y < m.h; y++ { for x := 0; x <= m.w; x++ { fmt.Printf("%s", ...
day18/main.go
0.538498
0.435541
main.go
starcoder
package types // Unique Layer identifier. type LayerTree_LayerId string // Unique snapshot identifier. type LayerTree_SnapshotId string // Rectangle where scrolling happens on the main thread. type LayerTree_ScrollRect struct { // Rectangle itself. Rect DOM_Rect `json:"rect"` // Reason for rectangle to force scro...
types/layertree.go
0.795896
0.409929
layertree.go
starcoder
package stats import ( "context" "sort" "strconv" "strings" "sync" ) // TrackerMock can collect stats for tests with labels ignored. type TrackerMock struct { mu sync.Mutex values map[string]float64 labeledValues map[string]float64 } var escaper = strings.NewReplacer("\n", `\\n`, `\`, `\\`,...
mock.go
0.678966
0.42483
mock.go
starcoder
package quickhull import ( "log" "math" "github.com/golang/geo/r3" ) const ( defaultEpsilon = 0.0000001 ) // QuickHull can be used to calculate the convex hull of a point cloud. // See: https://en.wikipedia.org/wiki/Quickhull type QuickHull struct { epsilon float64 epsilonSquared float64 planar ...
quickhull.go
0.724481
0.701866
quickhull.go
starcoder