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 model //------------------------------------------------------------------------------ // UndefinedState indicates a component state is undefined const UndefinedState string = "undefined" // FailureState indicates a component related failure has occured const FailureState string = "failure" // InitialState ...
src/tsai.eu/solar/model/constants.go
0.555073
0.55447
constants.go
starcoder
package pegasos import ( "bufio" "bytes" "fmt" "io" "io/ioutil" "log" "math" "math/rand" "os" "strings" "time" ) // binary classification func hingeLoss(w float64, y int) float64 { loss := 1.0 - w*float64(y) if loss > 0.0 { return loss } return 0.0 } func HingeLoss(w Weights, fv *FeatureVector, y i...
src/github.com/tetsuok/go-pegasos/pegasos/pegasos.go
0.68056
0.407098
pegasos.go
starcoder
package indextbl import ( "sort" "sync" "github.com/RoaringBitmap/roaring" "github.com/hillbig/rsdic" ) // Implementation of an R-way Trie data structure. // Ref: https://en.wikipedia.org/wiki/Trie // A succinct data structure supporting rank/select efficiently is used here for querying and filtering data. // D...
tsdb/indextbl/trie_tree.go
0.714728
0.643805
trie_tree.go
starcoder
// As soon as we add another Goroutine to our program, we add a huge amount of complexity. We can't // always let the Goroutine run stateless. There has to be coordination. There are, in fact, 2 // things that we can do with multithread software. // (1) We either have to synchronize access to share state like that Wai...
go/concurrency/data_race_1.go
0.55929
0.57084
data_race_1.go
starcoder
package tsm1 import ( "bytes" "encoding/binary" "fmt" "hash/crc32" "io" "sort" "strings" "github.com/influxdata/influxdb/v2/pkg/binaryutil" ) const ( // MeasurementMagicNumber is written as the first 4 bytes of a data file to // identify the file as a tsm1 stats file. MeasurementStatsMagicNumber string = ...
tsdb/tsm1/stats.go
0.714728
0.405743
stats.go
starcoder
package ogre /* #cgo LDFLAGS: -lllcoi #include "llcoi/ogre_interface.h" */ import "C" type Quaternion struct { cptr C.QuaternionHandle } func CreateQuaternion() Quaternion { var result Quaternion result.cptr = C.quaternion_create() return result } func CreateQuaternionFromValues(w, x, y, z float32) Quaternion...
quaternion.go
0.741674
0.55911
quaternion.go
starcoder
package parser // Function represents a function of the expression language and is // used by function nodes. type Function struct { Name string ArgTypes []ValueType Variadic int ReturnType ValueType } // Functions is a list of all functions supported by PromQL, including their types. var Functions = map[string...
promql/parser/functions.go
0.538498
0.824956
functions.go
starcoder
package stringmatrix import ( "fmt" ) type StringMatrix struct { Fields [][]string RowCount int ColCount int } func NewStringMatrix() StringMatrix { m := StringMatrix{} m.RowCount = 0 m.ColCount = 0 return m } func NewStringMatrixWithSize(h int, w int) StringMatrix { m := StringMatrix{} m.RowCo...
stringmatrix.go
0.628407
0.430925
stringmatrix.go
starcoder
package internal import ( "math" "github.com/twpayne/go-geom" ) // IsPointWithinLineBounds calculates if the point p lays within the bounds of the line // between end points lineEndpoint1 and lineEndpoint2 func IsPointWithinLineBounds(p, lineEndpoint1, lineEndpoint2 geom.Coord) bool { minx := math.Min(lineEndpoin...
xy/internal/cga.go
0.78691
0.401776
cga.go
starcoder
package include import "strings" // Exampledagadvanced created with astro dev init var Exampledagadvanced = strings.TrimSpace(` from datetime import datetime, timedelta from typing import Dict # Airflow operators are templates for tasks and encompass the logic that your DAG will actually execute. # To use an operato...
airflow/include/advancedexampledag.go
0.749087
0.676994
advancedexampledag.go
starcoder
package riksbank import ( "fmt" "strings" ) // AnalysisMethod represents the analysis method for comparing values in a period type AnalysisMethod int func (am AnalysisMethod) String() string { if name, ok := AnalysisMethodNames[am]; ok { return name } return "" } const ( // Real is the actual value for the ...
analysis.go
0.740268
0.564939
analysis.go
starcoder
package basic // ZIPNumberToNumber is template to generate itself for different combination of data type. func ZIPNumberToNumber() string { return ` func TestZip<FINPUT_TYPE1><FINPUT_TYPE2>(t *testing.T) { list1 := []<INPUT_TYPE1>{1, 2, 3, 4} list2 := []<INPUT_TYPE2>{10, 20, 30, 40} expectedMap := map[<INPUT_TYP...
internal/template/basic/ziptest.go
0.590779
0.609205
ziptest.go
starcoder
package models import ( "fmt" "reflect" "regexp" "testing" "go.wandrs.dev/framework/modules/setting" "github.com/stretchr/testify/assert" "xorm.io/builder" ) // consistencyCheckable a type that can be tested for database consistency type consistencyCheckable interface { checkForConsistency(t *testing.T) } ...
models/consistency.go
0.581897
0.553747
consistency.go
starcoder
package text import ( "io" "regexp" "unicode/utf8" "github.com/pgavlin/goldmark/util" ) const invalidValue = -1 // EOF indicates the end of file. const EOF = byte(0xff) // A Reader interface provides abstracted method for reading text. type Reader interface { io.RuneReader // Source returns a source of the ...
provider/vendor/github.com/pgavlin/goldmark/text/reader.go
0.640861
0.430985
reader.go
starcoder
package parseutil import ( "github.com/lighttiger2505/sqls/ast" "github.com/lighttiger2505/sqls/ast/astutil" "github.com/lighttiger2505/sqls/token" ) type NodeWalker struct { Paths []*astutil.NodeReader Index int } func astPaths(reader *astutil.NodeReader, pos token.Pos) []*astutil.NodeReader { paths := []*ast...
parser/parseutil/walk.go
0.567697
0.491578
walk.go
starcoder
package ts import ( "fmt" "time" "github.com/m3db/m3/src/query/errors" "github.com/m3db/m3/src/query/models" ) // Series is the public interface to a block of timeseries values. Each block has a start time, // a logical number of steps, and a step size indicating the number of milliseconds represented by each ...
src/query/ts/series.go
0.756807
0.491151
series.go
starcoder
package model import ( "github.com/df-mc/dragonfly/server/block/cube" "github.com/df-mc/dragonfly/server/entity/physics" "github.com/df-mc/dragonfly/server/world" "github.com/go-gl/mathgl/mgl64" ) // Stair is a model for stair-like blocks. These have different solid sides depending on the direction the // stairs ...
server/block/model/stair.go
0.680029
0.487002
stair.go
starcoder
package scl import ( "github.com/aiseeq/s2l/lib/point" "github.com/beefsack/go-astar" "math" ) type MapAccessor interface { IsPathable(p point.Pointer) bool IsBuildable(p point.Pointer) bool HeightAt(p point.Pointer) float64 } // A Tile is a tile in a grid which implements Pather. type Tile struct { // X and ...
lib/scl/astar.go
0.777933
0.596492
astar.go
starcoder
package iso20022 // Cash movements from or to a fund as a result of investment funds transactions, eg, subscriptions or redemptions. type FundCashForecast1 struct { // Date and, if required, the time, at which the price has been applied. TradeDateTime *DateAndDateTimeChoice `xml:"TradDtTm"` // Previous date and t...
data/train/go/f239af622991a47b764dec2f3103f7dabd1053d6FundCashForecast1.go
0.814385
0.416322
f239af622991a47b764dec2f3103f7dabd1053d6FundCashForecast1.go
starcoder
package gocyk import ( grm "github.com/ghigt/gocyk/grammar" "github.com/ghigt/gocyk/ptree" "github.com/ghigt/gocyk/rtable" ) // GoCYK type contains the recognition table, the parsing tree, // the grammar and the substrings. It provides methods to abstract // the calculation of the CYK algorithm to modify the parsi...
gocyk.go
0.684475
0.401512
gocyk.go
starcoder
package asn1 import ( "errors" "fmt" "math/big" "strings" ) // BIT STRING func NewBitString() BitString { return BitString{} } // BitString is the structure to use when you want an ASN.1 BIT STRING type. A // bit string is padded up to the nearest byte in memory and the number of // valid bits is recorded. Padd...
types.go
0.680135
0.40248
types.go
starcoder
// Copyright ©2019 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build go1.14,!go1.15 package yaegi import ( "reflect" "gonum.org/v1/gonum/blas/blas64" "gonum.org/v1/gonum/blas/cblas128" "gonum.org/v1/gonum/ma...
yaegi/go1_14_gonum.org_v1_gonum_mat.go
0.678433
0.44071
go1_14_gonum.org_v1_gonum_mat.go
starcoder
package gslices import ( "github.com/nwillc/genfuncs" "github.com/nwillc/genfuncs/container" ) // Associate returns a map containing key/values created by applying a function to elements of the slice. func Associate[T, V any, K comparable](slice container.GSlice[T], keyValueFor genfuncs.MapKeyValueFor[T, K, V]) (re...
container/gslices/gslice_functions.go
0.812644
0.592667
gslice_functions.go
starcoder
package function import ( "errors" "fmt" "math" "reflect" "strings" "github.com/golang/geo/s2" "github.com/mmcloughlin/geohash" "github.com/gojek/merlin/pkg/transformer/types/converter" ) const ( earthRadiusKm = 6371 // radius of the earth in kilometers. pointFive = 0.5 zero ...
api/pkg/transformer/symbol/function/geospatial.go
0.783658
0.535524
geospatial.go
starcoder
package henge import ( "reflect" ) type ( // InstanceStore is an interface for Converter holds some key-value pairs. InstanceStore interface { // InstanceGet returns the value saved using Set. InstanceGet(key string) interface{} // InstanceSet saves the value on the key. InstanceSet(key string, value inter...
henge.go
0.786705
0.401923
henge.go
starcoder
package miner import ( "container/ring" "sync" "github.com/matrix/go-matrix/common" "github.com/matrix/go-matrix/core/types" "github.com/matrix/go-matrix/log" ) // headerRetriever is used by the unconfirmed block set to verify whether a previously // mined block is part of the canonical chain or not. type head...
miner/unconfirmed.go
0.633183
0.424114
unconfirmed.go
starcoder
package trisoban import ( tl "github.com/JoelOtter/termloop" ) // Crate inherits the entity making it a drawable, it also inherits the coordinates struct, and has a bool for the rachedgoal check. type Crate struct { *tl.Entity Coordinates } // NewCrate creates an entity for the crate and returns a pointer to a cr...
src/crate.go
0.824815
0.424889
crate.go
starcoder
package hole import ( "math/rand" "strconv" "strings" ) // a bounding box (bbox) is defined in // terms of its top-left vertex coordinates // (x, y) and its width and height (w, h). type bbox struct{ x, y, w, h int } // couldn't find a quick way to loop a struct func strconvbox(box bbox) (out string) { var outs ...
hole/intersection.go
0.596081
0.437223
intersection.go
starcoder
package main /** 给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。 百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个节点也可以是它自己的祖先)。” 例如,给定如下二叉树: root =[3,5,1,6,2,0,8,null,null,7,4] 示例 1: 输入: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1 输出: 3 解释: 节点 5 和节点 1 的最近公共祖先是节点 3。 示例2: 输入: root = [3,5,1,6,2,0,8,n...
lcof/lowestCommonAncestor2/lowestCommonAncestor2.go
0.541651
0.698593
lowestCommonAncestor2.go
starcoder
package satellite import ( "log" "math" ) // this procedure converts the day of the year, epochDays, to the equivalent month day, hour, minute and second. func days2mdhms(year int64, epochDays float64) (mon, day, hr, min, sec float64) { lmonth := [12]int{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} if year % ...
conversions.go
0.727782
0.52829
conversions.go
starcoder
package trie import ( "encoding/json" "github.com/daotl/go-libp2p-xor/key" ) // Trie is a trie for equal-length bit vectors, which stores values only in the leaves. // Trie node invariants: // (1) Either both branches are nil, or both are non-nil. // (2) If branches are non-nil, key must be nil. // (3) If both bra...
trie/trie.go
0.751739
0.512754
trie.go
starcoder
package conf // Int16Var defines an int16 flag and environment variable with specified name, default value, and usage string. // The argument p points to an int16 variable in which to store the value of the flag and/or environment variable. func (c *Configurator) Int16Var(p *int16, name string, value int16, usage stri...
value_int16.go
0.731155
0.49292
value_int16.go
starcoder
package blockchain import ( "bytes" "errors" "time" "github.com/it-chain/yggdrasill/common" ) // ErrHashCalculationFailed 변수는 Hash 계산 중 발생한 에러를 정의한다. var ErrHashCalculationFailed = errors.New("Hash Calculation Failed Error") var ErrInsufficientFields = errors.New("Previous seal or transaction list seal is not s...
blockchain/validator.go
0.619586
0.450057
validator.go
starcoder
package osc import ( "encoding/json" ) // Volume Information about the volume. type Volume struct { // The number of I/O operations per second (IOPS):<br /> - For `io1` volumes, the number of provisioned IOPS<br /> - For `gp2` volumes, the baseline performance of the volume Iops *int32 `json:"Iops,omitempty"` //...
v2/model_volume.go
0.811825
0.449211
model_volume.go
starcoder
package io import ( "math" "reflect" "strconv" "github.com/modern-go/reflect2" ) func (dec *Decoder) stringToFloat32(s string) float32 { f, err := strconv.ParseFloat(s, 32) if err != nil { dec.Error = err } return float32(f) } func (dec *Decoder) stringToFloat64(s string) float64 { f, err := strconv.Pars...
io/float_decoder.go
0.712332
0.421254
float_decoder.go
starcoder
package iso20022 // Set of characteristics related to a cheque instruction, such as cheque type or cheque number. type Cheque7 struct { // Specifies the type of cheque to be issued. ChequeType *ChequeType2Code `xml:"ChqTp,omitempty"` // Unique and unambiguous identifier for a cheque as assigned by the agent. Che...
Cheque7.go
0.741861
0.44559
Cheque7.go
starcoder
package skill import ( "github.com/xiaonanln/goworld/engine/entity" "math" ) func Distance(src, dest entity.Vector3) float64 { return math.Sqrt(math.Pow(float64(src.X-dest.X), float64(src.Y-dest.Y))) } // p2p类型技能 type PointSkill struct { Distance float64 } func (this *PointSkill) IsInDistance(src, dest entity.V...
examples/unity_demo/skill/skill_base.go
0.63624
0.69579
skill_base.go
starcoder
package iso20022 // Nature of the amount and currency on a document referred to in the remittance section, typically either the original amount due/payable or the amount actually remitted for the referenced document. type RemittanceAmount1 struct { // Amount specified is the exact amount due and payable to the credi...
RemittanceAmount1.go
0.769946
0.583203
RemittanceAmount1.go
starcoder
package model import ( "time" ) // Earthquake structure defines all the data that describes the // earthquake. All the fields and their values are also used to // send earthquake info back to the client in JSON format. So, the // mapping to JSON key names is also specified. type Earthquake struct { ID str...
src/app/model/earthquake.go
0.812719
0.44746
earthquake.go
starcoder
package hungarian import ( "math" ) /** * Author: Stanford * Date: Unknown * Source: Stanford Notebook * Description: Min cost bipartite matching. Negate costs for max cost. * Time: O(N^3) * Status: tested during ICPC 2015 * Repo: https://github.com/lungsin/go-hungarian */ func zero(x float64) bool { retur...
hungarian.go
0.752104
0.464962
hungarian.go
starcoder
package graphnode import ( "database/sql/driver" "encoding/hex" "encoding/json" "fmt" "math/big" ) type Float struct { float *big.Float } func NewFloat(f *big.Float) Float { return Float{float: f} } func FloatAdd(a, b Float) Float { return Float{float: new(big.Float).Add(a.float, b.float)} } ...
consumers/pancakeswap-to-graphnode/graph-node/numeric.go
0.757705
0.427456
numeric.go
starcoder
package iso20022 // Set of elements used to provide information specific to the individual transaction(s) included in the message. type CreditTransferTransactionInformation13 struct { // Set of elements used to reference a payment instruction. PaymentIdentification *PaymentIdentification3 `xml:"PmtId"` // Set of ...
CreditTransferTransactionInformation13.go
0.707607
0.568116
CreditTransferTransactionInformation13.go
starcoder
package palette // TODO // * Write test images with some transparent pixels, or fully transparent. import ( "fmt" "image" "image/color" "math/rand" "sort" "github.com/lucasb-eyer/go-colorful" "github.com/muesli/clusters" "github.com/muesli/kmeans" ) type colorSpace interface { ColorToObservation(c color.Co...
palette/extract.go
0.617513
0.490663
extract.go
starcoder
package user import ( "errors" "fmt" "strconv" "strings" ) // Range errors var ( ErrInvalidRange = errors.New("invalid range; a range must consist of positive integers and the upper bound must be greater than or equal to the lower bound") ) // ErrParseRange is an error encountered while parsing a Range type Err...
vendor/github.com/openshift/source-to-image/pkg/util/user/range.go
0.737442
0.495178
range.go
starcoder
package tests import ( "reflect" "testing" "github.com/google/uuid" "github.com/murlokswarm/app" ) // TestMarkup is a test suite used to ensure that all markups implementations // behave the same. func TestMarkup(t *testing.T, newMarkup func(factory app.Factory) app.Markup) { factory := app.NewFactory() factor...
tests/markup.go
0.591959
0.45181
markup.go
starcoder
package common import ( "engo.io/engo" "engo.io/gl" ) // Level is a parsed TMX level containing all layers and default Tiled attributes type Level struct { // Orientation is the parsed level orientation from the TMX XML, like orthogonal, isometric, etc. Orientation string // RenderOrder is the in Tiled specified...
common/level.go
0.688154
0.540439
level.go
starcoder
package elements import ( . "github.com/drbrain/go-unicornify/unicornify/core" ) type FlatTracer struct { p1, p2, p3 BallProjection bounds Bounds fourCorners bool w1, w2 Vector dir Vector fourthColor Color wv WorldView } func NewFlatTracer(wv WorldView, b1, b2, b3 *Ball, fourCorne...
unicornify/elements/flat.go
0.572245
0.460895
flat.go
starcoder
package shape import ( "gioui.org/f32" "gioui.org/layout" "gioui.org/op" "gioui.org/op/clip" "gioui.org/op/paint" "image/color" ) const c = 0.55228475 // 4*(sqrt(2)-1)/3 type Circle struct { Center f32.Point Radius float32 } func (cc Circle) Stroke(col color.RGBA, width float32, gtx *layout.Context) f32.Rec...
circle.go
0.614047
0.426501
circle.go
starcoder
package main /** 统计一个数字在排序数组中出现的次数。 示例 1: 输入: nums = [5,7,7,8,8,10], target = 8 输出: 2 示例2: 输入: nums = [5,7,7,8,8,10], target = 6 输出: 0 限制: 0 <= 数组长度 <= 50000 注意:本题与主站 34 题相同(仅返回值不同):https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/ */ /** 两次2分 找左和右 */ func search(nums []int,...
lcof/search/search.go
0.734024
0.487368
search.go
starcoder
package main import ( "encoding/binary" "io" "math" "os" "gorgonia.org/tensor" ) // ParseTinyYOLOv2 Parse darknet weights (v2) func ParseTinyYOLOv2(fname string) []float32 { fp, err := os.Open(fname) if err != nil { panic(err) } defer fp.Close() summary := []byte{} data := make([]byte, 4096) for { da...
examples/tiny-yolo-v2-coco/weights_darknet.go
0.502686
0.481332
weights_darknet.go
starcoder
package v1alpha1 // BuildPipelineListerExpansion allows custom methods to be added to // BuildPipelineLister. type BuildPipelineListerExpansion interface{} // BuildPipelineNamespaceListerExpansion allows custom methods to be added to // BuildPipelineNamespaceLister. type BuildPipelineNamespaceListerExpansion interfa...
client/listers/devops/v1alpha1/expansion_generated.go
0.535098
0.404507
expansion_generated.go
starcoder
package internal import ( "math" "math/big" "reflect" "time" "github.com/tada/catch" "github.com/tada/dgo/dgo" ) type ( timeType int timeVal struct { time.Time } ) // DefaultTimeType is the unconstrainted Time type const DefaultTimeType = timeType(0) var reflectTimeType = reflect.TypeOf(time.Time{}) f...
internal/time.go
0.747063
0.433142
time.go
starcoder
package dagger import ( "encoding/json" "github.com/autom8ter/dagger/primitive" "io" "sort" ) var globalGraph = primitive.NewGraph() // NodeCount returns the total number of nodes in the graph func NodeCount() int { i := 0 globalGraph.RangeNodes(func(n primitive.Node) bool { if n != nil { i++ } return...
dagger.go
0.75392
0.413418
dagger.go
starcoder
package indicator import ( "github.com/markcheno/go-talib" "math" ) // SuperTrend V1.0 - Buy or Sell Signal // https://cn.tradingview.com/chart/5wBFaZWw/ // trend true = green, false = red // red->green = false->true = buy // green->red = true->false = sell func SuperTrend(factor float64, period int, inHigh, inLow,...
supertrend.go
0.516108
0.432063
supertrend.go
starcoder
package draw2dAnimation import ( "code.google.com/p/go-avltree/trunk" ) // Used as compare method for type int. func compareInts(first int, second int) int { if first < second { return -1 } else if first > second { return 1 } return 0 } // Used as compare method for interface Figurer. func compareFigures(f...
draw2dAnimation/figuresCollection.go
0.845528
0.450178
figuresCollection.go
starcoder
package grid import ( "time" "github.com/google/gapid/test/robot/web/client/dom" ) // Grid is a two-dimensional grid that uses an HTML canvas for display. // Call New() to create a default initialized Grid. type Grid struct { canvas *dom.Canvas datasets []*dataset // The grid dataset(s). rowSort...
test/robot/web/client/widgets/grid/grid.go
0.7478
0.447158
grid.go
starcoder
package gopie import ( "github.com/eugenezinoviev/gopie/assets" "github.com/golang/freetype/truetype" ) //go:generate go run mbed/mbed.go -d ./assets -o ./assets/assets.go -p assets // Value represents chart value. type Value struct { Value float64 // Value. Label string // Label of value. } // PieChart struct...
pie_chart.go
0.651355
0.403684
pie_chart.go
starcoder
package main /* Problem: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. */ func P4() int { return palindromeProductSearchAndDestroy(999) } /* Let's say we...
004.go
0.742422
0.603143
004.go
starcoder
package advent import ( "sort" ) var _ Problem = &syntaxScoring{} type syntaxScoring struct { dailyProblem } func NewSyntaxScoring() Problem { return &syntaxScoring{ dailyProblem{ day: 10, }, } } func (s *syntaxScoring) Solve() interface{} { input := s.GetInputLines() var results []int results = appe...
internal/advent/day10.go
0.544075
0.515925
day10.go
starcoder
package dataloader import ( "context" "github.com/go-log/log" ) // DataLoader is the identifying interface for the dataloader. // Each DataLoader instance tracks the resolved elements. // Note that calling Load and LoadMany on the same dataloader instance // will increment the same counter, once for each method ca...
dataloader.go
0.832475
0.439326
dataloader.go
starcoder
package zopfli const ( // Minimum and maximum length that can be encoded in deflate. MAX_MATCH = 258 MIN_MATCH = 3 // The window size for deflate. Must be a power of two. This should be // 32768, the maximum possible by the deflate spec. Anything less hurts // compression more than speed. WINDOW_SIZE = 32768 ...
vendor/git.townsourced.com/townsourced/go-zopfli/zopfli/util.go
0.688573
0.552359
util.go
starcoder
package packed // Efficient sequential read/write of packed integers. type BulkOperationPacked9 struct { *BulkOperationPacked } func newBulkOperationPacked9() BulkOperation { return &BulkOperationPacked9{newBulkOperationPacked(9)} } func (op *BulkOperationPacked9) decodeLongToInt(blocks []int64, values []int32, i...
core/util/packed/bulkOperation9.go
0.544559
0.73563
bulkOperation9.go
starcoder
package common import ( "math" "reflect" ) var interfaceType reflect.Type func init() { interfaceType = reflect.ValueOf(make([]interface{}, 0)).Type().Elem() } type FilterFunc func(reflect.Value, reflect.Value) func Munge(left, right interface{}) interface{} { return munge(reflect.ValueOf(left), reflect.ValueO...
common/munge.go
0.657648
0.524395
munge.go
starcoder
package dist import ( "math" "math/rand" ) // Produce a new Normal distribution func NewNormalDist(mean, stdDev float64) *Normal { dist := &Normal{ Mu: mean, Sigma: stdDev, space: AllRealSpace, } dist.DefContinuousDistSampleN.dist = dist dist.DefContinuousDistProb.dist = dist dist.DefContinuousDistLgP...
dist/normal.go
0.903627
0.528655
normal.go
starcoder
SDF for 2D polygons. */ //----------------------------------------------------------------------------- package sdf import ( "math" ) //----------------------------------------------------------------------------- // PolySDF2 is an SDF2 made from a closed set of line segments. type PolySDF2 struct { vertex []V2...
sdf/poly2.go
0.798108
0.513851
poly2.go
starcoder
package matchr // NYSIIS computes the NYSIIS phonetic encoding of the input string. It is a // modification of the traditional Soundex algorithm. func NYSIIS(s1 string) string { cleans1 := runestring(cleanInput(s1)) input := runestring(make([]rune, 0, len(s1))) // The output can't be larger than the string itself ...
vendor/github.com/antzucaro/matchr/nysiis.go
0.586286
0.495667
nysiis.go
starcoder
package nifi import ( "encoding/json" ) // VersionedFlowsEntity struct for VersionedFlowsEntity type VersionedFlowsEntity struct { VersionedFlows *[]VersionedFlowEntity `json:"versionedFlows,omitempty"` } // NewVersionedFlowsEntity instantiates a new VersionedFlowsEntity object // This constructor will assign def...
model_versioned_flows_entity.go
0.742888
0.468122
model_versioned_flows_entity.go
starcoder
package trade_knife import ( "math" "github.com/markcheno/go-talib" ) func AutoFiboRectracement(inHigh, inLow, inClose, ratios []float64, depth int, deviation float64) []map[float64]float64 { result := make([]map[float64]float64, len(inClose)) for i := len(inClose) - 1; i > depth*2; i-- { outHigh := inHigh[:i...
auto_fibo_rectracement.go
0.545044
0.40251
auto_fibo_rectracement.go
starcoder
package multiset // MultiSetBool type type MultiSetBool map[bool]int // NewBool creates new set func NewBool() MultiSetBool { return make(map[bool]int) } // Add adds elements func (s MultiSetBool) Add(elements ...bool) { for _, element := range elements { s[element]++ } } // AddN adds n elements func (s Multi...
datastructures/multiset/gen-multiset.go
0.68595
0.415966
gen-multiset.go
starcoder
package gts import ( "bytes" "index/suffixarray" "reflect" "sort" "github.com/go-flip/flip" ) // Shiftable represents a shiftable metadata. type Shiftable interface { Shift(i, n int) interface{} } // Expandable represents a expandable metadata. type Expandable interface { Expand(i, n int) interface{} } // S...
sequence.go
0.858333
0.528229
sequence.go
starcoder
package redblack // Delete deletes a node with the given key. func (t *Tree) Delete(key Key) { t.lock.Lock() defer t.lock.Unlock() if n := t.search(t.root, key); n != t.sentinel { t.delete(n) } } func (t *Tree) delete(z *node) { var ( y = z yOriginalColor = y.color x *node ) ...
redblack/delete.go
0.701611
0.573021
delete.go
starcoder
package netdicom import ( "fmt" "math" ) type faultInjectorAction int const ( faultInjectorContinue = iota faultInjectorDisconnect ) type faultInjectorStateTransition struct { state stateType event *stateEvent action *stateAction } // FaultInjector is a unittest helper. It's used by the statemachine to in...
faultinjector.go
0.532668
0.521837
faultinjector.go
starcoder
package main import ( "encoding/json" "fmt" "github.com/rapito/go-spotify/spotify" "log" "os" "strings" ) // Global variable to hold Spotify API request struct var spot spotify.Spotify // The channel that is written to when we find a link between an origin and // destination artist. This halts the program, and...
src/spotifind/spotifind.go
0.509276
0.420659
spotifind.go
starcoder
package bitmap import "fmt" // And returns the bitwise AND of two bitmaps. func And(a, b Dense) Dense { short, long := a, b if b.len < a.len { short, long = b, a } rLen := short.len if short.negated { rLen = long.len } r := Dense{ bits: make([]byte, 0, BytesFor(rLen)), len: rLen, negated: a.ne...
go/bb84/bitmap/op.go
0.63375
0.400163
op.go
starcoder
package properties import ( "fmt" "math" ) // During layout, float numbers sometimes need special values like "auto" or nil (None in Python). // This file define a float64-like type handling these cases. const ( // AutoF indicates a value specified as "auto", which will // be resolved during layout. AutoF speci...
css/properties/float.go
0.822474
0.444143
float.go
starcoder
package bloom import ( "encoding/binary" "math" ) const ( // Used for a sanity check that we don't allocate too much when determining // bloom filter size in NewFilterWithFalsePositiveRate. maxBuckets = 104857600 // We use uint32 for bucket size internally bytesPerBucket = 4 ) func optimalSubhashes(numBucket...
src/server/pkg/bloom/bloom.go
0.762998
0.571378
bloom.go
starcoder
// Package day05 solves AoC 2021 day 5. package day05 import ( "strconv" "github.com/fis/aoc/glue" "github.com/fis/aoc/util" ) const inputRegexp = `^(\d+),(\d+) -> (\d+),(\d+)$` func init() { glue.RegisterSolver(2021, 5, glue.RegexpSolver{ Solver: solve, Regexp: inputRegexp, }) } func solve(input [][]str...
2021/day05/day05.go
0.66236
0.584508
day05.go
starcoder
package mise import ( "fmt" "math" "reflect" "strconv" ) // GetValueKind get the given value's kind func GetValueKind(val interface{}) (reflect.Value, reflect.Kind) { v := reflect.ValueOf(val) kd := v.Kind() if kd == reflect.Ptr { return GetValueKind(v.Elem().Interface()) } return v, kd } // ParseFloat pa...
vendor/github.com/iyidan/goutils/mise/mise.go
0.685213
0.486454
mise.go
starcoder
package smudge import ( "errors" "net" "sort" "strconv" "strings" "sync" ) // All known nodes, living and dead. Dead nodes are pinged (far) less often, // and are eventually removed var knownNodes = nodeMap{} // All nodes that have been updated "recently", living and dead var updatedNodes = nodeMap{} var dead...
vendor/github.com/clockworksoul/smudge/registry.go
0.571408
0.42674
registry.go
starcoder
package keyvaluestoretest import ( "fmt" "math" "strconv" "strings" "sync" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/theaaf/keyvaluestore" ) type testBinaryMarshaler struct{} func (testBinaryMarshaler) MarshalBinary() ([]byte, error) { return []byte(...
keyvaluestoretest/backend.go
0.539469
0.584508
backend.go
starcoder
package main /* Methods and Interfaces -- the constructs that define objects and their behavior. * How to define methods on types, how to declare interfaces, and how to put everything together. also Errors, Readers and Images */ import ( "io" "os" "fmt" "math" "time" "image" "strconv" "strings" "image/col...
bootstrap/stages/killin_it/killin_it.go
0.580471
0.466542
killin_it.go
starcoder
package graphics import ( "github.com/go-gl/mathgl/mgl32" "math" ) const ( planeRight = 0 planeLeft = 1 planeBottom = 2 planeTop = 3 planeBack = 4 planeFront = 5 planeNormalX = 0 planeNormalY = 1 planeNormalZ = 2 planeToOrigin = 3 ) // Frustum // based on https://gist.github.com/j...
framework/graphics/frustum.go
0.769687
0.587618
frustum.go
starcoder
package gofrac type Result struct { Z complex128 C complex128 Iterations int NFactor float64 } // Results is a 2D slice of Result objects. type Results struct { results [][]Result maxIterations int } // NewResults constructs a 2D slice of Result objects, with outer and inner // dime...
results.go
0.827863
0.489748
results.go
starcoder
package blackscholes func BSDeltaNum(v, t, x, k, r, q float64, o OptionType, eps float64) float64 { if CheckPriceParams(t, x, k, o) != nil { return nan() } e := abs(eps) pu := BSPriceNoErrorCheck(v, t, x+e, k, r, q, o) if x < e { pm := BSPriceNoErrorCheck(v, t, x, k, r, q, o) pd := ZeroUnderlyingBSPrice(...
num.go
0.681197
0.485539
num.go
starcoder
package dcel import ( "fmt" "strconv" ) // DCEL stores the state of the data structure and provides methods for linking of three sets of // objects: vertecies, edges and faces. type DCEL struct { Vertices []*Vertex Faces []*Face HalfEdges []*HalfEdge } // Vertex represents a node in the DCEL structure. Eac...
dcel.go
0.813646
0.721706
dcel.go
starcoder
package gocv import ( "github.com/fwessels/go-cv-simd/sse2" ) // AlphaBlending performs alpha blending operation. // All images must have the same width and height. Source and destination images must have the same format (8 bit per channel, for example GRAY8, BGR24 or BGRA32). Alpha must be 8-bit gray image. // For...
conversion.go
0.58676
0.60996
conversion.go
starcoder
package content const PhoneCode = `{ "297": "Aruba", "93": "Afghanistan", "244": "Angola", "1264": "Anguilla", "358": "Åland Islands", "355": "Albania", "376": "Andorra", "971": "United Arab Emirates", "54": "Argentina", "374": "Armenia", "1684": "American Samoa", "1268"...
internal/content/phonecode.go
0.533884
0.544317
phonecode.go
starcoder
package gfx // BlendState represents the blend state to use when rendering an object whose // AlphaMode == BlendedAlpha. type BlendState struct { // The constant blend color to be used (e.g. with BConstantColor). Color Color // Specifies the blend operand to use for the source RGB components. // All predefined B...
gfx/blending.go
0.880476
0.491456
blending.go
starcoder
package interpreter import ( "fmt" "image" "reflect" ) type Circle struct { Center Point Radius Number } func (c Circle) Compare(other Value) (Value, error) { if r, ok := other.(Circle); ok { if c == r { return Number(0), nil } } return nil, nil } func (c Circle) Add(other Value) (Value, error) { re...
internal/interpreter/circle.go
0.767603
0.40116
circle.go
starcoder
package wkb import ( "encoding/binary" "fmt" "io" "github.com/airmap/tegola" ) //Polygon is a Geometry of one or more rings. The first ring is assumed to be the // outer bounding ringer, and traversed in a clockwise manner. The remaining rings // should be within the bounding area of the first ring, and is trave...
wkb/polygon.go
0.817137
0.497009
polygon.go
starcoder
package poly2tri import ( "fmt" ) type Triangle struct { Points []*Point Neighbors []*Triangle Interior bool ConstrainedEdge []bool DelaunayEdge []bool } func NewTriangle(a, b, c *Point) *Triangle { return &Triangle{ Points: []*Point{a, b, c}, Neighbors: []*Triangle...
vendor/github.com/ByteArena/poly2tri-go/triangle.go
0.678327
0.66224
triangle.go
starcoder
package main import ( "bytes" "encoding/csv" "errors" "fmt" "io" "strconv" "time" ) type Measurement struct { UnixTime int64 Temperature float32 Humidity float32 } // Measurement implemenation {{{ const measurementTimeFormat = "2006-01-02 15:04:05" func (x *Measurement) Update(lag float32, m Measu...
cmd/pimon/measurement.go
0.713531
0.512693
measurement.go
starcoder
package point import ( "github.com/austingebauer/go-ray-tracer/maths" "github.com/austingebauer/go-ray-tracer/vector" ) // Point represents a point in a left-handed 3D coordinate system type Point struct { // X, Y, and Z represent components in a left-handed 3D coordinate system X, Y, Z float64 } // NewPoint ret...
point/point.go
0.932114
0.678254
point.go
starcoder
package pcapng import ( "bytes" "encoding/binary" "fmt" "strings" "github.com/bearmini/pcapng-go/pcapng/optioncode" "github.com/bearmini/pcapng-go/pcapng/blocktype" "github.com/pkg/errors" ) /* 4.1. Section Header Block The Section Header Block (SHB) is mandatory. It identifies the beginning of a se...
pcapng/section_header_block.go
0.661376
0.417865
section_header_block.go
starcoder
package graph import ( "github.com/stackrox/rox/pkg/set" ) // RemoteReadable represents a shared graph state somewhere else that should be considered the current state of the // RemoteGraph object. type RemoteReadable func(reader func(graph RGraph)) // NewRemoteGraph returns an instance of a RemoteGraph with the in...
pkg/dackbox/graph/remote.go
0.784071
0.489381
remote.go
starcoder
Package imageutil contains utility function to create/manipulate images. Asciiraster contains support for raster fonts for images. Using RenderSymbols you can add text and symbols to an image. By specifying a symbol map containing ASCII art it is possible to define how each rune should be rendered. */ package imageuti...
imageutil/asciiraster.go
0.848078
0.609146
asciiraster.go
starcoder
package types import ( "encoding/base64" "fmt" "strings" sdk "github.com/cosmos/cosmos-sdk/types" ) /* A Contract is a special structure encapsulating the context of a coordinated execution made by the Contract Execution Environment. This context represents a piece of code and a set of methods, data that are r...
x/metadata/types/contract.go
0.646125
0.410461
contract.go
starcoder
package gofinancial import ( "fmt" "math" "github.com/razorpay/go-financial/enums/paymentperiod" "github.com/shopspring/decimal" ) /* Pmt compute the fixed payment(principal + interest) against a loan amount ( fv = 0). It can also be used to calculate the recurring payments needed to achieve a certain future va...
reducing_utils.go
0.757525
0.667825
reducing_utils.go
starcoder
// Package queueimpl5 implements an unbounded, dynamically growing FIFO queue. // Internally, queue store the values in fixed sized slices that are linked using // a singly linked list. // This implementation tests the queue performance when storing the "next" pointer // as part of the values slice instead of having i...
queueimpl5/queueimpl5.go
0.858244
0.53279
queueimpl5.go
starcoder
package log // LookupFieldByName returns the value associated with the specified name in the specified field set and `true`, or `nil` and `false` if there's no such value // It treats absent (i.e. `nil`) field sets as empty and tries to use the IndexableFieldSet interface when available before searching through the se...
log/helpers.go
0.780453
0.47926
helpers.go
starcoder