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 extend import ( "github.com/anaminus/luasyntax/go/tree" ) // FileScope contains information about the scopes of a file, including // variables and their associations with a parse tree. type FileScope struct { // Root is the root scope. Root *Scope // Globals is a list of global variables that have been as...
go/extend/scope.go
0.664976
0.502014
scope.go
starcoder
package solutions import ( "fmt" "reflect" ) func canCompleteCircuit(gas []int, cost []int) int { size := len(gas) total, left, start := 0, 0, 0 for i := 0; i < size; i++ { diff := gas[i] - cost[i] total += diff left += diff if left < 0 { left = 0 start = (i + 1) % size } } fmt.Println("total->...
solutions/0134.go
0.549641
0.601828
0134.go
starcoder
package encoder import ( "fmt" "github.com/gojek/merlin/pkg/transformer/spec" "github.com/gojek/merlin/pkg/transformer/types/converter" "math" "time" ) const ( floatZero = 0.0000000001 q1LastMonth = 3 q2LastMonth = 6 q3LastMonth = 9 h1LastMonth = 6 february = 2 minInSec = 60 hourInSec = 3600 dayI...
api/pkg/transformer/types/encoder/cyclical_encoder.go
0.678753
0.513242
cyclical_encoder.go
starcoder
package core import ( "runtime" . "github.com/gooid/gocv/opencv3/internal/native" ) const _channelsMatOfRect2d = 4 var _depthMatOfRect2d = CvTypeCV_64F type MatOfRect2d struct { *Mat } func NewMatOfRect2d() (rcvr *MatOfRect2d) { rcvr = &MatOfRect2d{} rcvr.Mat = NewMat2() runtime.SetFinalizer(rcvr, func(inte...
opencv3/core/MatOfRect2d.java.go
0.608361
0.496704
MatOfRect2d.java.go
starcoder
// Package day20 solves AoC 2017 day 20. package day20 import ( "math" "sort" "strconv" "github.com/fis/aoc/glue" ) const inputRegexp = `^p=<(-?\d+),(-?\d+),(-?\d+)>, v=<(-?\d+),(-?\d+),(-?\d+)>, a=<(-?\d+),(-?\d+),(-?\d+)>$` func init() { glue.RegisterSolver(2017, 20, glue.RegexpSolver{ Solver: solve, Re...
2017/day20/day20.go
0.650578
0.432782
day20.go
starcoder
package storage import ( "fmt" "math/bits" ) // ref Libra Position module // maxLevel for index in uint64 const maxLevel = 63 // InorderIndex represents the inorder traversal index of a binary tree with limited level type InorderIndex uint64 // FromIndexOnLevel calculates inorder index from the index of nodes up...
storage/inorderindex.go
0.770465
0.496582
inorderindex.go
starcoder
package schemer import ( "encoding/json" "errors" "fmt" "io" "reflect" ) // BoolSchema is a Schema for encoding and decoding boolean values type BoolSchema struct { SchemaOptions } // Encode uses the schema to write the encoded value of i to the output stream func (s *BoolSchema) Encode(w io.Writer, i interfac...
bool.go
0.741955
0.414247
bool.go
starcoder
// Snippet check looks through documents for CTE snippets (```cte ... ```) // and attempts to parse it in order to verify that it is valid. package main import ( "bytes" "flag" "fmt" "io/ioutil" "os" "regexp" "github.com/kstenerud/go-concise-encoding/ce" "github.com/kstenerud/go-describe" ) func main() { q...
tests/snippet_check/main.go
0.516352
0.543954
main.go
starcoder
Copyright 2016 GitHub Inc. See https://github.com/github/gh-ost/blob/master/LICENSE */ /* Copyright 2021 The Vitess Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apac...
go/vt/vttablet/onlineddl/vrepl/types.go
0.881538
0.408454
types.go
starcoder
package disjointset /** * Node for DisjointSet datastructure. * Contains the parent id, the node rank and the number * of components in the tree (only useful for root nodes) */ type DisjointSetNode struct { parent int rank int size int } /** * DisjointSet type, contains the elements (nodes) that * the di...
disjointset/disjointset.go
0.806396
0.449393
disjointset.go
starcoder
package feistel import ( "bytes" "encoding/binary" "io" ) type ecb struct{} // ECB contains the Encrypt and Decrypt functions using the ECB algorithm var ECB ecb // EncryptReader reads data from an reader and writes the encrypted data to the writer func (ecb) EncryptReader(r io.Reader, w io.Writer, rounds int, k...
ecb.go
0.7324
0.434701
ecb.go
starcoder
package mlpack /* #cgo CFLAGS: -I./capi -Wall #cgo LDFLAGS: -L. -lmlpack_go_cf #include <capi/cf.h> #include <stdlib.h> */ import "C" import "gonum.org/v1/gonum/mat" type CfOptionalParam struct { Algorithm string AllUserRecommendations bool InputModel *cfModel Interpolation string IterationOnly...
cf.go
0.663887
0.460956
cf.go
starcoder
package account import ( "strconv" ) type Account struct { // The account's available funds // Required: true AvailableFunds float64 // The account's available to withdrawal funds // Required: true AvailableWithdrawalFunds float64 // The account's balance // Required: true Balance float64 // The selected ...
v3/structures/account/account.go
0.575827
0.40642
account.go
starcoder
package xmath import ( "math" "time" ) // Set is a set of statistical properties of a set of numbers. type Set struct { count int first, last float64 min, max float64 mean, dSquared float64 } // NewSet creates a new Set. func NewSet() Set { return Set{ min: math.MaxFloat64, } } // Push a...
oremi/vendor/github.com/drakos74/go-ex-machina/xmath/stats.go
0.879522
0.492798
stats.go
starcoder
package collection import ( "constraints" ) // Graph implements a directed graph. type Graph[K comparable, V any, W constraints.Unsigned] struct { edges map[K]map[K]edge[V, W] } // SetEdge inserts an edge into the graph. If an edge already exists between // the nodes, that edge is overwritten. func (g *Graph[K, V,...
graph.go
0.73678
0.478468
graph.go
starcoder
package main import "fmt" type matrix [][]float64 func zero(n int) matrix { r := make([][]float64, n) a := make([]float64, n*n) for i := range r { r[i] = a[n*i : n*(i+1)] } return r } func eye(n int) matrix { r := zero(n) for i := range r { r[i][i] = 1 } return r ...
lang/Go/lu-decomposition-1.go
0.648466
0.469216
lu-decomposition-1.go
starcoder
package functiongrapher import ( "math" "github.com/benoitkugler/maths-online/maths/expression" "github.com/benoitkugler/maths-online/maths/repere" ) type BezierCurve struct { P0, P1, P2 repere.Coord `dart-extern:"repere.gen.dart"` } func (seg segment) toCurve() BezierCurve { p1 := controlFromDerivatives(seg.f...
server/src/maths/functiongrapher/grapher.go
0.807688
0.525551
grapher.go
starcoder
package eighttree import ( "errors" "fmt" ) var ( ErrInvalidTree = errors.New("invalid tree") ) // InternalCountFromLeaves returns the number of internal nodes needed to store the given number of // leaf nodes in a complete 8-tree representation. func InternalCountFromLeaves(leafNodes int) int { if leafNodes < 2...
pkg/eighttree/eighttree.go
0.746878
0.424472
eighttree.go
starcoder
package main import ( "errors" "fmt" ) const ( opening = iota endgame pawnPhase = 1 << iota bishopPhase rookPhase queenPhase knightPhase = bishopPhase totalPhase = 2 * (queenPhase + 2*rookPhase + 2*bishopPhase + 2*knightPhase + 8*pawnPhase) ) // errInsufficient is returned by Eval when neither player has...
eval.go
0.638272
0.447641
eval.go
starcoder
package stats import ( "fmt" "github.com/360EntSecGroup-Skylar/excelize/v2" excel "github.com/zhs007/adacore/excel" ) // memberDataSetStats - DataSetStats member var memberDataSetStats = []string{ "Name", "Nums", "MeanSDev1", "MeanSDev2", "MeanSDev3", "Min", "Max", "COV", "Median", "MedianAbsoluteDeviat...
stats/excel.go
0.582372
0.405655
excel.go
starcoder
package main import ( "encoding/json" "math/rand" "sort" ) var FamousPlaces []Coordinate = []Coordinate{ {Latitude: 34.81667, Longitude: 137.4}, {Latitude: 34.4833, Longitude: 136.84186}, {Latitude: 36.65, Longitude: 138.31667}, {Latitude: 34.9, Longitude: 137.5}, {Latitude: 35.06667, Longitude: 135.21667}, ...
initial-data/make_verification_data/nazotte.go
0.577734
0.54153
nazotte.go
starcoder
package function import ( "encoding/hex" "fmt" "strconv" "strings" "time" "unsafe" "github.com/shopspring/decimal" "github.com/liquidata-inc/go-mysql-server/sql" ) // AsciiFunc implements the sql function "ascii" which returns the numeric value of the leftmost character func AsciiFunc(_ *sql.Context, val in...
sql/expression/function/string.go
0.714329
0.40539
string.go
starcoder
package merkletree2 import ( "fmt" "math" ) // The SkipPointers struct is constructed for a specific Seqno s (version) of // the tree and contains the hashes of RootMetadata structs at specific previous // Seqnos (versions) of the tree. Such versions are fixed given s according to // the algorithm in GenerateSkipPo...
go/merkletree2/skippointers.go
0.661486
0.432063
skippointers.go
starcoder
package gabi import ( "crypto/rand" "math/big" ) // Some utility code (mostly math stuff) useful in various places in this // package. // Often we need to refer to the same small constant big numbers, no point in // creating them again and again. var ( bigZERO = big.NewInt(0) bigONE = big.NewInt(1) bigTWO ...
mathutil.go
0.579519
0.486697
mathutil.go
starcoder
package nasConvert import ( "encoding/hex" "fmt" "github.com/omec-project/nas/nasMessage" "github.com/omec-project/nas/nasType" "github.com/omec-project/openapi/models" ) // TS 24.501 9.11.3.37 func RequestedNssaiToModels(nasNssai *nasType.RequestedNSSAI) ([]models.MappingOfSnssai, error) { var requestNssai [...
nasConvert/Nssai.go
0.564339
0.412175
Nssai.go
starcoder
package iso20022 // Execution of a redemption order. type RedemptionExecution3 struct { // Unique and unambiguous identifier for an order, as assigned by the instructing party. OrderReference *Max35Text `xml:"OrdrRef"` // Unique and unambiguous identifier for an order execution, as assigned by a confirming party....
RedemptionExecution3.go
0.808937
0.44071
RedemptionExecution3.go
starcoder
package decim import ( "errors" "io" "math" ) // Same interface as gonum/plot XYer. type XYer interface { XY(i int) (x, y float64) Len() int } type Sampler struct { idx int tol float64 xPivot, yPivot, xPrev, yPrev float64 angleMin, angleMax float64...
sampler.go
0.709321
0.442275
sampler.go
starcoder
package main import ( "math/rand" "time" ) type tileType int const ( floor tileType = iota wall boundary ) type tile struct { glyph rune kind tileType color int } func (t tile) isWalkable() bool { return t.kind == floor } func (t tile) isDiggable() bool { return t.kind == wall } type world struct { d...
world.go
0.580114
0.47658
world.go
starcoder
package database import ( "cloud.google.com/go/datastore" "golang.org/x/net/context" ) const ( datastoreKind = "Tweet" ) // Dao defines the interface for the data access object that abstracts database interactions. type Dao interface { WriteCelebrityTweets(tweets []Tweet) (err error) GetCelebrityTweets(celebrit...
database/dao.go
0.575827
0.406626
dao.go
starcoder
package navigation import ( "math" "github.com/furgbol/ai/model" ) // CasteljauPathPlanner - This type implements the PathPlanner interface. It plans the path based on Casteljau's algorithm that uses Bézier curves. type CasteljauPathPlanner struct { NumberOfPathPoints int NumberOfUsedPoints int DistanceFactor ...
control/navigation/casteljau.go
0.853455
0.587854
casteljau.go
starcoder
package prioq import ( "golang.org/x/exp/constraints" "errors" ) // CompareFunc is a generic function that compares two values and that should return true // whenever those values should be swapped type CompareFunc[T any] func(a T, b T) bool // PrioQ represents a generic priority queue data structure type PrioQ[T ...
prioq.go
0.780412
0.514827
prioq.go
starcoder
package manifest import ( "bytes" "crypto" "crypto/ecdsa" "crypto/elliptic" "crypto/rsa" "encoding/binary" "fmt" "math/big" "github.com/tjfoc/gmsm/sm2" ) // Key is a public key of an asymmetric crypto keypair. type Key struct { KeyAlg Algorithm `json:"key_alg"` Version uint8 `require:"0x10" json:"k...
pkg/intel/metadata/manifest/key.go
0.729038
0.437944
key.go
starcoder
package ratelimit import ( "errors" "time" ) type LimitChange struct {} // Increase the rate limit. // LimitChange requires 1 argument of type time.Duration to be passed in // This argument is the unit by which the piecewise function works around func (l *LimitChange) Increase(limit time.Duration, states ...interf...
lib.go
0.689828
0.447762
lib.go
starcoder
package timeext import ( "math" "time" errors "github.com/weathersource/go-errors" ) const timestampFormat = time.RFC3339 // Timestamp validates t is formatted RFC 3339 and returns time object. func Timestamp(t string) (timestamp time.Time, err error) { timestamp, err = time.Parse(timestampFormat, t) if err !...
timestamp.go
0.845337
0.401688
timestamp.go
starcoder
package mud import ( "bytes" "encoding/binary" "io" "math" "math/rand" "strconv" "strings" "time" "github.com/vmihailenco/msgpack" ) // MessageType is a log message line type type MessageType int // Message types for log items const ( MESSAGESYSTEM MessageType = iota MESSAGECHAT MESSAGEACTION MESSAGEAC...
util.go
0.801237
0.485661
util.go
starcoder
package ent import ( "fmt" "strings" "entgo.io/ent/dialect/sql" "github.com/joelschutz/gomecoma/src/ent/rating" ) // Rating is the model entity for the Rating schema. type Rating struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // Origin holds the value of the "origin" field. Origi...
src/ent/rating.go
0.685107
0.442396
rating.go
starcoder
package helpers import ( "errors" "reflect" "sort" ) // GetTotalArea calculates total area of rectangles func GetTotalArea(rects []Rectangle) (int, error) { nonZeroRects := Filter(rects, func(rect Rectangle) bool { return rect.Area() != 0 }) dividers := getUniqueSortedXSlice(nonZeroRects) splitted, err := s...
area.go
0.651244
0.431045
area.go
starcoder
package drawing import ( "github.com/rs/zerolog" "image" "image/color" ) // Canvas to draw on type Canvas struct { img image.Image log zerolog.Logger } // Pixel is an x,y point on the image type Pixel struct { X, Y int } // Line is an array of pixels that we'll create from the approximate changes type Line []...
drawing/types.go
0.61555
0.487368
types.go
starcoder
package mathut import ( "fmt" "github.com/colt3k/utils/stats" "math" "strconv" ) // Round func Round(x, unit float64) float64 { return math.Round(x/unit) * unit } /* The format fmt is one of 'b' (-ddddp±ddd, a binary exponent), 'e' (-d.dddde±dd, a decimal exponent), 'E' (-d.ddddE±dd, a decimal exponent), ...
mathut/math.go
0.608245
0.529324
math.go
starcoder
package geom /* #include "geos.h" */ import "C" import "errors" // CoordinateSeq wraps C coordinate sequence type CoordinateSeq struct { CSeq *C.GEOSCoordSequence } func initCoordSeq(size int, dims int) (*CoordinateSeq, error) { seq := C.GEOSCoordSeq_create(C.uint(size), C.uint(dims)) if seq == nil { return n...
geom/coordinateseq.go
0.87938
0.410579
coordinateseq.go
starcoder
package compact_float import ( "fmt" "io" "math/big" "github.com/cockroachdb/apd/v2" "github.com/kstenerud/go-uleb128" ) var ErrorIncomplete = fmt.Errorf("Compact float value is incomplete") // Maximum number of bytes required to encode a DFloat. func MaxEncodeLength() int { // (64 bits / 7) + (33 bits / 7) ...
compact-float.go
0.764012
0.452899
compact-float.go
starcoder
package yarf import ( "reflect" ) var uintType = reflect.TypeOf(uint64(0)) var intType = reflect.TypeOf(int64(0)) var floatType = reflect.TypeOf(float64(0)) var stringType = reflect.TypeOf(string("")) var boolType = reflect.TypeOf(false) type converter func(in interface{}) (interface{}, bool) func untypedFloat(in ...
param.go
0.711932
0.495789
param.go
starcoder
package unityai import ( "fmt" "math" ) type Vector3f struct { x, y, z float32 } var Vector3_One = Vector3f{1, 1, 1} var Vector2_One = Vector2f{1, 1} func NewVector3f(x, y, z float32) Vector3f { var v Vector3f v.Set(x, y, z) return v } func (this *Vector3f) Set(x, y, z float32) { this.x = x this.y = y thi...
vector.go
0.824108
0.755862
vector.go
starcoder
package BrickMosaic // This package is responsible for translating the Extent ([]Location) of pieces relative to // different anchor points. E.g. by default the extent is relative to 'upper left' corner // of brick. But if we're placing it such that lower right corner is the origin, we need // to translate the upper l...
translate.go
0.705176
0.528229
translate.go
starcoder
package table import ( "bytes" "encoding/csv" "errors" "fmt" "strings" "github.com/grokify/mogo/math/mathutil" ) // Pivot takes a "straight table" where the columnn names // and values are in a single column and lays it out as a standard tabular data. func (tbl *Table) Pivot(colCount uint, haveColumns bool) (T...
data/table/format.go
0.582135
0.423279
format.go
starcoder
package lib import "golang.org/x/exp/constraints" // Min returns the minimum of the supplied values. func Min[T constraints.Ordered](vals ...T) T { Assertf(len(vals) > 0, "No values given") min := vals[0] for _, v := range vals[1:] { if v < min { min = v } } return min } // Max returns the maximum of th...
lib/math.go
0.846038
0.555676
math.go
starcoder
package lexer import ( "bytes" "io" "strings" ) // lexer.Lexer helps you tokenize bytes type Lexer interface { // PeekRune allows you to look ahead at runes without consuming them PeekRune(int) rune // NetRune consumes and returns the next rune in the input NextRune() rune // BackupRune un-conumes the last...
lexer.go
0.772015
0.425187
lexer.go
starcoder
package useful import . "github.com/SimonRichardson/wishful/wishful" type Either interface { Of(Any) Point Ap(Applicative) Applicative Chain(func(Any) Monad) Monad Concat(Semigroup) Semigroup Map(Morphism) Functor Bimap(Morphism, Morphism) Monad Fold(Morphism, Morphism) Any Swap() Monad Sequence(Point) Any ...
useful/either.go
0.716417
0.42054
either.go
starcoder
package aeshash import _ "unsafe" import "leb.io/hashland/nhash" var masks [32]uint64 var shifts [32]uint64 // used in asm_{386,amd64}.s const hashRandomBytes = 32 // this is really 2 x 128 bit round keys var aeskeysched [hashRandomBytes]byte var aesdebug [hashRandomBytes]byte func aeshashbody() //func Hash(p un...
aeshash.go
0.538498
0.467453
aeshash.go
starcoder
package wordwrap import ( "io" "strings" ) // Options adjust word-wrapping behavior. type Options struct { // NoWrap disables word wrapping, so that only the existing line breaks are used. NoWrap bool // BreakWords allows to break the line mid-word if absolutely necessary. BreakWords bool // BreakMarker is a...
wrap.go
0.644561
0.425486
wrap.go
starcoder
package glw import "errors" /* First I found a list of transforms in the field of mathematics on wikipedia: https://en.wikipedia.org/wiki/List_of_transforms Then I found Sequential euclidean distance transforms: https://en.wikipedia.org/wiki/Sequential_euclidean_distance_transforms This led me to the Euclidean dist...
glw/metric.go
0.837321
0.906446
metric.go
starcoder
package rui import ( "fmt" "math" "strconv" "strings" ) // AngleUnitType : type of enumerated constants for define a type of AngleUnit value. // Can take the following values: Radian, Degree, Gradian, and Turn type AngleUnitType uint8 const ( // Radian - angle in radians Radian AngleUnitType = 0 // Radian - a...
angleUnit.go
0.844794
0.515437
angleUnit.go
starcoder
package pass import ( "fmt" "github.com/mmcloughlin/addchain/acc/ir" ) // Allocator pass assigns a minimal number of temporary variables to execute a program. type Allocator struct { // Input is the name of the input variable. Note this is index 0, or the // identity element of the addition chain. Input string ...
acc/pass/alloc.go
0.666171
0.471041
alloc.go
starcoder
package main // In computer science, merge sort (also commonly spelled mergesort) is an efficient, general-purpose, comparison-based import ( "fmt" "math/rand" "time" ) // sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the // input order of equal element...
merge-sort/mergeSort.go
0.765681
0.671131
mergeSort.go
starcoder
package sorting import ( "sync" ) // Sorts the given slice of integer using bubble sort algorithm. func BubbleSort(sl []int) { sliceLength := len(sl) for i := 0; i < sliceLength-1; i++ { for j := 0; j < sliceLength-i-1; j++ { if sl[j] > sl[j+1] { sl[j], sl[j+1] = sl[j+1], sl[j] } } } } // Sorts th...
golang/sorting/sorting.go
0.752559
0.584894
sorting.go
starcoder
package agent import ( "github.com/aperturerobotics/bifrost/peer" "github.com/aperturerobotics/controllerbus/directive" ) // AttachAgentToNode is a directive to attach an agent to a node. type AttachAgentToNode interface { // Directive indicates AttachAgentToNode is a directive. directive.Directive // AttachAge...
agent/directive.go
0.728845
0.426441
directive.go
starcoder
package parser import ( "errors" "fmt" "regexp" "strings" ) type Scanner struct { src source // the source the scanner is drawing from sliceStart int // the start of the slice visible to the scanner, based on the original src sliceLength int // the length of the slice visible to the scanner, bas...
parser/scanner.go
0.67405
0.424531
scanner.go
starcoder
package cam import ( "math" "github.com/go-gl/mathgl/mgl32" "github.com/go-gl/mathgl/mgl64" "github.com/nvisioner/glutils/win" ) type FpsCamera struct { // Camera options moveSpeed float64 cursorSensitivity float64 // Eular Angles pitch float64 yaw float64 // Camera attributes pos mgl32.V...
cam/camera.go
0.788787
0.501099
camera.go
starcoder
package syntax import ( "bytes" "fmt" "regexp" "strings" ) // The parse tree for search input. It is a list of expressions. type ParseTree []*Expr // Values returns the raw string values associated with a field. func (p ParseTree) Values(field string) []string { var v []string for _, expr := range p { if exp...
enterprise/internal/batches/search/syntax/parse_tree.go
0.729231
0.422207
parse_tree.go
starcoder
package check import ( "math" ) // IsUniqueFloat64Slice checks if all elements of a float64 slice are unique (so the slice does not contain duplicated elements). // The Epsilon parameter sets the accuracy of the comparison of two floats. // If the slice has no elements, the function returns true (since it does not c...
unique.go
0.86521
0.549701
unique.go
starcoder
package integration // EqualsAST does deep equals between the two objects. func EqualsAST(inA, inB AST) bool { if inA == nil && inB == nil { return true } if inA == nil || inB == nil { return false } switch a := inA.(type) { case BasicType: b, ok := inB.(BasicType) if !ok { return false } return ...
go/tools/asthelpergen/integration/ast_equals.go
0.639511
0.502441
ast_equals.go
starcoder
package dprocedures import "github.com/dolthub/go-mysql-server/sql" var DoltProcedures = []sql.ExternalStoredProcedureDetails{ {Name: "dolt_add", Schema: int64Schema("status"), Function: doltAdd}, {Name: "dolt_backup", Schema: int64Schema("success"), Function: doltBackup}, {Name: "dolt_branch", Schema: int64Schem...
go/libraries/doltcore/sqle/dprocedures/init.go
0.547706
0.549641
init.go
starcoder
package exodus import "math/rand" func NewPopulation(populationSize int, individualSize int, newGene NewGeneFunction) Population { population := NewEmptyPopulation(populationSize) for i := 0; i < populationSize; i++ { population.Individuals[i] = NewIndividual(individualSize, newGene) } return ...
population.go
0.706393
0.541106
population.go
starcoder
// Package codec provides support for interpreting byte slices as slices of // other basic types such as runes, int64's or strings. Go's lack of generics // make this awkward and this package currently supports a fixed set of // basic types (slices of byte/uint8, rune/int32, int64 and string). package codec import "f...
algo/codec/codec.go
0.746693
0.418043
codec.go
starcoder
package ckks import ( //"fmt" "math" "math/cmplx" ) func chebyshevNodesU(n int, a, b complex128) (u []complex128) { u = make([]complex128, n) var x, y complex128 for k := 1; k < n+1; k++ { x = 0.5 * (a + b) y = 0.5 * (b - a) u[n-k] = x + y*complex(math.Cos((float64(k)-0.5)*(3.141592653589793/float64(n))),...
ckks/function_approximations.go
0.610802
0.429429
function_approximations.go
starcoder
package forGraphBLASGo import ( "github.com/intel/forGoParallel/pipeline" "sort" ) // sparseVector has no duplicate cols type sparseVector[T any] struct { nsize int cols []int values []T } func newSparseVector[T any](size int, cols []int, values []T) sparseVector[T] { return sparseVector[T]{ nsize: size,...
functional_VectorSparse.go
0.635675
0.689789
functional_VectorSparse.go
starcoder
package saml import ( "crypto/x509" "fmt" "time" ) // A Checker is a predicate against a signed element. The element can be a response or an assertion, // but bear in mind that all not data might be signed. Checkers in this package will mention when // they operate on the assertion only (in which case they require...
checkers.go
0.61451
0.458349
checkers.go
starcoder
package model import ( "fmt" "io" "strconv" ) type File struct { ID string `json:"id"` Name string `json:"name"` } type Ingredient struct { ID string `json:"id"` Title *string `json:"title"` Description *string `json:"description"` Image *string `json:"image"` } type IngredientInpu...
graph/model/models_gen.go
0.638046
0.416263
models_gen.go
starcoder
// This package implements a basic LISP interpretor for embedding in a go program for scripting. // This file contains the binary primitive functions. package golisp import ( "fmt" ) func RegisterBinaryPrimitives() { MakePrimitiveFunction("binary-and", "2", BinaryAndImpl) MakePrimitiveFunction("binary-or", "2", ...
prim_binary.go
0.735452
0.501343
prim_binary.go
starcoder
package neural import ( "fmt" ) type Sample struct { Inputs []float64 Outputs []float64 } // Backpropagation type BP struct { p *MLP ldeltas [][]float64 learningRate float64 // (0 <= learningRate <= 1) outputs []float64 costFunc CostFunc } func NewBP(p *MLP, cf CostFunc) *BP { if...
backpropagation.go
0.622574
0.454775
backpropagation.go
starcoder
package line import ( "strings" "github.com/adamcolton/geom/calc/cmpr" "github.com/adamcolton/geom/d2" "github.com/adamcolton/geom/geomerr" ) // Line in 2D space invoked parametrically type Line struct { T0 d2.Pt D d2.V } // Pt1 returns a Pt on the line func (l Line) Pt1(t float64) d2.Pt { return l.T0.Add(l...
d2/curve/line/line.go
0.854733
0.647422
line.go
starcoder
package main import ( "bufio" "fmt" "math" "os" "strconv" "strings" ) var permutations [][]byte func perm(a []byte, f func([]byte), i int) { if i > len(a) { f(a) return } perm(a, f, i+1) for j := i + 1; j < len(a); j++ { a[i], a[j] = a[j], a[i] perm(a, f, i+1) a[i], a[j] = a[j], a[i] } } type...
day_24/main.go
0.554953
0.453201
main.go
starcoder
package calculator import ( "errors" "fmt" "math" "strconv" "strings" ) // Add takes two or subsequent numbers and returns the result of adding them together. func Add(a, b float64, nums ...float64) float64 { result := a + b for _, n := range nums { result += n } return result } // Subtract takes two or s...
calculator.go
0.866302
0.585309
calculator.go
starcoder
package slices // Filter returns a new slice consisting of all elements that pass the predicate function func Filter[TSlice ~[]T, T any](slice TSlice, predicate func(T) bool) TSlice { selected := make(TSlice, 0) for _, t := range slice { if predicate(t) { selected = append(selected, t) } } retur...
slices/slice.go
0.903449
0.610453
slice.go
starcoder
package core import ( "errors" "fmt" "io/ioutil" "log" "math" "math/rand" "os" "os/exec" "path" "sort" "strconv" "strings" "time" ) type ModelerType uint8 const ( ScriptBasedModelerType ModelerType = iota KNNModelerType ModelerType = iota + 1 ) func NewModelerType(t string) ModelerType { if ...
core/modeling.go
0.595022
0.470068
modeling.go
starcoder
package gobulk // TrackerNextContainersOpt represents optional paratemers which could be used to modify the tracker // behaviour in the NextContainers method. type TrackerNextContainersOpt int const ( // TrackerNextContainersOptNoLock prevents containers from being locked. TrackerNextContainersOptNoLock TrackerNext...
tracker.go
0.545286
0.418429
tracker.go
starcoder
package zcalendar import ( "bytes" "errors" "fmt" "sort" "strconv" "strings" ) // A component is a single unit of the event expression. It represent a // potentially repeating value or range in an unspecified time unit. type component struct { From int To int Repeat int } // parseValue create a compon...
component.go
0.776877
0.405743
component.go
starcoder
package p502 /** Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it has limited resources, it can only finish at most k distinct projects before the IPO. Help LeetCode de...
algorithms/p502/502.go
0.70304
0.635392
502.go
starcoder
package generation import ( "image" "image/color" "image/png" "io" "math" "github.com/breiting/g3next/noise" "github.com/g3n/engine/math32" ) type NoiseMap struct { data [][]float32 Width int Height int } func NewNoiseMap(seed int64, width, height int, ofs, scale float64, octaves int, persistance, lacu...
generation/noisemap.go
0.633977
0.471284
noisemap.go
starcoder
package yamlpath import ( "errors" "strings" "github.com/dprotaso/go-yit" "gopkg.in/yaml.v3" ) // Path is a compiled YAML path expression. type Path struct { f func(node, root *yaml.Node) yit.Iterator } // Find applies the Path to a YAML node and returns the addresses of the subnodes which match the Path. func...
pkg/yamlpath/path.go
0.682045
0.480479
path.go
starcoder
package hash import ( "math" "sort" "sync" "github.com/sachaservan/vec" ) /* This implements a hash function by finding the closest point of the leech lattice See Appendix B of http://web.mit.edu/andoni/www/papers/cSquared.pdf The lattice provides the densest sphere packing of 24 dimensional space. Sloane proved...
hash/lattice_hash.go
0.832169
0.523664
lattice_hash.go
starcoder
package cronschedule import ( "errors" "fmt" "strconv" "strings" ) // Range definitions for the Time fields of a cron entry const ( MinuteMinimum int = 0 MinuteMaximum int = 59 HourMinimum int = 0 HourMaximum int = 23 DayOfMonthMinimum int = 1 DayOfMonthMaximum int = 31 MonthMinimum int = 1 MonthMaximu...
cron-schedule.go
0.696371
0.529811
cron-schedule.go
starcoder
package schema import ( "fmt" "path" "github.com/ipld/go-ipld-prime" ) // FUTURE: we also want something *almost* identical to this Validate method, // but returning a `typed.Node` in the case of no error. // (Such a method would go in the same package as `typed.Node`, presumably.) // How do we avoid writing th...
schema/validate.go
0.5144
0.456168
validate.go
starcoder
package output import ( "github.com/Jeffail/benthos/lib/log" "github.com/Jeffail/benthos/lib/metrics" "github.com/Jeffail/benthos/lib/output/writer" "github.com/Jeffail/benthos/lib/types" ) //------------------------------------------------------------------------------ func init() { Constructors[TypeDynamoDB]...
lib/output/dynamodb.go
0.794664
0.759961
dynamodb.go
starcoder
package geom // Ported to Go from the C++ implementation made by <NAME> (https://github.com/juj/RectangleBinPack/) import ( "github.com/maxfish/go-libs/pkg/imath" "math" ) type RectNode struct { Rect // Width and Height include padding Index int // This index is used to keep track of which of the inpu...
pkg/geom/maxrectsbin.go
0.868367
0.70282
maxrectsbin.go
starcoder
package gofuzzheaders import ( "errors" "fmt" "reflect" ) type ConsumeFuzzer struct { data []byte CommandPart []byte RestOfArray []byte NumberOfCalls int position int } func IsDivisibleBy(n int, divisibleby int) bool { return (n % divisibleby) == 0 } f...
vendor/github.com/AdamKorcz/go-fuzz-headers/consumer.go
0.600305
0.408395
consumer.go
starcoder
package base import ( "github.com/corbym/gogiven/testdata" "sync" ) // Some holds the test context and has a reference to the test's testing.T type Some struct { sync.RWMutex globalTestingT TestingT testMetaData *TestMetaData testTitle string interestingGivens testdata.InterestingGivens captur...
base/some.go
0.525856
0.458288
some.go
starcoder
package v1alpha1 // NamespaceListerExpansion allows custom methods to be added to // NamespaceLister. type NamespaceListerExpansion interface{} // NamespaceNamespaceListerExpansion allows custom methods to be added to // NamespaceNamespaceLister. type NamespaceNamespaceListerExpansion interface{} // NamespaceAuthor...
client/listers/servicebus/v1alpha1/expansion_generated.go
0.505859
0.637934
expansion_generated.go
starcoder
package uniqrode import ( "fmt" "bytes" "errors" ) // UniQRode object type UniQRode struct { // should we draw QR-code in negative Invert bool mode asciiMapping data *[][]bool } // Stores map table and "resolution" for this table type asciiMapping struct { // "resolution" of the r...
ascii_mapper/ascii_mapper.go
0.707
0.530541
ascii_mapper.go
starcoder
package pflag import "strconv" // -- float32 Value type float32Value float32 func newFloat32Value(val float32, p *float32) *float32Value { *p = val return (*float32Value)(p) } func (f *float32Value) Set(s string) error { v, err := strconv.ParseFloat(s, 32) *f = float32Value(v) return err } func (f *float32Val...
vendor/github.com/spf13/pflag/float32.go
0.835986
0.491151
float32.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 SettlementParties11 struct { // First party in the set...
SettlementParties11.go
0.683525
0.49884
SettlementParties11.go
starcoder
package transaction /* Author - <NAME> Date - 11th October 2020 RFC3261 - SIP: Session Initiation Protocol https://tools.ietf.org/html/rfc3261#section-17.1 Client Transaction The client transaction provides its functionality through the maintenance of a state machine. The TU communicates wi...
sip/transaction/client.go
0.652131
0.433862
client.go
starcoder
package gendemographics // GenBusinesses returns a map of business to number of businesses for the given population size. func GenBusinesses(population int) map[string]int { res := make(map[string]int) for _, bt := range BusinessTypes { if population > bt.Serves { //log.Println(fmt.Sprintf("%q: %d", bt.Name, po...
gendemographics/business.go
0.62223
0.565539
business.go
starcoder
package geometry import ( "github.com/schidstorm/engine/gls" "github.com/schidstorm/engine/math32" "math" ) // NewCone creates a cone geometry with the specified base radius, height, // number of radial segments, number of height segments, and presence of a bottom cap. func NewCone(radius, height float64, radialS...
geometry/cone-cylinder.go
0.854824
0.667629
cone-cylinder.go
starcoder
package model3d import ( "fmt" "math" "github.com/heustis/tsp-solver-go/model" ) // Edge3D represents the line segment between two points type Edge3D struct { Start *Vertex3D `json:"start"` End *Vertex3D `json:"end"` vector *Vertex3D length float64 } // DistanceIncrease returns the difference in length b...
model3d/edge3d.go
0.897874
0.674288
edge3d.go
starcoder
package osc import ( "encoding/json" ) // Phase2Options Information about Phase 2 of the Internet Key Exchange (IKE) negotiation. type Phase2Options struct { // The Diffie-Hellman (DH) group numbers allowed for the VPN tunnel for phase 2. Phase2DhGroupNumbers *[]int32 `json:"Phase2DhGroupNumbers,omitempty"` // T...
v2/model_phase2_options.go
0.812644
0.464598
model_phase2_options.go
starcoder
package migratest import ( "database/sql" "testing" "time" "github.com/stretchr/testify/assert" "github.com/driver005/oauth/consent" "github.com/driver005/oauth/jwk" "github.com/driver005/oauth/models" "github.com/driver005/oauth/oauth2" sqlPersister "github.com/driver005/oauth/persistence/sql" "github.com...
persistence/sql/migratest/assertion_helpers.go
0.604632
0.625252
assertion_helpers.go
starcoder
package regexpmap import ( "regexp" "sort" ) // RegexpList is a utility struct that keeps an array of strings sorted by // length type RegexpList []string // NewRegexpList returns a new RegexpList, if any initialValues is in place // will add into the utility. func NewRegexpList(initialValues ...string) (result *...
pkg/fqdn/regexpmap/regexp_map.go
0.621081
0.469703
regexp_map.go
starcoder
package syntax import ( "github.com/strict-lang/sdk/pkg/compiler/grammar/token" "github.com/strict-lang/sdk/pkg/compiler/grammar/tree" ) // parseConditionalStatement parses a conditional statement and it's optional else-clause. func (parsing *Parsing) parseConditionalStatement() *tree.ConditionalStatement { parsin...
pkg/compiler/grammar/syntax/statement_control.go
0.660172
0.44089
statement_control.go
starcoder
package pattern import ( "fmt" "math" ) // Tessellation generator pattern. func (p Pattern) Tessellation() { // 3.4.6.4 semi-regular tessellation sideLen := p.reMap(p.seedToInt(0, 1), 0, 15, 10, 35) // was dMin: 5, dMax: 40 hexWidth := sideLen * 2 hexHeight := sideLen * math.Sqrt(3) triangleHeight := sideLen /...
geopattern/pattern/tessellation.go
0.617167
0.425068
tessellation.go
starcoder