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 square // Represents a collection of catalog objects for the purpose of applying a `PricingRule`. Including a catalog object will include all of its subtypes. For example, including a category in a product set will include all of its items and associated item variations in the product set. Including an item in...
square/model_catalog_product_set.go
0.86421
0.566019
model_catalog_product_set.go
starcoder
package data // LanguageInfo exposes the data for a language's Linguist YAML entry as a Go struct. // See https://github.com/github/linguist/blob/master/lib/linguist/languages.yml type LanguageInfo struct { // Name is the language name. May contain symbols not safe for use in some filesystems (e.g., `F*`). Name str...
data/languageInfo.go
0.727201
0.577555
languageInfo.go
starcoder
package api // GetAllSubjects gets the list of subjects that show up in the current policy. func (e *Enforcer) GetAllSubjects() []string { return e.model.GetValuesForFieldInPolicy("p", "p", 0) } // GetAllObjects gets the list of objects that show up in the current policy. func (e *Enforcer) GetAllObjects() []string...
api/management_api.go
0.703244
0.407569
management_api.go
starcoder
package tree import "github.com/pkg/errors" var ( // ErrCyclicDependencyEncountered is triggered a tree has a cyclic dependency ErrCyclicDependencyEncountered = errors.New("a cycle dependency encountered in the tree") ) // MultiRootTree - represents a data type which has multiple independent root nodes // all root...
core/tree/multi_root_tree.go
0.680879
0.447098
multi_root_tree.go
starcoder
package encoding import ( "encoding/binary" "io" "math" "math/big" "golang.org/x/text/transform" ) const writeScratchSize = 4096 // Encoder encodes hdb protocol datatypes an basis of an io.Writer. type Encoder struct { wr io.Writer err error b []byte // scratch buffer (min 15 Bytes - Decimal) tr trans...
driver/internal/protocol/encoding/encode.go
0.665737
0.442637
encode.go
starcoder
package main const helpScriggo = ` Scriggo is a template engine and Go interpreter. The scriggo command is a tool that can be used to execute a template, initialize an interpreter, generate the source files for a package importer and also provides a web server that serves a template rooted at the current directory, u...
cmd/scriggo/help.go
0.827619
0.602062
help.go
starcoder
package tree import ( "bytes" "errors" "fmt" "math" "reflect" "github.com/stefantds/go-epi-judge/data_structures/stack" utils "github.com/stefantds/go-epi-judge/test_utils" ) type TreeLike interface { GetData() int GetLeft() TreeLike GetRight() TreeLike } func isNil(tree TreeLike) bool { return tree == n...
data_structures/tree/utils.go
0.684053
0.406037
utils.go
starcoder
package datastructures import "fmt" func NewBinarySearchTree() binarySearchTree { return binarySearchTree{} } // Iterative Insert func (bst *binarySearchTree) Insert(entry int) { tNode := bst.root var pNode *treeNode = nil for tNode != nil { pNode = tNode if entry > tNode.entry { tNode = tNode.rightNode ...
binarysearchtree.go
0.650356
0.452113
binarysearchtree.go
starcoder
package clang // #include "go-clang.h" import "C" import ( "fmt" "reflect" "unsafe" ) /** * \brief A semantic string that describes a code-completion result. * * A semantic string that describes the formatting of a code-completion * result as a single "template" of text that should be inserted into the * sou...
complete.go
0.810329
0.478224
complete.go
starcoder
package rule import ( "errors" "fmt" "go/token" "strconv" "hash/fnv" ) // An Expr is a logical expression that can be evaluated to a value. type Expr interface { Eval(Params) (*Value, error) } // A Params is a set of parameters passed on rule evaluation. // It provides type safe methods to query params. type ...
rule/expr.go
0.740925
0.422922
expr.go
starcoder
package geom import "math" type Element = float32 type Vector2 struct { X Element Y Element } type Vector3 struct { X Element Y Element Z Element } type Vector4 struct { X Element Y Element Z Element W Element } // column-major matrix type Matrix4 [16]Element func (v *Vector2) Add(v2 *Vector2) *Vector2 ...
geom/geometry.go
0.798462
0.679175
geometry.go
starcoder
package brotli import "encoding/binary" /* Copyright 2015 Google Inc. All Rights Reserved. Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Function for fast encoding of an input fragment, independently from the input history. This function use...
vendor/github.com/andybalholm/brotli/compress_fragment_two_pass.go
0.594787
0.442817
compress_fragment_two_pass.go
starcoder
package lingo import ( "errors" "fmt" ) // Matrix represents a 2 dimensional matrix of float64. type Matrix [][]float64 // Order returns the tensor order. For a matrix, this is always 2. func (m Matrix) Order() int { return 2 } // Rows returns the number of rows the matrix contains. func (m Matrix) Rows() int { ...
matrix.go
0.870281
0.627438
matrix.go
starcoder
package gogm import ( "constraints" "fmt" "math" ) type number interface { constraints.Integer | constraints.Float } // Vec2 is a vector with 2 components, of type T. type Vec2[T number] [2]T // Vec2CopyVec2 copies the content of src to dst. func Vec2CopyVec2[T1, T2 number](dst *Vec2[T1], src *Vec2[T2]) { dst[...
vec2.go
0.801392
0.622517
vec2.go
starcoder
package segment import ( "github.com/scionproto/scion/go/lib/addr" ) // SrcDstPaths enumerates all possible end-to-end segments between a source and // destination ISD-AS pair from a given set of segments. For constant-bounded // segment length, the runtime complexity is linear in the number of // enumeratable segme...
segment/enumerate.go
0.699665
0.420897
enumerate.go
starcoder
package utils import ( "github.com/bnert/mfr" ) // Contains returns true if the item is in the array. func Contains[T comparable](array []T, item T) bool { return mfr.Reduce[T, bool](array, false, func(ctx mfr.Ctx[T], acc bool) bool { return acc || (ctx.Item == item) }) } // IsAll returns true if all the items ...
utils/checks.go
0.689515
0.57329
checks.go
starcoder
package activationfn import ( "math" "github.com/azuwey/gonetwork/matrix" ) // ActivationFunction is an alias for the type of the activation functions type ActivationFunction struct { Name string ActivationFn, DeactivationFn func(*matrix.Matrix) matrix.ApplyFn } func calculateApplySum(s ...
activationfn/activationfn.go
0.759761
0.588682
activationfn.go
starcoder
package serialization import ( i "io" "time" "github.com/google/uuid" ) // SerializationWriter defines an interface for serialization of models to a byte array. type SerializationWriter interface { i.Closer // WriteStringValue writes a String value to underlying the byte array. WriteStringValue(key string, val...
abstractions/go/serialization/serialization_writer.go
0.607896
0.470797
serialization_writer.go
starcoder
package graph //DenseGraph is a data structure representing a simple undirected labelled graph. //DenseGraph stores the number of vertices, the number of edges, the degree sequence of the graph and stores the edges in a []byte array which has an indicator of an edge being present. The edges are in the order 01, 02, 12...
graph/graph_dense.go
0.805211
0.875628
graph_dense.go
starcoder
package history import ( "sort" ) type targetsList []uint64 func (t targetsList) InsertSorted(version uint64) targetsList { if len(t) == 0 { t = append(t, version) return t } index := sort.Search(len(t), func(i int) bool { return t[i] > version }) if index > 0 && t[index-1] == version { return t } ...
balloon/history/consistency.go
0.660282
0.500854
consistency.go
starcoder
package pairings import ( "fmt" "math/big" ) //BN256G2CURVE structure type BN256G2CURVE struct { FieldModulus *big.Int TWISTBX *big.Int TWISTBY *big.Int PTXX uint PTXY uint PTYX uint PTYY uint PTZX uint PTZY uint } // Init Initialized the required ...
utils/pairings/bn256g.go
0.719384
0.453141
bn256g.go
starcoder
package data import ( "fmt" "github.com/axiom-org/axiom/util" ) // Money is measured in "microaxioms". // A million microaxioms = Ax$1. // The target is for Ax$1 to be worth roughly $1 in USD. // The price of decentralized storage is currently pegged at $3 per gigabyte per month. // The goal is 1/3 goes to the fil...
data/account.go
0.666605
0.467393
account.go
starcoder
package util import ( "errors" "image" "image/color" ) // Matrix2Image 矩阵转成 image.Image func Matrix2Image(imgMatrix [][][]uint8) (image.Image, error) { height := len(imgMatrix) width := len(imgMatrix[0]) if height == 0 || width == 0 { return nil, errors.New("the input of matrix is illegal") } nrgba := ima...
image/util/matrix.go
0.50952
0.410284
matrix.go
starcoder
package remotewrite import ( "strings" "unicode" ) type table struct { First *unicode.RangeTable Rest *unicode.RangeTable } var metricNameTable = table{ First: &unicode.RangeTable{ R16: []unicode.Range16{ {0x003A, 0x003A, 1}, // : {0x0041, 0x005A, 1}, // A-Z {0x005F, 0x005F, 1}, // _ {0x0061, 0x0...
pkg/services/live/remotewrite/convert.go
0.608594
0.448789
convert.go
starcoder
package solid import ( "math" "github.com/cpmech/gosl/chk" "github.com/cpmech/gosl/tsr" ) // Mmatch computes M=q/p and qy0 from c and φ corresponding to the strength that would // be modelled by the Mohr-Coulomb model matching one of the following cones: // typ == 0 : compression cone (outer) // == 1 : ext...
mdl/solid/auxiliary.go
0.564098
0.534005
auxiliary.go
starcoder
package conversions import ( "errors" "math" "github.com/tomchavakis/turf-go/constants" ) var factors = map[string]float64{ constants.UnitMiles: constants.EarthRadius / 1609.344, constants.UnitNauticalMiles: constants.EarthRadius / 1852.0, constants.UnitDegrees: constants.EarthRadius / 111325.0, ...
conversions/conversions.go
0.848941
0.697751
conversions.go
starcoder
package gfx import ( "image" "image/color" ) // Layer represents a layer of paletted tiles. type Layer struct { Tileset *Tileset Width int // Width of the layer in number of tiles. Data LayerData } // LayerData is the data for a layer. type LayerData []int // Size returns the size of the layer data given ...
vendor/github.com/peterhellberg/gfx/layer.go
0.891227
0.660446
layer.go
starcoder
package core import ( "bytes" "fmt" "log" "math" "math/rand" "strconv" "strings" ) // BhattacharyyaEstimator is the similarity estimator that quantifies the similarity // of the distribution between the datasets. type BhattacharyyaEstimator struct { AbstractDatasetSimilarityEstimator // struct used to map d...
core/similaritybhattacharyya.go
0.665411
0.641478
similaritybhattacharyya.go
starcoder
package parquet import "unsafe" func (d *int32Dictionary) lookup(indexes []int32, rows array, size, offset uintptr) { checkLookupIndexBounds(indexes, rows) for i, j := range indexes { *(*int32)(rows.index(i, size, offset)) = d.index(j) } } func (d *int64Dictionary) lookup(indexes []int32, rows array, size, off...
dictionary_purego.go
0.522689
0.60577
dictionary_purego.go
starcoder
package tezerrors var errorsDescrs = `{ "Bad deserialized counter": { "title": "Deserialized counter does not match the stored one", "descr": "The byte sequence references a multisig counter that does not match the one currently stored in the given multisig contract" }, "Bad_hash": { ...
internal/bcd/tezerrors/errors.go
0.838316
0.599573
errors.go
starcoder
package mandel import ( "math" "github.com/karlek/wasabi/fractal" ) // OrbitTrap returns the smallest distance and it's point from a distance // function calculated on each point in the orbit. func OrbitTrap(z, c complex128, frac *fractal.Fractal, trap func(complex128) float64) (dist float64, closest complex128) {...
mandel/trap.go
0.877398
0.550064
trap.go
starcoder
package gotree import "strconv" // BinaryTree https://en.wikipedia.org/wiki/Binary_tree type BinaryTree struct { Root *Node } // TODO: interfaces to interact with BinarySearchTrees // Node contains data (and usually a value or a pointer to a value) and pointers to the child nodes type Node struct { Left *Node R...
binary-tree.go
0.603815
0.677829
binary-tree.go
starcoder
package mandelbrot import ( "image" "math" "github.com/lucasb-eyer/go-colorful" ) // This function renders the Mandelbrot set using the complex coordinates (centerX, centerY) and zoom factor. The colors parameter is // a slice of color hex string that will be used to color the image. The last color in the slice...
mandelbrot.go
0.840128
0.691237
mandelbrot.go
starcoder
package Math import ( "errors" "math" ) // a vector is constructed having row and columns of the input // data contains our points type Vector struct { Row_dimension int `json:"row_dimension"` Col_dimension int `json:"col_dimension"` Data []float64 `json:"data"` } // check if the row and column dimensions o...
Math/vector.go
0.646795
0.652144
vector.go
starcoder
package graph import ( "fmt" "github.com/fogleman/delaunay" ) type Graph struct { Vertices []*Vertex Edges []*Edge Adjacency map[*Vertex][]*connection // We using an Adjaceny List boys. |E|/|V|^2 is typically > 1/64, at least in the graphs I like seeing it make } type connection struct { edge *Edge ve...
game/util/graph/graph.go
0.706494
0.425605
graph.go
starcoder
package mocks import ( "encoding/json" "github.com/taxjar/taxjar-go" ) // SummaryRates - mock response var SummaryRates = new(taxjar.SummaryRatesResponse) var _ = json.Unmarshal([]byte(SummaryRatesJSON), &SummaryRates) // SummaryRatesJSON - mock SummaryRates JSON var SummaryRatesJSON = `{ "summary_rates": [ ...
test/mocks/SummaryRates_mock.go
0.693473
0.422445
SummaryRates_mock.go
starcoder
package value import "strings" type compareStringFunc func(a, b string) bool // StringSlice holds a slice of string values type StringSlice struct { valsPtr *[]string } // NewStringSlice makes a new StringSlice with the given string values. func NewStringSlice(vals ...string) *StringSlice { slice := make([]string...
value/stringslice.go
0.845688
0.556219
stringslice.go
starcoder
package ternarytree // Search tests whether a string is present in the ternary search tree. func (tree *TernaryTree) Search(s string) bool { if len(s) > 0 { return searchVisitor(tree.head, s[0], s[1:]) } else if tree.hasEmpty { return true } else { return false } } func searchVisitor(node *treeNode, head by...
search.go
0.764188
0.476092
search.go
starcoder
package av import ( "encoding/csv" "io" "sort" "time" "github.com/pkg/errors" ) const ( // digitalCurrencySeriesDateFormat is the format that digital currency time series data comes in digitalCurrencySeriesDateFormat = "2006-01-02 15:04:05" ) // DigitalCurrencySeriesValue is a piece of data for a given time ...
vendor/github.com/cmckee-dev/go-alpha-vantage/digital_currency.go
0.717903
0.523968
digital_currency.go
starcoder
package rf import r "reflect" // Flags constituting the return value of `rf.Filter`. // Unknown bits will be ignored. const ( // Don't visit self or descendants. Being zero, this is the default. VisNone = 0b_0000_0000 // Visit self. VisSelf = 0b_0000_0001 // Visit descendants. VisDesc = 0b_0000_0010 // Visi...
rf_walk.go
0.873862
0.687584
rf_walk.go
starcoder
package cron import ( "errors" "fmt" "time" ) type Scheduler interface { Next(t time.Time) time.Time Done() bool } type PeriodScheduler struct { period time.Duration } func (p *PeriodScheduler) Next(t time.Time) time.Time { return t.Truncate(time.Second).Add(p.period) } func (p *PeriodScheduler) Done() bool...
cron/scheduler.go
0.639849
0.413359
scheduler.go
starcoder
package lshensemble import ( "math" ) // LshForestArray represents a MinHash LSH implemented using an array of LshForest. // It allows a wider range for the K and L parameters. type LshForestArray struct { maxK int numHash int array []*LshForest } // NewLshForestArray initializes with parameters: // maxK is...
lsharray.go
0.732305
0.400105
lsharray.go
starcoder
package scene import ( "strings" "github.com/Laughs-In-Flowers/shiva/lib/lua" "github.com/Laughs-In-Flowers/shiva/lib/math" "github.com/Laughs-In-Flowers/shiva/lib/render" "github.com/Laughs-In-Flowers/shiva/lib/xrror" l "github.com/yuin/gopher-lua" ) type CamT int const ( NOT_A_CAMERA_TYPE CamT = iota PER...
lib/scene/camera.go
0.633637
0.44077
camera.go
starcoder
package draw2dAnimation import ( "image/color" "math" ) // An adroid figure. Change width and height for adjusting the figure to the desired ratio. type Android struct { *ComposedFigure BodyWidth float64 BodyHeight float64 } // Constructor setting current struct's fields and default values for the base struct ...
draw2dAnimation/android.go
0.878308
0.681462
android.go
starcoder
package regression import ( "go.skia.org/infra/go/sklog" "go.skia.org/infra/go/vec32" "go.skia.org/infra/perf/go/clustering2" "go.skia.org/infra/perf/go/config" "go.skia.org/infra/perf/go/dataframe" "go.skia.org/infra/perf/go/stepfit" "go.skia.org/infra/perf/go/types" ) // StepFit finds regressions by looking ...
perf/go/regression/stepfit.go
0.54577
0.441613
stepfit.go
starcoder
package uncategorized /* Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Note: The length of the array is in range [1, 20,000]. The range of numbers in the array is [-1000, 1000] and the rang...
uncategorized/SubArraySums.go
0.81538
0.843509
SubArraySums.go
starcoder
package blockchain import ( "math/big" "github.com/elastos/Elastos.ELA.SPV/util" "github.com/elastos/Elastos.ELA/common" ) var PowLimit = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 255), big.NewInt(1)) func CalcWork(bits uint32) *big.Int { // Return a work value of zero if the passed difficulty bits repre...
blockchain/difficulty.go
0.774583
0.416322
difficulty.go
starcoder
package assert import ( "bufio" "bytes" "fmt" "io" "strings" ) func min(a, b int) int { if a < b { return a } return b } func max(a, b int) int { if a > b { return a } return b } func calculateRatio(matches, length int) float64 { if length > 0 { return 2.0 * float64(matches) / float64(length) } ...
difflib.go
0.592667
0.407363
difflib.go
starcoder
package assert // T reports when failures occur. // testing.T implements this interface. type T interface { // Fail indicates that the test has failed but // allowed execution to continue. Fail() // FailNow indicates that the test has failed and // aborts the test. // FailNow is called in strict mode (via New). ...
pkg/assert/assertion.go
0.808029
0.545649
assertion.go
starcoder
package gdsp import ( "math" "math/cmplx" ) // WindowType values represent a window function and its inverse. type WindowType int // Types of windows. const ( WindowTypeHann WindowType = iota + 1 WindowTypeHamming WindowTypeNuttal ) // Window applies a window function given by windowType to the input signal. f...
window.go
0.782455
0.446434
window.go
starcoder
package cmatrix import ( "bytes" "fmt" ) // CMatrix represents a matrix storing complex128 values. // Follows the Matrix interface of gonum, which is found at: // https://github.com/gonum/matrix/blob/master/mat64/matrix.go type CMatrix interface { // Dims returns the dimensions of a CMatrix. Dims() (r, c int) ...
CMatrix.go
0.85446
0.500793
CMatrix.go
starcoder
package csg import ( "fmt" ) // Box is a bounding box representation type Box struct { Min Vector Max Vector } // Center returns the center of the bounding box func (b *Box) Center() *Vector { return b.Max.Minus(&b.Min).DividedBy(2.0).Plus(&b.Min) } //AddVector increases the size of the boundig box to include t...
csg/box.go
0.893559
0.704503
box.go
starcoder
package aggregate import ( "math" "squirreldb/types" "github.com/prometheus/prometheus/pkg/value" ) type AggregatedPoint struct { Timestamp int64 Min float64 Max float64 Average float64 Count float64 } type AggregatedData struct { Points []AggregatedPoint ID types.MetricID T...
aggregate/aggregate.go
0.818011
0.448004
aggregate.go
starcoder
package mat3 import ( "math" "github.com/jakubDoka/mlok/mat" ) type Vec struct { X, Y, Z float64 } func V(x, y, z float64) Vec { return Vec{x, y, z} } // Rotated rotates vector around pivot by angle with a right hand rule // so tongue is pivot and curved fingers point to the direction of rotation func (v Vec) ...
mat/mat3/vec.go
0.912668
0.614481
vec.go
starcoder
package ch02 import ( "bytes" "fmt" "reflect" ) type Interpreter struct { // sym_table is part of the environment and holds the list of currently defined symbols. sym_table Atom } func New() *Interpreter { return &Interpreter{ sym_table: NIL{}, } } func (i *Interpreter) Version() string { return "chapter-...
ch02/lisp.go
0.669205
0.477615
lisp.go
starcoder
package geom import "fmt" // operand represents either the first (A) or second (B) geometry in a binary // operation (such as Union or Covers). type operand int const ( operandA operand = 0 operandB operand = 1 ) type label struct { // Set to true once inSet has a valid value. populated bool // Indicates whet...
geom/dcel_label.go
0.734215
0.603056
dcel_label.go
starcoder
package jsoncodec import ( "encoding/hex" "github.com/orbs-network/crypto-lib-go/crypto/encoding" "github.com/pkg/errors" "math/big" "reflect" "strconv" "strings" ) const supported = "Supported types are: uint32 uint64 uint256 bool string bytes bytes20 bytes32 uint32Array uint64Array uint256Array boolArray st...
jsoncodec/args.go
0.635109
0.471223
args.go
starcoder
package cmd import ( "bufio" "fmt" "io" "os" "github.com/seanhagen/jane-coding-challenge/games" "github.com/spf13/cobra" ) var matchData *os.File var ranking *games.Ranking // parseCmd represents the parse command var parseCmd = &cobra.Command{ Use: "parse path/to/match-data.txt", Short: "Read and parse m...
cmd/parse.go
0.611382
0.450178
parse.go
starcoder
package eval import ( "errors" "github.com/eliquious/aechbar/calculator/ast" "github.com/eliquious/lexer" "math/big" ) func Evaluate(expr ast.Expression) (string, error) { exp, err := evalExpression(expr) if err != nil { return "", err } return exp.String(), nil } func evalExpression(expr ast.Expression) (...
calculator/eval/evaluator.go
0.651577
0.468487
evaluator.go
starcoder
package toml import ( "bufio" "bytes" "fmt" "io" "io/ioutil" "strconv" "strings" "time" "unicode/utf8" ) type FormatRule func(*Formatter) error // Set the character to indent lines. If tab is let to 0, tab character will // be used otherwise one or multiple space(s) func WithTab(tab int) FormatRule { retur...
format.go
0.639286
0.411643
format.go
starcoder
package nurbs import "fmt" /* findSpan : determines the knot span index */ /* knot span :The range of parameter values between two successive knots in a spline. */ /* input: --n : last index in control points vector --p : degree --u : the variable that lies on the knot span --U : the knot vector */ func findSpan(n, ...
nurbs/basis.go
0.543833
0.503479
basis.go
starcoder
package search // BinarySearch 搜索和目标值相等的数 func BinarySearch(array []int, target int) int { n := len(array) if n <= 0 { return -1 } left := 0 right := n - 1 for left <= right { mid := left + (right-left)/2 if array[mid] == target { return mid } else if array[mid] < target { left = mid + 1 } else ...
algorithm/binary-search/binary_search.go
0.619817
0.557303
binary_search.go
starcoder
package value import ( "fmt" ) type valueType int // ToNative converts a value from the jqp type system // to the native go type system. func ToNative(v Value) interface{} { switch vt := v.(type) { case Int: return int(vt) case String: return string(vt) case Float: return float64(vt) case Array: res :=...
value/value.go
0.732305
0.437343
value.go
starcoder
package proc import ( "reflect" "github.com/gyuho/linux-inspect/schema" ) // NetDevSchema represents '/proc/net/dev'. // Reference http://man7.org/linux/man-pages/man5/proc.5.html // and http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html. var NetDevSchema = schema.RawData{ IsYAML: false, Columns: []sch...
proc/schema.go
0.615088
0.449574
schema.go
starcoder
package check import "math" // IsValueInMapStringString checks if a string (X) is among the map's values. // Returns a tuple of slice providing the map's keys that have this value, and a bool value (true if the returned slice is not empty). func IsValueInMapStringString(X string, Map map[string]string) ([]string, boo...
isvalueinmap.go
0.862641
0.628635
isvalueinmap.go
starcoder
package export import "github.com/prometheus/client_golang/prometheus" // QueryCacheExporter contains all the Prometheus metrics that are possible to gather from the tranquillity service type QueryCacheExporter struct { DeltaNumEntries *prometheus.GaugeVec `description:"number of cache entries (since last emission...
pkg/export/query_cache.go
0.682997
0.491456
query_cache.go
starcoder
package cloudwatcher import ( "gonum.org/v1/gonum/floats" // Float math tools. "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudwatch" "go.uber.org/zap" // Logging ) // AggregationData represents a container for some data series // about Elasticsearch nodes, that can be converted // ...
v2/internal/app/cloudwatcher/aggregation.go
0.770551
0.403684
aggregation.go
starcoder
package value import ( "fmt" "time" ) // From creates a new Value variable from a given base value func From(v interface{}) (ret Value) { switch x := v.(type) { case bool: p := new(bool) *p = x return BindBool(p) case *bool: p := new(bool) *p = *x return BindBool(p) case byte: p := new(byte) *p...
factory.go
0.535098
0.507202
factory.go
starcoder
package rfc5424 import ( "fmt" "strings" ) // StructuredData holds the structured data of a log record, if any. type StructuredData []StructuredDataElement // String returns the RFC 5424 representation of the structured data. func (sd StructuredData) String() string { if len(sd) == 0 { return "-" } elems :=...
cluster-autoscaler/vendor/github.com/juju/rfc/v2/rfc5424/structureddata.go
0.756627
0.420778
structureddata.go
starcoder
package velocypack import ( "reflect" "time" ) // Value is a helper structure used to build VPack structures. // It holds a single data value with a specific type. type Value struct { vt ValueType data interface{} unindexed bool } // NewValue creates a new Value with type derived from Go type of gi...
deps/github.com/arangodb/go-velocypack/value.go
0.830078
0.630173
value.go
starcoder
package rule import ( "regexp" "github.com/insidersec/insider/engine" ) var AndroidRules []engine.Rule = []engine.Rule{ Rule{ And: []*regexp.Regexp{regexp.MustCompile(`\.crypto\.Cipher`), regexp.MustCompile(`Cipher\.getInstance\(\s*"RSA/.+/NoPadding`)}, NotAnd: []*regexp.Regexp{regexp.MustCompile(`\.crypto\.Ci...
rule/android.go
0.604749
0.456834
android.go
starcoder
package graph import ( "fmt" ) const errInvaliVertexNumber = "graph: invalid vertex number %v" // UndirectedGraph represents an undirected graph. type UndirectedGraph struct { bags [][]*vertex } type vertex struct { i int isVisited bool } // New returns a new undirected graph instance with v vertexs. f...
graph/undirected_graph.go
0.822118
0.505737
undirected_graph.go
starcoder
package mapperz import ( "github.com/modfin/henry/compare" "github.com/modfin/henry/exp/numberz" "github.com/modfin/henry/slicez" ) type IElm[E any] struct { Element E Index int } // Indexed wraps each element in a IElm struct and adds the current index in the slice of the element // eg. // slice := []int{1...
exp/mapperz/mapperz.go
0.756178
0.492432
mapperz.go
starcoder
package retry // Retrier is how a task should be retried type Retrier interface { // This attempts to retry the function passed into it. // It will return nil if no error occurred, or an Errorer if at least 1 failure occurred. // Scaling failure occurs when the function passed as a parameter returns a non-nil valu...
interface.go
0.681833
0.420421
interface.go
starcoder
package types import ( "fmt" xo "github.com/xo/xo/types" "golang.org/x/exp/maps" ) // sqlTypeConverter is an internal struct that contains data related to current // conversion. type sqlTypeConverter struct { // Enums is a map of the enums' name to the underlying enum. Enums map[string]*xo.Enum // Target is th...
types/sqlType.go
0.509032
0.424054
sqlType.go
starcoder
package main import ( "go-guide/datastruct/binaryTree/traversal/levelorder" . "go-guide/datastruct/binaryTree/treeNode" "log" "math/rand" ) /** 题目:https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/ 给你一个整数数组 nums ,其中元素已经按 升序 排列,请你将其转换为一棵 高度平衡 二叉搜索树。 高度平衡 二叉树是一棵满足「每个节点的左右两个子树的高度差的绝对值不超过 1...
datastruct/binaryTree/leetcodeQuestion/sortedArrayToBST/sortedArrayToBST.go
0.678007
0.403537
sortedArrayToBST.go
starcoder
package geometry import ( "math" ) // Triangle is a triangle type Triangle struct { A Point B Point C Point AB Edge BC Edge CA Edge } // TriangleMesh is a mesh of triangles type TriangleMesh struct { Triangles []Triangle Nodes []Point // the centroids of each triangle Vertices []Point Edges []...
pkg/geometry/triangles.go
0.879069
0.638131
triangles.go
starcoder
package genworldvoronoi import ( "math" ) // rErode erodes all region by the given amount. // NOTE: This is based on mewo2's erosion code // See: https://github.com/mewo2/terrain func (m *Map) rErode(amount float64) []float64 { er := m.rErosionRate() newh := make([]float64, m.mesh.numRegions) _, maxr := minMax(er...
genworldvoronoi/erosion.go
0.778818
0.469763
erosion.go
starcoder
package maze import ( "fmt" "github.com/KludgePub/TheMazeRunner/maze/asset" ) // Graph with nodes and paths type Graph struct { // Nodes with their relation Nodes map[string]*Node `json:"maze_nodes"` } // Node represent single cell type Node struct { // Visited if node was traversed Visited bool `json:"-"` /...
maze/dispatcher.go
0.717408
0.482856
dispatcher.go
starcoder
package radolan import ( "bufio" ) // encoding types of the composite type encoding int const ( runlength encoding = iota littleEndian singleByte unknown ) // parsing methods var parse = [4]func(c *Composite, rd *bufio.Reader) error{} // init maps the parsing methods to the encoding type func init() { parse[...
data.go
0.668015
0.416737
data.go
starcoder
package models import ( i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time" i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // AttackSimulationSimulationUserCoverage type AttackSimulationSimulationUserCoverage...
models/attack_simulation_simulation_user_coverage.go
0.609757
0.468973
attack_simulation_simulation_user_coverage.go
starcoder
package shortestPath import ( "context" "fmt" "github.com/RyanCarrier/dijkstra" "github.com/romanornr/autodealer/internal/singleton" "github.com/sirupsen/logrus" "github.com/thrasher-corp/gocryptotrader/currency" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotra...
internal/algo/shortestPath/pairs.go
0.797044
0.400339
pairs.go
starcoder
package main import ( "bufio" "fmt" "io" "log" "os" "strings" ) // Body is a "small Solar System body", i.e. an object in space. A Body orbits // another Body and they are represented as a tree. The root of the tree is the // COM (Center of Mass). // See https://english.stackexchange.com/a/281983 type Body stru...
day06/main.go
0.702224
0.475118
main.go
starcoder
package raytracer import ( "gonum.org/v1/gonum/spatial/r3" "math" ) type Light interface { hasPosition() bool getPosition() *r3.Vec getColorFrac() r3.Vec getLightIntensity() float64 getSpecularLightIntensity() float64 getInverseSquareLawDecayFactor() float64 isPointVisible(point *r3.Vec, traceFunction func(r...
raytracer/light.go
0.890764
0.443962
light.go
starcoder
/* Package spec provides a flexible behavior-driven development (BDD) framework. It wraps the functionality of the standard Go package "testing" to provide descriptive and maintainable behavior specifications. Because it wraps "testing", it can be used with command Gotest. Or, it can be used with the companion command ...
src/github.com/bmatsuo/go-spec/spec/spec.go
0.613468
0.594316
spec.go
starcoder
package gfx import ( "github.com/go-gl/gl/v4.5-core/gl" "github.com/go-gl/mathgl/mgl32" ) // Vertex is a Vertex. type Vertex struct { Vert, Norm mgl32.Vec3 UV mgl32.Vec2 } // BindVertexAttributes binds the attributes per vertex. func BindVertexAttributes(s uint32) { vertAttrib := uint32(gl.GetAttribLoca...
gfx/vertex.go
0.687525
0.51013
vertex.go
starcoder
package gmeasure import "time" /* Stopwatch provides a convenient abstraction for recording durations. There are two ways to make a Stopwatch: You can make a Stopwatch from an Experiment via experiment.NewStopwatch(). This is how you first get a hold of a Stopwatch. You can subsequently call stopwatch.NewStopwatc...
gmeasure/stopwatch.go
0.709925
0.435181
stopwatch.go
starcoder
package parser import ( "bufio" "io" "log" "github.com/jessejohnston/ProductIngester/product" "github.com/pkg/errors" "github.com/shopspring/decimal" ) const ( // RecordLength is the expected length of each flat-file record RecordLength = 142 // TaxRate is the product tax rate. TaxRate = 0.07775 // Numb...
parser/parser.go
0.629205
0.501221
parser.go
starcoder
package artmatlang import ( // "errors" "fmt" "math" ) type syntaxTreeNode struct { oper byte val float64 nodes []syntaxTreeNode } // validate verifies that the node is makes sense. // It requires that the node have an acceptable number of sub nodes for it's operation // eg can not have three nodes and try ...
src/syntaxTree.go
0.527317
0.542439
syntaxTree.go
starcoder
package containers import "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/types" func MakeVector(typ types.Type, nullable bool, opts ...*Options) (vec Vector) { switch typ.Oid { case types.Type_BOOL: vec = NewVector[bool](typ, nullable, opts...) case types.Type_INT8: vec = NewVector[int8](typ, nullable, o...
pkg/vm/engine/tae/containers/factory.go
0.500732
0.564158
factory.go
starcoder
package hfile import ( "bytes" ) /* Implementation of hadoop's variable-length, signed int: http://grepcode.com/file/repo1.maven.org/maven2/org.apache.hadoop/hadoop-common/2.5.0/org/apache/hadoop/io/WritableUtils.java#WritableUtils.readVInt%28java.io.DataInput%29 As far as I understand, the above-mentioned java im...
hfile/vint.go
0.55929
0.486941
vint.go
starcoder
package service // Stability is a type that represents the relative stability of a service // module type Stability int const ( // StabilityExperimental represents relative stability of the most immature // service modules. At this level of stability, we're not even certain we've // built the right thing! Stabili...
pkg/service/types.go
0.736306
0.549278
types.go
starcoder
package entity import ( "github.com/go-gl/mathgl/mgl32" "github.com/veandco/go-sdl2/sdl" ) // Controllable is implemented by all entities that can be controlled with a // controller (e.g. the input controller, or one of the AI controllers). type Controllable interface { // Move moves the entity an amount forwards,...
entity/input.go
0.753104
0.459076
input.go
starcoder
package misc import ( "context" "time" "al.go/terminal" "al.go/terminal/objects/rectangle" "al.go/visualizer" ) //MovingRectangle is a Animation of a Rectangle Moving Around the screen type MovingRectangle struct { rect *rectangle.Rectangle state visualizer.AnimationState } func newRectangle(x int, y int, w...
visualizer/animations/misc/moving-rectangle.go
0.715325
0.425665
moving-rectangle.go
starcoder
package heaputil /* For a given index into a slice or array acting as a binary heap, calculate the index of the parent node. We are guaranteed of not being presented an index less than 3. */ func getParentIndex(cIdx int) int { var pIdx int if cIdx%2 == 1 { pIdx = (cIdx - 1) / 2 } else { pIdx = (cIdx - 2) ...
maxint.go
0.75985
0.555797
maxint.go
starcoder
package fiscal import ( "time" ) const Day = 24 * time.Hour // YearForDate returns the fiscal year (as used by Apple) for a given date. func YearForDate(date time.Time) int { _, end := Year(date.Year()) if end.Before(date) { return date.Year() + 1 } else { return date.Year() } } // QuarterForDate returns t...
fiscal/fiscal.go
0.82734
0.517205
fiscal.go
starcoder
package cmd import ( "fmt" "strconv" "strings" "github.com/jaredbancroft/aoc2020/pkg/helpers" "github.com/jaredbancroft/aoc2020/pkg/shuttle" "github.com/spf13/cobra" ) // day13Cmd represents the day13 command var day13Cmd = &cobra.Command{ Use: "day13", Short: "Advent of Code 2020 - Day13: Shuttle Search",...
cmd/day13.go
0.557364
0.411939
day13.go
starcoder
package generate import ( "image" "image/color" "math" ) // Direction constant - direction of the gradient from first color to the second color. type Direction int const ( // H - horizontal direction H Direction = iota // V - vertical direction V ) func normalize(value float64, min float64, max float64) flo...
generate/generate.go
0.758421
0.583915
generate.go
starcoder
package encoding func (e *encoder) setByte1Int64(value int64, offset int) int { e.d[offset] = byte(value) return offset + 1 } func (e *encoder) setByte2Int64(value int64, offset int) int { e.d[offset+0] = byte(value >> 8) e.d[offset+1] = byte(value) return offset + 2 } func (e *encoder) setByte4Int64(value int6...
internal/encoding/set.go
0.727879
0.500244
set.go
starcoder
package dleq import ( "errors" "github.com/dedis/kyber" ) // Suite wraps the functionalities needed by the dleq package. type Suite interface { kyber.Group kyber.HashFactory kyber.XOFFactory kyber.Random } var errorDifferentLengths = errors.New("inputs of different lengths") var errorInvalidProof = errors.New...
lib/dedis/kyber/proof/dleq/dleq.go
0.7478
0.503601
dleq.go
starcoder