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 quicksort import "math/rand" func insertionSort(a []int) { n := len(a) if n <= 1 { return; } for i := 0; i < n - 1; i++ { j := i + 1 key := a[j] for ;j > 0 && key < a[j-1]; j-- { a[j] = a[j - 1] } a[j] = key } } func min(a, b int...
Lecture 04- Quicksort/src/quicksort/quicksort.go
0.573678
0.428951
quicksort.go
starcoder
package linkedlist import ( "errors" "fmt" ) type node struct { Data interface{} Next *node } // linkedList is the actual linked list of nodes. type linkedList struct { Length int Head *node } // InitList initializes and returns the reference to a new linkedlist. func InitList() *linkedList { return &linke...
DataStructures/linkedList/singlyLinkedList.go
0.660063
0.411229
singlyLinkedList.go
starcoder
package bitmap import ( "unsafe" ) // Range iterates over all of the bits set to one in this bitmap. func (dst Bitmap) Range(fn func(x uint32)) { for blkAt := 0; blkAt < len(dst); blkAt++ { blk := (dst)[blkAt] if blk == 0x0 { continue // Skip the empty page } // Iterate in a 4-bit chunks so we can redu...
range.go
0.519034
0.506713
range.go
starcoder
package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // FeatureReference refers to a Feature resource and specifies its intended activation state. type FeatureReference struct { // Name is the name of the Feature resource, which represents a feature the system offers. // +kubebuilder:validati...
apis/config/v1alpha1/featuregate_types.go
0.76454
0.401629
featuregate_types.go
starcoder
package intset import ( "encoding/json" "sort" ) type Set struct{ items []int } // New creates a set with a given cap func New(size int) *Set { return &Set{items: make([]int, 0, size)} } // Use turns a slice into a set, re-using the underlying slice // WARNING: this function is destructive and will mutate the pa...
intset.go
0.732879
0.417212
intset.go
starcoder
package main import ( "errors" "fmt" ) // Orientation is a type that indicates in which direction the piece is moved. type Orientation int // Location is a type that represents a 2 dimensional coordinate. type Location struct { x int y int } // Direction constants. const ( Up Orientation = iota Right Down L...
board.go
0.787319
0.523847
board.go
starcoder
package part2 import "strings" type P struct { W int X int Y int Z int } func (p P) Neighbors2d() (all []P) { return append(all, p.North(), p.South(), p.East(), p.West(), p.NorthWest(), p.NorthEast(), p.SouthWest(), p.SouthEast(), ) } func (p P) Neighbors3d() (all []P) { all = append(all, p.Ne...
go/2020/day17/part2/part2.go
0.547948
0.454291
part2.go
starcoder
package rely import ( "math" ) // sequenceBuffer is a generic store for sent and received packets, as well as fragments of packets. // The entry data is the actual custom packet data that the user is trying to send type sequenceBuffer struct { Sequence uint16 NumEntries int EntrySequence []uint32 } const availab...
seqbuf.go
0.751101
0.469277
seqbuf.go
starcoder
package env import ( "fmt" "reflect" "strconv" "strings" "time" ) // setField determines a field's type and parses the given value // accordingly. An error will be returned if the field is unexported. func setBuiltInField(fieldValue reflect.Value, value string) (err error) { switch fieldValue.Kind() { case re...
vendor/github.com/codingconcepts/env/setter.go
0.61057
0.467393
setter.go
starcoder
package wkttoorb import ( "fmt" "strconv" "github.com/paulmach/orb" "github.com/pkg/errors" ) type Parser struct { *Lexer } func (p *Parser) Parse() (orb.Geometry, error) { t, err := p.scanToken() if err != nil { return nil, err } switch t.ttype { case Point: return p.parsePoint() case Linestring: ...
parser.go
0.690559
0.522263
parser.go
starcoder
package main import ( "flag" "fmt" "math" "os" ) // R is an ideal gas constant const R = 0.0831 // Temperature represents gas temperature type Temperature float64 // GasVolume is the amount of gas in liters type GasVolume float64 // CylinderVolume is cylinder size in liters type CylinderVolume float64 // GasW...
app.go
0.824356
0.58439
app.go
starcoder
package polygon import ( "fmt" ) var ErrNoData = fmt.Errorf("polygon: no data") // Polygon represents and enclosed area given a set of coordinates type Polygon struct { data []Point // these store the min/max of our points minLat, maxLat, minLon, maxLon float64 isMinMaxComputed bool } // Point re...
polygon.go
0.793306
0.52074
polygon.go
starcoder
package jumble // FrameOval sets the frame shape to // oval (default is rectangle) func FrameOval(val bool) func(f *Frame) { return func(fr *Frame) { fr.oval = val } } // FrameColor sets the frame color func FrameColor(hex string) func(f *Frame) { return func(fr *Frame) { fr.color = hex } } // FrameStroke en...
frame.go
0.878151
0.402598
frame.go
starcoder
package omgo import ( "encoding/json" "time" ) type ForecastJSON struct { Latitude float64 Longitude float64 Elevation float64 GenerationTime float64 `json:"generationtime_ms"` CurrentWeather CurrentWeather `json:"current_weather"` HourlyUnits map[string]strin...
parsing.go
0.700997
0.424949
parsing.go
starcoder
package main // The width and height of the individual boards and the game board as a whole. // This value must be odd, and values of 3 or 5 are recommended. const XY int = 5 // The coorindates of the central cell of the board. Since the board arrays are // zero-indexed, it is one less than expected. const CENTRE int...
board.go
0.676299
0.536738
board.go
starcoder
package tsplot import ( "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "image/color" ) // PlotOption defines the type used to configure the underlying *plot.Plot. // A function that returns PlotOption can be used to set options on the *plot.Plot. type PlotOption func(p *plot.Plot) // WithForeground sets the fore...
tsplot/options.go
0.851907
0.468851
options.go
starcoder
package grid import ( "math" aocmath "github.com/bewuethr/advent-of-code/go/math" ) // Vec2 represents a 2d vector with integer components. type Vec2 struct { x, y int } // Special 2d vectors var ( Origin = Vec2{0, 0} // Origin of the grid Ux = Vec2{1, 0} // Horizontal unit vector Uy = Vec2{0, 1} // V...
go/grid/vec2.go
0.927009
0.634671
vec2.go
starcoder
package docs import ( "bytes" "encoding/json" "strings" "github.com/alecthomas/template" "github.com/swaggo/swag" ) var doc = `{ "schemes": {{ marshal .Schemes }}, "swagger": "2.0", "info": { "description": "{{.Description}}", "title": "{{.Title}}", "contact": {}, "v...
application/docs/docs.go
0.548915
0.412708
docs.go
starcoder
package color import ( "errors" "math" colorful "github.com/lucasb-eyer/go-colorful" ) var colorMap map[string]colorful.Color var clusterMap map[string]colorful.Color func init() { colorMap = make(map[string]colorful.Color, len(colors)) for name, color := range colors { colorMap[name], _ = colorful.Hex(colo...
color/color.go
0.597608
0.431105
color.go
starcoder
package reflectx import ( "reflect" ) // IsSlice returns true if the given instance is a slice. func IsSlice(instance interface{}) bool { value, ok := instance.(reflect.Value) if !ok { value = reflect.ValueOf(instance) } return GetIndirectType(value.Type()).Kind() == reflect.Slice } // GetSliceType returns t...
reflectx/slice.go
0.796886
0.459015
slice.go
starcoder
package pe import ( "bytes" "encoding/binary" ) const ( // DansSignature ('DanS' as dword) is where the rich header struct starts. DansSignature = 0x536E6144 // RichSignature ('0x68636952' as dword) is where the rich header struct ends. RichSignature = "Rich" // AnoDansSigNotFound is reported when rich head...
richheader.go
0.713631
0.405566
richheader.go
starcoder
package main import ( "math" "math/rand" "github.com/hajimehoshi/ebiten" vec "github.com/woodywood117/vector" ) type Particle struct { pos, vel *vec.Vec color *ebiten.Image history []vec.Vec } // Create a particle with a random starting position/color. // Particles created by this function have no starti...
particle.go
0.653901
0.413004
particle.go
starcoder
package simplecsv // countIndexesInSlices counts how many times an integrer shows up in one or more slices func countIndexesInSlices(indexes [][]int) map[int]int { valuesMap := map[int]int{} var valueExists bool for _, toCount := range indexes { for _, v := range toCount { _, valueExists = valuesMap[v] if v...
logic.go
0.743634
0.557845
logic.go
starcoder
package blokus import "fmt" // BasicState is a quite inefficient way of storing the game state type BasicState struct { board [20][20]boardValue notPlayedPieces [4][]Piece lastMoveMono [4]bool startPiece Piece isPlayerTwoFirst bool // stored inverted, so initial state is correct isColorInvalid...
2021/blokus/basic_state.go
0.692538
0.403508
basic_state.go
starcoder
package main import ( "bufio" "fmt" "os" "strconv" "strings" "github.com/dowlandaiello/word_search/types" "github.com/gookit/color" ) // main is the main word search solver function. func main() { var grid *types.Grid // Declare grid buffer reader := bufio.NewReader(os.Stdin) // Initialize reader if len(...
main.go
0.563858
0.416322
main.go
starcoder
package gerber import ( "fmt" "io" "math" "github.com/gmlewis/go3d/float64/vec2" ) const ( sf = 1e6 // scale factor maxPts = 10000 ) // Shape represents the type of shape the apertures use. type Shape string const ( // RectShape uses rectangles for the aperture. RectShape Shape = "R" // CircleShape us...
gerber/primitives.go
0.82251
0.488649
primitives.go
starcoder
package parser import ( "fmt" "io" "strconv" "strings" "github.com/zoncoen/query-go/ast" "github.com/zoncoen/query-go/token" ) // Parser represents a parser. type Parser struct { s *scanner pos int tok token.Token lit string errors Errors } // NewParser returns a new parser. func NewParser(...
parser/parser.go
0.620162
0.421552
parser.go
starcoder
package lattice import ( "errors" "fmt" "github.com/arbori/population.git/population/space" ) type Lattice struct { Dimention int Limits []int lines []interface{} } func New(dim ...int) (Lattice, error) { return NewWithValue(nil, dim...) } func NewWithValue(value interface{}, dim ...int) (Lattice, er...
lattice/lattice.go
0.582135
0.492615
lattice.go
starcoder
package it import "fmt" type KeyType int64 const ( maxKey = KeyType(0x7fffffffffffffff) minKey = -maxKey - 1 ) const ( Red = 0 Black = 1 ) type Node struct { Low, High KeyType Upper KeyType Parent, Left, Right *Node Color uint8 } type Tree struct { Root, Nil *Node ...
Lecture 11- Augmenting data structures/src/it/it.go
0.559531
0.442817
it.go
starcoder
package mysql_nodejs import ( . "github.com/gocircuit/circuit/gocircuit.org/render" ) func RenderImage() string { return RenderHtml("Prepare host images", Render(imageBody, nil)) } const imageBody = ` <h1>Prepare host images</h1> <p>We are going to describe here a sequence of steps that will result in creating a ...
gocircuit.org/tutorial/mysql-nodejs/image.go
0.547464
0.499084
image.go
starcoder
package game import ( "math" "github.com/faiface/pixel" ) const ( bulletSizeX = int64(1) bulletSizeY = int64(2) ) type bullet struct { sprite pixel.Sprite direction Direction x, y int64 size [2]int64 state State tank *tank } func (g *game) loadBullet(x int64, y int64, direction Dire...
game/bullet.go
0.590779
0.485844
bullet.go
starcoder
package model import ( "encoding/binary" "fmt" "math" ) // Used to down size the frequences to a 9 bit ints // XXX: we could also use 10.7Hz directly const freqStep = MaxFreq / float64(1<<9) // Used to down size the delta times to 14 bit ints (we use 16s as the max duration) const deltaTimeStep = 16 / float64(1<<...
internal/pkg/model/table.go
0.712532
0.546678
table.go
starcoder
package list import "strings" // Head returns the FIRST item in a string-based-list func Head(value string, delimiter string) string { index := strings.Index(value, delimiter) if index == -1 { return value } return value[:index] } // Tail returns any values in the string-based-list AFTER the first item func...
list.go
0.766992
0.524029
list.go
starcoder
package runtime import ( "math" "sort" "sync" "github.com/rcrowley/go-metrics" ) // Initial slice capacity for the values stored in a ResettingHistogram const InitialResettingHistogramSliceCap = 10 // newResettingHistogram constructs a new StandardResettingHistogram func newResettingHistogram() Histogram { if ...
runtime/resetting_histogram.go
0.848941
0.71144
resetting_histogram.go
starcoder
package main import ( "fmt" "math" ) type MatrixPoint [2]uint64 //--------------------------------------------------------------------------------------- const ROW = 1000 //--------------------------------------------------------------------------------------- type GeoMatrixData struct { polygon Polygon data ...
go/GeoMatrix.go
0.503906
0.472014
GeoMatrix.go
starcoder
// Package slicer provides an easy API to slice a stream of bytes using a custom slice of indicies. package slicer import ( "fmt" ) // Slicer provides an easy API to slice a stream of bytes. type Slicer struct { indicies []int strict bool // strict mode } // New returns a new slicer that slices an input stream...
pkg/slicer/Slicer.go
0.751101
0.672091
Slicer.go
starcoder
package gofuncs import ( "fmt" "math/big" "math/cmplx" "reflect" ) const ( indexOfErrorMsg = "slc must be a slice" valueOfKeyErrorMsg = "mp must be a map" filterErrorMsg = "fn must be a non-nil function of one argument of any type that returns bool" lessThanErrorMsg = "val must be a lessable type" ...
funcs.go
0.729712
0.423965
funcs.go
starcoder
package uuidnil import ( "log" "reflect" "github.com/google/uuid" ) // assignFunc assigns the from value to the to value. type assignFunc func(to reflect.Value, from reflect.Value) error // proxyArray returns a proxy type and assign function for the specified array // type. func proxyArray(typ reflect.Type, opts...
proxy.go
0.706596
0.498352
proxy.go
starcoder
package milight import ( "net" "time" "github.com/lucasb-eyer/go-colorful" ) // Zone constants are used to declare the target zone const ( ZoneAll int = iota Zone1 Zone2 Zone3 Zone4 ) var ( trailer byte = 0x55 on = [][]byte{{0x42, 0x00}, {0x45, 0x00}, {0x47, 0x00}, {0x49, 0x00}, {0x4B, 0x00}} off =...
milight.go
0.659953
0.403802
milight.go
starcoder
package main import ( "fmt" "os" "strconv" "time" rpio "github.com/stianeikeland/go-rpio" ) var timeout = 100000 // SignalPair is a pair of values that show the state of the ir receiver type SignalPair struct { state rpio.State // State of the ir receiver (0 = pulse, 1 = gap) time int64 // Time the ir ...
decode.go
0.596081
0.413004
decode.go
starcoder
package coordinate import ( "math" "math/rand" "time" ) type Coordinate struct { Vec []float64 Error float64 Adjustment float64 Height float64 } const ( secondsToNanoseconds = 1.0e9 zeroThreshold = 1.0e-6 ) type DimensionalityConflictError struct{} func (e DimensionalityConflictError) Error() string {...
hashicorp/serf/coordinate/coordinate.go
0.819749
0.450239
coordinate.go
starcoder
package client // ToBooler converts a redis value to a bool. // In case the conversion is not supported a ConversionError is returned. func (r *result) ToBool() (bool, error) { if err := r.wait(); err != nil { return false, err } return r.value.ToBool() } // ToFloat64 converts a redis value to a float64. // In ...
client/result_gen.go
0.849753
0.459622
result_gen.go
starcoder
package main import ( "math/rand" "github.com/hajimehoshi/ebiten" "github.com/hajimehoshi/ebiten/inpututil" ) type Point struct { X, Y int } func LinePoints(x0, y0, x1, y1 int) []Point { var points []Point // implemented straight from WP pseudocode dx := x1 - x0 if dx < 0 { dx = -dx } dy := y1 - y0 if...
util.go
0.540196
0.465145
util.go
starcoder
package math32 // Line3 represents a 3D line segment defined by a start and an end point. type Line3 struct { start Vector3 end Vector3 } // NewLine3 creates and returns a pointer to a new Line3 with the // specified start and end points. func NewLine3(start, end *Vector3) *Line3 { l := new(Line3) l.Set(start...
math32/line3.go
0.920034
0.666629
line3.go
starcoder
package actions import ( "github.com/LindsayBradford/crem/internal/pkg/model/action" "github.com/LindsayBradford/crem/internal/pkg/model/planningunit" ) const HillSlopeRestorationType action.ManagementActionType = "HillSlopeRestoration" func NewHillSlopeRestoration() *HillSlopeRestoration { return new(HillSlopeR...
internal/pkg/model/models/catchment/actions/HillSlopeRestoration.go
0.781664
0.544983
HillSlopeRestoration.go
starcoder
package idx import ( "github.com/reearth/reearth-cms/server/pkg/util" "golang.org/x/exp/slices" ) type List[T Type] []ID[T] type RefList[T Type] []*ID[T] func ListFrom[T Type](ids []string) (List[T], error) { return util.TryMap(ids, From[T]) } func MustList[T Type](ids []string) List[T] { return util.Must(List...
server/pkg/id/idx/list.go
0.501221
0.608681
list.go
starcoder
package evolution import ( "fmt" "math/rand" ) /** Selection is the stage of a genetic algorithm in which individual genomes are chosen from a population for later breeding (using the crossover operator). A generic selection procedure may be implemented as follows: 1. The Fitness function is evaluated for each ...
evolution/parentselection.go
0.81538
0.775052
parentselection.go
starcoder
package sudoku import ( "errors" ) // Take an unsolved Sudoku input and return a solved Sudoku output func solveSerial(sudokuIn Sudoku, iter ...int) (sudokuOut Sudoku, solved bool, iteration int, err error) { /* Solve the Sudoku puzzle as follows: 1) mapper: find out potential numbers that can be filled for ea...
sudoku/sudokusolveserial.go
0.513181
0.631552
sudokusolveserial.go
starcoder
package tart import ( "sort" ) // Developed by <NAME> in 1976 and featured in Stocks & Commodities // Magazine in 1985, the Ultimate Oscillator is a momentum oscillator designed // to capture momentum across three different timeframes. The multiple timeframe // objective seeks to avoid the pitfalls of other oscillat...
ultosc.go
0.642993
0.442335
ultosc.go
starcoder
package ogame import "strconv" // MissionID represent a mission id type MissionID int func (m MissionID) String() string { switch m { case Attack: return "Attack" case GroupedAttack: return "GroupedAttack" case Transport: return "Transport" case Park: return "Park" case ParkInThatAlly: return "ParkIn...
constants.go
0.681303
0.401189
constants.go
starcoder
package typ import ( "fmt" "sort" ) // Vars is a sorted set of type variable kinds. type Vars []Kind func (vs Vars) Len() int { return len(vs) } func (vs Vars) Less(i, j int) bool { return vs[i] < vs[j] } func (vs Vars) Swap(i, j int) { vs[i], vs[j] = vs[j], vs[i] } // Copy returns a copy of vs fun...
typ/vars.go
0.713831
0.450118
vars.go
starcoder
package coldata // zeroedNulls is a zeroed out slice representing a bitmap of size BatchSize. // This is copied to efficiently clear a nulls slice. var zeroedNulls [(BatchSize-1)>>6 + 1]uint64 // filledNulls is a slice representing a bitmap of size BatchSize with every // single bit set. var filledNulls [(BatchSize-...
pkg/sql/exec/coldata/nulls.go
0.712532
0.582075
nulls.go
starcoder
package pquerier import ( "encoding/binary" "math" "github.com/v3io/v3io-tsdb/pkg/aggregate" ) /* main query flow logic fire GetItems to all partitions and tables iterate over results from first to last partition hash lookup (over labels only w/o name) to find dataFrame if not found create new dataFrame bas...
vendor/github.com/v3io/v3io-tsdb/pkg/pquerier/collector.go
0.566378
0.477676
collector.go
starcoder
package plaid import ( "encoding/json" ) // RecipientBACSNullable struct for RecipientBACSNullable type RecipientBACSNullable struct { // The account number of the account. Maximum of 10 characters. Account *string `json:"account,omitempty"` // The 6-character sort code of the account. SortCode *string `json:"s...
plaid/model_recipient_bacs_nullable.go
0.765067
0.606528
model_recipient_bacs_nullable.go
starcoder
package pair import ( "fmt" "math" "sort" ) type Point struct { x, y float64 } func NewPoint(x, y float64) *Point { return &Point{x, y} } func (p *Point) String() string { return fmt.Sprintf("P(%f,%f)", p.x, p.y) } func (p *Point) X() float64 { return p.x } func (p *Point) Y() float64 { return p.y } func...
pair/pair.go
0.611498
0.533701
pair.go
starcoder
package inmemory import ( "fmt" "regexp" "strings" "go.jlucktay.dev/arrowverse/pkg/models" ) type subexpressionName string func (s subexpressionName) String() string { return string(s) } const ( multiPartNumber subexpressionName = "mpn" multiPartTitle subexpressionName = "mpt" ) var ( rePart = regexp.Mus...
pkg/collection/inmemory/sort.go
0.54698
0.407451
sort.go
starcoder
package copypasta import ( "math" "math/bits" ) /* FFT: fast Fourier transform 快速傅里叶变换 https://en.wikipedia.org/wiki/Fast_Fourier_transform 【推荐】一小时学会快速傅里叶变换 https://zhuanlan.zhihu.com/p/31584464 傅里叶变换学习笔记 https://www.luogu.com.cn/blog/command-block/fft-xue-xi-bi-ji 从多项式乘法到快速傅里叶变换 http://blog.miskcoo.com/2015/04/po...
copypasta/math_fft.go
0.515864
0.473962
math_fft.go
starcoder
package transformation import ( "bytes" "encoding/binary" "errors" "fmt" "strings" "github.com/golang/protobuf/proto" equality "github.com/solo-io/protoc-gen-ext/pkg/equality" ) // ensure the imports are used var ( _ = errors.New("") _ = fmt.Print _ = binary.LittleEndian _ = bytes.Compare _ = strings.Co...
projects/gloo/pkg/api/external/envoy/extensions/transformation/transformation.pb.equal.go
0.632049
0.424412
transformation.pb.equal.go
starcoder
// Package jwtauth provides functions and structs that allowes the generation // and validation of JWTs package jwtauth import ( "errors" "time" jwt "github.com/dgrijalva/jwt-go" ) // JwtWrapper represents the wrapper that contains values of the JWT except for // the claims type JwtWrapper struct { SecretKey ...
BackEnd/jwtauth/jwtauth.go
0.672224
0.444625
jwtauth.go
starcoder
package vectormath import "fmt" const g_SLERP_TOL = 0.999 func V3Copy(result *Vector3, vec *Vector3) { result.X = vec.X result.Y = vec.Y result.Z = vec.Z } func V3MakeFromElems(result *Vector3, x, y, z float32) { result.X = x result.Y = y result.Z = z } func V3MakeFromP3(result *Vector3, pnt *Point3) { res...
vec_aos.go
0.818193
0.50177
vec_aos.go
starcoder
package main // TinyGo version of the 1st WebGL Fundamentals lesson // https://webglfundamentals.org/webgl/lessons/webgl-fundamentals.html import ( "math/rand" "syscall/js" "github.com/justinclift/webgl" ) var ( // Vertex shader source code vertCode = ` // an attribute will receive data from a buffer attribu...
main.go
0.75274
0.406332
main.go
starcoder
package sheet // BaseCofD2e describes the base of every CofD2e sheet type BaseCofD2e struct { // Core Name string `json:"name"` Chronicle string `json:"chronicle"` Concept string `json:"concept"` Experiences int `json:"experiences"` Beats int `json:"beats"` Notes []Note `json:"no...
usecases/sheet/cofd2e.go
0.717507
0.451447
cofd2e.go
starcoder
package json2 import ( "unicode" ) // Scanner is a func that returns a subset of the input and a success bool. type Scanner func([]rune) ([]rune, bool) // If returns a scanner that accepts the a rune if it satisfies the condition. func If(condition func(rune) bool) Scanner { return func(input []rune) ([]rune, bool...
scanner.go
0.753376
0.480052
scanner.go
starcoder
package commitment import ( "fmt" "io" "math/big" "gitlab.com/alephledger/threshold-ecdsa/pkg/curve" ) //NewElGamalFactory creates a new ElGamal-type Commitments factory func NewElGamalFactory(h curve.Point) *ElGamalFactory { egf := &ElGamalFactory{h: h} egf.curve = curve.NewSecp256k1Group() egf.neutral = egf...
pkg/crypto/commitment/commitment.go
0.859133
0.429429
commitment.go
starcoder
// Package convertor implements some functions to convert data. package convertor import ( "bytes" "encoding/gob" "encoding/json" "fmt" "reflect" "regexp" "strconv" "strings" ) // ToBool convert string to a boolean func ToBool(s string) (bool, error) { return strconv.ParseBool(s) } // ToBytes convert inter...
convertor/convertor.go
0.784071
0.413418
convertor.go
starcoder
package cue import ( "cuelang.org/go/cue/token" "cuelang.org/go/internal/core/adt" ) // Op indicates the operation at the top of an expression tree of the expression // use to evaluate a value. type Op = adt.Op // Values of Op. const ( NoOp Op = adt.NoOp AndOp Op = adt.AndOp OrOp Op = adt.OrOp SelectorOp O...
cue/op.go
0.573798
0.563558
op.go
starcoder
package iso20022 // Completion of a securities settlement instruction, wherein securities are delivered/debited from a securities account and received/credited to the designated securities account. type ReceiveInformation11 struct { // Date and time at which the securities are to be exchanged at the International Ce...
ReceiveInformation11.go
0.731634
0.475118
ReceiveInformation11.go
starcoder
package radiance import ( "image" "image/color" "math" ) const R_LUMINANCE = 0.2126 const G_LUMINANCE = 0.7152 const B_LUMINANCE = 0.0722 const DISPLAY_LUMINANCE_MAX = 200.0 const GAMMA_ENCODE = 0.45 type Radiance struct { R, G, B float64 } type RadianceImage struct { Width, Height int pix []float...
src/minilight/radiance/radiance.go
0.763043
0.467818
radiance.go
starcoder
package modelchecking import ( "errors" "fmt" ) /* TransitionSystemState Description: This type is an object which contains the Transition System's State. */ type TransitionSystemState struct { Name string System *TransitionSystem } /* Equals Description: Checks to see if two states in the transition system ...
transitionsystemstate.go
0.68056
0.48932
transitionsystemstate.go
starcoder
package artifacts import ( "github.com/pkg/errors" "github.com/insolar/insolar/insolar" ) func NewCodeDescriptor(code []byte, machineType insolar.MachineType, ref insolar.Reference) CodeDescriptor { return &codeDescriptor{ code: code, machineType: machineType, ref: ref, } } // CodeDescript...
logicrunner/artifacts/descriptors.go
0.840455
0.429788
descriptors.go
starcoder
package gosnowth import ( "bytes" "context" "encoding/json" "fmt" "net/url" "path" "strconv" "time" "github.com/openhistogram/circonusllhist" ) // HistogramValue values are individual data points of a histogram metric. type HistogramValue struct { Time time.Time Period time.Duration Data map[string]i...
vendor/github.com/circonus-labs/gosnowth/histogram.go
0.805517
0.404507
histogram.go
starcoder
package convert import ( "errors" "github.com/go-spatial/tegola" "github.com/go-spatial/tegola/basic" "github.com/go-spatial/tegola/geom" ) var ErrUnknownGeometry = errors.New("Unknown Geometry") func ToGeom(g tegola.Geometry) (geom.Geometry, error) { switch geo := g.(type) { default: return nil, ErrUnknown...
internal/convert/convert.go
0.508056
0.503235
convert.go
starcoder
package v1 import ( "bytes" "encoding/binary" "errors" "fmt" "strings" "github.com/golang/protobuf/proto" equality "github.com/solo-io/protoc-gen-ext/pkg/equality" ) // ensure the imports are used var ( _ = errors.New("") _ = fmt.Print _ = binary.LittleEndian _ = bytes.Compare _ = strings.Compare _ = e...
projects/gloo/pkg/api/v1/upstream.pb.equal.go
0.538498
0.435421
upstream.pb.equal.go
starcoder
package histogram import ( "sort" "strconv" "strings" "github.com/grokify/mogo/type/stringsutil" "github.com/grokify/gocharts/v2/data/table" ) type HistogramSets struct { Name string HistogramSetMap map[string]*HistogramSet } func NewHistogramSets(name string) *HistogramSets { return &HistogramS...
data/histogram/histogram_sets.go
0.628977
0.487551
histogram_sets.go
starcoder
package nn import ( mat "github.com/nlpodyssey/spago/pkg/mat32" "github.com/nlpodyssey/spago/pkg/ml/ag" ) // ProcessingMode regulates the different usage of some operations (e.g. Dropout, BatchNorm, etc.), // depending on whether you're doing training or inference. // Failing to set the right mode will yield incon...
pkg/ml/nn/model.go
0.817647
0.618435
model.go
starcoder
package graphics import ( "image" "image/color" "math" ) // reference white point var d65 = [3]float64{0.95047, 1.00000, 1.08883} func labF(t float64) float64 { if t > 6.0/29.0*6.0/29.0*6.0/29.0 { return math.Cbrt(t) } return t/3.0*29.0/6.0*29.0/6.0 + 4.0/29.0 } func square(value float64) float64 { return ...
src/github.com/inkyblackness/shocked-client/graphics/StandardBitmapper.go
0.843605
0.407805
StandardBitmapper.go
starcoder
package iso20022 // Details about tax paid, or to be paid, to the government in accordance with the law, including pre-defined parameters such as thresholds and type of account. type TaxInformation3 struct { // Party on the credit side of the transaction to which the tax applies. Creditor *TaxParty1 `xml:"Cdtr,omit...
TaxInformation3.go
0.739422
0.560614
TaxInformation3.go
starcoder
package iso20022 // Margin required to cover the risk because of the price fluctuations occurred on the unsettled exposures towards central counterparty. type VariationMargin3 struct { // Provides details about the security identification. FinancialInstrumentIdentification *SecurityIdentification14 `xml:"FinInstrmI...
VariationMargin3.go
0.813868
0.442396
VariationMargin3.go
starcoder
package color import ( "github.com/juan-medina/goecs" ) // Solid represents a RGBA color type Solid struct { R uint8 // R is the green Color component G uint8 // G is the green Color component B uint8 // B is the blue Color component A uint8 // A is the alpha Color component } // Type return this goecs.Componen...
components/color/color.go
0.881876
0.46035
color.go
starcoder
package seamcarving import ( "image" "github.com/wangjohn/quickselect" ) type EnergyFunction int const ( Energy1 EnergyFunction = iota Energy2 EnergyFunction = iota ) type Seam struct { Points []image.Point } func Resize(source image.Image, targetHeight, targetWidth int) (image.Image, error) { energie...
seamcarving/seamcarving.go
0.530723
0.473596
seamcarving.go
starcoder
package iso20022 // Information related to the transportation of goods by air. type TransportByAir4 struct { // Place from where the goods must leave. DepartureAirport *AirportName1Choice `xml:"DprtureAirprt"` // Place where the goods must arrive. DestinationAirport *AirportName1Choice `xml:"DstnAirprt"` // Fl...
TransportByAir4.go
0.787359
0.511046
TransportByAir4.go
starcoder
package base import "time" // ThroughputMetric is used to measure the byte throughput of some component // that performs work in a single-threaded manner. The throughput can be // approximated by Bytes/(WorkDuration+IdleTime). The idle time is represented // separately, so that the user of this metric could approxim...
internal/base/metrics.go
0.845974
0.405125
metrics.go
starcoder
package auth0fga import ( "encoding/json" ) // Assertion struct for Assertion type Assertion struct { TupleKey *TupleKey `json:"tuple_key,omitempty"` Expectation bool `json:"expectation"` } // NewAssertion instantiates a new Assertion object // This constructor will assign default values to properties tha...
model_assertion.go
0.728169
0.469155
model_assertion.go
starcoder
package beautiful_array /* 对于某些固定的 N,如果数组 A 是整数 1, 2, ..., N 组成的排列,使得: 对于每个 i < j,都不存在 k 满足 i < k < j 使得 A[k] * 2 = A[i] + A[j]。 那么数组 A 是漂亮数组。 给定 N,返回任意漂亮数组 A(保证存在一个)。 示例 1: 输入:4 输出:[2,1,4,3] 示例 2: 输入:5 输出:[3,1,2,5,4] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/beautiful-array 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注...
solutions/beautiful-array/d.go
0.530236
0.523725
d.go
starcoder
package operator func calculateAddArray(array []float64, addarray []float64, numCPU int, channels []chan []float64) []float64 { addChannel := make([]float64, len(array)) for i := 0; i < numCPU; i++ { from := int(i * len(array) / numCPU) to := int((i + 1) * len(array) / numCPU) go addArrayRoutine(array[from:to]...
src/calculation/operator/calculate.go
0.504883
0.405743
calculate.go
starcoder
package Physics import ( "math" "fmt" ) type Vector struct{ X, Y, Z float64 } func (v *Vector) IsFilled() bool { if v.X != 0 || v.Y != 0 || v.Z != 0 { return true } return false } func (v *Vector) Rotate(axis *Vector, angle float64) *Vector { if axis == nil || !axis.IsFilled() { panic("Cannot Rotate Ve...
GoFiles/Utilities/Physics/vector.go
0.803829
0.51879
vector.go
starcoder
package ast //OperationType : A constant that defines the type of operation we're dealing with to allow information to be extracted by //converting the operation to the correct type. type OperationType int8 //StatementType : A constant that defines the type of statement we're dealing with to allow the compiler to gen...
src/ast/node.go
0.655446
0.634897
node.go
starcoder
package chainnode import ( sdk "github.com/hbtc-chain/bhchain/types" "github.com/stretchr/testify/mock" ) type MockChainnode struct { mock.Mock } var _ Chainnode = (*MockChainnode)(nil) func (m *MockChainnode) SupportChain(chain string) bool { args := m.Called(chain) return args.Bool(0) } func (m *MockChainno...
chainnode/mock.go
0.753557
0.439807
mock.go
starcoder
package iter import "unicode/utf8" // Iterator[T] represents an iterator yielding elements of type T. type Iterator[T any] interface { // Next yields a new value from the Iterator. Next() Option[T] } type stringIter struct { input string } // String returns an Iterator yielding runes from the supplied string. fu...
iterator.go
0.82308
0.444505
iterator.go
starcoder
package ytbx import ( "fmt" yaml "gopkg.in/yaml.v2" ) // Grab get the value from the provided YAML tree using a path to traverse through the tree structure func Grab(obj interface{}, pathString string) (interface{}, error) { path, err := ParsePathString(pathString, obj) if err != nil { return nil, err } po...
vendor/github.com/homeport/ytbx/pkg/v1/ytbx/getting.go
0.697403
0.472501
getting.go
starcoder
package geom // A Point represents a single point. type Point struct { geom0 } // NewPoint allocates a new Point with layout l and all values zero. func NewPoint(l Layout) *Point { return NewPointFlat(l, make([]float64, l.Stride())) } // NewPointFlat allocates a new Point with layout l and flat coordinates flatCoo...
vendor/github.com/twpayne/go-geom/point.go
0.915696
0.680608
point.go
starcoder
package slices import ( "reflect" "github.com/fatih/structs" "github.com/pkg/errors" ) var ( // ErrNotSlice happens when the value passed is not a slice. ErrNotSlice = errors.New("not slice") // ErrNotString happens when the value of the field is not a string. ErrNotString = errors.New("not string") // Err...
slices/slices.go
0.733738
0.400339
slices.go
starcoder
package types import ( "bytes" "errors" "math" "strconv" "time" pb "github.com/go-graphite/carbonzipper/carbonzipperpb3" pickle "github.com/lomik/og-rek" ) var ( // ErrWildcardNotAllowed is an eval error returned when a wildcard/glob argument is found where a single series is required. ErrWildcardNotAllowed...
expr/types/types.go
0.686895
0.431524
types.go
starcoder
package series import ( "fmt" "math" "strconv" ) type floatListElement struct { e []float64 nan bool } // force floatListElement struct to implement Element interface var _ Element = (*floatListElement)(nil) func (e *floatListElement) Set(value interface{}) { e.nan = false switch val := value.(type) { cas...
series/type-float-list.go
0.507324
0.555857
type-float-list.go
starcoder
package visualregression import ( "image" "image/color" "image/draw" "image/png" "os" ) var HighlightColor = color.RGBA{ R: 255, G: 0, B: 255, A: 255, } func readAndDecode(filename string) (image.Image, error) { f, err := os.Open(filename) if err != nil { return nil, err } defer f.Close() img, err...
images.go
0.665302
0.581481
images.go
starcoder
package route import ( "fmt" "github.com/yasshi2525/RushHour/entities" ) // Model has minimux distance route information to specific Node. type Model struct { GoalIDs []uint Nodes map[entities.ModelType]map[uint]*Node Edges map[entities.ModelType]map[uint]*Edge } // NewModel creates instance or copies orig...
route/model.go
0.613237
0.416975
model.go
starcoder
package smtproofs import ( "crypto/sha256" "fmt" ics23 "github.com/confio/ics23/go" "github.com/lazyledger/smt" ) // PreimageMap represents an interface for accessing hashed tree paths and retrieving their // corresponding preimages. type PreimageMap interface { // KeyFor returns the preimage (key) for given pa...
store/tools/ics23/smt/create.go
0.63443
0.438845
create.go
starcoder
package draw2d import ( "image/color" "github.com/lafriks/go-svg" "github.com/lafriks/go-svg/renderer" "github.com/llgcode/draw2d" ) // Draw the parsed SVG into the graphic context with the specified options. func Draw(gc draw2d.GraphicContext, s *svg.Svg, opts ...renderer.RenderOption) { opt := renderer.Optio...
renderer/draw2d/draw.go
0.658418
0.457803
draw.go
starcoder
package array import ( "reflect" ) type Array []interface{} // Create an `Array` func NewArray(array ...interface{}) Array { a := Array{} if len(array) > 1 { a.Push(array...) } else if len(array) == 1 { v := reflect.ValueOf(array[0]) for i := 0; i < v.Len(); i++ { a.Push(v.Index(i).Interface()) } } ...
array/array.go
0.733261
0.511168
array.go
starcoder
package layer import ( "fmt" "github.com/aunum/log" g "gorgonia.org/gorgonia" t "gorgonia.org/tensor" ) // Conv2D is a 2D convolution. type Conv2D struct { // Input channels. // required Input int // Output channels. // required Output int // Height of the filter. // required Height int // Width of...
vendor/github.com/aunum/goro/pkg/v1/layer/conv2d.go
0.831143
0.425247
conv2d.go
starcoder