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 recurring import ( "time" "github.com/icholy/recurring/timeutil" ) // Next finds the next occurence of the temporal expression starting at t func Next(t time.Time, te TemporalExpression) time.Time { t = timeutil.BeginningOfDay(t) for !te.Includes(t) { t = t.Add(24 * time.Hour) } return t } // NextN ...
recurring.go
0.807954
0.661267
recurring.go
starcoder
package weather import "fmt" // ModulesBatteryStatus represents the battery status for additionnal modules type ModulesBatteryStatus int const ( // ModulesBatteryMax represents the maximum level of a module battery ModulesBatteryMax ModulesBatteryStatus = 6000 // ModulesBatteryFull represents the full level of a ...
weather/model_common.go
0.677367
0.418935
model_common.go
starcoder
package models import ( "math/rand" "strings" ) // batchNameLists: these lists are each randomly shuffled and then one item is // pulled from each list to generate a batch name. In a perfect world, all // lists would be the same size, just to make for absolute uniqueness per // iteration, but that isn't worth worr...
src/models/batch_name.go
0.500732
0.424591
batch_name.go
starcoder
package gobot import ( "errors" ) const ( // EmptyStone means no one has a stone in this space EmptyStone Stone = iota // BlackStone is a stone of black's BlackStone // WhiteStone is a stone of white's WhiteStone // BoundaryStone represents a stone that is outside the board dimensions BoundaryStone ) // Sto...
board.go
0.623492
0.435301
board.go
starcoder
package track import ( "fmt" "github.com/aunum/log" g "gorgonia.org/gorgonia" ) // TrackedValue is a value being tracked. type TrackedValue interface { // Name of the value. Name() string // Scalar value. Scalar() float64 // Print the value. Print() // Data converts the value to a historical value. Dat...
pkg/v1/track/value.go
0.772101
0.422832
value.go
starcoder
package swagger type BillingSettings struct { // Time length of the grace period between the end of a billing cycle and invoice generation. *NOTE*: The specified length is unitless. Unit is designated with the `invoice_grace_period_unit` field. InvoiceGracePeriodLength int32 `json:"invoice_grace_period_length,omitem...
internal/swagger/model_billing_settings.go
0.851737
0.505859
model_billing_settings.go
starcoder
package pbars import ( "fmt" "math" "time" ) type NaiveRateWatcher struct { firstupdatetime time.Time lastseenposition int64 lastupdatetime time.Time estimatedPercentage float32 estimatedRemaining time.Duration estimatedRate float32 hasEstimate bool timefunc func() tim...
naive_rate_watcher.go
0.621426
0.442998
naive_rate_watcher.go
starcoder
package ident import ( "bytes" ) // BytesID is a small utility type to avoid the heavy weight of a true ID // implementation when using in high throughput places like keys in a map. type BytesID []byte // var declaration to ensure package type BytesID implements ID var _ ID = BytesID(nil) // Bytes returns the und...
src/x/ident/bytes_id.go
0.820577
0.449091
bytes_id.go
starcoder
package domain type View []*Block type Shape struct { views []View viewIndex int visible bool } func (s *Shape) Init() { s.viewIndex = 0 s.visible = false } func (s *Shape) Rotate() { s.viewIndex += 1 if s.viewIndex > len(s.views)-1 { s.viewIndex = 0 } } func (s *Shape) RotateBack() { s.viewIndex ...
domain/shapes.go
0.741112
0.693006
shapes.go
starcoder
package cirno import ( "fmt" "math" ) // Contact returns the contact points between two given shapes // (if they exist). func Contact(one, other Shape) ([]Vector, error) { if one == nil { return nil, fmt.Errorf("the first shape is nil") } if other == nil { return nil, fmt.Errorf("the second shape is nil") ...
contact.go
0.820901
0.583352
contact.go
starcoder
package main import "math" var ( nan = math.NaN() inf = math.Inf(1) zero = 0.0 ) var tests = []struct { f, g complex128 out complex128 }{ {complex(zero, zero), complex(zero, zero), complex(nan, nan)}, {complex(zero, zero), complex(zero, -zero), complex(nan, nan)}, {complex(zero, zero), complex(z...
test/cmplxdivide1.go
0.533397
0.859664
cmplxdivide1.go
starcoder
package suncalc import ( "errors" "github.com/soniakeys/meeus/julian" "math" "time" ) const ( J1970 float64 = 2440588 J2000 float64 = 2451545 deg2rad = math.Pi / 180 M0 = 357.5291 * deg2rad M1 = 0.98560028 * deg2rad J0 = 0.0009 J1 = 0.0053 J2...
suncalc/suncalc.go
0.650689
0.411998
suncalc.go
starcoder
package montecarlo import ( "github.com/uluyol/heyp-agents/go/intradc/sampling" "golang.org/x/exp/rand" ) func estimateUsageGeneric(rng *rand.Rand, sampler sampling.Sampler, usages []float64, tracker *sampleTracker) usageEstimate { aggEst := sampler.NewAggUsageEstimator() distEst := sampler.NewUsageDistEstimator...
go/intradc/montecarlo/zestusage.go
0.675015
0.46563
zestusage.go
starcoder
package unit // Length represents a SI unit of length (in meters, m) type Length Unit // ... const ( // SI Yoctometer = Meter * 1e-24 Zeptometer = Meter * 1e-21 Attometer = Meter * 1e-18 Femtometer = Meter * 1e-15 Picometer = Meter * 1e-12 Nano...
length.go
0.900486
0.538012
length.go
starcoder
package geojson import ( "github.com/quesurifn/tile38/pkg/geojson/geo" "github.com/quesurifn/tile38/pkg/geojson/geohash" "github.com/quesurifn/tile38/pkg/geojson/poly" ) // SimplePoint is a geojson object with the type "Point" and where there coordinate is 2D and there is no bbox. type SimplePoint struct { X, Y f...
pkg/geojson/simplepoint.go
0.838647
0.660234
simplepoint.go
starcoder
package nune import ( "sync" "github.com/vorduin/slices" ) // handleZip processes an elementwise operation accordingly. func handleZip[T Number](lhs, rhs Tensor[T], f func(T, T) T, nCPU int) { if lhs.Rank() == 0 { lhs.Ravel()[0] = f(lhs.Ravel()[0], rhs.Ravel()[0]) } var wg sync.WaitGroup for i := 0; i < nC...
zip.go
0.663015
0.411229
zip.go
starcoder
package gravitree import ( "fmt" "math" ) /* NOTE: Many of the loops in this file are very very hot, so some optimizations are a bit aggressive. */ // Potential computes the potential for each point in the tree. Potentials are // written to the array phi and are in units where G * mp = 1. func (t *Tree) Potential(...
potential.go
0.710427
0.58433
potential.go
starcoder
package memory import ( "fmt" "strings" "github.com/blackchip-org/pac8/pkg/util/bits" ) // LoadLE loads a 16-bit little endian value from memory m at addr. func LoadLE(m Memory, addr uint16) uint16 { lo := m.Load(addr) hi := m.Load(addr + 1) return bits.Join(hi, lo) } // StoreLE stores a 16-bit little endian ...
pkg/memory/util.go
0.769427
0.404684
util.go
starcoder
package setup import client "github.com/kamontat/my_settings/settings/clients" // MacDockSetup is the command able to interact to outer package // this using parameter to define which type of setup func MacDockSetup(mode Mode) { macSimpleDockSetup(mode == ADVANCE) if mode == ADVANCE { macAdvanceDockSetup() } } ...
settings/setups/mac_dock.go
0.625896
0.477493
mac_dock.go
starcoder
package nzmap import ( "bytes" "math" ) var nzIconPts [151][141]pt var nzrcIconPts [29][29]pt var nzsIconPts [25][22]pt var nzMediumPts [151][140]pt var nzrcMediumPts [28][29]pt var nzrMediumPts [22][22]pt var nzsMediumPts [25][22]pt type pt struct { x, y int } type Point struct { Longitude, Latitude float64 ...
map180/nzmap/nzmap.go
0.661814
0.417271
nzmap.go
starcoder
package repo import ( "errors" "fmt" "strings" "time" ) func init() { if err := bootstrapCurrencyDictionaries(); err != nil { panic(err) } } type ( // CurrencyCode is a string-based currency symbol CurrencyCode string // CurrencyDefinition defines the characteristics of a currency CurrencyDefinition stru...
repo/currency_definition.go
0.6488
0.513485
currency_definition.go
starcoder
package common import ( "fmt" "net" ) // In order for the IpPortTuple and the TcpTuple to be used as // hashtable keys, they need to have a fixed size. This means the // net.IP is problematic because it's internally represented as a slice. // We're introducing the HashableIpPortTuple and the HashableTcpTuple // typ...
vendor/github.com/elastic/beats/libbeat/common/tuples.go
0.689201
0.413477
tuples.go
starcoder
package slice import "errors" // MaxByte returns the maximum value of a byte slice or an error in case of a nil or empty slice func MaxByte(a []byte) (byte, error) { if len(a) == 0 { return 0, errors.New("returns the maximum of a nil or empty slice") } max := a[0] for k := 1; k < len(a); k++ { if a[k] > max ...
max.go
0.901135
0.578091
max.go
starcoder
package sketch import ( "image" "image/color" "image/jpeg" "image/png" "io" "math" "math/rand" "time" "github.com/fogleman/gg" "github.com/ajagnic/gogenart/funcs" ) // Params represents the configuration of a sketch. type Params struct { Iterations int PolygonSidesMin int PolygonSidesMax int P...
sketch/sketch.go
0.796411
0.436442
sketch.go
starcoder
package dos import ( "github.com/gdamore/tcell/v2" ) // The BoxDecoration allows for an individual rune per side and corner of the // box being drawn. See https://en.wikipedia.org/wiki/Box-drawing_character type BoxDecoration struct { Hor, Vert rune // Horizontal and vertical sides TL, TR, BR, BL rune // Cloc...
box.go
0.795698
0.483709
box.go
starcoder
package tps import ( "errors" ) // Grid holds all the page and grid specification required for the Report to // create new pages and place content. type Grid struct { ColumnCount int ColumnWidth float64 GutterCount int GutterWidth float64 LineHeight float64 Margin float64 Orientation int PageWidth fl...
grid.go
0.842539
0.529932
grid.go
starcoder
package typ import "xelf.org/xelf/knd" const kndVal = knd.All | knd.Exp // AssignableTo returns whether *all* values represented by type t can be assigned to dst. func (t Type) AssignableTo(dst Type) bool { if t.ID > 0 && t.ID == dst.ID { return true } if dst.Kind&knd.Var != 0 && dst.Kind&kndVal == knd.Void { ...
typ/comp.go
0.596198
0.485051
comp.go
starcoder
package gate import ( "fmt" "math" "math/cmplx" "strconv" "github.com/itsubaki/q/pkg/math/matrix" "github.com/itsubaki/q/pkg/math/number" ) func New(v ...[]complex128) matrix.Matrix { g := make(matrix.Matrix, len(v)) for i := 0; i < len(v); i++ { g[i] = v[i] } return g } func Empty(n ...int) []matrix.M...
pkg/quantum/gate/gate.go
0.65368
0.452415
gate.go
starcoder
package strtotime import ( "fmt" "math" "regexp" "strconv" "strings" "time" ) // Parse takes an English string - such as "next Friday 3 pm" - and an int64 unix timestamp to compare it with. // It returns the translated English text into an int64 unix timestamp, or an error if the input cannot be recognized. fun...
vendor/github.com/carmo-evan/strtotime/strtotime.go
0.664214
0.406037
strtotime.go
starcoder
package tubes import ( "strings" "unicode" ) const pipe = '|' const dash = '-' const plus = '+' const space = ' ' const left = 1 const right = 2 const top = 4 const bottom = 8 // WalkTheLine returns the path taken by the lost network packet func WalkTheLine(content string) (string, int) { result := "" steps := ...
tubes/tubes.go
0.698946
0.469095
tubes.go
starcoder
package calc import ( "errors" "fmt" "math" "strconv" "strings" "unicode" ) var oprData = map[string]struct { prec int rAsoc bool // true = right // false = left fx func(x, y float64) float64 }{ "^": {4, true, func(x, y float64) float64 { return math.Pow(x, y) }}, "*": {3, false, func(x, y float64) flo...
solver.go
0.594904
0.46557
solver.go
starcoder
package query import ( . "github.com/apmckinlay/gsuneido/compile/ast" "github.com/apmckinlay/gsuneido/util/strs" ) // renameExpr renames identifiers in an expression. // It does not modify the expression. // If any renames are done, it returns a new expression. func renameExpr(expr Expr, from, to []string) Expr { ...
dbms/query/expr.go
0.515864
0.458227
expr.go
starcoder
package russian var ( thousandNumberCase = [3]string{"тысяча", "тысячи", "тысяч"} millionNumberCase = [3]string{"миллион", "миллиона", "миллионов"} milliardNumberCase = [3]string{"миллиард", "миллиарда", "миллиардов"} trillionNumberCase = [3]string{"триллион", "триллиона", "триллионов"} quadrillionNu...
russian/numbers.go
0.553988
0.490053
numbers.go
starcoder
package v1_0 func init() { Profile["/tosca/kubernetes/1.0/data.yaml"] = ` tosca_definitions_version: tosca_simple_yaml_1_3 data_types: Count: derived_from: integer constraints: - greater_or_equal: 0 Factor: derived_from: float constraints: - in_range: [ 0.0, 1.0 ] Amount: proper...
tosca/profiles/kubernetes/v1_0/data.go
0.931626
0.582372
data.go
starcoder
package strdist import ( "fmt" "math" ) // NGramSet represents a set of n-grams. Each n-gram has an associated weight // which is the number of occurences in the original string from which it is // derived type NGramSet map[string]int // Dot returns the dot product of the two n-gram sets func Dot(n1, n2 NGramSet) ...
strdist/ngrams.go
0.813313
0.49762
ngrams.go
starcoder
package core import "fmt" type Rect2d struct { X float64 Y float64 Width float64 Height float64 } func NewRect2d(x float64, y float64, width float64, height float64) (rcvr *Rect2d) { rcvr = &Rect2d{} rcvr.X = x rcvr.Y = y rcvr.Width = width rcvr.Height = height return } func NewRect2d2() (rcvr *...
opencv3/core/Rect2d.java.go
0.661486
0.704637
Rect2d.java.go
starcoder
package triangolatte import "errors" // Joint is a type of connection happening when lines joining two points meet. type Joint int const ( // Normal triangulates with no joint correction. Normal Joint = 0 // Miter triangulates producing miter joints, i.e. extending the lines until // they meet at some point. Mi...
line.go
0.81119
0.671952
line.go
starcoder
package cuda import ( "strings" "github.com/go-stack/stack" "github.com/jjeffery/kv" ) // This file contains several functions that map slots to GPUs and visa versa // GetDevices will return a list of the possible devices that support a specified compute slot count. The returned // order of cards is ascending ...
internal/cuda/devices.go
0.60871
0.596022
devices.go
starcoder
package expressions import ( "fmt" "github.com/efritz/gostgres/internal/shared" ) func NewEquals(left, right Expression) Expression { return newComparison(left, right, "=", func(lVal, rVal interface{}, ot shared.OrderType) (interface{}, error) { return ot == shared.OrderTypeEqual, nil }) } func NewIsDistinctF...
internal/expressions/comparison.go
0.68721
0.441793
comparison.go
starcoder
// snapcat is a simple CLI that reads from stdin and writes to stdout. If the // input is a Snappy compressed stream it is decompressed and written to stdout. // If the input is not a Snappy compressed stream then it is compressed and // written to stdout. package main import ( "bytes" "io" "os" "github.com/gola...
cmd/snapcat/main.go
0.606032
0.472501
main.go
starcoder
package messagelayer import ( "time" "github.com/iotaledger/hive.go/configuration" ) // ParametersDefinition contains the definition of the parameters used by the messagelayer plugin. type ParametersDefinition struct { // TangleWidth can be used to specify the number of tips the Tangle tries to maintain. TangleW...
plugins/messagelayer/parameters.go
0.776708
0.534491
parameters.go
starcoder
Implements the k-Nearest Neighbors Machine Learning algorithm. */ package algo import ( "errors" "math" "sort" ) /* Source : Machine Learning in Action by <NAME>. Chapter 2. KNN Algorithm : For every point in our dataset: calculate the distance between inX and the current point sort the distances in increasin...
src/go/src/github.com/redsofa/knn/algo/algo.go
0.756447
0.664819
algo.go
starcoder
package gofaker import "strconv" // BeerName will return a random beer name func BeerName() string { return getRandValue([]string{"beer", "name"}) } // BeerStyle will return a random beer style func BeerStyle() string { return getRandValue([]string{"beer", "style"}) } // BeerHop will return a random beer hop func...
beer.go
0.565539
0.459682
beer.go
starcoder
package similarities import ( "fmt" "github.com/jtejido/golucene/core/search" ) var _ Similarity = (*dfrSimilarityImpl)(nil) var _ DFRSimilarity = (*dfrSimilarityImpl)(nil) type DFRSimilarity interface { SimilarityBase } /** * Implements the <em>divergence from randomness (DFR)</em> framework * introduced in <...
core/search/similarities/dfr.go
0.849097
0.451145
dfr.go
starcoder
package btree import "bytes" type leafNode struct { baseNode values [][]byte } func newLeafNode(t *MVCCBtree, r uint64) *leafNode { return &leafNode{ baseNode: baseNode{ tree: t, revision: r, keys: make([][]byte, 0, t.order-1), }, values: make([][]byte, 0, t.order-1), } } func (n *leafNod...
leaf_node.go
0.584864
0.463991
leaf_node.go
starcoder
package vector import ( "math" "github.com/puoklam/physics2d/math/float" ) const ( ErrNilVector = "nil vector received" ) const ( Pi = math.Pi ) type Vector2D struct { X, Y float64 } func (v *Vector2D) Normalize() *Vector2D { mag := Magnitude(v) v.X /= mag v.Y /= mag return v } func (v *Vector2D) Revers...
math/vector/vector2d.go
0.683842
0.732305
vector2d.go
starcoder
package lowest_common_ancestor_of_a_binary_tree import "container/list" /* 236. 二叉树的最近公共祖先 https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree 给定一个二叉树, 找到该树中两个指定结点的最近公共祖先。 百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x, 满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个结点也可以是它自己的祖先)。” 例如,给定如下二叉树: root = [3,5,1,...
solutions/lowest-common-ancestor-of-a-binary-tree/d.go
0.556641
0.541833
d.go
starcoder
package gpio import ( "unsafe" ) // Pin represents one phisical pin (specific pin in specific port). type Pin struct { h uintptr // [31:7] port address, [6:5] port number, [4:0] pin number } // IsValid reports whether p represents a valid pin. func (p Pin) IsValid() bool { return p.h&^0x7F != 0 } // Port return...
hal/gpio/pin.go
0.834373
0.520862
pin.go
starcoder
package app import ( "fmt" "github.com/mescanne/goledger/book" "regexp" "strconv" "strings" ) var BookOperationUsage = `Book Operations Note: For regular expressions syntax used is used is Golang's. This is available here: https://github.com/google/re2/wiki/Syntax. Operations: map=/search-regex/repla...
cmd/app/book_op.go
0.671363
0.447098
book_op.go
starcoder
package harmonic import ( "encoding/gob" "math/rand" "os" "github.com/pointlander/sync/fixed" "github.com/pointlander/sync/slices" "github.com/pointlander/sync/util" "github.com/MaxHalford/eaopt" "github.com/mjibson/go-dsp/fft" ) const Threshold = 8 * fixed.FixedOne // Message is a message sent from one h...
harmonic/harmonic.go
0.63307
0.514461
harmonic.go
starcoder
package hibe import ( "crypto/sha256" "encoding/json" "github.com/Nik-U/pbc" "github.com/qantik/ratcheted/primitives" ) // maxDepth is the limit to how deep a Boneh hierarchy can reach. const maxDepth = 10 // Boneh designates a Boneh-Boyen-Goh protocol instance. type Boneh struct{} // bonehParams composes the...
primitives/hibe/boneh.go
0.624866
0.462048
boneh.go
starcoder
package sphere import ( "math" "github.com/twpayne/go-kml/v2" ) const ( degrees = 180 / math.Pi radians = math.Pi / 180 ) // A T is a sphere of radius R. type T struct { R float64 } var ( // Unit is the unit sphere. Unit = T{R: 1} // FAI is the FAI sphere, measured in meters. FAI = T{R: 6371000} // WGS...
sphere/sphere.go
0.887223
0.650745
sphere.go
starcoder
package driver import ( "database/sql/driver" "io" "sort" ) // Rows is an iterator over an executed query's results. // It implements sort and driver.Rows interfaces. type Rows struct { data [][]driver.Value less []lessFunc cols []string size, pos int } // Len func (r *Rows) Len() int { return...
driver/rows.go
0.611034
0.433981
rows.go
starcoder
package nom import ( "encoding/gob" "fmt" "time" bh "github.com/kandoo/beehive" "github.com/kandoo/beehive/strings" ) // InPort is the input port field. type InPort UID func (in InPort) HasSameType(f Field) bool { switch f.(type) { case InPort: return true } return false } func (in InPort) Equals(f Fiel...
nom/flow.go
0.701202
0.451327
flow.go
starcoder
package geom import ( "log" ) /***** * * About Coordinates. * * Material Coordinates (MC) refer to the original dimensions of the material with * (0, 0) at the bottom left and (material width, material height) at the top right. * * Carving coordinates are expressed in the Material Coordinates space. * * Nor...
geom/xform.go
0.82887
0.412412
xform.go
starcoder
package glm import ( "fmt" "math" "github.com/kshedden/statmodel/statmodel" ) // FamilyType is the type of GLM family used in a model. type FamilyType uint8 // BinomialFamily, ... are families for a GLM. const ( BinomialFamily FamilyType = iota PoissonFamily QuasiPoissonFamily GaussianFamily GammaFamily In...
glm/families.go
0.626124
0.449634
families.go
starcoder
package termloop import ( "github.com/gdamore/tcell" "strings" ) // A Canvas is a 2D array of Cells, used for drawing. // The structure of a Canvas is an array of columns. // This is so it can be addressed canvas[x][y]. type Canvas [][]Cell // NewCanvas returns a new Canvas, with // width and height defined by arg...
termloop.go
0.788583
0.442396
termloop.go
starcoder
package bitvector import ( "errors" "fmt" ) //BitVector Type BitVector type BitVector []int var bitsPerWord = 32 var size = 0 //NewBitVector create a new BitVector func NewBitVector(n int) (bv *BitVector, err error) { if n < 0 { return bv, &NegativeBitVectorSize{size: n} } size = (n / bitsPerWord) + 1 bitV...
column1-oyster/bit-vectors/bit-vectors.go
0.643217
0.55441
bit-vectors.go
starcoder
package ptr import "time" // CloneInt makes a copy of the value to a new memory address func CloneInt(i *int) *int { if i == nil { return NewInt() } return &(*i) } // CloneInt8 makes a copy of the value to a new memory address func CloneInt8(i *int8) *int8 { if i == nil { return NewInt8() } return &(*i) ...
clone.go
0.734405
0.450541
clone.go
starcoder
package parser import ( "fmt" ) import ( "../token" "../node" ) type Parser struct { tokens []*token.Token pos int variables map[string]int stack int } func (p *Parser) peek() *token.Token { return p.tokens[p.pos] } func (p *Parser) next() *token.Token { token := p.tokens[p.pos] p.pos++ retu...
parser/parser.go
0.568536
0.514705
parser.go
starcoder
package rasterize import ( "github.com/RH12503/Triangula/geom" "math" ) // DDATriangleBlocks calls function line for each line a triangle covers, and // calls function block for each block the triangle covers. func DDATriangleBlocks(triangle geom.Triangle, blockSize int, line func(x0, x1, y int), block func(x, y in...
rasterize/blocks.go
0.553747
0.647603
blocks.go
starcoder
package stats import ( "fmt" "math" "os" "sort" ) // Mean returns the mean of an integer array as a float func Mean(nums []int) (mean float64) { if len(nums) == 0 { return 0.0 } for _, n := range nums { mean += float64(n) } return mean / float64(len(nums)) } // Median returns the median of an integer ar...
stats.go
0.806319
0.534066
stats.go
starcoder
// Package ngt provides implementation of Go API for https://github.com/yahoojapan/NGT package ngt /* #cgo LDFLAGS: -lngt #include <NGT/Capi.h> */ import "C" import ( "strings" "github.com/kpango/fastime" "github.com/vdaas/vald/internal/errors" ) // Option represents the functional option for NGT. type Option f...
internal/core/algorithm/ngt/option.go
0.629319
0.427815
option.go
starcoder
package gohome import ( "github.com/PucklaMotzer09/mathgl/mgl32" "image/color" "math" "strconv" ) const ( MESH2DVERTEXSIZE = 2 * 2 * 4 // 2*2*sizeof(float32) INDEXSIZE = 4 // sizeof(unsigned int 32) SHAPE3DVERTEXSIZE = 3*4 + 4*4 SHAPE2DVERTEXSIZE = 2*4 + 4*4 ) // A vertex of a 2D mesh type M...
src/gohome/math.go
0.800887
0.590779
math.go
starcoder
package golisp import "fmt" func buildUnexpectedEndOfStringError() error { return fmt.Errorf("parse error: unexpected end of string") } func buildUnexpectedCloseParenError() error { return fmt.Errorf("parse error: unexpected close paren") } func buildUnexpectedTrailingTextError() error { return fmt.Errorf("parse...
errors.go
0.809653
0.437223
errors.go
starcoder
package main import "fmt" func search(nums []int, target int) int { low := 0 high := len(nums) - 1 for low <= high { mid := low + (high-low)/2 if nums[mid] == target { return mid } else if nums[mid] > target { high = mid - 1 } else { low = mid + 1 } } return -1 } // left bound search, close i...
leetcode/lc704/main.go
0.508544
0.494995
main.go
starcoder
package anime4kgo import ( "bytes" "fmt" "image" "image/color" "image/png" "io/ioutil" "log" "math" "os" "github.com/TianZerL/Anime4KGo/options" "github.com/disintegration/gift" ) //Img defined the image class type Img struct { W int H int FmtType string data image.Image } //LoadImg r...
anime4kgo/anime4kgo.go
0.510985
0.503662
anime4kgo.go
starcoder
package main // MapToString is a right-bias mapping function and an alias for MapRightToString func (e *EitherStringOrString) MapToString(f func(string) string) *EitherStringOrString { if e.isLeft { return &EitherStringOrString{ left: e.left, isLeft: true, } } return &EitherStringOrString{ right: f(...
examples/gen_either_compose_2.go
0.828766
0.448487
gen_either_compose_2.go
starcoder
package solve import vec "github.com/tflovorn/scExplorer/vector" // Function plus first derivatives. type Diffable struct { F vec.FnDim0 Df vec.FnDim1 Fdf vec.FnDim0_1 Dimension int // length of vectors } // System of functions plus first derivatives. type DiffSystem struct { F vec....
solve/diffable.go
0.792183
0.649301
diffable.go
starcoder
package contexttest import ( "context" "sync" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // WithValue can be tested to have the behavior of context.WithValue. type WithValue func(ctx context.Context, key, val interface{}) context.Context // TestWithValue tests the be...
value.go
0.62223
0.677677
value.go
starcoder
package telemetry import "context" // Unit encodes the standard name for describing the quantity measured by a // Metric (if applicable). type Unit string // Predefined units for use with the monitoring package. const ( None Unit = "1" Bytes Unit = "By" Seconds Unit = "s" Milliseconds Unit =...
metric.go
0.800224
0.515559
metric.go
starcoder
package abi func GetCTokenABI() string { abi := ` [ { "constant": false, "inputs": [ { "internalType": "address", "name": "tokenHolder", "type": "address" }, { "internalType": "address", ...
contract/abi/cToken.go
0.535098
0.413892
cToken.go
starcoder
package f32color import ( "image/color" "math" ) var ( White = color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF} Black = color.NRGBA{0x00, 0x00, 0x00, 0xFF} Red = color.NRGBA{0xFF, 0x00, 0x00, 0xFF} Green = color.NRGBA{0x00, 0xFF, 0x00, 0xFF} Blue = color.NRGBA{0x00, 0x00, 0xFF, 0xFF} Yellow = color.NRGBA{0xFF, 0xF...
f32color/color.go
0.802942
0.561876
color.go
starcoder
package github import ( "strconv" "strings" gh "github.com/google/go-github/v28/github" ) const ( releaseNoteBlock = "```release-note" upstreamPRsBlock = "```upstream-prs" ) func textBlockBetween(body, str string) string { lines := strings.Split(body, "\n") beginning, end := -1, -1 for idx, line := range l...
pkg/github/labels.go
0.587233
0.456773
labels.go
starcoder
package lbs import ( "bytes" "fmt" "math" "strconv" "strings" ) const E float64 = 6378.137 // 地球半径,单位为 km type LngLat struct { Longitude float64 `json:"longitude"` //经度 Latitude float64 `json:"latitude"` //纬度 } func (L LngLat) String() string { return fmt.Sprintf("%f,%f", L.Longitude, L.Latitude) } func ...
lbs/types.go
0.610221
0.490419
types.go
starcoder
package flow import ( "context" "encoding/json" "errors" "fmt" ) type Flow struct { Key string Error error firstNode Node rawNodes map[string]Handler nodes map[string]Node inVertex map[string]bool outVertex map[string]bool raw RawFlow } type RawFlow struct { Nodes []string `js...
flow.go
0.531696
0.412382
flow.go
starcoder
package ast import ( "fmt" "strings" ) type ValueType int const ( STRING = iota INT FLOAT NUMBER BOOL CHAR NIL ) type Module struct { Name string Subvalues []Ast ConcreteTypes []Ast Imports map[string]bool } type BasicAst struct { Type string StringValue string CharValue...
src/braid/ast/ast.go
0.530966
0.498291
ast.go
starcoder
package router // Holds a bunch of helper functions for dealing with labels. // SplitDomainName splits a name string into it's labels. // www.miek.nl. returns []string{"www", "miek", "nl"} // The root label (.) returns nil. Note that using // strings.Split(s) will work in most cases, but does not handle // escaped do...
router/labels.go
0.606964
0.472988
labels.go
starcoder
package ckks import ( "fmt" "math" "sort" ) // PrecisionStats is a struct storing statistic about the precision of a CKKS plaintext type PrecisionStats struct { MaxDelta complex128 MinDelta complex128 MaxPrecision complex128 MinPrecision complex128 MeanDelta complex128 MeanPrecision...
ckks/precision.go
0.762159
0.463019
precision.go
starcoder
package lib import ( "image" "image/color" "math" "github.com/fogleman/gg" "github.com/lucasb-eyer/go-colorful" ) // GenerateGamutMask generates a wheel (as *image.RGBA64) of Gamut Mask with a size of maskWidth, maskHeight func GenerateGamutMask(img image.Image, maskWidth, maskHeight, paddingX, paddingY int) (w...
lib/lib.go
0.738858
0.532243
lib.go
starcoder
package main // This is a small go-based program to generate nice maze using recursive backtracking algorithm. // It has feature to draw the full maze into ascii format thus allowing user to play over gui. // Version : 1.0 // Author : <NAME> // Created : 22 November 2021 import ( "math/rand" "strings" "time" ...
bmaze.go
0.744842
0.486514
bmaze.go
starcoder
package pcx import ( "image" "image/color" "io" ) // Encode writes the Image m to w in PCX format. func Encode(w io.Writer, m image.Image) error { switch im := m.(type) { case *image.RGBA: return encodeRGBA(w, im) case *image.Paletted: return encodePaletted(w, im) case image.PalettedImage: cm := im.Color...
pcx/encoder.go
0.630912
0.401043
encoder.go
starcoder
package gparselib import ( "errors" "fmt" "regexp" "strconv" "strings" "unicode" "unicode/utf8" ) // ParseLiteral parses a literal value at the current position of the parser. // The configuration has to be the literal string we expect. func ParseLiteral( pd *ParseData, ctx interface{}, pluginSemantics Seman...
simple_parser.go
0.632843
0.440289
simple_parser.go
starcoder
package gameboard import ( "bytes" "errors" "sort" "text/template" "github.com/adambullmer/go-boggle/internal/lexicon" log "github.com/sirupsen/logrus" ) // The GameBoard type holds the state of all the characters on the gamebaord type GameBoard struct { Width int Height int Board [][]Cell } /* NewGameBo...
internal/gameboard/gameboard.go
0.568655
0.429968
gameboard.go
starcoder
package main import ( "fmt" ) func permutationsGenerator(resultChannel chan<- [10]int) { freeElements := map[int]bool{ 1: true, 2: true, 3: true, 4: true, 5: true, 6: true, 7: true, 8: true, 9: true, 10: true, } recursivePermutations([10]int{}, 0, freeElements, resultChannel) } func recursivePermutations...
project-euler/68.go
0.5794
0.409221
68.go
starcoder
package proto import ( "github.com/lyraproj/data-protobuf/datapb" "github.com/lyraproj/puppet-evaluator/eval" "github.com/lyraproj/puppet-evaluator/serialization" "github.com/lyraproj/puppet-evaluator/types" ) // A ProtoConsumer consumes values and produces a datapb.Data type ProtoConsumer interface { serializat...
proto/convert.go
0.651466
0.500977
convert.go
starcoder
package zstd const ( prime3bytes = 506832829 prime4bytes = 2654435761 prime5bytes = 889523592379 prime6bytes = 227718039650203 prime7bytes = 58295818150454627 prime8bytes = 0xcf1bbcdcb7a56463 ) // hashLen returns a hash of the lowest l bytes of u for a size size of h bytes. // l must be >=4 and <=8. Any other ...
vendor/github.com/klauspost/compress/zstd/hash.go
0.642881
0.484868
hash.go
starcoder
package main import ( "fmt" "math" ) /** You have 4 cards each containing a number from 1 to 9. You need to judge whether they could operated through *, /, +, -, (, ) to get the value of 24. Example 1: Input: [4, 1, 8, 7] Output: True Explanation: (8-4) * (7-1) = 24 Example 2: Input: [1, 2, 1, 2] Output: False ...
main/judgePoint24.go
0.819785
0.643693
judgePoint24.go
starcoder
// For example, the pair [0, 1], indicates that to take course 0 you have to first take course 1. // Return the ordering of courses you should take to finish all courses. If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array. // Example 1: // Input: num...
0210-course-schedule-ii.go
0.659076
0.725406
0210-course-schedule-ii.go
starcoder
package common import ( "fmt" "net" ) // In order for the IpPortTuple and the TcpTuple to be used as // hashtable keys, they need to have a fixed size. This means the // net.IP is problematic because it's internally represented as a slice. // We're introducing the HashableIpPortTuple and the HashableTcpTuple // ty...
libbeat/common/tuples.go
0.687735
0.442094
tuples.go
starcoder
// Ensure changes made to blas/cgo are reflected in blas/native where relevant. /* Package cgo provides bindings to a C BLAS library. This wrapper interface panics when the input arguments are invalid as per the standard, for example if a vector increment is zero. Please note that the treatment of NaN values is not s...
Godeps/_workspace/src/github.com/gonum/blas/cgo/doc.go
0.619241
0.775732
doc.go
starcoder
package appdash import ( "fmt" "reflect" "sort" "strconv" "strings" "sync" "time" ) func flattenValue(prefix string, v reflect.Value, f func(k, v string)) { switch o := v.Interface().(type) { case time.Time: f(prefix, o.Format(time.RFC3339Nano)) return case time.Duration: ms := float64(o.Nanoseconds()...
vendor/sourcegraph.com/sourcegraph/appdash/reflect.go
0.574395
0.410047
reflect.go
starcoder
package parser import ( "strings" "github.com/d5/tengo/v2/token" ) // Expr represents an expression node in the AST. type Expr interface { Node exprNode() } // ArrayLit represents an array literal. type ArrayLit struct { Elements []Expr LBrack Pos RBrack Pos } func (e *ArrayLit) exprNode() {} // Pos re...
parser/expr.go
0.839635
0.439326
expr.go
starcoder
package storage import ( "context" "time" "google.golang.org/appengine/datastore" ) const GameEntity = "KaiserGame" type Game struct { Key *datastore.Key PlayerIDs []string // Organizing player is 0-index; clockwise afterwards (e.g., 0 and 2 are partners). Created time.Time Updated time.Time Compl...
server/pkg/storage/game.go
0.581184
0.566378
game.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // WorkbookChartSeries type WorkbookChartSeries struct { Entity // Represents the formatting of a chart series, which includes fill and line formatting. R...
models/workbook_chart_series.go
0.748812
0.468547
workbook_chart_series.go
starcoder
package graphite import ( "strings" ) type Result struct { results []*Series cursor int curr *Series } type Series struct { cursor int curr *DataPoint Name string DataPoints []DataPoint } type DataPoint struct { X, Y *float64 } // NextItem can be called inside `for` and will populate t...
service/graphite/result.go
0.705988
0.438785
result.go
starcoder
package fsm import ( "fmt" "sort" ) // VisualizeType the type of the visualization type VisualizeType string const ( // GRAPHVIZ the type for graphviz output (http://www.webgraphviz.com/) GRAPHVIZ VisualizeType = "graphviz" // MERMAID the type for mermaid output (https://mermaid-js.github.io/mermaid/#/stateDiag...
visualizer.go
0.632503
0.629447
visualizer.go
starcoder
package simulation import ( "encoding/json" "fmt" "math/rand" "time" "github.com/hbtc-chain/bhchain/baseapp" sdk "github.com/hbtc-chain/bhchain/types" "github.com/hbtc-chain/bhchain/x/gov" "github.com/hbtc-chain/bhchain/x/params" "github.com/hbtc-chain/bhchain/x/simulation" ) type simParamChange struct { s...
x/params/simulation/msgs.go
0.626924
0.483648
msgs.go
starcoder
package syntax // Note to implementers: // In this package, re is always a *Regexp and r is always a rune. import ( "bytes" "strconv" "strings" "unicode" ) // A Regexp is a node in a regular expression syntax tree. type Regexp struct { Op Op // operator Flags Flags Sub []*Regexp // subexpressi...
src/regexp/syntax/regexp.go
0.596786
0.517144
regexp.go
starcoder
package common import ( "encoding/binary" "encoding/hex" "fmt" "github.com/spacemeshos/go-spacemesh/common/hexutil" "math/big" "math/rand" "reflect" ) const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength is the expected length of the address AddressLength = 20 ) func B...
common/bytes.go
0.760206
0.488771
bytes.go
starcoder