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 sqlcon // HelpMessage returns a string explaining how to set up SQL using environment variables. func HelpMessage() string { return `- DATABASE_URL: A URL to a persistent backend. Various backends are supported: - Changes are lost on process death (ephemeral storage): - Memory: If DATABASE_URL is "memory...
sqlcon/message.go
0.761804
0.42173
message.go
starcoder
package schema // SettingsSchemaJSON is the content of the file "settings.schema.json". const SettingsSchemaJSON = `{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "settings.schema.json#", "title": "Settings", "description": "Configuration settings for users and organizations on Sourcegraph.", ...
schema/settings_stringdata.go
0.723993
0.444263
settings_stringdata.go
starcoder
// Package ring gives a simple implementation of a ring/b.bufular buffer. package ring import ( "fmt" "io" "runtime" "sync" ) // Buffer is a simple implementation of a ring/b.bufular buffer. // See https://en.wikipedia.org/wiki/b.bufular_buffer for more details. type Buffer struct { sync.Mutex buf []byte // P...
tools/lib/ring/buffer.go
0.754282
0.473109
buffer.go
starcoder
package main //Using math and sort import ( "fmt" "math" "sort" ) // Operation is the Binary Operation for func Accumulate() type Operation func(float64, float64) float64 // Accumulate is the member function of []float64 func Accumulate(data []float64, initValue float64, f Operation) float64 { res ...
math/moments/golang/moments.go
0.818918
0.53048
moments.go
starcoder
package series import ( "fmt" "math" "strconv" ) type floatElement struct { e float64 nan bool } func (e *floatElement) Set(value interface{}) { e.nan = false switch value.(type) { case string: if value.(string) == "NaN" { e.nan = true return } f, err := strconv.ParseFloat(value.(string), 64) ...
series/type-float.go
0.69451
0.533823
type-float.go
starcoder
package sqlchain import ( "errors" "github.com/SQLess/SQLess/crypto/hash" "github.com/SQLess/SQLess/proto" ) // Answer is responded by node to confirm other nodes that the node stores data correctly. type Answer struct { // The block id that the question belongs to PreviousBlockID BlockID // The node id that p...
sqlchain/storageproof.go
0.652795
0.42662
storageproof.go
starcoder
package input import ( "bytes" "fmt" "sort" "strings" "github.com/Jeffail/benthos/v3/internal/docs" "github.com/Jeffail/benthos/v3/lib/message/batch" "github.com/Jeffail/benthos/v3/lib/util/config" "gopkg.in/yaml.v3" ) //------------------------------------------------------------------------------ func san...
lib/input/docs.go
0.677794
0.424173
docs.go
starcoder
package rowconv import ( "context" "errors" "fmt" "io" "github.com/liquidata-inc/dolt/go/libraries/utils/set" "github.com/liquidata-inc/dolt/go/libraries/doltcore/doltdb" "github.com/liquidata-inc/dolt/go/libraries/doltcore/schema" "github.com/liquidata-inc/dolt/go/store/hash" "github.com/liquidata-inc/dol...
go/libraries/doltcore/rowconv/super_schema.go
0.605916
0.427038
super_schema.go
starcoder
package extime import ( "fmt" "math" "strings" "time" ) // Microsecond time.Time 转为 微秒 func Microsecond(t time.Time) int64 { return t.UnixNano() / int64(time.Microsecond) } // Millisecond time.Time 转为 毫秒 func Millisecond(t time.Time) int64 { return t.UnixNano() / int64(time.Millisecond) } // NowUS time.Now() ...
extime/extime.go
0.607547
0.427158
extime.go
starcoder
package dbs import ( "math" "math/cmplx" ) // Span of contour - line or arc type Span struct { A Point Bulge float64 Z Point } func square(x float64) float64 { return x * x } // Vector returns line direction func (span *Span) Vector() Point { return span.Z.Sub(&span.A) } // Area calculates area term...
dbs/span.go
0.82347
0.677558
span.go
starcoder
package iotago import ( "encoding/binary" "encoding/hex" "errors" "fmt" "strings" ) // OutputType defines the type of outputs. type OutputType = byte const ( // OutputSigLockedSingleOutput denotes a type of output which is locked by a signature and deposits onto a single address. OutputSigLockedSingleOutput O...
output.go
0.695028
0.411879
output.go
starcoder
package colorx import ( "image/color" "math" "github.com/somebadcode/go-colorx/v2/internal/mathx" ) // HSVA is an implementation of the HSV (Hue, Saturation and Value) color model. HSV is also known as HSB (Hue, // Saturation, Brightness). type HSVA struct { H float64 // Hue ∈ [0, 360) S float64 // Saturation ∈...
hsv.go
0.850841
0.497986
hsv.go
starcoder
// +build ingore // Package log implements a simple logging package. It defines a type, Logger, with // methods for formatting output. It also has a predefined 'standard' Logger // accessible through helper functions Print[f|ln], Fatal[f|ln], and Panic[f|ln], // which are easier to use than creating a Logger manually...
src/log/doc_zh_CN.go
0.651909
0.469034
doc_zh_CN.go
starcoder
package gslb /** * Configuration for GSLB site resource. */ type Gslbsite struct { /** * Name for the GSLB site. Must begin with an ASCII alphanumeric or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), equals (=), and hyphen (-) characte...
resource/config/gslb/gslbsite.go
0.722821
0.406567
gslbsite.go
starcoder
package cephalodistance import ( "math" "github.com/paulidealiste/Cephalopod/cephalobjects" "github.com/paulidealiste/Cephalopod/cephaloutils" ) type pair struct { x1, y1, x2, y2 float64 } // CalculateDistanceMatrix fills the distance property of a datastore based on the supplied metric func CalculateDistanceMa...
cephalodistance/cephalodistance.go
0.698638
0.458531
cephalodistance.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // UnifiedRoleAssignmentScheduleRequest type UnifiedRoleAssignmentScheduleRequest struct { Request // Represents the type of the operation on the role ass...
models/unified_role_assignment_schedule_request.go
0.749179
0.444565
unified_role_assignment_schedule_request.go
starcoder
package packed // Efficient sequential read/write of packed integers. type BulkOperationPacked12 struct { *BulkOperationPacked } func newBulkOperationPacked12() BulkOperation { return &BulkOperationPacked12{newBulkOperationPacked(12)} } func (op *BulkOperationPacked12) decodeLongToInt(blocks []int64, values []int...
core/util/packed/bulkOperation12.go
0.617397
0.671124
bulkOperation12.go
starcoder
package gfx import ( "fmt" "unsafe" "github.com/go-gl/gl/v4.1-core/gl" ) // Mesh is a collection of vertices, that // define the shape of a 3D object type Mesh struct { // VAO is the vertex array object that stores the vertex data VAO uint32 // VBO is the vertex buffer object used as a source for vertex array ...
gfx/mesh.go
0.590543
0.481454
mesh.go
starcoder
package indicators import ( "github.com/jaybutera/gotrade" ) // A Linear Regression Intercept Indicator (LinRegInt) type LinRegInt struct { *LinRegWithoutStorage selectData gotrade.DOHLCVDataSelectionFunc // public variables Data []float64 } // NewLinRegInt creates a Linear Regression Intercept Indicator (LinR...
indicators/linregint.go
0.704567
0.611237
linregint.go
starcoder
package src /** Computes the determinant of a matrix * Matrix must be square. */ func det(m *Matrix) (float64, string) { if (m.N != m.M) { return 0.0, "ERROR: Matrix must be square"; } reduced := copyMatrix(m); det := findDet(reduced, 1); return det, ""; } /** Method: * det of ident...
src/det.go
0.869382
0.562717
det.go
starcoder
package tado import ( "fmt" "net/http" "time" ) // DayReport contains the daily report info type DayReport struct { ZoneType string `json:"zoneType"` Interval struct { From time.Time `json:"from"` To time.Time `json:"to"` } `json:"interval"` HoursInDay int `json:"hoursInDay"` MeasuredData struct { M...
models_dayreport.go
0.690142
0.416915
models_dayreport.go
starcoder
package filter import ( "errors" "image" "math" "github.com/jangler/imp/util" ) var joinHelp = `join <file> <edge> [<align>] Adjoin another image to an edge of the working image. Possible values for 'edge' are top, bottom, left, and right. The 'align' argument is used to control which edge of the resulting imag...
filter/join.go
0.608943
0.494934
join.go
starcoder
package main import ( "fmt" "math/rand" "os" "strconv" "strings" "time" lib "devstats" yaml "gopkg.in/yaml.v2" ) // gaps contain list of metrics to fill gaps type gaps struct { Metrics []metricGap `yaml:"metrics"` } // metricGap conain list of series names and periods to fill gaps // Series formula allows...
cmd/gha2db_sync/gha2db_sync.go
0.664758
0.439567
gha2db_sync.go
starcoder
package types import ( "sort" "github.com/attic-labs/noms/go/hash" ) type Set struct { seq orderedSequence h *hash.Hash } func newSet(seq orderedSequence) Set { return Set{seq, &hash.Hash{}} } func NewSet(v ...Value) Set { data := buildSetData(v) ch := newEmptySetSequenceChunker(nil, nil) for _, v := r...
go/types/set.go
0.75101
0.419707
set.go
starcoder
package mockreader import ( "bytes" "fmt" "io" "io/fs" "strconv" "sync" "github.com/chronos-tachyon/assert" "github.com/chronos-tachyon/bufferpool" ) type Expectation struct { op Op input0 []byte input1 int64 input2 int input3 string output0 int64 output1 fs.FileInfo output2 ...
internal/mockreader/mockreader.go
0.523177
0.522872
mockreader.go
starcoder
package gnuplot const ( cpuPlotPNG = `set term png size 1024,768 set output 'cpu.png' set timefmt '%s' set xdata time set title 'CPU(Cores)' set xlabel 'Time' plot 'cpu.data' using 1:2 with lines` memPlotPNG = `set term png size 1024,768 set output 'mem.png' set timefmt '%s' set xdata time set title 'Mem(Mb)' set x...
internal/cmd/functional-benchmarker/reports/gnuplot/plot_scripts.go
0.740831
0.439326
plot_scripts.go
starcoder
Package client provides a method to query an API endpoint to extract data about the latest covid numbers and report these to the cmd line via stdout or save them as a csv or markdown file */ package client import ( "encoding/json" "errors" "fmt" "net/http" "strings" "time" ) //APIClient the client and the reque...
client/client.go
0.70202
0.413951
client.go
starcoder
package cephalobjects // GroupType - Possible values for grouping keys in a DataPoint struct type GroupType int // Possible values for grouping keys in a DataPoint struct => enum-like const ( Actual GroupType = iota Grouped ) // DistanceMetric - possible distances for calculating the distance matrix of a DataStore...
cephalobjects/cephalobjects.go
0.664323
0.638751
cephalobjects.go
starcoder
package tetra3d import ( "github.com/kvartborg/vector" ) // TextureAnimation is an animation struct. There is no function to create a new TextureAnimation because instantiating a struct is actually cleaner // and easier to read than doing so through a function for this simple of a struct. The TextureAnimation.Frames...
textureAnimation.go
0.825203
0.69643
textureAnimation.go
starcoder
package aes // m(x) = x^8 + x^4 + x^3 + x + 1 = 0x11B const m uint = 0x11B func getOrder(p uint) uint { // Check for edge case where p = 0 if p == 0 { return 0 } // Returns the order of polynomial p order := uint(0) // Keep increasing order until we reach order of p for (p >> order...
galois.go
0.833189
0.62289
galois.go
starcoder
package vision import ( "fmt" "strconv" ) // ParseInteger parse value and return Integer object func ParseInteger(arg interface{}) (Integer, Error) { switch obj := arg.(type) { case string: i, err := strconv.ParseInt(obj, 10, 64) if err != nil { return 0, ErrInvalid } return Integer(i), nil case bool:...
integer.go
0.71889
0.409929
integer.go
starcoder
package utils import ( "fmt" "reflect" "strconv" ) func CoerceFloat(value interface{}) (float32, bool) { switch result := value.(type) { case int: return float32(result), true case int32: return float32(result), true case int64: return float32(result), true case uint: return float32(result), true cas...
vendor/github.com/playlyfe/go-graphql/utils/coerce.go
0.501709
0.468061
coerce.go
starcoder
package export import ( "github.com/prometheus/client_golang/prometheus" ) // QueryBrokerExporter contains all the Prometheus metrics that are possible to gather from the brokers type QueryBrokerExporter struct { QueryTime *prometheus.HistogramVec `description:"milliseconds taken to complete a query"` ...
pkg/export/query_broker.go
0.770378
0.467149
query_broker.go
starcoder
package tentsuyu import ( "image" "github.com/hajimehoshi/ebiten" ) //BasicImageParts is easy to set up basic sprite image type BasicImageParts struct { Width, Height, Sx, Sy, DestWidth, DestHeight int Reverse bool SourceRect *image.Rectangl...
basicimageparts.go
0.755817
0.484746
basicimageparts.go
starcoder
package parse import "regexp" // ParseCountry accepts a VIN string and returns an ISO country code representing the country the vehicle was manufactured in func ParseCountry(vin string) string { for c, m := range countryMatchers { if m.MatchString(vin) { return c } } return "" } var countryMatchers = map[s...
parse/country.go
0.557484
0.409811
country.go
starcoder
package transform import ( "errors" "fmt" ) const ( _BWT_MAX_HEADER_SIZE = 8 * 4 ) // Utility class to en/de-code a BWT data block and its associated primary index(es) // BWT stream format: Header (m bytes) Data (n bytes) // Header: For each primary index, // mode (8 bits) + primary index (8,16 or 24 bits) // ...
transform/BWTBlockCodec.go
0.749821
0.476153
BWTBlockCodec.go
starcoder
package sketchy // PointHeap is a min/max heap for Points using inter-point distance as the metric type PointHeap struct { size int points []MetricPoint isMinHeap bool } func NewMaxPointHeap() *PointHeap { return &PointHeap{ size: 0, points: []MetricPoint{}, isMinHeap: false, } } func NewM...
heaps.go
0.757346
0.502869
heaps.go
starcoder
package torch // #include "torch.hpp" // #include <stdlib.h> import "C" import ( "bytes" "encoding/binary" "fmt" "reflect" "runtime" "unsafe" ) // Tensor holds a multi-dimensional array of elements of a single data type. type Tensor struct { context C.Torch_TensorContext goData unsafe.Pointer } // NewTensor...
tensor.go
0.771155
0.698664
tensor.go
starcoder
package utils import ( "encoding/binary" "math" ) func LIntToBytes(val int) ([]byte) { return LUInt32ToBytes(uint32(val)) } func LBytesToInt(bytes []byte) int { val := LBytesToUInt32(bytes) return int(val) } func BIntToBytes(val int) ([]byte) { return BUInt32ToBytes(uint32(val)) } func BBytesToInt(bytes []by...
utils/bytes.go
0.61115
0.541045
bytes.go
starcoder
package viertris import ( "fmt" "image/color" "math/rand" ) type ActiveTris struct { Board *GameBoard Rotation X BoardDimension Y BoardDimension TrisKind } // Offsets on an ActiveTris takes into account rotation func (at *ActiveTris) Offsets() [4][2]int8 { return at.TestOffsets(at.Rotation) } func (at *Act...
internal/scenes/viertris/tris.go
0.652574
0.412116
tris.go
starcoder
package meter import ( "sync" "sync/atomic" "time" "unsafe" ) // MultiHistogram associates Histogram objects to keys which can be // selected when recording. Is completely go-routine safe. type MultiHistogram struct { // Size is used to initialize the Size member of the underlying Histogram // objects. Size ...
meter_histogram_multi.go
0.727104
0.52141
meter_histogram_multi.go
starcoder
package metrics import "github.com/Jeffail/benthos/v3/internal/docs" //------------------------------------------------------------------------------ func init() { Constructors[TypePrometheus] = TypeSpec{ constructor: NewPrometheus, Summary: ` Host endpoints (` + "`/metrics` and `/stats`" + `) for Prometheus sc...
lib/metrics/prometheus_config.go
0.787114
0.418875
prometheus_config.go
starcoder
package list type unit struct{} // List represents a lazily evaluated list type type List interface{} // Mzero returnes an empty list func Mzero() List { return unit{} } // Return returns a single-element list func Return(i interface{}) List { return Returnf(func() interface{} { return i }) } // Cons pushes an ...
list/list.go
0.818374
0.487795
list.go
starcoder
package biff import ( "encoding/json" "fmt" "go/ast" "go/parser" "io/ioutil" "os" "reflect" "runtime" "runtime/debug" "strings" ) var exit = func() { os.Exit(1) } // deprecated // AssertNotEqual return true if `obtained` is not equal to `expected` otherwise // it will print trace and exit. func (a *A) Ass...
asserts.go
0.575111
0.457682
asserts.go
starcoder
Ported from Java com.google.gwt.dev.util.editdistance, which is: Copyright 2010 Google Inc. 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.apache.org/licenses/LICENSE-2.0 Unless requir...
triage/berghelroach/doc.go
0.80784
0.68462
doc.go
starcoder
package image import ( "bufio" "image" "io" "os" "strings" ) // Options are the encoding and decoding parameters. type Options interface { Lossless() bool Quality() float32 } type internalOptions struct { Options struct { Lossless bool Quality float32 } } func (opt *internalOptions) Lossless() bool {...
format.go
0.760917
0.421373
format.go
starcoder
package vector import ( "fmt" "math" ) // Vec is a two dimensional vector type Vec struct { X, Y float64 } // New returns a new vector at (x, y) func New(x, y float64) *Vec { return &Vec{x, y} } // Zero returns a zero-vector func Zero() *Vec { return &Vec{0, 0} } // Unit returns a unit vector at the given ang...
vector.go
0.936176
0.561936
vector.go
starcoder
package psd import ( "image" "image/color" psdColor "github.com/oov/psd/color" ) type picker interface { image.Image setSource(rect image.Rectangle, src ...[]byte) } func findPicker(depth int, colorMode ColorMode, hasAlpha bool) picker { switch colorMode { case ColorModeBitmap, ColorModeGrayscale: return f...
vendor/github.com/oov/psd/picker.go
0.716715
0.401306
picker.go
starcoder
package models import ( "github.com/peake100/turnup-go/models/timeofday" "github.com/peake100/turnup-go/values" "time" ) type SpikeChanceBreakdown [values.PricePeriodCount]float64 // Return the spike chance for a given Weekday + time of day func (spikes *SpikeChanceBreakdown) ForDay( weekday time.Weekday, tod ti...
models/predictionSpikeInfo.go
0.812496
0.461441
predictionSpikeInfo.go
starcoder
package decision_tree import ( "sync" "fmt" "errors" ) const GINI = "gini" type splitFunction func([][]float64, []float64, int) (float64, float64) type decisionTree struct { root *treeNode // actual tree context *treeContext // fitting context } type treeContext struct { splitter splitFunction // wh...
decision_tree/decision_tree.go
0.654564
0.443962
decision_tree.go
starcoder
package pipe import ( "crypto/rand" "fmt" "pipelined.dev/pipe/internal/runner" "pipelined.dev/signal" ) // pipeline components type ( // Pump is a source of samples. Pump method returns a new buffer with signal data. // If no data is available, io.EOF should be returned. If pump cannot provide data // to fulf...
line.go
0.759404
0.412885
line.go
starcoder
// The commit_log binary runs a simulation of the design for a commit-log // based signer, with a simulated Kafka-like interface and a simulated // master election package (which can be triggered to incorrectly report // multiple masters), and with the core algorithm in the signer code. // glog.Warning is used through...
docs/storage/commit_log/main.go
0.533641
0.419886
main.go
starcoder
package box2d import ( "math" ) type EPAxisType uint8 // This structure is used to keep track of the best separating axis. const ( EPAxisTypeUnknown EPAxisType = 0 EPAxisTypeEdgeA EPAxisType = 1 EPAxisTypeEdgeB EPAxisType = 2 ) type EPAxis struct { Type EPAxisType Index int Separation float64 ...
pkg/box2d/collide_edge.go
0.684264
0.629746
collide_edge.go
starcoder
package restruct import ( "encoding/binary" "reflect" ) func fieldFromIntf(v interface{}) (field, reflect.Value) { val := reflect.ValueOf(v) if val.Kind() == reflect.Ptr { val = val.Elem() } f := fieldFromType(val.Type()) return f, val } /* Unpack reads data from a byteslice into a value. Two types of valu...
sgx-tools/vendor/github.com/go-restruct/restruct/packing.go
0.770551
0.499939
packing.go
starcoder
The logger package defines the function that initializes a Rabia Logger and several logger-related functions. A Logger can be set as a terminal logger (output to stdout only), or file logger (output to a file in the log folder), or a terminal & file logger. Notes: 1. If the logger write to a file, the file point...
internal/logger/logger.go
0.667798
0.450601
logger.go
starcoder
package gart import ( "fmt" "math" ) // Vector2d is a immutable struct for doing 2d vector operations. type Vector2d struct { X float64 Y float64 } // NewVector2d creates a new vector from the x and y components func NewVector2d(x, y float64) Vector2d { return Vector2d{x, y} } // NewVector2dFromPolar creates a...
vector.go
0.81571
0.885086
vector.go
starcoder
package trie // A Navigator allows a trie to be navigated, by keeping previous state // (for example the prefix and the nodes back up the trie). type Navigator struct { nodes []TrieNode prefix []byte } // NewNavigator creates a navigator for the provided trie. func NewNavigator(tn TrieNode) *Navigator { result :=...
navigator.go
0.833697
0.5047
navigator.go
starcoder
package randomock // Policy configures the policy that RandoMock objects adhere to when they are called more times than they have return // values. type Policy int const ( // ErrorOutPolicy is the default policy and causes RandoMock to panic when called more times // than there are return values for a specific key....
mock.go
0.801392
0.457924
mock.go
starcoder
package evalprocessor import "github.com/vjeantet/bitfan/processors/doc" func (p *processor) Doc() *doc.Processor { return &doc.Processor{ Name: "evalprocessor", ImportPath: "github.com/vjeantet/bitfan/processors/filter-eval", Doc: "Modify or add event's field with the result of\n\n* an expression...
processors/filter-eval/docdoc.go
0.665628
0.453988
docdoc.go
starcoder
package list const takeDropFunctions = ` //------------------------------------------------------------------------------------------------- // Take returns a new {{.TName}}List containing the leading n elements of the source list. // If n is greater than the size of the list, the whole list is returned. func (list {...
internal/list/takedrop.go
0.797872
0.467089
takedrop.go
starcoder
package fitness // A CacheFunction represents a fitness function that caches data for efficiency. type CacheFunction interface { Function SetBase(function CacheFunction) Cache() []CacheData SetCache([]CacheData) } type CacheData interface { Equals(data CacheData) bool Hash() uint64 Data() float64 CachedHash(...
fitness/cache.go
0.882668
0.616965
cache.go
starcoder
package option import ( "fmt" "strconv" ) // Option is a type that allows optional values. It is similar to a Sum type // and can either be Some(value) or None. type Option[T any] struct { value *some[T] } func (o Option[T]) String() string { if o.IsNone() { return "None" } val := printv(o.Value()) return f...
option/option.go
0.739893
0.506225
option.go
starcoder
package goja // Ported from Rhino (https://github.com/mozilla/rhino/blob/master/src/org/mozilla/javascript/DToA.java) import ( "bytes" "fmt" "math" "math/big" "strconv" ) const ( frac_mask = 0xfffff exp_shift = 20 exp_msk1 = 0x100000 exp_shiftL = 52 exp_mask_shifted = 0x7ff frac_maskL = 0xff...
vendor/github.com/dop251/goja/dtoa.go
0.605682
0.416144
dtoa.go
starcoder
// Package conti provides business logic of trial account calculation package conti import ( "fmt" "math" ) const decimals float64 = 10000 // postTransactionsToAccounts calculates the balance (for balance categories and the cumulative // sums for P/L categories) per category on the basis of records of transaction...
conti/calc.go
0.705379
0.52007
calc.go
starcoder
package bst import ( "math" "sync" ) // NewBSTree returns an empty binary search tree. func NewBSTree() *BSTree { return &BSTree{ RWMutex: sync.RWMutex{}, root: nil, } } // Root returns the payload of the root node of the tree. func (t *BSTree) Root() interface{} { t.RLock() defer t.RUnlock() if t.roo...
bst/tree.go
0.789193
0.538559
tree.go
starcoder
package zsample import ( "time" ) func NewFloatSampler(size int, frequency time.Duration) *FloatSampler { return &FloatSampler{ size: size, frequency: frequency, samples: make([]float64, size), times: make([]time.Time, size), } } type FloatSampler struct { size int frequency time.Duratio...
zsample/zsample.go
0.763043
0.538073
zsample.go
starcoder
package qsort type smallsort64 func(data []uint64, base int, swap func(int, int)) type partition64 func(data []uint64, base int, swap func(int, int)) int func quicksort64(data []uint64, base, cutoff int, smallsort smallsort64, partition partition64, swap func(int, int)) { for len(data) > 1 { if len(data) <= cutoff...
qsort/sort8.go
0.510741
0.424472
sort8.go
starcoder
package astits import ( "fmt" "github.com/asticode/go-astilog" "github.com/pkg/errors" ) // PSI table IDs const ( PSITableTypeBAT = "BAT" PSITableTypeDIT = "DIT" PSITableTypeEIT = "EIT" PSITableTypeNIT = "NIT" PSITableTypeNull = "Null" PSITableTypePAT = "PAT" PSITableTypePMT = "P...
data_psi.go
0.609175
0.467271
data_psi.go
starcoder
package keys import ( "bytes" "encoding/hex" "fmt" "math/big" "prencrypt/point" "prencrypt/util" ) type PublicKey struct { Point *point.Point } func NewPublicKeyFromHex(s string) (*PublicKey, error) { b, err := hex.DecodeString(s) if err != nil { return nil, fmt.Errorf("cannot decode hex string: %v", err...
keys/publickey.go
0.640748
0.479077
publickey.go
starcoder
Common 3D shapes. */ //----------------------------------------------------------------------------- package sdf import "math" //----------------------------------------------------------------------------- // Counter Bored Hole func CounterBored_Hole3D( l float64, // total length r float64, // hole radius cb_...
sdf/shapes3.go
0.855021
0.467271
shapes3.go
starcoder
package op import( "fmt" ) // Performs an addition and updates the State. func (self *State)Add(a,b any)any{ self.IncOperations(self.coeff["+"]+self.off["+"]) var t string = fmt.Sprintf("%T", a) switch t { case "int": return a.(int)+b.(int) case "int8": return a.(int8)+b.(int8) case "int16": retu...
op/arithmetic_operators.go
0.568416
0.538437
arithmetic_operators.go
starcoder
package dataset import ( "math" "github.com/adam-lavrik/go-imath/i64" "github.com/adam-lavrik/go-imath/u64" ) // DataSet represents a set of documents from the source query system // It serves as an abstractions of the DBMS/Data Processor/... specific table/dataset/collection/... type DataSet struct { // The Nam...
dataset/dataset.go
0.741019
0.590248
dataset.go
starcoder
package quadedge import ( "log" "github.com/go-spatial/geom/winding" "github.com/go-spatial/geom/planar" "github.com/go-spatial/geom" ) // Splice operator affects the two edge rings around the origin of a and b, // and, independently, the two edge rings around the left faces of a and b. // In each case, (i) if...
planar/triangulate/delaunay/quadedge/topo.go
0.565059
0.489259
topo.go
starcoder
package core const ( // Each constant represents a different chunk of random numbers in // the table. For example, the 64 random numbers for black bishops // would begin at the 4 chunk of 64 random numbers, or the 4*64= // 256 index. BlackPawn = iota WhitePawn BlackKnight WhiteKnight BlackBishop WhiteBishop ...
core/zobrist.go
0.744099
0.472623
zobrist.go
starcoder
package maps import ( "constraints" "github.com/dairaga/gs" "github.com/dairaga/gs/funcs" "github.com/dairaga/gs/slices" ) type M[K comparable, V any] map[K]V // Pair is a 2 dimensional tuple contains key and value in map. type Pair[K comparable, V any] struct { _ struct{} Key K Value V } // P builds...
maps/maps.go
0.648132
0.594669
maps.go
starcoder
package main import ( "math" "math/rand" ) // ReflectDir gets a new direction reflected around normal. func ReflectionDir(incident, surfaceNormal V3) V3 { IdotN := incident.Dot(surfaceNormal) return incident.Sub(surfaceNormal.Mul(2 * IdotN)) } // RefractionDir gets a new direction based on refraction. func Refra...
reflect.go
0.636014
0.536374
reflect.go
starcoder
package joejson import ( "encoding/json" "fmt" ) // TypeFeature is the value for a Feature's 'type' member. const TypeFeature string = "Feature" // Feature represents a spatially bounded 'thing'. type Feature struct { // ID is an optional Feature identifier ('id'). ID any // Properties is an optional JSON obje...
feature.go
0.749362
0.582402
feature.go
starcoder
package main import ( "github.com/otyg/threagile/model" "github.com/otyg/threagile/model/confidentiality" ) type insecureHandlingOfSensitiveData string var RiskRule insecureHandlingOfSensitiveData func (r insecureHandlingOfSensitiveData) Category() model.RiskCategory { return model.RiskCategory{ Id: ...
risks/insecure-handling-of-sensitive-data/insecure-handling-of-sensitive-data.go
0.763396
0.578418
insecure-handling-of-sensitive-data.go
starcoder
package neighbors import ( "fmt" "runtime" "sort" "github.com/pa-m/sklearn/base" "github.com/pa-m/sklearn/metrics" "gonum.org/v1/gonum/mat" "gonum.org/v1/gonum/stat" ) // KNeighborsRegressor is a Regression based on k-nearest neighbors. // The target is predicted by local interpolation of the targets // asso...
neighbors/regression.go
0.821725
0.451508
regression.go
starcoder
package tile import ( "fmt" "math" ) const threeSixty float64 = 360.0 const oneEighty float64 = 180.0 const radius float64 = 6378137.0 const webMercatorLatLimit float64 = 85.05112877980659 type GenerateTilesConsumerFunc func(tile *Tile) type GenerateTilesOptions struct { Bounds *LngLatBbox Zooms []...
tile/tile.go
0.848659
0.595787
tile.go
starcoder
package poly import ( "container/list" "fmt" "math" ) type Monomial struct { Coef float64 Degree int } type Polynomial struct { monoms *list.List degree int } func New(monoms ...Monomial) *Polynomial { p := &Polynomial{ monoms: list.New(), } for _, m := range monoms { if m.Coef == 0 { continue ...
gm64/poly/poly.go
0.68056
0.448245
poly.go
starcoder
package reflecttools import ( "errors" "fmt" "reflect" "strings" ) const dotPathSep = "." // SetPtrToStruct is used to inject an object into the specified field on a another object. The target object, supplied value and the type // of the named target field must all be a pointer to a struct. func SetPtrToStruct(...
reflecttools/reflecttools.go
0.745213
0.547464
reflecttools.go
starcoder
package functions import ( "fmt" "reflect" ) type Slices struct { } func (s Slices) Length(slice interface{}) int { return reflect.ValueOf(slice).Len() } func (s Slices) StringAt(slice interface{}, index int) (string, error) { if actual, ok := slice.([]string); ok { return actual[index], nil } return "", fm...
functions/slices.go
0.710528
0.431285
slices.go
starcoder
package main import ( "fmt" "os" "runtime" "strconv" "strings" "github.com/TomasCruz/projecteuler" "github.com/TomasCruz/projecteuler/001-100/091-100/096/sudoku" ) /* Problem 96; Su Doku Su Doku (Japanese meaning number place) is the name given to a popular puzzle concept. Its origin is unclear, but credit m...
001-100/091-100/096/main.go
0.646014
0.4474
main.go
starcoder
package evaluator import ( "strconv" "github.com/lyraproj/issue/issue" "github.com/lyraproj/pcore/px" "github.com/lyraproj/pcore/types" "github.com/lyraproj/puppet-evaluator/pdsl" "github.com/lyraproj/puppet-parser/parser" ) func evalArithmeticExpression(e pdsl.Evaluator, expr *parser.ArithmeticExpression) px....
evaluator/arithmetic.go
0.676834
0.406302
arithmetic.go
starcoder
package storage import ( "fmt" "sort" "zircon/apis" ) type MemoryStorage struct { isClosed bool chunks map[apis.ChunkNum]map[apis.Version][]byte latest map[apis.ChunkNum]apis.Version } // Creates an in-memory-only location to store data, and construct an interface by which a chunkserver can store chunks fu...
src/zircon/chunkserver/storage/memory.go
0.702326
0.423279
memory.go
starcoder
package apivideosdk import ( //"encoding/json" ) // VideoWatermark struct for VideoWatermark type VideoWatermark struct { // id of the watermark Id *string `json:"id,omitempty"` // Distance expressed in px or % between the top-border of the video and the watermark-image. Top *string `json:"top,omitempty"` // Di...
model_video_watermark.go
0.786869
0.457924
model_video_watermark.go
starcoder
package mssqlx import ( "context" "database/sql" "github.com/jmoiron/sqlx" ) // Stmtx wraps over sqlx.Stmt type Stmtx struct { *sqlx.Stmt } // Exec executes a prepared statement with the given arguments and returns a Result summarizing the effect of the statement. func (s *Stmtx) Exec(args ...interface{}) (sql....
stmtx.go
0.712232
0.409339
stmtx.go
starcoder
package day19 import ( "math" "strconv" "strings" "github.com/heindsight/aoc21/utils/set" "github.com/heindsight/aoc21/utils/input" "github.com/heindsight/aoc21/utils/numeric" ) type Vector [3]int func (p Vector) Sub(q Vector) Vector { d := Vector{} for i := range p { d[i] = p[i] - q[i] } return d } fu...
solutions/day19/day19.go
0.622918
0.542076
day19.go
starcoder
// Package testt provides utilities for functions that consume *testing.T. package testt import ( "errors" "fmt" "reflect" "runtime" "sync" "testing" ) // ExpectFatal fails the test if the specified function does _not_ fail fatally, // i.e. does not call any of t.{FailNow, Fatal, Fatalf}. // If it does fail fa...
testt.go
0.696991
0.522141
testt.go
starcoder
package xarray import ( "bytes" "encoding/json" "github.com/go-xe2/x/core/rwmutex" "github.com/go-xe2/x/type/t" "github.com/go-xe2/x/utils/xrand" "math" "sort" ) type TArray struct { mu *rwmutex.RWMutex array []interface{} } func New(unsafe ...bool) *TArray { return NewArraySize(0, 0, unsafe...) } func...
container/xarray/xarray_normal_any.go
0.506103
0.423279
xarray_normal_any.go
starcoder
package main import ( "sort" "strconv" "github.com/james-wallis/adventofcode/utils" ) // ReadLinesAndConvertToInts reads a file, splits it into lines and converts the lines into ints (assumes given file only contains ints) func ReadLinesAndConvertToInts(path string) ([]int64, error) { lines, readFileErr := utils...
1/day1.go
0.561455
0.424889
day1.go
starcoder
package pir import ( "errors" "math" "sync" "github.com/ncw/gmp" "github.com/sachaservan/paillier" "github.com/sachaservan/pir/dpf" ) // DBMetadata contains information on the layout // and size information for a slot database type type DBMetadata struct { SlotBytes int DBSize int } // Database is a set ...
db.go
0.675872
0.453867
db.go
starcoder
package exporter import ( "fmt" "time" ) // Keep track of labels values for a metric. type LabelValueTracker interface { Observe(labels map[string]string) (bool, error) DeleteByLabels(labels map[string]string) ([]map[string]string, error) DeleteByRetention(retention time.Duration) []map[string]string } // Repr...
vendor/github.com/fstab/grok_exporter/exporter/labelValueTracker.go
0.805479
0.573678
labelValueTracker.go
starcoder
package color import ( "image/color" ) // ToNRGBA converts a color to RGBA values which are not premultiplied, unlike color.RGBA(). func ToNRGBA(c color.Color) (r, g, b, a int) { // We use UnmultiplyAlpha with RGBA, RGBA64, and unrecognized implementations of Color. // It works for all Colors whose RGBA() method i...
vendor/fyne.io/fyne/v2/internal/color/color.go
0.699973
0.545528
color.go
starcoder
package spline import ( "image/draw" "image/color" "math" ) type Canvas struct { draw.Image Matrix } func (canvas *Canvas) DrawLine(x1, y1, x2, y2 float64, col color.Color, antialiased bool) *Canvas { if antialiased { xiaolinWuLine(canvas, x1, y1, x2, y2, col.(color.NRGBA)) } else { bresenhamLine(canvas, ...
line.go
0.626238
0.638455
line.go
starcoder
package day18 import ( "adventofcode/utils" "fmt" "math" "strconv" ) type TNode struct { parent *TNode left *TNode right *TNode value int } func (tn TNode) String() string { if tn.isLeaf() { return fmt.Sprint(tn.value) } return fmt.Sprintf("[%s,%s]", tn.left, tn.right) } func (tn TNode) isLeaf() bo...
day18/day18.go
0.54359
0.44089
day18.go
starcoder
package metronome import ( "time" "gitlab.com/gomidi/midi/smf" ) // absPosToMsec transforms the absolute ticks to microseconds based on the tempi func absPosToMsec(metricTicks smf.MetricTicks, temps tempi, absPos uint64) (msec int64) { /* calculate the abstime in msec for every tempo position up to the last te...
metronome/helpers.go
0.715424
0.78108
helpers.go
starcoder
package hash import "math/big" func newGroup(a, b, c *big.Int) *group { return &group{a: a, b: b, c: c} } func cloneGroup(g *group) *group { return newGroup(g.a, g.b, g.c) } func newGroupFromDiscriminant(a, b, d *big.Int) *group { z := new(big.Int).Sub(new(big.Int).Mul(b, b), d) c := floorDivision(z, new(big.In...
pkg/util/difficulty/hash/group.go
0.682679
0.468547
group.go
starcoder
package copier import ( "database/sql" "reflect" ) type Converter func(from reflect.Value, toType reflect.Type) (reflect.Value, error) type Transformer map[string]interface{} type Mapper interface { From(fromValue interface{}) CopyCommand RegisterConverter(matcher TypeMatcher, converter Converter) Mapper Reg...
copier.go
0.641647
0.417806
copier.go
starcoder