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 ytypes import ( "fmt" "github.com/openconfig/goyang/pkg/yang" ) // Refer to: https://tools.ietf.org/html/rfc6020#section-9.3. // ValidateDecimalRestrictions checks that the given decimal matches the // schema's range restrictions (if any). It returns an error if the validation // fails. func ValidateDeci...
ytypes/decimal_type.go
0.805632
0.460653
decimal_type.go
starcoder
package speller const ( letters = "abcdefghijklmnopqrstuvwxyz" // Sample provides a corpus used to train the dictionary Sample = "big.txt.gz" ) var ( wordFreq map[string]int wordTotal int ) // probability returns the percent of times `word` is found in the corpus func probability(word string) float64 { retur...
speller.go
0.796688
0.458409
speller.go
starcoder
package slice // FilterBool performs in place filtering of a bool slice based on a predicate func FilterBool(a []bool, keep func(x bool) bool) []bool { if len(a) == 0 { return a } n := 0 for _, v := range a { if keep(v) { a[n] = v n++ } } return a[:n] } // FilterByte performs in place filtering of...
filter.go
0.850717
0.569673
filter.go
starcoder
package binarysearchtree import ( "fmt" "github.com/kevinpollet/go-datastructures/errors" ) type node struct { value int left, right *node } // BinarySearchTree data structure implementation. type BinarySearchTree struct { root *node size int } // Add adds the given value to the tree. func (tree *Binar...
binarysearchtree/binary_search_tree.go
0.883368
0.528594
binary_search_tree.go
starcoder
package util import ( "errors" "math/rand" "sort" ) // CopyStr copy a string slice to another func CopyStr(a []string) []string { var b []string b = append(a[:0:0], a...) // See https://github.com/go101/go101/wiki return b } // CutStr removes a sub-slice from start(inclusive in removed slice) // to end (exclus...
util/slice/string.go
0.711832
0.40072
string.go
starcoder
package token import "strings" //go:generate go run gen/gen.go // A CharData token represents a run of text. type CharData struct { Position Value string } func (t *CharData) String() string { return t.Value } // SplitLines splits this token into one or more, one for each line. // This will return empty tokens...
token/token.go
0.622459
0.459137
token.go
starcoder
package pixelpusher import ( "encoding/binary" "fmt" "image" "image/color" ) // x, y and pitch should be int32, since they are likely to be used together with other int32 types. // go-sdl2 uses int32 for most things. // PixelsToImage converts a pixel buffer to an image.RGBA image func PixelsToImage(pixels []uint...
image.go
0.789234
0.519887
image.go
starcoder
package metrics import ( "encoding/json" "io" "time" ) // MarshalJSON returns a byte slice containing a JSON representation of all // the metrics in the Registry. func (r StandardRegistry) MarshalJSON() ([]byte, error) { data := make(map[string]map[string]interface{}) r.Each(func(name string, i interface{}) { ...
vendor/gx/ipfs/QmeYJHEk8UjVVZ4XCRTZe6dFQrb8pGWD81LYCgeLp8CvMB/go-metrics/json.go
0.718989
0.409634
json.go
starcoder
package dbx import ( "errors" "fmt" "sort" "strings" ) // Builder supports building SQL statements in a DB-agnostic way. // Builder mainly provides two sets of query building methods: those building SELECT statements // and those manipulating DB data or schema (e.g. INSERT statements, CREATE TABLE statements). t...
builder.go
0.780537
0.584153
builder.go
starcoder
package distributions import ( "math" "gonum.org/v1/gonum/integrate/quad" "gonum.org/v1/gonum/stat/distuv" "scientificgo.org/special" ) // consistent interface for statistica distributions func findlimits(f func(x float64) float64) float64 { val := 0.0 x := 0.0 for !math.IsNaN(val) { val = f(x) x = x + 2...
distributions.go
0.832985
0.509886
distributions.go
starcoder
package xprop /* xprop/atom.go contains functions related to interning atoms and retrieving atom names from an atom identifier. It also manages an atom cache so that once an atom is interned from the X server, all future atom interns use that value. (So that one and only one request is sent for interning each atom.) ...
vendor/github.com/BurntSushi/xgbutil/xprop/atom.go
0.737536
0.605945
atom.go
starcoder
package soba import ( "fmt" "strings" "time" ) // A Field is an operation that add a key-value pair to the logger's context. // Most fields are lazily marshaled, so it's inexpensive to add fields to disabled debug-level log statements. type Field struct { name string handler func(Encoder) } // Name returns f...
fields.go
0.818011
0.415017
fields.go
starcoder
package e2e import ( "testing" "time" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/watch" "github.com/kok-stack/native-kubelet/internal/test/e2e/framework" "github.com/kok-stack/native-kubelet/internal/test/suite" ) const defaultWatchTimeout = 2 * time.Minute // f is a testing framework that is acces...
test/e2e/suite.go
0.572842
0.420897
suite.go
starcoder
package semver import ( "fmt" "strconv" "strings" ) // SemVer is the immutable semantic version per https://semver.org type SemVer struct { major int minor int patch int } func New(major, minor, patch int) SemVer { return SemVer{ major: major, minor: minor, patch: patch, } } var zero = New(0, 0, 0) f...
cmd/gorepomod/internal/semver/semver.go
0.73659
0.40251
semver.go
starcoder
package pulsar import ( "net/url" "strconv" "strings" "github.com/streamnative/pulsarctl/pkg/pulsar/common" "github.com/streamnative/pulsarctl/pkg/pulsar/utils" ) // Namespaces is admin interface for namespaces management type Namespaces interface { // GetNamespaces returns the list of all the namespaces for ...
pkg/pulsar/namespace.go
0.613584
0.425367
namespace.go
starcoder
package fragment import ( "github.com/ms-uzh/calc/models" ) func CalculateFragments(head models.Head, tail models.Tail, polyamines ...models.Polyamine) models.Fragments { fragments := make([]models.Fragment, len(polyamines)) fragments = calculateFromHead(fragments, head, tail, polyamines...) fragments = calculate...
calculation/fragment/fragment.go
0.662796
0.509825
fragment.go
starcoder
package function import ( "fmt" "regexp" "strings" "github.com/src-d/go-mysql-server/sql" "github.com/src-d/go-mysql-server/sql/expression" errors "gopkg.in/src-d/go-errors.v1" ) // RegexpMatches returns the matches of a regular expression. type RegexpMatches struct { Text sql.Expression Pattern sql.Expre...
sql/expression/function/regexp_matches.go
0.626238
0.420005
regexp_matches.go
starcoder
package zng import ( "strconv" "github.com/brimsec/zq/pkg/byteconv" "github.com/brimsec/zq/zcode" ) func NewUint64(v uint64) Value { return Value{TypeUint64, EncodeUint(v)} } func EncodeByte(b byte) zcode.Bytes { return []byte{b} } func EncodeInt(i int64) zcode.Bytes { var b [8]byte n := zcode.EncodeCounted...
zng/int.go
0.707607
0.417331
int.go
starcoder
package sort import ( "fmt" "sort" "strings" glsssn "github.com/hfmrow/gen_lib/strings/strNum" glte "github.com/hfmrow/gen_lib/types" gltsct "github.com/hfmrow/gen_lib/types/convert" ) // SliceSortDate: Sort 2d string slice with date inside func SliceSortDate(slice [][]string, fmtDate string, dateCol, secDate...
slices/sort/sliceSort.go
0.519765
0.409103
sliceSort.go
starcoder
package plaid import ( "encoding/json" ) // DeductionsTotal An object representing the total deductions for the pay period type DeductionsTotal struct { // Raw amount of the deduction CurrentAmount NullableFloat32 `json:"current_amount,omitempty"` // The ISO-4217 currency code of the line item. Always `null` if ...
plaid/model_deductions_total.go
0.801276
0.558207
model_deductions_total.go
starcoder
package vars //DummyDataFaker is used in tests type DummyDataFaker struct { Dummy string } func (ddf DummyDataFaker) Brand() string { return ddf.Dummy } func (ddf DummyDataFaker) Character() string { return ddf.Dummy } func (ddf DummyDataFaker) Characters() string { return ddf.Dummy } func (ddf DummyDataFaker) Ci...
vars/dummy_data_faker.go
0.617743
0.731215
dummy_data_faker.go
starcoder
package trees import ( "math" "math/rand" "github.com/vodinhphuc/golearn/base" ) type IsolationForest struct { nTrees int maxDepth int subSpace int trees []regressorNode } // Select A random feature for splitting from the data. func selectFeature(data [][]float64) int64 { return int64(rand.Intn(len(dat...
trees/isolation.go
0.763131
0.656025
isolation.go
starcoder
package gointerfaces import ( "encoding/binary" "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/gointerfaces/types" ) func ConvertH256ToHash(h256 *types.H256) [32]byte { var hash [32]byte binary.BigEndian.PutUint64(hash[0:], h256.Hi.Hi) binary.BigEndian.PutUint64(hash[8:], h256.Hi.Lo) binary.B...
gointerfaces/type_utils.go
0.617397
0.40439
type_utils.go
starcoder
package input import ( "github.com/Jeffail/benthos/v3/internal/docs" "github.com/Jeffail/benthos/v3/lib/input/reader" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/message/batch" "github.com/Jeffail/benthos/v3/lib/metrics" "github.com/Jeffail/benthos/v3/lib/types" ) //--------------...
lib/input/gcp_pubsub.go
0.676727
0.706266
gcp_pubsub.go
starcoder
package structure // references: https://github.com/mitchellh/mapstructure import ( "fmt" "reflect" "strconv" "strings" ) // Option is the configuration that is used to create a new decoder type Option struct { TagName string WeaklyTypedInput bool } // Decoder is the core of structure type Decoder st...
common/structure/structure.go
0.642096
0.461563
structure.go
starcoder
// The chromatic adaptation algorithms on this web site may all be implemented as a linear transformation of a // source color (XS, YS, ZS) into a destination color (XD, YD, ZD) by a linear transformation [M] // which is dependent on the source reference white (XWS, YWS, ZWS) and the // destination reference white ...
f64/white/chrom_ad.go
0.593609
0.614914
chrom_ad.go
starcoder
package gmath import ( "math" "math/cmplx" "strconv" ) // Decbin Returns a string containing a binary representation of the given num argument. func Decbin(num int64) string { return strconv.FormatInt(num, 2) } // Dechex Returns a string containing a hexadecimal representation of the given unsigned num argument....
util/gmath/gmath.go
0.940953
0.76176
gmath.go
starcoder
// Package drivertest provides a conformance test for implementations of // runtimevar. package drivertest import ( "context" "reflect" "testing" "github.com/Lioric/go-cloud/runtimevar" "github.com/google/go-cmp/cmp" ) // Harness descibes the functionality test harnesses must provide to run conformance tests. ...
runtimevar/drivertest/drivertest.go
0.663669
0.417093
drivertest.go
starcoder
package stringutils2 import ( "crypto/md5" "encoding/hex" "fmt" "math/rand" "strings" "time" ) func GetMD5Hash(text string) string { hasher := md5.New() hasher.Write([]byte(text)) return hex.EncodeToString(hasher.Sum(nil)) } func EscapeString(str string, pairs [][]string) string { if len(pairs) == 0 { p...
pkg/util/stringutils2/stringutils.go
0.575111
0.416085
stringutils.go
starcoder
package trietree import ( "context" ) // DTree is dynamic tree. type DTree struct { Root DNode lastEdgeID int } // DNode is a node of dynamic tree. type DNode struct { Label rune Low *DNode High *DNode Child *DNode EdgeID int Level int Failure *DNode } func (dn *DNode) dig(c rune) *DNode { p := d...
dynamic.go
0.559049
0.439507
dynamic.go
starcoder
package main import ( "math" "math/cmplx" "github.com/fogleman/ln/ln" ) func main() { eye := ln.Vector{-2, -2, 5} center := ln.Vector{0.1, 0, 0} up := ln.Vector{0, 1, 0} scene := ln.Scene{} scene.Add(CalabiYau(5, math.Pi/4, 16, -1, 1)) dpi := 96.0 width := 11.0 * dpi height := 14.0 * dpi fovy := 45.0 pa...
examples/calabi_yau.go
0.639286
0.444022
calabi_yau.go
starcoder
package parser import ( "strconv" "github.com/Zac-Garby/radon/ast" "github.com/Zac-Garby/radon/token" ) // parseExpression parses an expression starting at the current token. It leaves // cur on the last token of the expression. func (p *Parser) parseExpression(precedence int) ast.Expression { nud, ok := p.nuds[...
parser/expressions.go
0.703448
0.475057
expressions.go
starcoder
package sql import ( "io" ) // Row is a tuple of values. type Row []interface{} // NewRow creates a row from the given values. func NewRow(values ...interface{}) Row { row := make([]interface{}, len(values)) copy(row, values) return row } // Copy creates a new row with the same values as the current one. func (...
sql/row.go
0.773772
0.516961
row.go
starcoder
package missing_file_validation import ( "github.com/threagile/threagile/model" ) func Category() model.RiskCategory { return model.RiskCategory{ Id: "missing-file-validation", Title: "Missing File Validation", Description: "When a technical asset accepts files, these input files should be stri...
risks/built-in/missing-file-validation/missing-file-validation-rule.go
0.612889
0.459743
missing-file-validation-rule.go
starcoder
package common import ( "errors" "fmt" "github.com/mikeyhu/glipso/interfaces" ) type evaluator func([]interfaces.Value, interfaces.Scope) (interfaces.Value, error) type lazyEvaluator func([]interfaces.Type, interfaces.Scope) (interfaces.Value, error) var inbuilt map[REF]FI func init() { inbuilt = map[REF]FI{} ...
common/inbuilt.go
0.613237
0.483161
inbuilt.go
starcoder
package v1alpha1 import ( v1alpha1 "kubeform.dev/provider-oci-api/apis/ai/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" ) // AnomalyDetectionDataAssetLister helps list AnomalyDetectionDataAssets. // All objects returned here must be treated as rea...
client/listers/ai/v1alpha1/anomalydetectiondataasset.go
0.612657
0.429788
anomalydetectiondataasset.go
starcoder
package core import ( "reflect" "github.com/lorenzodonini/ocpp-go/ocpp1.6/types" ) // -------------------- MeterValues (CP -> CS) -------------------- const MeterValuesFeatureName = "MeterValues" // The field definition of the MeterValues request payload sent by the Charge Point to the Central System. type Meter...
ocpp1.6/core/meter_values.go
0.804713
0.530662
meter_values.go
starcoder
package tuikit import ( "strconv" "github.com/nsf/tulib" ) //---------------------------------------------------------------------------- // Point //---------------------------------------------------------------------------- // A Point is an X, Y coordinate pair. The axes increase right and down. type Point stru...
tuikit/geometry.go
0.88639
0.59514
geometry.go
starcoder
package tart // Developed by <NAME>, the Accumulation Distribution // Line is a volume-based indicator designed to measure the // cumulative flow of money into and out of a security. // Chaikin originally referred to the indicator as the // Cumulative Money Flow Line. As with cumulative indicators, // the Accumulation...
ad.go
0.757525
0.694173
ad.go
starcoder
package canvas import ( "image" "image/color" "image/draw" "golang.org/x/image/colornames" "gonum.org/v1/gonum/mat" ) // Constants used to define the location of an Axis primitive. const ( BottomAxis Alignment = 0 LeftAxis Alignment = 1 TopAxis Alignment = 2 RightAxis Alignment = 3 ) // Axis represen...
canvas/axis.go
0.717705
0.54825
axis.go
starcoder
package ptr import "strconv" // IntToStringp converts x to a string pointer. func IntToStringp(x int) *string { str := strconv.FormatInt(int64(x), 10) return &str } // IntpToStringp converts x to a string pointer. // It returns nil if x is nil. func IntpToStringp(x *int) *string { if x == nil { return nil } r...
ptr/convert.go
0.787686
0.435962
convert.go
starcoder
package basic import "strings" // ReducePtrTest reduces a list to a single value by combining elements via a supplied function func ReducePtrTest() string { return ` func TestReduce<FTYPE>Ptr(t *testing.T) { var v1 <TYPE> = 1 var v2 <TYPE> = 2 var v3 <TYPE> = 3 var v4 <TYPE> = 4 var v5 <TYPE> = 5 list := []*<...
internal/template/basic/reduceptrtest.go
0.5564
0.560794
reduceptrtest.go
starcoder
package drawing import ( "fmt" ) // PathBuilder describes the interface for path drawing. type PathBuilder interface { // LastPoint returns the current point of the current sub path LastPoint() (x, y float64) // MoveTo creates a new subpath that start at the specified point MoveTo(x, y float64) // LineTo adds a...
drawing/path.go
0.744471
0.675923
path.go
starcoder
package retry // Strategy is a plugin to the Retrier that provides a hook to manipulate retry behavior. type Strategy interface { // Get returns the retry strategy instance itself. The instance may have internal state to keep track of things like // how much time has elapsed since Get() was called. Get() StrategyIn...
strategy.go
0.752104
0.400808
strategy.go
starcoder
package losses import ( mat "github.com/nlpodyssey/spago/pkg/mat32" "github.com/nlpodyssey/spago/pkg/ml/ag" ) // MAE measures the mean absolute error (a.k.a. L1 Loss) between each element in the input x and target y. func MAE(g *ag.Graph, x ag.Node, y ag.Node, reduceMean bool) ag.Node { loss := g.Abs(g.Sub(x, y))...
pkg/ml/losses/losses.go
0.884339
0.682618
losses.go
starcoder
package v1 import ( "context" "reflect" "github.com/pkg/errors" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" ) // Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. The items in the PhraseSet are favored by the recognition model when you send a call that includes the ...
sdk/go/google/speech/v1/phraseSet.go
0.779825
0.42662
phraseSet.go
starcoder
Package goutils provides utility functions to manipulate strings in various ways. The code snippets below show examples of how to use goutils. Some functions return errors while others do not, so usage would vary as a result. Example: package main import ( "fmt" "github.com/aokoli/g...
vendor/github.com/Masterminds/goutils/wordutils.go
0.644225
0.514217
wordutils.go
starcoder
package iocap import ( "io" "time" ) const ( _ = (1 << (10 * iota)) / 8 Kb // Kilobit Mb // Megabit Gb // Gigabit ) var ( // The zero-value of RateOpts is used to indicate that no rate limit // should be applied to read/write operations. Unlimited = RateOpts{0, 0} ) // Reader implements the io.Reader inte...
iocap.go
0.709724
0.414484
iocap.go
starcoder
package grapho import "sort" // uint64Slice attaches the methods of sort.Interface to []uint64, sorting in increasing order. type uint64Slice []uint64 func (p uint64Slice) Len() int { return len(p) } func (p uint64Slice) Less(i, j int) bool { return p[i] < p[j] } func (p uint64Slice) Swap(i, j int) { ...
graph.go
0.781997
0.518059
graph.go
starcoder
package utils import ( "image" "image/draw" _ "image/gif" _ "image/jpeg" _ "image/png" "runtime" "sync" ) func Rotate270(i image.Image) image.Image { src := ConvertToRGBA(i) b := src.Bounds() dst := image.NewRGBA(image.Rectangle{ Min: image.Point{ X: b.Min.Y, Y: b.Min.X, }, Max: image.Point{ ...
pkg/utils/utils.go
0.569494
0.453141
utils.go
starcoder
package fp func (l BoolList) GroupByBool(f func(bool) bool) map[bool]BoolList { m := make(map[bool]BoolList) l.Foreach(func(e bool) { key := f(e) var group BoolList if value, found := m[key]; found { group = value } else { group = NilBoolList } group = group.Cons(e) m[key] = group }) return...
fp/bootstrap_list_groupby.go
0.575588
0.402568
bootstrap_list_groupby.go
starcoder
package main import ( "bufio" "fmt" "math" "os" ) type position struct { x, y int } func (p *position) dist(to position) int { return int(math.Abs(float64(p.x-to.x)) + math.Abs(float64(p.y-to.y))) } func (p *position) closest(positions []*position) (*position, int, bool) { var closestPosition *position lowe...
2018/06/main.go
0.666171
0.5
main.go
starcoder
package physics import ( "github.com/roeldev/go-sdl2-experiments/pkg/sdlkit/geom" ) type HitTester interface { // HitTest returns true when the x and y values are within the HitTester. HitTest(x, y float64) bool HitTestXY(xy geom.XYGetter) bool } func HitTestCircle(x, y float64, circle geom.Circle) bool { dx, ...
pkg/sdlkit/physics/hittest.go
0.849722
0.553686
hittest.go
starcoder
package runtime import ( "fmt" "sort" "github.com/onflow/cadence" "github.com/onflow/cadence/runtime/common" "github.com/onflow/cadence/runtime/sema" ) // exportType converts a runtime type to its corresponding Go representation. func exportType(typ sema.Type) cadence.Type { switch t := typ.(type) { case *sem...
runtime/convertTypes.go
0.587588
0.413063
convertTypes.go
starcoder
package sun import ( "errors" "math" "time" ) // Error values if sun not rises or sets at speciefied date and location var ( ErrNoRise = errors.New("the sun never rises on this location (on the specified date)") ErrNoSet = errors.New("the sun never sets on this location (on the specified date)") ) func rad(deg...
sun.go
0.792304
0.508727
sun.go
starcoder
package main import ( "time" ) func BeginningOfYear(t time.Time) time.Time { return time.Date(t.Year(), 1, 1, 0, 0, 0, 0, t.Location()) } func EndOfYear(t time.Time) time.Time { return BeginningOfYear(t).AddDate(1, 0, 0).AddDate(0, 0, -1) } func BeginningOfMonth(t time.Time) time.Time { return time.Date(t.Year(...
carbon.go
0.73848
0.691317
carbon.go
starcoder
// go build // ./exercise1 // Sample program to show how to cache data from an API, and then // use that data in analyzing a dataset. package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" "time" cache "github.com/patrickmn/go-cache" ) const ( // statusURL provides an explanation of Citib...
topics/data_science/caching/exercises/exercise1/exercise1.go
0.569972
0.403361
exercise1.go
starcoder
package world import ( "github.com/df-mc/dragonfly/server/block/cube" "time" ) var ( // Overworld is the Dimension implementation of a normal overworld. It has a blue sky under normal circumstances and // has a sun, clouds, stars and a moon. Overworld has a building range of [-64, 320]. Overworld overworld // N...
server/world/dimension.go
0.700178
0.569494
dimension.go
starcoder
&compiler.Module{ Pos: Position{Filename: "", Offset: 0, Line: 1, Column: 1}, Name: "main", Enums: []*compiler.Enum{ &compiler.Enum{ Pos: Position{Filename: "", Offset: 13, Line: 3, Column: 1}, Name: "Direction", Value: []string{ "Left", "Right", }, }, &compiler...
compiler/.snapshots/arithmetic.go
0.54698
0.627152
arithmetic.go
starcoder
package ast import ( "fmt" "github.com/michaelquigley/pfxlog" "reflect" "github.com/pkg/errors" ) func transformTypes(s SymbolTypes, nodes ...*Node) error { for _, node := range nodes { if sp, ok := (*node).(TypeTransformable); ok { transformed, err := sp.TypeTransform(s) if err != nil { return err ...
storage/ast/node_convert.go
0.650467
0.509276
node_convert.go
starcoder
package eve // DL provides a convenient way to write Display List commands. type DL struct { Writer } // DL wraps W to return Display List writer. See W for more information. func (d *Driver) DL(addr int) DL { return DL{d.W(addr)} } // AlphaFunc sets the alpha test function. func (dl *DL) AlphaFunc(fun, ref byte) ...
egpath/src/display/eve/dl.go
0.758958
0.498474
dl.go
starcoder
package grob type Config struct { // Autosizable boolean Determines whether the graphs are plotted with respect to layout.autosize:true and infer its container size. Autosizable Bool `json:"autosizable,omitempty"` // DisplayModeBar enumerated Determines the mode bar display mode. If *true*, the mode bar is always...
graph_objects/auto_config.go
0.884975
0.548674
auto_config.go
starcoder
package geometry import ( "github.com/g3n/engine/gls" "github.com/g3n/engine/math32" "math" ) // Circle represents the geometry of a filled circle (i.e. a disk) // The center of the circle is at the origin, and theta runs counter-clockwise // on the XY plane, starting at (x,y,z)=(1,0,0). type Circle struct { Geo...
geometry/circle.go
0.85558
0.632162
circle.go
starcoder
package ent import ( "fmt" "strings" "entgo.io/ent/dialect/sql" "github.com/efectn/go-orm-benchmarks/benchs/ent/model" ) // Model is the model entity for the Model schema. type Model struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // Name holds the value of the "name" field. Name ...
benchs/ent/model.go
0.691081
0.401864
model.go
starcoder
package models // Interface defining a potential object that has a spike of a given type type HasSpike interface { // Whether the object has the potential for a Big Spike pattern Has() bool } // Interface defining a potential object that has a hasSpikeAny range type HasSpikeRange interface { HasSpike // The firs...
models/spikeInfo.go
0.856122
0.580025
spikeInfo.go
starcoder
package diffq import ( "strings" "github.com/google/go-cmp/cmp" "github.com/pkg/errors" "github.com/r3labs/diff" ) // Changes and Change are abstracted to eliminate tight-coupling with underlying // diff library. // Change represents a single change identified by the differential. Change is // intentionally abs...
diff.go
0.730001
0.449453
diff.go
starcoder
package schedule import ( "bytes" _ "embed" "fmt" "github.com/PuerkitoBio/goquery" "github.com/fogleman/gg" "github.com/golang/freetype/truetype" "github.com/ulstu-schedule/parser/types" "golang.org/x/text/encoding/charmap" "image" "io" "log" "math/rand" "net/http" "strconv" "strings" "sync" "time" ) ...
schedule/utils.go
0.599016
0.430506
utils.go
starcoder
package period import ( "fmt" "math" "strings" ) // used for stages in arithmetic type period64 struct { // always positive values years, months, days, hours, minutes, seconds int64 // true if the period is negative neg bool input string } func (period Period) toPeriod64(input string) *period64 { if perio...
period/period64.go
0.71103
0.634798
period64.go
starcoder
package gocassa import ( "fmt" "reflect" ) func builtinLessThan(k1, k2 interface{}) (bool, error) { if reflect.TypeOf(k1) != reflect.TypeOf(k2) { return false, fmt.Errorf("skiplist/BuiltinLessThan: k1.(%s) and k2.(%s) have different types", reflect.TypeOf(k1).Name(), reflect.TypeOf(k2).Name()) } switch k1...
compare.go
0.523177
0.513181
compare.go
starcoder
package glmatrix import ( "fmt" "math" "math/rand" ) // NewVec4 creates a new, empty Vec4 func NewVec4() []float64 { return []float64{0., 0., 0., 0.} } // Vec4Create creates a new Vec4 initialized with values from an existing vector func Vec4Create() []float64 { return NewVec4() } // Vec4Clone creates a new ...
vec4.go
0.854779
0.705441
vec4.go
starcoder
package fantree import ( "fmt" "sync" ) //TreeNode is the node Of tree. type TreeNode struct { Name string //Name of TreeNode should equal to the node Value *Node //Value of TreeNode is a pointer to the Node Previous []*TreeNode // A TreeNode may have many previous Next []*TreeNode // A T...
forest.go
0.551332
0.520192
forest.go
starcoder
package trader import ( "errors" "fmt" "strings" "github.com/processout/decimal" ) // CurrencyCode represents a currency code in the norm ISO 4217 type CurrencyCode string // format sets the CurrencyCode to the right format func (c CurrencyCode) format() CurrencyCode { return CurrencyCode(strings.ToUpper(strin...
currency.go
0.845177
0.415907
currency.go
starcoder
package mom // MedianOfMedians is used as a pivot selection in the quickselect algorithm func MedianOfMedians(data []int, left, right, nTh, groupSize int) int { for { // get median pivot pivoIndex := getMedianPivot(data, left, right, groupSize) // do partitioning pivoIndex = partition(data, left, right-1, pi...
codes/mom/mom.go
0.751375
0.644896
mom.go
starcoder
package mat64 import ( "bitbucket.org/zombiezen/math3/vec64" "fmt" "math" ) // Matrix holds a 4x4 matrix. Each vector is a column of the matrix. type Matrix [4]vec64.Vector // Identity can be multiplied by another matrix to produce the same matrix. var Identity = Matrix{ {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, ...
mat64/matrix.go
0.791297
0.658884
matrix.go
starcoder
// The image package implements a basic 2-D image library. package image // An Image is a rectangular grid of Colors drawn from a ColorModel. type Image interface { ColorModel() ColorModel; Width() int; Height() int; // At(0, 0) returns the upper-left pixel of the grid. // At(Width()-1, Height()-1) returns the l...
src/pkg/image/image.go
0.888451
0.717358
image.go
starcoder
package bitbucket import ( "time" ) // GetDownloadCount returns the DownloadCount field if it's non-nil, zero value otherwise. func (a *Artifact) GetDownloadCount() int64 { if a == nil || a.DownloadCount == nil { return 0 } return *a.DownloadCount } // GetLinks returns the Links field. func (a *Artifact) GetLi...
bitbucket/bitbucket-accessors.go
0.802207
0.442396
bitbucket-accessors.go
starcoder
package design_compressed_string_iterator /* 对于一个压缩字符串,设计一个数据结构,它支持如下两种操作: next 和 hasNext。 给定的压缩字符串格式为:每个字母后面紧跟一个正整数,这个整数表示该字母在解压后的字符串里连续出现的次数。 next() - 如果压缩字符串仍然有字母未被解压,则返回下一个字母,否则返回一个空格。 hasNext() - 判断是否还有字母仍然没被解压。 注意: 请记得将你的类在 StringIterator 中 初始化 ,因为静态变量或类变量在多组测试数据中不会被自动清空。更多细节请访问 这里 。 示例: StringIterator ite...
solutions/design-compressed-string-iterator/d.go
0.572245
0.786664
d.go
starcoder
package cpi import ( "sort" "time" ) // timeSeries stores data and sort them by timestamp type timeSeries struct { timeline []int64 data map[int64]float64 } func newTimeSeries() *timeSeries { return &timeSeries{ data: make(map[int64]float64), } } func (t *timeSeries) add(value float64, timestamp time.Ti...
pkg/caelus/cpi/time_series.go
0.723407
0.400808
time_series.go
starcoder
package gosthopper func DoEncrypt(block [16]uint8, rkeys [10][16]uint8) [16]uint8 { // This is a spare, SLOW Go implementation of cipher. This code // should be only compiled for target platforms different from amd64. var r [16]uint8 ct := block // Encryption process follows. for i := 0; i < 9; i++ { // We hav...
crypto/gosthopper/docipher.go
0.681621
0.416025
docipher.go
starcoder
package framework import "fmt" // RecordEvidence records evidence for the compliance check active in the given context. func RecordEvidence(ctx ComplianceContext, status Status, msg string) { ctx.RecordEvidence(status, msg) } // RecordEvidencef records evidence for the compliance check active in the given context. ...
central/compliance/framework/control_helpers.go
0.621081
0.473109
control_helpers.go
starcoder
package repo import ( "errors" "fmt" "math" "math/big" "strconv" ) const ( CurrencyCodeValidMinimumLength = 3 CurrencyCodeValidMaximumLength = 4 ) var ( ErrCurrencyValueInsufficientPrecision = errors.New("unable to accurately represent value as int64") ErrCurrencyValueNegativeRate = errors.New("con...
repo/currency.go
0.831143
0.484136
currency.go
starcoder
package spdy /* Internals documentation The goroutines, lifetimes and channels of this package is a bit involved, so here's a quick overview. Once a connection has been established, there are 3 main goroutines. - The session goroutine - The stream goroutine - The outFramer goroutine Session goroutine: T...
doc.go
0.665519
0.605012
doc.go
starcoder
package hbook import "math" // Dist0D is a 0-dim distribution. type Dist0D struct { N int64 // number of entries SumW float64 // sum of weights SumW2 float64 // sum of squared weights } func (d Dist0D) clone() Dist0D { return d } // Rank returns the number of dimensions of the distribution. func (*Dist0...
hbook/dist.go
0.810816
0.579311
dist.go
starcoder
// API for: // 1) gonum/mat mat.VecDense and mat.Dense structures; // 2) float64 arrays. // Reading: https://en.wikipedia.org/wiki/Distance package distance import ( "fmt" "gonum.org/v1/gonum/mat" "math" ) type dimError struct { err string firstDim int secondDim int } func (e *dimError) Error() strin...
linalg/distance/distance.go
0.67854
0.54056
distance.go
starcoder
package util import ( "fmt" "math" ) // PairType defines a two-dimensional coordianate. type PairType struct { X, Y float64 } // Cluster breaks apart pairs into zero or more slices that each contain at // least minPts pairs and have gaps between X values no greater than gapX. // Elements in pairs must be ordered ...
go/util/mth.go
0.850562
0.602149
mth.go
starcoder
package graph type Graph struct { key string superstep int vertices map[string]*vertex } type vertex struct { value interface{} mutableValue interface{} edges map[string]*edge } type edge struct { value interface{} mutableValue interface{} } func NewGraph(capacity int) *Graph { ...
executor/graph/graph.go
0.63409
0.400486
graph.go
starcoder
Package cloudevents provides a CloudEvents library focused on target component requirements and on how responses should be composed. Basics The package provides a Replier object that should be instantiated as a singleton, and a set of pubic functions that are further divided into Knative managed and Custom managed re...
pkg/targets/adapter/cloudevents/doc.go
0.708213
0.807195
doc.go
starcoder
package nn type HiddenLayer struct { *Layer biasNeuron *BiasNeuron prevLayer ILayer withBias bool weights [][]float64 biasWeights []float64 activationDerivativeFunction ActivationDerivativeFunction learningRate ...
src/nn/layer_hidden.go
0.716318
0.546859
layer_hidden.go
starcoder
package be import ( cir "github.com/hoijui/escher/circuit" ) // *Spirit gates emit the residue of the enclosing circuit itself var SpiritVerb = cir.NewVerbAddress("*", "Spirit") // create all links before materializing gates func createLinks(design cir.Circuit) map[cir.Name]Reflex { // create all links before ma...
be/be-circuit.go
0.712632
0.408926
be-circuit.go
starcoder
package tree import ( "fmt" "log" json "github.com/rwxrob/json/pkg" "github.com/rwxrob/structs/types" ) // E ("tree-e") is an encapsulating struct to contain the Root Node and // all possible Types for any Node. Most users of a tree will make // direct use of E.Root (which has a type of 1 by convention). Tree ...
tree/tree.go
0.763836
0.460471
tree.go
starcoder
package ml import ( "github.com/cpmech/gosl/fun" "github.com/cpmech/gosl/fun/dbf" "github.com/cpmech/gosl/la" "github.com/cpmech/gosl/opt" ) // LogRegMulti implements a logistic regression model for multiple classes (Observer of data) type LogRegMulti struct { // input data *Data // X-y data // access nCla...
ml/logregmulti.go
0.613237
0.402157
logregmulti.go
starcoder
package network import ( "encoding/json" "fmt" "testing" "github.com/ingrammicro/cio/api/types" "github.com/ingrammicro/cio/utils" "github.com/stretchr/testify/assert" ) // ListDomainsMocked test mocked function func ListDomainsMocked(t *testing.T, domainsIn []*types.Domain) []*types.Domain { assert := asse...
api/network/domains_api_mocked.go
0.693784
0.497559
domains_api_mocked.go
starcoder
package resize import ( "image" "image/color" "math" ) // restrict an input float32 to the // range of uint16 values func clampToUint16(x float32) (y uint16) { y = uint16(x) if x < 0 { y = 0 } else if x > float32(0xfffe) { // "else if x > float32(0xffff)" will cause overflows! y = 0xffff } return } typ...
imaging/resize/filters.go
0.657209
0.481759
filters.go
starcoder
package main import ( "bytes" "fmt" "math" "strconv" "github.com/mjibson/go-dsp/spectral" "github.com/wayneashleyberry/terminal-dimensions" ) // Rasterizer fills one or more buffers with discreet audio samples type Rasterizer func([][]float64) // RenderMono rasterizes a TFunc into a mono Portaudio channel fun...
raster.go
0.696062
0.411052
raster.go
starcoder
package arrays //The efficiency of this algorithm is O(N) but it reverses the list. Use FoldLeft instead if you don't want this. func FoldRight[T1, T2 any](as []T1, z T2, f func(T1, T2) T2) T2 { if len(as) > 1 { //Slice has a head and a tail. h, t := as[0], as[1:len(as)] return f(h, FoldRight(t, z, f)) } else i...
arrays/arrays.go
0.561696
0.636763
arrays.go
starcoder
package nakamura import "strings" type Nakamura struct { date, format string } // NewDate creates a new nakamura object to perform //various date formatting and manipulations n func NewDate(date, format string) Nakamura { if len(strings.TrimSpace(date)) == 0 { return Nakamura{Today(), "YYYY-MM-DD"} } return N...
nakamura.go
0.852383
0.630728
nakamura.go
starcoder
// Package polynomial provides interfaces for polynomial and polynomial commitment schemes defined in gnark-crypto/ecc/.../fr. package polynomial import "io" var ( ErrVerifyOpeningProof = "error verifying opening proof" ErrVerifyBatchOpeningSinglePoint = "error verifying batch opening proof at single po...
polynomial/commitment.go
0.648689
0.51879
commitment.go
starcoder
package simple var docS1000 = `Use plain channel send or receive Select statements with a single case can be replaced with a simple send or receive. Before: select { case x := <-ch: fmt.Println(x) } After: x := <-ch fmt.Println(x) Available since 2017.1 ` var docS1001 = `Replace with copy() Use copy() fo...
vendor/honnef.co/go/tools/simple/doc.go
0.774754
0.503479
doc.go
starcoder
package sm import ( "context" "fmt" "github.com/Jim3Things/CloudChamber/simulation/internal/common" "github.com/Jim3Things/CloudChamber/simulation/internal/tracing" ) // StateIndex denotes that the value is used as an index into the state machine // action states. type StateIndex interface { fmt.Stringer } typ...
simulation/internal/sm/sm.go
0.738386
0.606207
sm.go
starcoder
package nifi import ( "encoding/json" ) // ClusterSummaryDTO struct for ClusterSummaryDTO type ClusterSummaryDTO struct { // When clustered, reports the number of nodes connected vs the number of nodes in the cluster. ConnectedNodes *string `json:"connectedNodes,omitempty"` // The number of nodes that are curren...
model_cluster_summary_dto.go
0.7659
0.565419
model_cluster_summary_dto.go
starcoder