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 hashsets // New factory that creates a hash set func New(values ...interface{}) *HashSet { set := HashSet{data: make(map[interface{}]struct{}, len(values))} set.Add(values...) return &set } // HashSet datastructure type HashSet struct { data map[interface{}]struct{} } // Add adds values to the set func (...
datastructures/sets/hashsets/hash_set.go
0.815783
0.471041
hash_set.go
starcoder
// Package eval provides an expression evaluator. package eval import ( "fmt" "math" ) // Env is the list of variables (name/value) type Env map[Var]float64 // Eval returns the value of the variable func (v Var) Eval(env Env) float64 { return env[v] } // Eval returns the value of the literal func (l literal) Ev...
Chapter-7/Exercice-14/eval/eval.go
0.748812
0.47317
eval.go
starcoder
package worker import ( "fmt" "github.com/splitio/go-split-commons/v3/dtos" "github.com/splitio/split-synchronizer/v4/splitio/common" ) func toImpressionsDTO(impressionsMap map[string][]dtos.ImpressionDTO) ([]dtos.ImpressionsDTO, error) { if impressionsMap == nil { return nil, fmt.Errorf("Impressions map canno...
splitio/producer/worker/util.go
0.625438
0.488893
util.go
starcoder
package block // FlowerType represents a type of flower. type FlowerType struct { flower } type flower uint8 // Dandelion is a dandelion flower. func Dandelion() FlowerType { return FlowerType{0} } // Poppy is a poppy flower. func Poppy() FlowerType { return FlowerType{1} } // BlueOrchid is a blue orchid flower...
server/block/flower_type.go
0.794385
0.532851
flower_type.go
starcoder
package dynamicanalysis import "fmt" // PassContext represents information about how an object was passed to a function type PassContext struct { Function string // canonical name of function passed to Keyword string // name of the argument, if it was passed with a keyword, or "*" or "**" Position int // Posit...
kite-go/dynamicanalysis/usage.go
0.736874
0.415492
usage.go
starcoder
package image import ( "context" "fmt" "github.com/google/gapid/core/data/protoutil" "github.com/google/gapid/gapis/database" ) // Converter is used to convert the the image formed from the parameters data, // width and height into another format. If the conversion succeeds then the // converted image data is r...
core/image/convert.go
0.656768
0.463444
convert.go
starcoder
package main import ( "bufio" "flag" "fmt" "log" "math" "os" "strconv" "strings" ) type point struct { id, x, y int } type grid map[point]int var input = flag.String("input", "input", "Puzzle input file") var maxTotalDistance = flag.Int("distance", 10000, "Max total distance threshold") func main() { fla...
2018/06/main.go
0.669096
0.433802
main.go
starcoder
package main import "fmt" // Heap is a heap. type Heap struct { values []int size int maxsize int } // newHeap creates a heap. func newHeap(maxsize int) *Heap { return &Heap{ values: []int{}, size: 0, maxsize: maxsize, } } // leaf checks whether index is a leaf. func (h *Heap) leaf(index int) boo...
data_structures/heap/heap.go
0.658308
0.436742
heap.go
starcoder
package specs import ( "testing" "github.com/go-rel/rel" "github.com/go-rel/rel/where" "github.com/stretchr/testify/assert" ) func createPreloadUser(repo rel.Repository) User { var ( user = User{ Name: "preload", Gender: "male", Age: 25, Addresses: []Address{ {Name: "primary"}, {Name:...
specs/preload.go
0.525369
0.475666
preload.go
starcoder
package csvdec import ( "reflect" "strconv" ) // Populates any slice value. func fillSlice(value reflect.Value, fields []string) error { kind := value.Type().Elem().Kind() switch kind { case reflect.String: return fillStringSlice(value, fields) case reflect.Int: return fillIntSlice(value, fields) case ref...
csvdec/fillslice.go
0.870157
0.60288
fillslice.go
starcoder
package constants // NewConstantValue010 get new instance of ConstantValue010 func NewConstantValue010() *ConstantVals { return &ConstantVals{ int64values: map[ConstantName]int64{ EmissionCurve: 6, BlocksPerYear: 5256000, IncentiveCurve: 100, //...
constants/constants_v1.go
0.658527
0.426919
constants_v1.go
starcoder
package packed // Efficient sequential read/write of packed integers. type BulkOperationPacked23 struct { *BulkOperationPacked } func newBulkOperationPacked23() BulkOperation { return &BulkOperationPacked23{newBulkOperationPacked(23)} } func (op *BulkOperationPacked23) decodeLongToInt(blocks []int64, values []int...
core/util/packed/bulkOperation23.go
0.592313
0.747155
bulkOperation23.go
starcoder
package vector import ( "gonet/base/containers" "log" ) func assert(x bool, y string) { if bool(x) == false { log.Printf("\nFatal :{%s}", y) } } const ( VectorBlockSize = 16 ) type ( Vector struct { elementCount int arraySize int array []interface{} } IVector interface { containers.Cont...
base/vector/vector.go
0.603348
0.517022
vector.go
starcoder
package vec2 import ( "fmt" "image" "github.com/andreas-jonsson/fix16" ) func Rectangle(r image.Rectangle) T { if r.Min != image.ZP { panic("rectangle min is not zero") } return Point(r.Max) } func Point(pt image.Point) T { return Int(pt.X, pt.Y) } func Int(x, y int) T { return T{fix16.Int(x), fix16.Int(...
vec2/vec2.go
0.833325
0.498901
vec2.go
starcoder
package pemutil import ( "crypto/x509" "encoding/pem" "errors" "fmt" "io/ioutil" ) var ( ErrNoBlocks = errors.New("no PEM blocks") ) type Block struct { Type string Headers map[string]string Object interface{} } func LoadBlocks(path string) ([]Block, error) { return loadBlocks(path, 0, "") } func Par...
pkg/common/pemutil/block.go
0.538255
0.442998
block.go
starcoder
package basic // KeysNumberToNumberTest is template func KeysNumberToNumberTest() string { return ` func TestKeys<FINPUT_TYPE1><FINPUT_TYPE2>(t *testing.T) { m := map[<INPUT_TYPE1>]<INPUT_TYPE2>{1: 1} expectedList := []<INPUT_TYPE1>{1} actualList := Keys<FINPUT_TYPE1><FINPUT_TYPE2>(m) if !reflect.DeepEqual(expect...
internal/template/basic/keystest.go
0.669637
0.485905
keystest.go
starcoder
package main import ( "fmt" "os" "strings" "text/tabwriter" "github.com/bradfitz/slice" ) // Character is the type representing a role playing character type Character struct { Name string Backgrounds map[string]Background Aptitudes map[string]Aptitude Characteristics map[string]Charact...
src/adeptus/character.go
0.667581
0.418994
character.go
starcoder
package sorting import "math" /* A non-empty zero-indexed array A consisting of N integers is given. The product of triplet (P, Q, R) equates to A[P] * A[Q] * A[R] (0 ≤ P < Q < R < N). For example, array A such that: A[0] = -3 A[1] = 1 A[2] = 2 A[3] = -2 A[4] = 5 A[5] = 6 contains the following example ...
sorting/MaxProductOfThree.go
0.845465
0.827445
MaxProductOfThree.go
starcoder
package exp import ( "io" "strconv" "strings" "xelf.org/xelf/ast" "xelf.org/xelf/cor" "xelf.org/xelf/knd" "xelf.org/xelf/lit" "xelf.org/xelf/typ" ) // Parse parses str and returns an expression or an error. func Parse(reg *lit.Reg, str string) (Exp, error) { return Read(reg, strings.NewReader(str), "") } //...
exp/parse.go
0.556882
0.464112
parse.go
starcoder
package squareRoot import ( "github.com/acra5y/go-dilation/internal/eye" "gonum.org/v1/gonum/mat" "math" ) /* The algorithm to calculate the square root of a positive definite matrix is taken from "A New Algorithm for Computing the Square Rootof a Matrix" (https://scholarworks.rit.edu/cgi/view...
internal/squareRoot/squareRoot.go
0.829008
0.727104
squareRoot.go
starcoder
package roots import ( "math" "github.com/applied-math-coding/heuristic/common" "github.com/applied-math-coding/heuristic/meta_opt_pso" "github.com/applied-math-coding/heuristic/newton" "github.com/applied-math-coding/heuristic/pso" "gonum.org/v1/gonum/mat" ) type Params = struct { Root_Recognition float64...
roots/roots.go
0.760295
0.528898
roots.go
starcoder
package stack import ( "sync" ) // Stacker is an interface describing the behaviour of a FILO (first in, last out) stack. It allows concurrency-safe // stacks to be used in the same places as regular stacks, if performance or concurrency safety are specific // requirements. type Stacker interface { Len() int ...
stack.go
0.779112
0.431045
stack.go
starcoder
package cios import ( "encoding/json" ) // SinglePoint struct for SinglePoint type SinglePoint struct { Point Point `json:"point"` } // NewSinglePoint instantiates a new SinglePoint object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by A...
cios/model_single_point.go
0.835249
0.439627
model_single_point.go
starcoder
package merkle import ( "bytes" "errors" "fmt" "sort" ) const MaxUint = ^uint(0) // ValidatePartialTree uses leafIndices, leaves and proof to calculate the merkle root of the tree and then compares it // to expectedRoot. func ValidatePartialTree(leafIndices []uint64, leaves, proof [][]byte, expectedRoot []byte, ...
validation.go
0.710427
0.447038
validation.go
starcoder
package waf import ( "encoding/json" ) // WafDnsRecord A DNS record A dns record describes an individual piece of DNS functionality in a DNS zone. type WafDnsRecord struct { // The name of the network node to which a zone resource record pertains Use the value \"@\" to denote current root domain name. Name *stri...
pkg/waf/model_waf_dns_record.go
0.832679
0.481332
model_waf_dns_record.go
starcoder
package main import ( "fmt" "math/big" "math/rand" "time" ) // Pollard's Rho iterator type type PollardRhoIterator struct { point1 *Point point2 *Point X1 *Point X2 *Point a1 int64 b1 int64 a2 int64 b2 int64 X *Point a int64 b int64 } func NewPollardRhoIterator(P *Point, Q *Point) (*PollardRhoIt...
logs/pollardsrho.go
0.58059
0.468304
pollardsrho.go
starcoder
package templates import "strings" var ( // ReadMe README.md template. ReadMe = `# {{.project_name}} [![Actions Status](https://{{.module_name}}/workflows/Go/badge.svg)](https://{{.module_name}}/actions) [![GoDoc](https://godoc.org/{{.module_name}}?status.svg)](https://pkg.go.dev/mod/{{.module_name}}) [![GoReportC...
templates/readme.go
0.649023
0.6463
readme.go
starcoder
package hlt import ( "math" "sort" "strconv" "strings" ) // Map describes the current state of the game type Map struct { MyID, Width, Height int Planets []Planet Players []Player Entities []Entity } // Player has an ID for establishing ownership, and a number of ships type...
airesources/Go/src/hlt/gamemap.go
0.767951
0.432183
gamemap.go
starcoder
package metrics import ( "regexp" "time" "github.com/Masterminds/semver" ) // AllJobs represents a regex that will collect results from all jobs. var AllJobs = regexp.MustCompile(".*") // Phase is a phase of an osde2e run. type Phase string // Result is the result of a JUnit test. type Result string const ( /...
pkg/metrics/objects.go
0.808219
0.415373
objects.go
starcoder
package plot import ( "io" "math/rand" "gonum.org/v1/plot" "gonum.org/v1/plot/plotutil" "gonum.org/v1/plot/vg" ) //Verses does a verses line plot with the data passed. //title,xaxis,yaxis are the labels for the plot image //h,w are the size of the image //returns a WriteTo. I did this because I thought the use...
ui/plot/plot_vsline.go
0.684053
0.633453
plot_vsline.go
starcoder
package main import ( "image" "image/color" "math" "gocv.io/x/gocv" ) var ( // Points of the polygon encasing the region of interest vertices = []image.Point{ image.Point{X: 10, Y: 525}, image.Point{X: 10, Y: 325}, image.Point{X: 200, Y: 275}, image.Point{X: 600, Y: 275}, image.Point{X: 790, Y: 325},...
image.go
0.723602
0.524334
image.go
starcoder
package types import ( "strings" "time" "github.com/pkg/errors" "github.com/spf13/pflag" ) type Period struct { Period string Duration time.Duration `json:",omitempty"` } var _ pflag.Value = (*Period)(nil) const ( EveryWeek = "everyWeek" EveryDay = "everyDay" EveryTwoWeeks = "everyTwoWeeks" E...
server/utils/types/period.go
0.624179
0.411584
period.go
starcoder
package rf import ( "bytes" "fmt" "io/ioutil" "math" "github.com/wcharczuk/go-chart" ) // Basic RF calculations // FrequencyToWavelength calculates a wavelength from a frequency func FrequencyToWavelength(freq Frequency) Wavelength { return Wavelength(C / freq) } // WavelengthToFrequency calculates a frequen...
helpers.go
0.834677
0.651147
helpers.go
starcoder
package main import ( "encoding/binary" "fmt" "io" ) // Endianess represents a byte order type Endianess string // All supported byte orders const ( EndianessLittle Endianess = "little" // Little endian (x86) EndianessBig Endianess = "big" // Big endian (PPC) ) const MaxUint16 = ^uint16(0) // SaveModel ...
tools/objconv/binfmt.go
0.553023
0.435121
binfmt.go
starcoder
package description import ( "github.com/uncharted-distil/distil-compute/pipeline" ) // InferenceStepData provides data for a pipeline description placeholder step, // which marks the point at which a TA2 should be begin pipeline inference. type InferenceStepData struct { inputRefs map[string]DataRef Inputs []...
primitive/compute/description/inference_step_data.go
0.799677
0.535766
inference_step_data.go
starcoder
// Utilizes a BSD-3-Clause license. Refer to the included LICENSE file for details. // Package dlx implements Dancing Links (Algorithm X). // The algorithm is described in the "Dancing Links" paper by <NAME> // published in "Millennial Perspectives in Computer Science. P159. Volume 187" // (2000). package dlx // Mat...
dlx.go
0.884539
0.634487
dlx.go
starcoder
package collection // Set is the classic `set` data structure type Set[T comparable] Map[T, struct{}] // Add will add the element to the set func (s Set[T]) Add(element T) { s[element] = struct{}{} } // Clear will delete all the set elements. func (s Set[T]) Clear() { for k := range s { delete(s, k) } } // Del...
set.go
0.798187
0.587499
set.go
starcoder
package main /* 1. think of pre-processing steps: sort, arrange the data, index the data, prefix sums! 2. split into small functions which you will implement later 3. solution scanning and offer alternatives (always talk about complexity in space and time) 1. pattern matching (find similar problems) 2. simplify and ...
go/interview/codility/8_1_dominator/main.go
0.635222
0.606382
main.go
starcoder
package query import ( "fmt" "reflect" "sort" "strings" "time" "github.com/fishedee/tools/decimal" "github.com/fishedee/tools/kind" ) // SelectReflect 反射实现 func SelectReflect[T, R any](data []T, selectFuctor func(a T) R) []R { dataValue := reflect.ValueOf(data) dataLen := dataValue.Len() selectFuctorValue...
query/internal/query/query.go
0.517327
0.425426
query.go
starcoder
package abi import ( "encoding/hex" "math/big" ) const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength is the expected length of the address AddressLength = 20 ) const ( // number of bits in a big.Word wordBits = 32 << (uint64(^big.Word(0)) >> 63) // number of bytes in a ...
hyperledger/burrow/abi/common.go
0.693265
0.528838
common.go
starcoder
package logic // Operand is the template for operands. type Operand interface { Evaluate(ctx interface{}) (bool, error) } // AndOperator is the template for boolean AND operators. type AndOperator struct { Operands []Operand } // Evaluate performs the evaluation of the boolean AND operator. func (o AndOperator) Ev...
logic/logic.go
0.797911
0.460107
logic.go
starcoder
package core import ( "sync" "github.com/OneOfOne/cmap/hashers" ) // shardCount must be a power of 2. // Higher shardCount will improve concurrency but will consume more memory. const shardCount = 1 << 8 // shardMask is the mask we apply to hash functions below. const shardMask = shardCount - 1 // targetMap is ...
src/core/cmap_targets.go
0.735452
0.401394
cmap_targets.go
starcoder
package trilinear import ( "errors" "image" "image/color" "math" "github.com/wayneashleyberry/lut/pkg/colorcube" "github.com/wayneashleyberry/lut/pkg/parallel" ) // bits per channel (we're assuming 8 bits). const bpc = 0xff // Interpolate will apply color transformations to the provided image using // triline...
pkg/trilinear/trilinear.go
0.690142
0.50238
trilinear.go
starcoder
package wolfenstein import ( "github.com/llgcode/draw2d/draw2dimg" "github.com/llgcode/draw2d/draw2dkit" "image/color" "math" ) type GameState struct { level []int mapSize int blockSize int player Player } type Player struct { position Point delta Point } type Point struct { x float64 y ...
src/wolfenstein/gameState.go
0.614278
0.407481
gameState.go
starcoder
package advent import ( . "github.com/davidparks11/advent2021/internal/advent/day5" "github.com/davidparks11/advent2021/internal/coordinate" ) type hydrothermalVenture struct { dailyProblem } func NewHydrothermalVenture() Problem { return &hydrothermalVenture{ dailyProblem{ day: 5, }, } } func (h *hydro...
internal/advent/day5.go
0.795142
0.492249
day5.go
starcoder
package gomath import ( "sort" ) const ( kXNotIncreasing = "X values must be strictly increasing" kZeroValueSpline = "Operation not allowed on zero value spline" ) // Point represents a single (x, y) point type Point struct { X float64 Y float64 } // Spline represents a cubic spline. type Spline struct { poi...
spline.go
0.832815
0.60964
spline.go
starcoder
package bat import ( "fmt" "reflect" ) // SliceStrIdx returns first index of `x` in `slice` and -1 if `x` is not present. func SliceStrIdx(slice []string, x string) int { for i, v := range slice { if v == x { return i } } return -1 } // SliceIntIdx returns first index of `x` in `slice` and -1 if `x` is n...
slice.go
0.707203
0.430925
slice.go
starcoder
package device const RamStartLocation = 0x200 // Givena a chip-8 adress, calculate the location // of the corresponding value in the ram array. func calculateRAMOffset(address uint16) uint16 { return address - RamStartLocation } // Check if an address is in the reserved range. func isAddressInReservedRange(address ...
pkg/emulator/device/memory.go
0.759761
0.580203
memory.go
starcoder
package gofa // Coord // Galactic Coordinates /* Icrs2g Transformation from ICRS to Galactic Coordinates. Given: dr float64 ICRS right ascension (radians) dd float64 ICRS declination (radians) Returned: dl float64 galactic longitude (radians) db float64 galactic...
coord.go
0.810891
0.65087
coord.go
starcoder
package element const BigNum = ` {{/* Only used for the Pornin Extended GCD Inverse Algorithm*/}} {{if eq .NoCarry true}} func (z *{{.ElementName}}) neg(x *{{.ElementName}}, xHi uint64) uint64 { var b uint64 z[0], b = bits.Sub64(0, x[0], 0) {{- range $i := .NbWordsIndexesNoZero}} z[{{$i}}], b = bits.Sub64(0, x[...
field/internal/templates/element/bignum.go
0.716417
0.505005
bignum.go
starcoder
package hrplot import ( "fmt" "io/ioutil" "math" "sort" "github.com/loov/plot" "github.com/loov/plot/plotsvg" ) // Benchmark declares interface for benchmarks it can plot. type Benchmark interface { Name() string Unit() string Float64s() []float64 } // Option is for declaring options to plotting. type Opt...
hrplot/plot.go
0.778228
0.424054
plot.go
starcoder
package gosu import ( "errors" "net/url" ) // BeatmapCall is used to build an API call to retrieve metadata on one beatmap. type BeatmapCall struct { // ID of the beatmap BeatmapID string // Specific game-mode. // 0 = standard, 1 = taiko, 2 = ctb, 3 = mania Mode string // Whether converted beatmaps are incl...
gosu/beatmap.go
0.558809
0.416856
beatmap.go
starcoder
package ari // Logging represents a communication path to an // Asterisk server for working with logging resources type Logging interface { // Create creates a new log. The levels are a comma-separated list of // logging levels on which this channel should operate. The name of the // channel should be the key's ...
logging.go
0.826887
0.405096
logging.go
starcoder
package main import ( "unsafe" "github.com/go-gl/gl/v3.3-core/gl" "github.com/go-gl/mathgl/mgl32" ) const ( triVerts = 3 // The number of vertices in a triangle. floatSize = 4 // The size of a float32 in bytes. positionAttribute = 1 colorAttribute = 1 positionElements = 3 // The number of floats descri...
gtk-examples/glarea/triangle.go
0.824002
0.717358
triangle.go
starcoder
package box2d import ( "fmt" "math" ) /// Wheel joint definition. This requires defining a line of /// motion using an axis and an anchor point. The definition uses local /// anchor points and a local axis so that the initial configuration /// can violate the constraint slightly. The joint translation is zero /// w...
DynamicsB2JointWheel.go
0.895922
0.772187
DynamicsB2JointWheel.go
starcoder
package wadlib import ( "bytes" "crypto/aes" "crypto/cipher" "crypto/sha1" "encoding/binary" "errors" "fmt" ) type WADFile struct { ContentRecord RawData []byte } func (w *WAD) LoadData(data []byte) error { // Each content within the data section is aligned to a 0x40/64-byte boundary. r := readable{ dat...
file.go
0.501465
0.4165
file.go
starcoder
package binary import ( "bytes" "crypto/sha256" "encoding/hex" "errors" "math" "strings" ) const ( left = iota right ) // MerkleTree is a binary tree with hash values. type MerkleTree struct { Parent *MerkleTree Left *MerkleTree Right *MerkleTree Hash []byte } // AuditPath is the shortest list of a...
binary/binary.go
0.720467
0.40698
binary.go
starcoder
package main import ( "fmt" "sort" "github.com/rolfschmidt/advent-of-code-2021/helper" ) func main() { fmt.Println("Part 1", Part1()) fmt.Println("Part 2", Part2()) } func Part1() int { return Run(false) } func Part2() int { return Run(true) } type Point struct { value int x int...
day09/main.go
0.648355
0.49884
main.go
starcoder
package man import ( . "github.com/gocircuit/circuit/gocircuit.org/render" ) func RenderRunPage() string { figs := A{ "FigTwoHosts": RenderFigurePngSvg("A circuit system of two hosts (i.e. two circuit servers).", "servers", "400px"), } return RenderHtml("Running Circuit servers", Render(runBody, figs)) } const...
gocircuit.org/man/run.go
0.69035
0.523786
run.go
starcoder
package tuple import ( "math" ) type Tuple [4]float64 func New(x, y, z, w float64) Tuple { return Tuple{x, y, z, w} } func Point(x, y, z float64) Tuple { return Tuple{x, y, z, 1.0} } func Vector(x, y, z float64) Tuple { return Tuple{x, y, z, 0.0} } // TODO should color be its own type? Or is tuple fine? // We...
tuple/tuple.go
0.623148
0.760451
tuple.go
starcoder
package navigation import ( "fmt" "github.com/vmykhailyk/advent-of-code-2021/pkg/structures" "math" ) type Path []structures.Point func (path Path) End() structures.Point { return path[len(path)-1] } func (path Path) ContinueWith(point structures.Point) Path { return append(path[0:len(path):len(path)], point) ...
pkg/submarine/navigation/path_finder.go
0.523664
0.583381
path_finder.go
starcoder
package index import "sort" // LessFn is a function type used for evaluating type LessFn func(s, t Track) bool type trackSlice struct { fn LessFn tracks []Track } func (o *trackSlice) Len() int { return len(o.tracks) } func (o *trackSlice) Swap(i, j int) { o.tracks[i], o.tracks[j] = o.tracks[j...
index/sort.go
0.834306
0.405508
sort.go
starcoder
package area import ( "fmt" "github.com/guillermo/terminal/char" ) // Area represents a rectangular area of Chars. // An empty Area is a valid one. type Area struct { Rows, Cols int content [][]char.Charer Fixed bool } // Size returns the current Size. func (a *Area) Size() (rows, cols int) { return a....
area/area.go
0.784154
0.446796
area.go
starcoder
package world import ( "fmt" "github.com/g3n/engine/math32" ) type Solid struct { Id int Sides []Side Editor *Editor } type Side struct { Id int Plane Plane Material string UAxis UVTransform VAxis UVTransform Rotation float32 LightmapScale ...
core/world/geometry.go
0.769167
0.441673
geometry.go
starcoder
package filter import ( "fmt" "github.com/gocraft/dbr" "github.com/sonm-io/marketplace/ds" pb "github.com/sonm-io/marketplace/proto" ) // Operator is used to indicate how to filter different values. type Operator int func (op Operator) String() string { var res string switch op { case LessThan: res = "<" ...
service/filter/filters.go
0.764276
0.530054
filters.go
starcoder
package filter import ( "math" "sort" "github.com/square/metrics/api" ) type filterList struct { index []int value []float64 ascending bool } func (list filterList) Len() int { return len(list.index) } func (list filterList) Less(i, j int) bool { if math.IsNaN(list.value[i]) { return false // NaN...
function/builtin/filter/filter.go
0.743168
0.419886
filter.go
starcoder
package gen import ( "math" "reflect" "github.com/leanovate/gopter" ) // Int64Range generates int64 numbers within a given range func Int64Range(min, max int64) gopter.Gen { if max < min { return Fail(reflect.TypeOf(int64(0))) } if max == math.MaxInt64 && min == math.MinInt64 { // Check for range overflow ...
vendor/github.com/leanovate/gopter/gen/integers.go
0.749087
0.443962
integers.go
starcoder
package input import ( "context" "crypto/tls" "errors" "fmt" "strconv" "strings" "sync" "time" "github.com/Jeffail/benthos/v3/internal/checkpoint" "github.com/Jeffail/benthos/v3/internal/component/input" "github.com/Jeffail/benthos/v3/internal/docs" "github.com/Jeffail/benthos/v3/lib/input/reader" "githu...
lib/input/kafka.go
0.706089
0.595493
kafka.go
starcoder
package iso20022 // Account between an investor(s) and a fund manager or a fund. The account can contain holdings in any investment fund or investment fund class managed (or distributed) by the fund manager, within the same fund family. type InvestmentAccount28 struct { // Name of the account. It provides an additio...
InvestmentAccount28.go
0.757974
0.475301
InvestmentAccount28.go
starcoder
package models // DataPRE is a Presentation func ParseDataPRE(tokens []string) DataPRE { pre := DataPRE{} pre.Adsh = tokens[0] pre.Report = parseInt(tokens[1]) pre.Line = parseInt(tokens[2]) pre.Stmt = tokens[3] pre.Inpth = tokens[4] pre.Tag = tokens[5] pre.Version = tokens[6] pre.Prole = tokens[7] pre.Plabe...
models/pre.go
0.709221
0.418162
pre.go
starcoder
package gofun // BoolOrElse returns x if x is bool, otherwise y. func BoolOrElse(x interface{}, y bool) bool { z, isOk := x.(bool) if isOk { return z } else { return y } } // ByteOrElse returns x if x is byte, otherwise y. func ByteOrElse(x interface{}, y byte) byte { z, isOk := ...
utils.go
0.695131
0.608914
utils.go
starcoder
package main import ( "fmt" ) // It takes one (1) minute to travel from one stop to another, there are eight (8) hours in a work // day and sixty (60) minutes in an hour which totals four-hundred and eighty (480) minutes and, // therefore, four-hundred and eighty (480) trips made in a work day. const MaxTrips in...
264-gossiping_bus_drivers/main.go
0.584153
0.507263
main.go
starcoder
package operator import ( "github.com/matrixorigin/matrixone/pkg/container/nulls" "github.com/matrixorigin/matrixone/pkg/container/vector" "github.com/matrixorigin/matrixone/pkg/vm/process" ) func ColOrCol(lv, rv *vector.Vector, proc *process.Process) (*vector.Vector, error) { lvs, rvs := lv.Col.([]bool), rv.Col....
pkg/sql/plan2/function/operator/or.go
0.548915
0.450178
or.go
starcoder
package matsa import ( "math" ) // Abs returns the List_f64 with nonnegative components. func (vec List_f64) Abs() List_f64 { var vec2 List_f64 if vec.Length() == 0 { return vec2 } for _, val := range vec { vec2 = append(vec2, math.Abs(val)) } return vec2 } // ...
linear.go
0.878568
0.536981
linear.go
starcoder
package gostuff import ( "fmt" "math" "golang.org/x/net/websocket" ) //fetches player's new rating by passing both player's rating and their deviation and game result and returns their rating and deviation func grabRating(pRating float64, pDeviation float64, oRating float64, oDeviation float64, results float64) (...
gostuff/rate.go
0.568176
0.439868
rate.go
starcoder
package query // RawResultHeap is a heap storing a list of values. // The ordering of such items are determined by `lessThanFn`. // The smallest item will be at the top of the heap. type RawResultHeap struct { dv []RawResult lessThanFn func(v1, v2 RawResult) bool } // NewRawResultHeap creates a new values ...
query/raw_result_heap.gen.go
0.895811
0.414425
raw_result_heap.gen.go
starcoder
// Package be provides holiday definitions for Belgium. package be import ( "time" "github.com/rickar/cal/v2" "github.com/rickar/cal/v2/aa" ) var ( // Nieuwjaar represents New Year's Day on 1-Jan Nieuwjaar = aa.NewYear.Clone(&cal.Holiday{Name: "Nieuwjaarsdag", Type: cal.ObservancePublic}) // Paasmaandag repr...
v2/be/be_holidays.go
0.531209
0.44553
be_holidays.go
starcoder
package cmd import ( "fmt" "github.com/spf13/cobra" "math" ) var day03cmd = &cobra.Command{ Use: "day03", Run: run03, } func init() { RootCmd.AddCommand(day03cmd) } func compute03(input int) int { output := doCompute03(input) fmt.Println(input, "=>", output) return output } func doCompute03(input int) int ...
cmd/03.go
0.625209
0.462837
03.go
starcoder
package ast import ( "bytes" "io" "github.com/jensneuse/graphql-go-tools/internal/pkg/unsafebytes" "github.com/jensneuse/graphql-go-tools/pkg/lexer/literal" "github.com/jensneuse/graphql-go-tools/pkg/lexer/position" ) type TypeKind int const ( TypeKindUnknown TypeKind = 14 + iota TypeKindNamed TypeKindList ...
pkg/ast/ast_type.go
0.535827
0.426322
ast_type.go
starcoder
package specs import ( "fmt" "github.com/jexia/semaphore/pkg/specs/labels" "github.com/jexia/semaphore/pkg/specs/metadata" "github.com/jexia/semaphore/pkg/specs/types" ) // Schemas represents a map string collection of properties type Schemas map[string]*Property // Get attempts to return the given key from the...
pkg/specs/property.go
0.852813
0.421492
property.go
starcoder
package horizon import ( "github.com/LdDl/viterbi" "github.com/golang/geo/s2" ) // ObservationResult Representation of gps measurement matched to G(v,e) /* Observation - gps measurement itself MatchedEdge - edge in G(v,e) corresponding to current gps measurement */ type ObservationResult struct { Observation *GP...
map_matcher_result.go
0.653569
0.509276
map_matcher_result.go
starcoder
package elarr import "reflect" var LIndex = LIndexInter // Get the index of the last item that is same as the given `item` parameter. // If can't found same item, return -1. func LIndexInter(v []interface{}, item interface{}) int { l := len(v) for i := l - 1; i >= 0; i-- { if reflect.DeepEqual(v[i], item) { r...
elarr/lindex.go
0.631708
0.407216
lindex.go
starcoder
package matroska import "honnef.co/go/xcapture/internal/matroska/ebml" func Segment(c ...ebml.Object) ebml.Element { return ebml.Element{0x18538067, c} } func SeekHead(c ...ebml.Object) ebml.Element { return ebml.Element{0x114D9B74, c} } func Seek(c ...ebml.Object) ebml.Element ...
internal/matroska/ids.go
0.569494
0.517571
ids.go
starcoder
package school import ( "strings" "unicode" "github.com/jinzhu/gorm" "github.com/freitzzz/iped/model/canteen" "github.com/freitzzz/iped/model/customerror" ) // School is a model that offers canteens // A school has a unique acronym, a descriptive name and needs to offer at least one canteen // A UML overview o...
model/school/school.go
0.697094
0.412294
school.go
starcoder
package announcements // Kind is used to record the kind of announcement type Kind string func (at Kind) String() string { return string(at) } const ( // ProxyUpdate is the event kind used to trigger an update to subscribed proxies ProxyUpdate Kind = "proxy-update" // PodAdded is the type of announcement emitte...
pkg/announcements/types.go
0.690663
0.578567
types.go
starcoder
package json import ( "fmt" "gopkg.in/mgo.v2/bson" "reflect" ) // Represents base-64 encoded binary data type BinData struct { Type byte Base64 string } // Represents the number of milliseconds since the Unix epoch. type Date int64 type ISODate string type ObjectId string // Represents a reference to anoth...
src/mongo/gotools/common/json/mongo_extjson.go
0.721449
0.441793
mongo_extjson.go
starcoder
package data import ( "crypto/md5" "encoding/binary" "fmt" "time" "github.com/golang/protobuf/ptypes" "github.com/simpleiot/simpleiot/internal/pb" "google.golang.org/protobuf/proto" ) // Point is a flexible data structure that can be used to represent // a sensor value or a configuration parameter. // ID, Typ...
data/point.go
0.809351
0.453927
point.go
starcoder
package v1api import ( "os" "path" "github.com/RumbleDiscovery/mustache/v2" ) // ParseString compiles a mustache template string. The resulting output can // be used to efficiently render the template multiple times with different data // sources. func ParseString(data string) (*mustache.Template, error) { retur...
v1api/v1api.go
0.718002
0.420302
v1api.go
starcoder
package ir import ( "github.com/umaumax/llvm/ir/value" ) // --- [ Binary instructions ] ------------------------------------------------- // ~~~ [ add ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // NewAdd appends a new add instruction to the basic block based on the given // operands. func ...
ir/block_binary.go
0.621426
0.409693
block_binary.go
starcoder
package google import "github.com/hashicorp/terraform/helper/schema" func canonicalizeServiceScope(scope string) string { // This is a convenience map of short names used by the gcloud tool // to the GCE auth endpoints they alias to. scopeMap := map[string]string{ "bigquery": "https://www.googleapis...
vendor/github.com/terraform-providers/terraform-provider-google/google/service_scope.go
0.544801
0.401336
service_scope.go
starcoder
package iso20022 // Extract of trade data for an investment fund order. type FundOrderData1 struct { // Account information of the individual order instruction for which the status is given. InvestmentAccountDetails *InvestmentAccount13 `xml:"InvstmtAcctDtls,omitempty"` // Financial instrument information of the ...
data/train/go/d7d67dc99e746faba70bacf12ec765abe4c12e4dFundOrderData1.go
0.838779
0.568895
d7d67dc99e746faba70bacf12ec765abe4c12e4dFundOrderData1.go
starcoder
package config import "github.com/pkg/errors" // WorkflowDefinition is the consumer friendly data structure that hosts the loaded workflow definition type WorkflowDefinition struct { Flowit Flowit } // Flowit is the consumer friendly data structure that hosts the loaded workflow definition main body type Flowit str...
internal/config/model.go
0.707304
0.465448
model.go
starcoder
package testdata // GetPaymentResponse example const GetPaymentResponse = `{ "resource": "payment", "id": "tr_WDqYK6vllg", "mode": "test", "createdAt": "2018-03-20T13:13:37+00:00", "amount": { "value": "10.00", "currency": "EUR" }, "description": "Order #12345", "method"...
testdata/payments.go
0.748995
0.451508
payments.go
starcoder
package bigfloat import ( "math/big" ) var zero = big.NewFloat(0) const ( cmpLt int = -1 cmpEq int = 0 cmpGt int = 1 cmpNil int = -42 ) // Add returns the result of adding the values of params x and y. // Notes: // - If x == nil && y == nil, returns nil. // - If x != nil && y == nil, returns x. // - If x ==...
bigfloat/bigfloat.go
0.868381
0.741814
bigfloat.go
starcoder
package main import "fmt" // SimulateCovidSpread is a function to generate Boards for each Day and store the them in a slice of the type Board func SimulateCovidSpread(initialBoard *Board, statePeriods Periods, lambda, gamma []float64, numDays int) []*Board { boards := make([]*Board, numDays+1) // create blank slic...
covid1/functions.go
0.684159
0.601564
functions.go
starcoder
package sctp import ( "github.com/pkg/errors" ) /* chunkHeartbeat represents an SCTP Chunk of type HEARTBEAT An endpoint should send this chunk to its peer endpoint to probe the reachability of a particular destination transport address defined in the present association. The parameter field contains the Heartbeat...
trunk/3rdparty/srs-bench/vendor/github.com/pion/sctp/chunk_heartbeat.go
0.564819
0.40031
chunk_heartbeat.go
starcoder
package vision import ( "image" "math" "sync" ) // Grad computes the grad and returns its magnitude and angle. func Grad(gray *image.Gray) (mag, ang *image.Gray) { dx := [][]float64{{1, 0, -1}, {2, 0, -2}, {1, 0, -1}} dy := [][]float64{{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}} mb, nb := gray.Bounds().Dy(), gray.Bound...
grad.go
0.703549
0.713706
grad.go
starcoder
package chassis import ( "fmt" "sync" ) // Attitude represents chassis attitude information. type Attitude struct { m sync.RWMutex pitch float64 roll float64 yaw float64 } // NewAttitude returns a new Attitude instance with the given pitch, roll and // yaw values (in degrees). func NewAttitude(pitch, ro...
sdk/modules/chassis/attitude.go
0.766206
0.538194
attitude.go
starcoder
package p381 import ( "math/rand" ) /** Design a data structure that supports all following operations in average O(1) time. Note: Duplicate elements are allowed. insert(val): Inserts an item val to the collection. remove(val): Removes an item val from the collection if present. getRandom: Returns a random element ...
algorithms/p381/381.go
0.74158
0.659652
381.go
starcoder
package scheme import ( "fmt" ) var ( builtinSyntaxes = Binding{ "actor": NewSyntax(actorSyntax), "and": NewSyntax(andSyntax), "begin": NewSyntax(beginSyntax), "cond": NewSyntax(condSyntax), "define": NewSyntax(defineSyntax), "define-macro": NewSyntax(defineMacroSyn...
scheme/syntax.go
0.574634
0.433082
syntax.go
starcoder