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 bufferChanLearning //buffer is a buffer type buffer struct { ChOut chan int //ChOut, the channel out to be read by client Slice []int //Slice which is the actual buffer confirmNewRead chan bool //used to wait for confirmation of grabbing the next value from input channel. size ...
concurrency/17-slice-buffer-reading-from-channel/main.go
0.526099
0.452778
main.go
starcoder
// Package scene encodes and decodes graphics commands in the format used by the // compute renderer. package scene import ( "image/color" "math" "unsafe" "gioui.org/f32" ) type Op uint32 type Command [sceneElemSize / 4]uint32 // GPU commands from scene.h const ( OpNop Op = iota OpLine OpQuad OpCubic OpF...
internal/scene/scene.go
0.637821
0.546799
scene.go
starcoder
package etensor import ( "errors" "fmt" "log" "strings" "github.com/apache/arrow/go/arrow" "github.com/emer/etable/bitslice" "github.com/goki/ki/ints" "github.com/goki/ki/kit" "gonum.org/v1/gonum/mat" ) // BoolType not in arrow.. type BoolType struct{} func (t *BoolType) ID() arrow.Type { return arrow.BO...
etensor/bits.go
0.734976
0.412234
bits.go
starcoder
package iterator import "github.com/gopherd/gonum/graph" // OrderedEdges implements the graph.Edges and graph.EdgeSlicer interfaces. // The iteration order of OrderedEdges is the order of edges passed to // NewEdgeIterator. type OrderedEdges struct { idx int edges []graph.Edge } // NewOrderedEdges returns an Or...
graph/iterator/edges.go
0.812793
0.592018
edges.go
starcoder
package slices // Slice provides a generic slice methods. type Slice[T comparable] struct { s []T } // NewSlice returns Slice[T]. func NewSlice[T comparable]() *Slice[T] { return &Slice[T]{ s: make([]T, 0), } } // Cap returns Slice[T] capacity. func (s *Slice[T]) Cap() int { return cap(s.s) } // Len returns S...
slices/generic.go
0.827236
0.480479
generic.go
starcoder
package ion import ( "math/big" ) // uintLen pre-calculates the length, in bytes, of the given uint value. func uintLen(v uint64) uint64 { length := uint64(1) v >>= 8 for v > 0 { length++ v >>= 8 } return length } // appendUint appends a uint value to the given slice. The reader is // expected to know ho...
ion/bits.go
0.830834
0.652048
bits.go
starcoder
package views import ( "encoding/json" "github.com/hyperledger-labs/fabric-smart-client/integration/fabric/atsa/fsc/states" "github.com/hyperledger-labs/fabric-smart-client/platform/fabric" "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state" "github.com/hyperledger-labs/fabric-smart-...
integration/fabric/atsa/fsc/views/agree.go
0.622804
0.400984
agree.go
starcoder
package ogletest import ( "path" "runtime" "github.com/smartystreets/goconvey/convey/assertions/oglematchers" ) func getCallerForAlias() (fileName string, lineNumber int) { _, fileName, lineNumber, _ = runtime.Caller(2) fileName = path.Base(fileName) return } // ExpectEq(e, a) is equivalent to ExpectThat(a, ...
Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions/ogletest/expect_aliases.go
0.641984
0.476397
expect_aliases.go
starcoder
package specs import ( "testing" "github.com/Fs02/grimoire" "github.com/Fs02/grimoire/c" "github.com/Fs02/grimoire/changeset" "github.com/Fs02/grimoire/params" "github.com/stretchr/testify/assert" ) // Update tests update specifications. func Update(t *testing.T, repo grimoire.Repo) { user := User{Name: "upda...
adapter/specs/update.go
0.578924
0.493592
update.go
starcoder
package grok import "github.com/vjeantet/bitfan/processors/doc" func (p *processor) Doc() *doc.Processor { return &doc.Processor{ Name: "grok", ImportPath: "github.com/vjeantet/bitfan/processors/filter-grok", Doc: "", DocShort: "", Options: &doc.ProcessorOptions{ Doc: "", Opti...
processors/filter-grok/docdoc.go
0.763484
0.461684
docdoc.go
starcoder
package runtime import ( "encoding/base64" "strconv" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/ptypes/duration" "github.com/golang/protobuf/ptypes/timestamp" ) // String just returns the given string. // It is just for compatibility to other types. func String(val string) (string, error) {...
runtime/convert.go
0.773002
0.405596
convert.go
starcoder
package geo // Point presents interface of point type Point interface { // X returns value of X dimension X() float64 // Y returns value of X dimension Y() float64 // Z returns value of X dimension Z() float64 // M returns value of X dimension M() float64 } type point struct{ x, y float64 } func (p point) X(...
geo/geo.go
0.908866
0.713057
geo.go
starcoder
package timeutil import ( "errors" "fmt" "sort" "strings" "time" ) /* // TimeSlice is used for sorting. e.g. // sort.Sort(sort.Reverse(timeSlice)) // sort.Sort(timeSlice) // var times TimeSlice := []time.Time{time.Now()} type TimeSlice []time.Time func (s TimeSlice) Less(i, j int) bool { return s[i].Before(s[j]...
time/timeutil/slice.go
0.578448
0.427815
slice.go
starcoder
// Package mgm provides a custom implementation of Multilinear Galois Mode (MGM) suitable for RU-WireGuard. // The supported tag and block sizes are 128 bit only. package mgm import ( "crypto/cipher" "crypto/hmac" "encoding/binary" "errors" "math/big" ) var ( r128 = new(big.Int).SetBytes([]byte{ 0x00, 0x00, ...
crypto/mgm/mgm.go
0.504394
0.40645
mgm.go
starcoder
package metrics import ( "context" "github.com/status-im/go-waku/waku/v2/utils" "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" "go.uber.org/zap" ) var ( Messages = stats.Int64("node_messages", "Number of messages received", stats.UnitDimensionless) Peers ...
waku/v2/metrics/metrics.go
0.508544
0.451568
metrics.go
starcoder
package models type Talents struct { fight *FightAnalysis `json:"-"` Points [3]int64 `json:"points"` Spec Specialization `json:"spec"` } func NewTalents(fight *FightAnalysis, points [3]int64) *Talents { t := &Talents{ fight: fight, Points: points, } t.guessSpec() return t } var guessers = []spec...
internal/models/talents.go
0.535098
0.41182
talents.go
starcoder
// Dotted Version Vector Sets implementation // based on http://haslab.uminho.pt/tome/files/dvvset-dais.pdf package dt import ( "sort" "time" "golang.org/x/xerrors" ) // Timestamp of individual event type Dot struct { node string counter uint32 timestamp uint32 } // Individual event with timestamp ty...
vclock.go
0.710226
0.455562
vclock.go
starcoder
package types import "sync" type TSafeInt64s interface { // Reset the slice. Reset() // Contains say if "s" contains "values". Contains(...int64) bool // ContainsOneOf says if "s" contains one of the "values". ContainsOneOf(...int64) bool // Copy create a new copy of the slice. Copy() TSafeInt64s // Diff...
syncint64s.go
0.700178
0.458591
syncint64s.go
starcoder
package vesper import ( "strings" ) // QuoteSymbol represents a quoted expression var QuoteSymbol = defaultVM.Intern("quote") // QuasiquoteSymbol represents a quasiquoted expression var QuasiquoteSymbol = defaultVM.Intern("quasiquote") // UnquoteSymbol represents an unquoted expression var UnquoteSymbol = defaultV...
list.go
0.69946
0.440048
list.go
starcoder
package gotalib // A simple moving average is formed by computing the average price of a security // over a specific number of periods. Most moving averages are based on closing // prices; for example, a 5-day simple moving average is the five-day sum of closing // prices divided by five. As its name implies, a moving...
sma.go
0.840684
0.68541
sma.go
starcoder
package onshape import ( "encoding/json" ) // BTPStatementVarDeclaration282 struct for BTPStatementVarDeclaration282 type BTPStatementVarDeclaration282 struct { BTPStatement269 BtType *string `json:"btType,omitempty"` Name *BTPIdentifier8 `json:"name,omitempty"` StandardType *string `json:"standardType,omitempty...
onshape/model_btp_statement_var_declaration_282.go
0.690037
0.417568
model_btp_statement_var_declaration_282.go
starcoder
package bookingclient import ( "encoding/json" ) // ReplaceBlockModel struct for ReplaceBlockModel type ReplaceBlockModel struct { // Start date and time from which the inventory will be blocked<br />Specify either a pure date or a date and time (without fractional second part) in UTC or with UTC offset as defined...
api/clients/bookingclient/model_replace_block_model.go
0.80329
0.495361
model_replace_block_model.go
starcoder
package svgFill // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill type Fill int // en: For <animate>, fill defines the final state of the animation. // Value freeze (Keep the state of the last animation frame) | remove (Keep the // state of the first animation frame) // Default value remove // Animat...
abstractType/svgFill/typeFill.go
0.843847
0.484685
typeFill.go
starcoder
package crypto import ( "crypto" "crypto/hmac" crand "crypto/rand" "math/big" ) // BlindPoint generates a random blinding factor, scalar multiplies it to the // supplied point, and returns both the new point and the blinding factor. func BlindPoint(p *Point) (*Point, []byte) { r, _, err := randScalar(p.Curve, cr...
crypto/voprf.go
0.784608
0.438785
voprf.go
starcoder
package encoding import ( "bytes" "encoding/binary" "io" "github.com/lindb/lindb/pkg/stream" ) const ( adjustValue = 1 lengthOfHeader = 1 EmptyOffset = -1 ) // FixedOffsetEncoder represents the offset encoder with fixed length type FixedOffsetEncoder struct { values []int buf *bytes.Buffer max ...
pkg/encoding/fixed_offset.go
0.748076
0.403244
fixed_offset.go
starcoder
package bitbox // BitBox is a dynamically sized bit container which allows // bits to be set and read quickly and somewhat efficiently. type BitBox struct { max int Bytes []byte } // NewBitBox returns a new BitBox configured for the given // number of bits. func NewBitBox(bits int) *BitBox { b := &BitBox{} b.Re...
bitbox.go
0.761095
0.51013
bitbox.go
starcoder
package main import ( "bufio" "fmt" "os" ) type vector struct { x, y, z int } type planet struct { pos vector vel vector startpos vector startvel vector } func (p planet) String() string { return fmt.Sprintf("pos: %v, vel: %v", p.pos, p.vel) } type universe struct { planets []pla...
12/12-pt2.go
0.521959
0.464962
12-pt2.go
starcoder
// Package resources contains common objects and conversion functions. package resources const ( // fleetspeakPrefix is the default label prefix prepended to all client labels. fleetspeakPrefix = "alphabet-" // LocationNamePrefix is the Fleetspeak label prefix for sensor location name. LocationNamePrefix = fleets...
source/resources/resources.go
0.694095
0.474022
resources.go
starcoder
package correlation import ( "sort" "github.com/knightjdr/prohits-viz-analysis/pkg/matrix" "github.com/knightjdr/prohits-viz-analysis/pkg/slice" ) // Data correlation settings. type Data struct { Columns []string Dimension string // Either "column" or "row" (default). IgnoreSo...
pkg/correlation/matrix.go
0.727395
0.482368
matrix.go
starcoder
package bezier import ( "math" "github.com/adamcolton/geom/calc/comb" "github.com/adamcolton/geom/d2" "github.com/adamcolton/geom/d2/affine" ) // Bezier curve defined by a slice of control points type Bezier []d2.Pt // Pt1 fulfills d2.Pt1 and returns the parametric curve point on the bezier // curve. func (b Be...
d2/curve/bezier/bezier.go
0.867612
0.500305
bezier.go
starcoder
package cryptypes import "database/sql/driver" // EncryptedUint32 supports encrypting Uint32 data type EncryptedUint32 struct { Field Raw uint32 } // Scan converts the value from the DB into a usable EncryptedUint32 value func (s *EncryptedUint32) Scan(value interface{}) error { return decrypt(value.([]byte), &s....
cryptypes/type_uint32.go
0.806434
0.523664
type_uint32.go
starcoder
package jio // Bool Generates a schema object that matches bool data type func Bool() *BoolSchema { return &BoolSchema{ rules: make([]func(*Context), 0, 3), } } var _ Schema = new(BoolSchema) // BoolSchema match bool data type type BoolSchema struct { baseSchema required *bool rules []func(*Context) } //...
bool.go
0.713531
0.448004
bool.go
starcoder
package firestorm import ( "bytes" "encoding/binary" "fmt" "github.com/golang/protobuf/proto" ) var TermFreqKeyPrefix = []byte{'t'} type TermFreqRow struct { field uint16 term []byte docID []byte docNum uint64 value TermFreqValue } func NewTermVector(field uint16, pos uint64, start uint64, end uint6...
index/firestorm/termfreq.go
0.525856
0.405625
termfreq.go
starcoder
package consistentHash /* Package consistentHash provides a consistent hashing implementation using murmur3 with a 64bit ring space. Virtual nodes are used to provide a good distribution. This package has an almost identical API to StatHat's consistent package at https://github.com/stathat/consistent, although that p...
doc.go
0.724286
0.411584
doc.go
starcoder
package ranking import ( "bytes" "encoding/json" "fmt" "io" "log" "math" "sort" "github.com/kiteco/kiteco/kite-golib/decisiontree" ) // DataPoint abstracts a data point that is to be ranked by the model. type DataPoint struct { ID int // index of this DataPoint Name string // name of thi...
kite-go/ranking/models.go
0.743913
0.469642
models.go
starcoder
// Package data implements Data API package data import ( "time" "github.com/farshidtz/senml/v2" ) //Specifying which field needs to be denormalized type DenormMask int32 const ( DenormMaskName DenormMask = 1 << iota DenormMaskTime DenormMaskUnit DenormMaskValue DenormMaskSum ) // RecordSet describes the r...
vendor/github.com/linksmart/historical-datastore/data/data.go
0.657428
0.443721
data.go
starcoder
package bst // New Initializes BST func New(less, isEqual CompareKeys) *BST { return &BST{ Head: nil, LessThan: less, isKeyEqual: isEqual, } } func (tree *BST) Insert(key, data interface{}) error { newNode := &BSTNode{key, data, nil, nil} if tree.Head == nil { tree.Head = newNode return nil } ...
bst/bst.go
0.538983
0.632928
bst.go
starcoder
package main /** 有一个正整数数组arr,现给你一个对应的查询数组queries,其中queries[i] = [Li,Ri]。 对于每个查询i,请你计算从Li到Ri的XOR值(即arr[Li] xor arr[Li+1] xor ... xor arr[Ri])作为本次查询的结果。 并返回一个包含给定查询queries所有结果的数组。 示例 1: 输入:arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]] 输出:[2,7,14,8] 解释: 数组中元素的二进制表示形式是: 1 = 0001 3 = 0011 4 = 0100 8 = 1000 查询的 XOR ...
leetcode/xorQueries/xorQueries.go
0.507324
0.471649
xorQueries.go
starcoder
package persistent_treap import ( "log" "math/rand" ) type PersistentTreap struct { root *treapNode } func NewPersistentTreap() PersistentTreap { return PersistentTreap{root: nil} } func (tree PersistentTreap) Find(key Sortable) bool { return tree.root.find(key) } func (tree PersistentTreap) GetValue(key Sor...
persistent_treap/persistent_treap.go
0.747524
0.486819
persistent_treap.go
starcoder
// Package other wraps an hash-to-curve implementation and exposes functions for operations on points and scalars. package other import ( nist "crypto/elliptic" "fmt" "math/big" "github.com/bytemare/crypto/group/internal" Curve "github.com/armfazh/h2c-go-ref/curve" C "github.com/armfazh/tozan-ecc/curve" "git...
group/other/point.go
0.906991
0.518302
point.go
starcoder
package types import ( "github.com/jcmturner/asn1" ) // Reference: https://www.ietf.org/rfc/rfc4120.txt // Section: 5.2.6 /* AuthorizationData -- NOTE: AuthorizationData is always used as an OPTIONAL field and -- should not be empty. AuthorizationData ::= SEQUENCE OF SEQUENCE { ad-type [0] Int32, ad-...
types/AuthorizationData.go
0.699152
0.552781
AuthorizationData.go
starcoder
package convey import "github.com/smartystreets/assertions" var ( ShouldEqual = assertions.ShouldEqual ShouldNotEqual = assertions.ShouldNotEqual ShouldAlmostEqual = assertions.ShouldAlmostEqual ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual ShouldResemble = assertions.ShouldResemble ShouldNotResemble =...
vendor/github.com/smartystreets/goconvey/convey/assertions.go
0.68437
0.763638
assertions.go
starcoder
// +build !reach /* Package cover is used to assert that code locations and variable values are covered by tests. The functions incur no runtime overhead unless the reach build tag was specified. Functions which observe a single subject value pass it through. Example: import "github.com/tsavola/reach/cover" fu...
cover/nocover.go
0.680454
0.735274
nocover.go
starcoder
package govalidator // Iterator is the function that accepts element of slice/array and its index type Iterator func(interface{}, int) // ResultIterator is the function that accepts element of slice/array and its index and returns any result type ResultIterator func(interface{}, int) interface{} // ConditionIterator...
vendor/github.com/asaskevich/govalidator/arrays.go
0.843992
0.563438
arrays.go
starcoder
package hash const ( // MaxLoadFactor is the ratio of entries to buckets which will force a resize MaxLoadFactor float64 = .75 // DefaultTableSize is set higher to avoid many resizes DefaultTableSize uint64 = 128 // SizeIncrease is the resize multiple when determining the new size of an // updated hash table Si...
data-structures/hash-table/hash_table.go
0.815122
0.485844
hash_table.go
starcoder
package main import ( "fmt" "reflect" "github.com/hashicorp/hcl2/hcl" ) func findTraversalSpec(got hcl.Traversal, candidates []*TestFileExpectTraversal) *TestFileExpectTraversal { for _, candidate := range candidates { if traversalsAreEquivalent(candidate.Traversal, got) { return candidate } } return ni...
vendor/github.com/hashicorp/hcl2/cmd/hclspecsuite/traversals.go
0.645008
0.407893
traversals.go
starcoder
package poly import ( "bytes" "strings" "math/rand" "errors" ) // complementBaseRuneMap provides 1:1 mapping between bases and their complements var complementBaseRuneMap = map[rune]rune{ 65: 84, // A -> T 66: 86, // B -> V 67: 71, // C -> G 68: 72, // D -> H 71: 67, // G -> C 72: 6...
sequence.go
0.657758
0.459501
sequence.go
starcoder
package schema import ( // "bufio" // "fmt" "io/ioutil" "os" "github.com/muxmuse/schema/mfa" "path/filepath" "gopkg.in/src-d/go-git.v4" "gopkg.in/src-d/go-git.v4/plumbing/object" ) func CreateNew(name string, path string, version string) { readme := []byte(`# ` + name + ` This is a [schema pm](https...
schema/create.go
0.566858
0.449997
create.go
starcoder
package geom import ( "github.com/golang/geo/s2" "github.com/mmcloughlin/geohash" "math" ) const ( // EarthRadius According to Wikipedia, the Earth's radius is about 6,371,004 m EarthRadius = 6371000 ) func NewLngLat(coordinates ...float64) *LngLat { length := len(coordinates) switch leng...
go/pkg/mojo/geom/lng_lat.go
0.901542
0.731874
lng_lat.go
starcoder
package math import ( "math" "go.starlark.net/starlark" ) // Return the arc cosine of x, in radians. func acos(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { return floatFunc("acos", args, kwargs, math.Acos) } // asin(x) - Return the arc sine...
math/trig.go
0.868729
0.430566
trig.go
starcoder
package microgui import ( "image" "image/color" "github.com/hajimehoshi/ebiten" "github.com/hajimehoshi/ebiten/ebitenutil" ) // TextField displays a string and lets the user modify it type TextField struct { bounds image.Rectangle content string hasFocus bool cursorPosition int contentO...
textfield.go
0.554712
0.482856
textfield.go
starcoder
package memtable import ( "github.com/patrickgombert/lsmt/common" c "github.com/patrickgombert/lsmt/comparator" ) // Stack based iterator which keeps the trees lineage in memory while iterating. type memtableIterator struct { init bool stack []persistentNode end []byte } // Creates a new bounded iterator for...
memtable/iterator.go
0.728169
0.441854
iterator.go
starcoder
package track import ( "fmt" "math" "github.com/anki/goverdrive/phys" ) // RoadPiece is the helper type used to define a track // - Straight or curved only; no fancy shapes like intersection or 'Y' // - Any anglular change through the piece is along a circular arc // - Maximum of angular change of +/- pi/2 ra...
goverdrive/robo/track/roadpiece.go
0.805135
0.409604
roadpiece.go
starcoder
package siaencoding import ( "encoding/binary" "math/big" ) // simple byte slice reversal func toggleEndianness(b []byte) []byte { r := make([]byte, len(b)) copy(r, b) i, j := 0, len(b)-1 for i < j { r[i], r[j] = r[j], r[i] i, j = i+1, j-1 } return r } // EncUint16 encodes a uint16 as a slice of 2 bytes...
siaencoding/integers.go
0.765243
0.53783
integers.go
starcoder
package botutil import ( "math" "github.com/chippydip/go-sc2ai/api" "github.com/chippydip/go-sc2ai/enums/ability" ) // Units ... type Units struct { raw []Unit filter func(Unit) bool } // NewUnits wraps a regular []Unit into a Units struct. func NewUnits(units []Unit) Units { return Units{raw: units} } fu...
botutil/units.go
0.759761
0.511168
units.go
starcoder
package search // Query struct includes the search query. type Query struct { // Expression is the (Lucene-like) string expression specifying the search query. // If not provided then all resources are listed (up to MaxResults). Expression string `json:"expression,omitempty"` // SortBy is the the field to sort by....
api/admin/search/search.go
0.78842
0.469581
search.go
starcoder
package shapes import ( "image" "image/color" "github.com/remogatto/mathgl" "github.com/remogatto/shaders" ) // Base represent a basic structure for shapes. type Base struct { // Vertices of the generic shape vertices []float32 // Matrices projMatrix mathgl.Mat4f modelMatrix mathgl.Mat4f viewMatrix math...
base.go
0.858704
0.599045
base.go
starcoder
package ameda import ( "fmt" "math" ) // Float64ToInterface converts float64 to interface. func Float64ToInterface(v float64) interface{} { return v } // Float64ToInterfacePtr converts float64 to *interface. func Float64ToInterfacePtr(v float64) *interface{} { r := Float64ToInterface(v) return &r } // Float64T...
vendor/github.com/henrylee2cn/ameda/float64.go
0.768646
0.424293
float64.go
starcoder
package gmeasure import ( "fmt" "sort" "github.com/bsm/gomega/gmeasure/table" ) /* RankingCriteria is an enum representing the criteria by which Stats should be ranked. The enum names should be self explanatory. e.g. LowerMeanIsBetter means that Stats with lower mean values are considered more beneficial, with ...
gmeasure/rank.go
0.795539
0.421492
rank.go
starcoder
package glm import ( "fmt" "math" ) // VecFunc is a function with two float64 array arguments. type VecFunc func([]float64, []float64) // Link specifies a GLM link function. type Link struct { Name string TypeCode LinkType // Link calculates the link function (usually mapping the mean // value to the linear ...
glm/links.go
0.724091
0.415136
links.go
starcoder
package decoders import ( "errors" "fmt" "github.com/wader/fq/format/avro/schema" "github.com/wader/fq/pkg/decode" ) func decodeMapFn(s schema.SimplifiedSchema) (DecodeFn, error) { if s.Values == nil { return nil, errors.New("map schema must have values") } // Maps are encoded as a series of blocks. Each b...
format/avro/decoders/map.go
0.640186
0.400808
map.go
starcoder
package jwt import ( "errors" "log" ) /* 7.1. Creating a JWT To create a JWT, the following steps are performed. The order of the steps is not significant in cases where there are no dependencies between the inputs and outputs of the steps. 1. Create a JWT Claims Set containing the desired claims. ...
encode.go
0.579162
0.643035
encode.go
starcoder
package calculator import ( "fmt" "math" ) var functions = map[string]interface{}{ "abs": math.Abs, "acos": math.Acos, "acosh": math.Acosh, "asin": math.Asin, "asinh": math.Asinh, "atan": math.Atan, "atan2": math.Atan2, "atanh": math.Atanh, "cbrt": ...
calculator.go
0.517571
0.434941
calculator.go
starcoder
package convert import ( "fmt" "reflect" spb "google.golang.org/protobuf/types/known/structpb" ) // Map2pbStruct convert map to pbstruct // ref: https://devnote.pro/posts/10000050901242 func Map2pbStruct(m map[string]interface{}) *spb.Struct { size := len(m) if size == 0 { return nil } fields := make(map[st...
bcs-services/bcs-project/internal/util/convert/convert.go
0.517083
0.527317
convert.go
starcoder
package cellshandler import ( "regexp" "strconv" "strings" "github.com/juanPabloMiceli/visual-simd-debugger/backend/xmmhandler" ) //CellData is the data of the cell that is received from the frontend type CellData struct { ID int `json:"id"` Code string `json:"code"` } //CellsData has the data of every c...
backend/cellshandler/cellshandler.go
0.520009
0.416085
cellshandler.go
starcoder
package calc import ( "math/big" "strings" "github.com/ALTree/bigfloat" complex "github.com/pointlander/c0mpl3x" ) var prec uint = 1024 // ValueType is a value type type ValueType int const ( // ValueTypeMatrix is a matrix value type ValueTypeMatrix ValueType = iota // ValueTypeExpression is an expression ...
calculator.go
0.663233
0.554109
calculator.go
starcoder
package graphsample2 import "github.com/wangyoucao577/algorithms_practice/graph" /* This sample directed graph comes from "Introduction to Algorithms - Third Edition" 22.1 V = 6 (node count) E = 8 (edge count) define directed graph G(V,E) as below: u(0) -> v(1) w(2) ↓ ↗ ↓ ↙ ↓ x(3) <- y(4) z(5...
graphsamples/graphsample2/sample2.go
0.729231
0.465752
sample2.go
starcoder
package ckks import ( "fmt" "math" "math/cmplx" "github.com/ldsec/lattigo/v2/ckks/bettersine" "github.com/ldsec/lattigo/v2/rlwe" "github.com/ldsec/lattigo/v2/utils" ) // Bootstrapper is a struct to stores a memory pool the plaintext matrices // the polynomial approximation and the keys for the bootstrapping. t...
ckks/bootstrapper.go
0.70912
0.438064
bootstrapper.go
starcoder
package imageflux import ( "crypto/hmac" "crypto/sha256" "encoding/base64" "fmt" "image" "image/color" "net/url" "strconv" "strings" "sync" ) var bufPool = sync.Pool{ New: func() interface{} { buf := make([]byte, 0, 32) return &buf }, } // Image is an image hosted on ImageFlux. type Image struct { P...
image.go
0.762866
0.45744
image.go
starcoder
package spn import ( "crypto/rand" "github.com/OpenWhiteBox/primitives/encoding" "github.com/OpenWhiteBox/primitives/gfmatrix" "github.com/OpenWhiteBox/primitives/number" ) // incrementalMatrices implements succint operations over a slice of incremental matrices. type incrementalMatrices []gfmatrix.IncrementalMa...
cryptanalysis/spn/sbox.go
0.849893
0.432243
sbox.go
starcoder
package golem import ( "math" "math/rand" ) func MinAndMaxKeyOfBayesProbMap(bpm map[float64]map[string]float64) (float64,float64) { mini,maxi := math.Inf(1), math.Inf(-1) for k,_ := range bpm { if k < mini { mini = k } if k > maxi { maxi = k } } return mini, maxi } /* */ func SampleSubrangesF...
golem/golem_base/bayes_prob_extensions.go
0.587825
0.406862
bayes_prob_extensions.go
starcoder
package listx type IList interface { // Len is the number of elements in the collection. Len() int // Swap swaps the elements with indexes i and j. Swap(i, j int) // Removes all of the elements from this list (optional operation). Clear() // Appends the elements to the end of this list (optional operation). A...
lang/listx/list.go
0.534127
0.422266
list.go
starcoder
package graphic import "github.com/go-gl/gl/v2.1/gl" // SGNode scenegraph node type SGNode interface { update(delta float64) render() findChilds(search interface{}) []interface{} addChild(child *SGNode) } // SceneGraph helper struct type SceneGraph struct { } // Scene helper struct type Scene struct { } // New...
lib/graphic/scene.go
0.61451
0.420719
scene.go
starcoder
package clang // #include "./clang-c/Index.h" // #include "go-clang.h" import "C" import ( "reflect" "unsafe" ) /* Contains the results of code-completion. This data structure contains the results of code completion, as produced by clang_codeCompleteAt(). Its contents must be freed by clang_disposeCodeComplete...
clang/codecompleteresults_gen.go
0.577257
0.407039
codecompleteresults_gen.go
starcoder
package main import ( "github.com/ByteArena/box2d" "github.com/wdevore/RangerGo/api" "github.com/wdevore/RangerGo/engine/rendering" ) // CircleComponent is a box type CircleComponent struct { visual api.INode b2Body *box2d.B2Body scale float64 categoryBits uint16 // I am a... maskBits uint16 // I can co...
examples/physics/intermediate/callback_listening/circle_component.go
0.751192
0.512022
circle_component.go
starcoder
package nexpose // Finding is the json struct representation of a vulnerabilities existence // on an asset in nexpose type Finding struct { // The identifier of the vulnerability. ID string `json:"id"` // The number of vulnerable occurrences of the vulnerability. This does not include `invulnerable` instances. I...
json_finding.go
0.734881
0.414899
json_finding.go
starcoder
package dxt import ( "bytes" "encoding/binary" "errors" "github.com/galaco/dxt/common" "image" "image/color" ) // Dxt5 // Dxt5 Image fulfills the standard golang image interface. // It also fulfils a slightly more specialised Dxt interface in the package. type Dxt5 struct { Header Header Pix []uint8 Strid...
dxt5.go
0.749271
0.442877
dxt5.go
starcoder
package graph import "fmt" type duplicateNodeError struct { nodeID NodeID } func (e duplicateNodeError) Error() string { return fmt.Sprintf("node with id %d has already been added", e.nodeID) } type duplicateEdgeError struct { fromID NodeID toID NodeID } func (e duplicateEdgeError) Error() string { return f...
graph/error.go
0.668339
0.443359
error.go
starcoder
package packed // Efficient sequential read/write of packed integers. type BulkOperationPacked6 struct { *BulkOperationPacked } func newBulkOperationPacked6() BulkOperation { return &BulkOperationPacked6{newBulkOperationPacked(6)} } func (op *BulkOperationPacked6) decodeLongToInt(blocks []int64, values []int3...
vendor/github.com/balzaczyy/golucene/core/util/packed/bulkOperation6.go
0.546012
0.728628
bulkOperation6.go
starcoder
package datadog import ( "encoding/json" "time" ) // UsageDBMHour Database Monitoring usage for a given organization for a given hour. type UsageDBMHour struct { // The total number of Database Monitoring host hours from the start of the given hour’s month until the given hour. DbmHostCount *int64 `json:"dbm_hos...
api/v1/datadog/model_usage_dbm_hour.go
0.779741
0.486332
model_usage_dbm_hour.go
starcoder
// +build go1.14,!go1.15 package symbols import ( "gonum.org/v1/plot/palette" "image/color" "reflect" ) func init() { Symbols["gonum.org/v1/plot/palette"] = map[string]reflect.Value{ // function, constant and variable definitions "Blue": reflect.ValueOf(palette.Blue), "Cyan": reflect.Value...
pkg/internal/runtime/symbols/go1_14_gonum.org_v1_plot_palette.go
0.622918
0.447158
go1_14_gonum.org_v1_plot_palette.go
starcoder
package aoc import ( "fmt" "math" ) // Point is a two dimensional point defined by x and y coordinates type Point struct { X, Y int } var EightNeighbourOffsets = []Point{ Point{X: -1, Y: -1}, Point{X: 0, Y: -1}, Point{X: 1, Y: -1}, Point{X: -1, Y: 0} /* */, Point{X: 1, Y: 0}, Point{X: -1, Y: 1},...
lib-go/point.go
0.860955
0.763858
point.go
starcoder
package filter import ( "errors" "image" "math" "strconv" "github.com/jangler/imp/util" ) var imposeHelp = `impose <layer> <file> [<x> <y>] Layer the working image on top of another image or vice versa. Possible values for 'layer' are over and under. Coordinates x and y may be given to offset the working image...
filter/impose.go
0.650689
0.475423
impose.go
starcoder
package main import "fmt" /* Given an m x n board of characters and a list of strings words, return all words on the board. Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once i...
golang/algorithms/others/word_search_2/main.go
0.622918
0.511351
main.go
starcoder
package vida import ( "bytes" "fmt" "math/rand" "time" ) // Bytes models a dynamic mutable array of bytes. type Bytes struct { Value []byte } // Value Interface func (b *Bytes) TypeName() string { return "Bytes" } func (b *Bytes) Description() string { return string(b.Value) } func (b *Bytes) Equals(other V...
vida/bytes.go
0.737253
0.442938
bytes.go
starcoder
package test import ( "strings" "github.com/ihcsim/wikiracer/errors" "github.com/ihcsim/wikiracer/internal/wiki" ) const separator = "|" // MockWiki is an in-memory wiki type MockWiki struct { pages map[string]*wiki.Page } // NewMockWiki returns a new instance of MockWiki func NewMockWiki() *MockWiki { testDa...
test/mock_wiki.go
0.577257
0.410313
mock_wiki.go
starcoder
package world // GameMode represents a game mode that may be assigned to a player. Upon joining the world, players will be // given the default game mode that the world holds. // Game modes specify the way that a player interacts with and plays in the world. type GameMode interface { // AllowsEditing specifies if a p...
server/world/game_mode.go
0.82176
0.626696
game_mode.go
starcoder
package plot import "math" // Length defines canvas space size. type Length = float64 // Point describes a canvas position or offset. type Point struct{ X, Y Length } // nanPoint describes a missing or invalid point. var nanPoint = Point{ X: math.NaN(), Y: math.NaN(), } // P is a convenience func for creating a ...
geom.go
0.927585
0.741066
geom.go
starcoder
package ast import ( "bytes" "strings" "Gengo/token" ) // Node A single node in the AST. type Node interface { TokenLiteral() string String() string } // Statement represents a statement node. type Statement interface { Node // Used to help the compiler tell the difference between a Statement and an Expressi...
ast/ast.go
0.771757
0.487673
ast.go
starcoder
// Package day22 solves AoC 2018 day 22. package day22 import ( "container/heap" "fmt" "github.com/fis/aoc/glue" "github.com/fis/aoc/util" ) func init() { glue.RegisterSolver(2018, 22, glue.LineSolver(solve)) } func solve(lines []string) ([]string, error) { var depth, tX, tY int if len(lines) != 2 { retur...
2018/day22/day22.go
0.636579
0.407923
day22.go
starcoder
package values // Unifier can be used to verify whether a list of values has equal entries. type Unifier struct { state unifierState } // NewUnifier returns a new instance. func NewUnifier() Unifier { return Unifier{state: unifierInitState{}} } // UnifierFor returns a unifier for a single value. func UnifierFor(va...
editor/values/Unifier.go
0.884408
0.558327
Unifier.go
starcoder
package pkg import ( wr "github.com/mroth/weightedrand" "math/rand" "time" ) // OptimizeType describes an optimization type type OptimizeType string const ( Load OptimizeType = "Load" Network OptimizeType = "Network" Latency OptimizeType = "Latency" ) // StrategyOptions describes the quorum system strategy...
pkg/strategy.go
0.848376
0.608245
strategy.go
starcoder
package arrays import ( "math" "strconv" ) func Includes(arr []int, val int) bool { for i := 0; i < len(arr); i++ { if arr[i] == val { return true } } return false } func Remove(arr []int, i int) []int { return append(arr[:i], arr[i+1:]...) } func Sum(arr []float64) float64 { var s float64 for i := 0...
arrays/arrays.go
0.655997
0.441011
arrays.go
starcoder
package cfg import "github.com/gofoji/foji/stringlist" // Merge merges all properties from an ancestor Config. func (c Config) Merge(from Config) Config { c.Formats = c.Formats.Merge(from.Formats) c.Files = c.Files.Merge(from.Files) c.Processes = c.Processes.Merge(from.Processes).ApplyFormat(c.Formats) return c ...
cfg/merge.go
0.739422
0.437403
merge.go
starcoder
package blockchain const erc20ABI = `[ { "constant": false, "inputs": [ { "name": "_spender", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "approve", "outputs": [ { "name": "success", "type": ...
common/blockchain/erc20_abi.go
0.645008
0.474205
erc20_abi.go
starcoder
package day12 import ( "bufio" "fmt" "math" "os" "regexp" "strconv" ) type position struct { vals [3]int } func newPos(x, y, z int) position { return position{[3]int{x, y, z}} } func (p position) String() string { return fmt.Sprintf("<x=%v, y=%v, z=%v>", p.vals[0], p.vals[1], p.vals[2]) } func (p position...
pkg/day12/moons.go
0.581303
0.409191
moons.go
starcoder
package bloomFilter import ( "ProbabilisticDataStructures/utils" "math" "github.com/bits-and-blooms/bitset" "github.com/spaolacci/murmur3" ) // BloomFilter is the struct that represents a Bloom Filter type BloomFilter struct { n uint m uint k uint e float64 bits *bitset.BitSet } // New crea...
bloomFilter/bloomFilter.go
0.862844
0.512449
bloomFilter.go
starcoder
package main import ( . "github.com/mmcloughlin/avo/build" . "github.com/mmcloughlin/avo/operand" ) func main() { Package("github.com/mmcloughlin/avo/examples/returns") TEXT("Interval", NOSPLIT, "func(start, size uint64) (uint64, uint64)") Doc( "Interval returns the (start, end) of an interval with the given...
examples/returns/asm.go
0.680454
0.42931
asm.go
starcoder
package mlpack /* #cgo CFLAGS: -I./capi -Wall #cgo LDFLAGS: -L. -lmlpack_go_kfn #include <capi/kfn.h> #include <stdlib.h> */ import "C" import "gonum.org/v1/gonum/mat" type KfnOptionalParam struct { Algorithm string Epsilon float64 InputModel *kfnModel K int LeafSize int Percentage float64 ...
kfn.go
0.677261
0.512998
kfn.go
starcoder
package bimg /* #cgo pkg-config: vips #include "vips/vips.h" */ import "C" import "errors" const ( // Quality defines the default JPEG quality to be used. Quality = 75 ) // maxSize defines maximum pixels width or height supported. var maxSize = 16383 // MaxSize returns maxSize. func MaxSize() int { return maxSiz...
options.go
0.684159
0.431764
options.go
starcoder