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 formats import "errors" type SNA struct { cpu CpuState ula UlaState mem [48 * 1024]byte } // Decode SNA from binary data func (data SnapshotData) DecodeSNA() (*SNA, error) { if len(data) != 49179 { return nil, errors.New("snapshot has invalid size") } var s SNA // Populate registers s.cpu.I = dat...
formats/SNA.go
0.50952
0.451871
SNA.go
starcoder
package main import ( "fmt" "sort" "strconv" ) type Graph struct { Edges []*Edge Nodes map[*Node]bool } type Edge struct { Parent *Node Child *Node Cost int } type Node struct { Name string } const Infinity = int(^uint(0) >> 1) // AddEdge adds an Edge to the Graph func (g *Graph) AddEdge(parent, child...
ch7/dijkstra.go
0.711932
0.457197
dijkstra.go
starcoder
package ionoscloud import ( "encoding/json" ) // KubernetesMaintenanceWindow struct for KubernetesMaintenanceWindow type KubernetesMaintenanceWindow struct { // The day of the week for a maintenance window. DayOfTheWeek *string `json:"dayOfTheWeek,omitempty"` // The time to use for a maintenance window. Accepted...
vendor/github.com/ionos-cloud/sdk-go/v5/model_kubernetes_maintenance_window.go
0.836921
0.415847
model_kubernetes_maintenance_window.go
starcoder
package problem064 type coordinates struct { x int y int } func CountKnightsPaths(boardSize int) int { totalCountChannel := make(chan int, boardSize*boardSize) countPaths := func(x int, y int) { visitedCoordinates := make(map[coordinates]bool) initialCoordinates := coordinates{x: x, y: y} visitedCoordinates...
problem064/problem064.go
0.643777
0.456834
problem064.go
starcoder
package caprice // Generate `n` random integers between `min` and `max`. // If `replacement` is true, pick random numbers with replacement. Default is false. // We do not support base selection, since it is easy to format into the base of your choice from base 10 func (rng trueRNG) GenerateIntegers(n, min, max int, re...
basic_methods.go
0.820505
0.436862
basic_methods.go
starcoder
package lineq import ( "math" "github.com/angelsolaorbaiceta/inkmath/mat" "github.com/angelsolaorbaiceta/inkmath/vec" ) /* PreconditionedConjugateGradientSolver is an interative solver for linear equation resolution where a preconditioner is used to speed up convergence. The preconditioner should be a square mat...
lineq/preconjgrad.go
0.780955
0.481332
preconjgrad.go
starcoder
package ops import ( "errors" "gogeo/gpkg" "math" "github.com/slawler/gdal" ) // LineLength returns the distance along a straight line in euclidean space func (gl gpkg.GoLine) LineLength() float64 { x0, y0 := gl[0][0], gl[0][1] x1, y1 := gl[1][0], gl[1][1] return math.Sqrt(math.Pow((x1-x0), 2) + math.Pow((y1-...
gogeo/ops/lines.go
0.840292
0.425665
lines.go
starcoder
package multi import ( "github.com/RoaringBitmap/roaring/roaring64" "github.com/matrixorigin/matrixone/pkg/container/nulls" "github.com/matrixorigin/matrixone/pkg/container/types" "github.com/matrixorigin/matrixone/pkg/container/vector" "github.com/matrixorigin/matrixone/pkg/vectorize/unixtimestamp" "github.com/...
pkg/sql/plan2/function/builtin/multi/unix_timestamp.go
0.524638
0.433981
unix_timestamp.go
starcoder
package helpers import "github.com/lquesada/cavernal/model" import "github.com/lquesada/cavernal/entity" import "hash/fnv" import "math" import "github.com/lquesada/cavernal/lib/g3n/engine/math32" type BasicEquipable struct { entity.Equipable cloneSpecification *BasicEquipableSpecification attackGenerator...
helpers/basicequipable.go
0.585101
0.42656
basicequipable.go
starcoder
package pgsql import ( "database/sql" "database/sql/driver" ) // TextArrayFromStringSlice returns a driver.Valuer that produces a PostgreSQL text[] from the given Go []string. func TextArrayFromStringSlice(val []string) driver.Valuer { return textArrayFromStringSlice{val: val} } // TextArrayToStringSlice returns ...
pgsql/textarr.go
0.703753
0.421195
textarr.go
starcoder
package neuralnet import ( "encoding/json" "io" "io/ioutil" "math" "math/rand" "time" ) // R is the source to be used for the initial random weights var R *rand.Rand func init() { R = rand.New(rand.NewSource(time.Now().Unix())) } type neuron struct { weights []float64 // the weights of the inputs bias ...
neuralnet.go
0.756088
0.550849
neuralnet.go
starcoder
// Copyright 2017 Microsoft Corporation. All rights reserved. // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. /* Package aztables can access an Azure Storage or CosmosDB account. The aztables package is capable of: - Creating, deleting, and listing tables in an ac...
sdk/data/aztables/doc.go
0.845017
0.482063
doc.go
starcoder
package packed // Efficient sequential read/write of packed integers. type BulkOperationPacked14 struct { *BulkOperationPacked } func newBulkOperationPacked14() BulkOperation { return &BulkOperationPacked14{newBulkOperationPacked(14)} } func (op *BulkOperationPacked14) decodeLongToInt(blocks []int64, values []int...
core/util/packed/bulkOperation14.go
0.605566
0.630173
bulkOperation14.go
starcoder
package n import ( "reflect" "github.com/pkg/errors" ) // IF provides a way to deal with conditionals more elegantly in Go type IF struct { State bool // Status of the result Error error // Errors that may have been captured Return []interface{} // Return values } // If provides a way to exe...
if.go
0.608827
0.417093
if.go
starcoder
package yasup import ( crypto "crypto/rand" "math/big" "math/rand" ) var zeroValueRune rune //RuneInsert will append elem at the position i. Might return ErrIndexOutOfBounds. func RuneInsert(sl *[]rune, elem rune, i int) error { if i < 0 || i > len(*sl) { return ErrIndexOutOfBounds } *sl = append(*sl, elem)...
runeSlices.go
0.641647
0.429489
runeSlices.go
starcoder
package structql import ( "database/sql" "fmt" "reflect" "strings" "github.com/inflowml/logger" ) // SelectFrom executes a SELECT FROM query on the Connection receiver over the // given object type and table. func (conn *Connection) SelectFrom(object interface{}, table string) ([]interface{}, error) { return c...
operations.go
0.560614
0.469034
operations.go
starcoder
package unit import ( "math" "github.com/brettbuddin/shaden/dsp" ) var log1 = math.Log(0.1) func newDynamics(io *IO, c Config) (*Unit, error) { return NewUnit(io, &dynamics{ in: io.NewIn("in", dsp.Float64(0)), control: io.NewIn("control", dsp.Float64(0)), threshold: io.NewIn("threshold", dsp.Float...
unit/dynamics.go
0.537527
0.414721
dynamics.go
starcoder
package swagger import ( "bytes" "encoding/json" "strings" "github.com/alecthomas/template" "github.com/swaggo/swag" ) var doc = `{ "schemes": {{ marshal .Schemes }}, "swagger": "2.0", "info": { "description": "{{.Description}}", "title": "{{.Title}}", "contact": { ...
internal/swagger/docs.go
0.581065
0.414247
docs.go
starcoder
package volume import ( "bytes" "image" "image/gif" "image/jpeg" "image/png" "io" "math" "github.com/kpacha/treemap" "github.com/tidwall/pinhole" ) // NewPNG returns the image of the received tree encoded as a PNG func NewPNG(tree *treemap.Block, width, height float64) (io.WriterTo, error) { return newEnco...
volume/render.go
0.78838
0.416263
render.go
starcoder
package foldable import ( "github.com/calebcase/base/data" "github.com/calebcase/base/data/eq" "github.com/calebcase/base/data/monoid" "github.com/calebcase/base/data/ord" ) type T[T any] interface{} type Class[ A any, B any, MA monoid.Class[A], MB monoid.Class[B], EA eq.Class[A], OA ord.Class[A], TA T...
data/foldable/foldable.go
0.502686
0.547101
foldable.go
starcoder
package msgraph // RatingAustraliaTelevisionType undocumented type RatingAustraliaTelevisionType int const ( // RatingAustraliaTelevisionTypeVAllAllowed undocumented RatingAustraliaTelevisionTypeVAllAllowed RatingAustraliaTelevisionType = 0 // RatingAustraliaTelevisionTypeVAllBlocked undocumented RatingAustralia...
v1.0/RatingAustraliaTelevisionTypeEnum.go
0.601477
0.433262
RatingAustraliaTelevisionTypeEnum.go
starcoder
// Package internal provides structures and functions to operate OPAQUE that are not part of the public API. package internal import ( "crypto" "crypto/hmac" "github.com/bytemare/crypto/hash" "github.com/bytemare/crypto/mhf" ) // NewKDF returns a newly instantiated KDF. func NewKDF(id crypto.Hash) *KDF { retur...
internal/hash.go
0.837254
0.461259
hash.go
starcoder
package dids // The rules for public keys are: // A DID Document MAY include a publicKey property. // The value of the publicKey property MUST be an array of public keys. // Each public key MUST include id and type properties, and exactly one value property. // The array of public keys SHOULD NOT contain duplicate ent...
publickey.go
0.703957
0.416085
publickey.go
starcoder
package objx import ( "fmt" "strconv" ) // Value provides methods for extracting interface{} data in various // types. type Value struct { // data contains the raw data being managed by this Value data interface{} } // Data returns the raw data contained by this Value func (v *Value) Data() interface{} { return...
vendor/github.com/stretchr/objx/value.go
0.664323
0.463505
value.go
starcoder
package linearblock import ( "encoding/json" "fmt" "github.com/nathanhack/errorcorrectingcodes/linearblock/internal" "github.com/nathanhack/errorcorrectingcodes/linearblock/messagepassing/bec" mat "github.com/nathanhack/sparsemat" "strings" ) type Systemic struct { HColumnOrder []int G mat.SparseMa...
linearblock/linearblock.go
0.663015
0.407776
linearblock.go
starcoder
package picasso import ( "image" "image/color" "image/draw" "github.com/disintegration/gift" ) type Node interface { Draw(width, height int) image.Image DrawWithBorder(width, height int, borderColor color.Color, borderWidth int) image.Image } type Picture struct { Picture image.Image } func (n Picture) Draw...
picasso.go
0.819135
0.465387
picasso.go
starcoder
package reflector import ( "errors" "reflect" "sort" ) type SliceReflector struct { value *Reflector sliceValue *Reflector canAppend bool } func newSliceReflector(value *Reflector) (*SliceReflector, error) { if !value.IsValid() { return nil, errors.New(ERR_INVALID_VALUE) } if value.IsSlice() { //...
slice.go
0.631935
0.422445
slice.go
starcoder
package toggl import ( "fmt" "time" "github.com/jinzhu/now" "github.com/pkg/errors" ) // A timeRangeProvider interface calculates time ranges between a given start and end date. type timeRangeProvider interface { // GetTimeRanges returns all time ranges between the given start and end date. // Returns an error...
toggl/timereange.go
0.763307
0.698291
timereange.go
starcoder
package p5 import ( "image" "image/color" "log" ) // Push saves the current drawing style settings and transformations. func Push() { gproc.Push() } // Pop restores the previous drawing style settings and transformations. func Pop() { gproc.Pop() } // Canvas defines the dimensions of the painting area, in pix...
api.go
0.798462
0.618435
api.go
starcoder
package vespyr import ( "fmt" "time" "github.com/pkg/errors" ) // SMA returns the simple moving average for an index within a slice // of float64s. func SMA(period uint, values []float64, index uint) float64 { sum := float64(0) num := 0 for i := int(index) - int(period) + 1; i <= int(index); i++ { if i < 0 ...
pkg/vespyr/ema.go
0.81626
0.511778
ema.go
starcoder
package gogrex import ( "fmt" ) //Vertex represent any type that can act as a Vertex object type Vertex interface{} //Edge represent any type that can act as a transition between states type Edge interface{ Name() string } //Bounds is a simple pair of start, and end Vertex type Bounds struct { start, end Vertex }...
src/ericaro.net/gogrex/graph.go
0.740174
0.546738
graph.go
starcoder
package bow import ( "fmt" "sort" "github.com/apache/arrow/go/arrow" "github.com/apache/arrow/go/arrow/array" ) func (b *bow) GetRow(rowIndex int) map[string]interface{} { row := map[string]interface{}{} for colIndex := 0; colIndex < b.NumCols(); colIndex++ { val := b.GetValue(colIndex, rowIndex) if val ==...
bowgetters.go
0.653238
0.565539
bowgetters.go
starcoder
package recurly import ( "time" ) type LineItemCreate struct { // 3-letter ISO 4217 currency code. If `item_code`/`item_id` is part of the request then `currency` is optional, if the site has a single default currency. `currency` is required if `item_code`/`item_id` is present, and there are multiple currencies de...
line_item_create.go
0.837288
0.486149
line_item_create.go
starcoder
package orbitmap import ( "fmt" "strings" ) // CalcOrbits determines the total number of direct and indirect orbits in the given orbit map. func CalcOrbits(orbitMap string) int { parsedMap := parseOrbitMap(orbitMap) objectOrbitsCenterMap, _ := createOrbitLookups(parsedMap) totalOrbits := 0 for object, center ...
06-universal-orbit-map/orbitmap/orbitmap.go
0.796094
0.489137
orbitmap.go
starcoder
package main import ( "fmt" "os" "github.com/crwilcox/advent-of-code/utils" ) // Returns number of octopi that flashed func processStep(grid [][]int) int { // First, the energy level of each octopus increases by 1. for x, rowVals := range grid { for y, _ := range rowVals { grid[x][y]++ } } type pair s...
2021/day11/day11.go
0.603815
0.46721
day11.go
starcoder
package component import "encoding/json" // ExampleAddFirst - func ExampleAddFirst() { js := `[ { "Operator": "add", "Arg": [ 122, 2 ] }, { "Operator": "sub", "Arg": [ 100 ] }, { "Operator": "mul", "Arg": [ 4 ] }, { "Operator": "div", "Arg": [ 2.5 ...
architecture/c2/component/example.go
0.587352
0.561335
example.go
starcoder
// Package headers provides functionality to generate S3 HTTP headers // randomly using type constraints of S3. Therefore this package // provides lookup functions to get the value type of a header key. package headers import ( gobase64 "encoding/base64" gohex "encoding/hex" "io" "strconv" gotime "time" "githu...
headers/types.go
0.807233
0.481881
types.go
starcoder
package functions import ( "fmt" "math" "regexp" "sort" "github.com/EMCECS/influx/query" "github.com/EMCECS/influx/query/execute" "github.com/EMCECS/influx/query/interpreter" "github.com/EMCECS/influx/query/plan" "github.com/EMCECS/influx/query/semantic" "github.com/EMCECS/influx/query/values" "github.com/...
query/functions/histogram.go
0.618665
0.432902
histogram.go
starcoder
package mathutils import ( "fmt" "log" "math" "sort" "strconv" "strings" arrayutils "github.com/alessiosavi/GoGPUtils/array" "github.com/alessiosavi/GoGPUtils/helper" ) // InitIntArray is delegated to initialize a new array of the given dimension, populated with the same input value func InitIntArray(dimensi...
math/mathutils.go
0.661814
0.490419
mathutils.go
starcoder
package main /** 给定一个n个元素有序的(升序)整型数组nums 和一个目标值target ,写一个函数搜索nums中的 target,如果目标值存在返回下标,否则返回 -1。 示例 1: 输入: nums = [-1,0,3,5,9,12], target = 9 输出: 4 解释: 9 出现在 nums 中并且下标为 4 示例2: 输入: nums = [-1,0,3,5,9,12], target = 2 输出: -1 解释: 2 不存在 nums 中因此返回 -1 提示: 你可以假设 nums中的所有元素是不重复的。 n将在[1, 10000]之间。 nums的每个元素都将在[-9999, 9999]...
leetcode/search/search.go
0.560493
0.561636
search.go
starcoder
package raytracer import ( "math" ) // Matrix definition. type Matrix [4]Vector var identityHmgMatrix = Matrix{ Vector{1, 0, 0, 0}, Vector{0, 1, 0, 0}, Vector{0, 0, 1, 0}, Vector{0, 0, 0, 1}, } // perspectiveProjection - Create perspective. func perspectiveProjection(fovy, aspect, near, far float64) Matrix { ...
raytracer/matrix.go
0.704364
0.663424
matrix.go
starcoder
package solpos /* * Contains: * S_solpos (computes solar position and intensity * from time and place) * * INPUTS: (via posdata struct) year, daynum, hour, * minute, second, latitude, longitude, timezone, * intervl * ...
Solpos.go
0.602296
0.601798
Solpos.go
starcoder
// Bloomstat is a utility for estimating Bloom filter sizes. package main import ( "fmt" "io" "log" "os" "strconv" "strings" "github.com/greatroar/blobloom" ) const usage = `usage: bloomstat capacity false-positive-rate [max-memory] The maximum memory may be specified as "10MB", "1.5GiB", etc.` func main()...
examples/bloomstat/main.go
0.713931
0.445349
main.go
starcoder
package avl import ( "sync" ) const ( // LeastToGreatest tells Tree.Transverse to start with the lowest key and transverse to the highest. LeastToGreatest Mode = iota // GreatestToLeast tells Tree.Transverse to start with the highest key and transverse to the lowest. GreatestToLeasta Mode ) // Mode is the...
development/tree/avl/avl.go
0.759315
0.555797
avl.go
starcoder
package effect import ( "korok.io/korok/math/f32" "korok.io/korok/gfx" "korok.io/korok/math" ) // SnowSimulator can simulate snow effect. type SnowSimulator struct { Pool RateController LifeController VisualController velocity Channel_v2 deltaRot Channel_f32 // Configuration. Config struct{ Duration, ...
effect/sim_snow.go
0.707101
0.468365
sim_snow.go
starcoder
package vision import ( "image" "image/color" "image/draw" "math" "math/rand" "sort" "time" ) // Blob represents a blob type Blob struct { Bounds image.Rectangle Centroid image.Point Area int Points []image.Point } // Connectivity is an image graph connectivity for use in blob detection type Conne...
blob.go
0.623148
0.409044
blob.go
starcoder
package float256 import ( "math/big" ) // Zero returns a new float with 256 bits of precision. This can be a good way to generate a new variable with minimal typing for input conversion functions particularly. func Zero() *big.Float { r := big.NewFloat(0.0) r.SetPrec(256) return r } // New returns a new floating...
float256.go
0.889187
0.596022
float256.go
starcoder
package main import ( "bytes" "fmt" "image" "image/color" "image/png" "io/ioutil" "log" "github.com/gitchander/neural" ) func main() { //testOperator(XOR) makeOperatorImage(XOR) //testNot() } func testOperator(op operator) { samples := makeSamplesByOperator(op) p, err := neural.NewMLP(2, 3, 1) check...
examples/bool/main.go
0.5083
0.424472
main.go
starcoder
package alphavantage import ( "encoding/json" "net/url" "github.com/tradyfinance/marshaler" ) // An ExchangeRate is the exchange rate for a currency pair. type ExchangeRate struct { FromCurrencyCode string `json:"1. From_Currency Code"` FromCurrencyName string `json:"2. From_Currency Na...
exchange_rate.go
0.72662
0.412353
exchange_rate.go
starcoder
package gvpy import ( "fmt" "reflect" "github.com/bluvec/gvpy/python" ) type GoToPyConv func(arg interface{}) (*python.PyObject, error) type PyToGoConv func(pyobj *python.PyObject) (interface{}, error) var gGoToPy []GoToPyConv var gPyToGo []PyToGoConv func RegGoToPyConv(conv GoToPyConv) { gGoToPy = append(gGoT...
convert.go
0.581422
0.443239
convert.go
starcoder
package decorated import ( "fmt" "github.com/swamp/compiler/src/ast" "github.com/swamp/compiler/src/decorated/dtype" "github.com/swamp/compiler/src/token" ) type LetVariable struct { name *ast.VariableIdentifier variableType dtype.Type references []*LetVariableReference comment *ast.MultilineC...
src/decorated/expression/let.go
0.615088
0.460774
let.go
starcoder
package goref import ( "encoding/json" "go/ast" "golang.org/x/tools/go/loader" ) // RefType is an enum of the various ways a package can reference an // identifier in another package (e.g. as a call, an instantiation, // etc.) type RefType int // These are the possible types of edges in a graph. const ( // Inst...
reftype.go
0.637031
0.420183
reftype.go
starcoder
package normality import ( "log" "math" ) // D'Agostino's K-squared test // https://en.wikipedia.org/wiki/D'Agostino's_K-squared_test func D_AgostinosKsquared(data *[]float64) (Ksquared float64, P_value float64) { n := len(*data) if n < 20 { log.Println("D'Agostino's K-squared test :: Data is too small. Should ...
normality/d_agostino.go
0.636127
0.41834
d_agostino.go
starcoder
package gofakeit import ( "math/rand" "strconv" "strings" "time" ) // Date will generate a random time.Time struct func Date() time.Time { return date(globalFaker.Rand) } // Date will generate a random time.Time struct func (f *Faker) Date() time.Time { return date(f.Rand) } func date(r *rand.Rand) time.Time { ...
vendor/github.com/brianvoe/gofakeit/v6/time.go
0.78436
0.455865
time.go
starcoder
package presto import ( "encoding/json" "fmt" "math" "reflect" "time" "unsafe" "github.com/grab/talaria/internal/encoding/typeof" talaria "github.com/grab/talaria/proto" ) // Append adds a value to the block. func (b *PrestoThriftInteger) Append(v interface{}) int { const size = 2 + 4 if v == nil { b.Nu...
internal/presto/columns.go
0.692746
0.479382
columns.go
starcoder
package entity import ( "github.com/go-gl/gl" "glutil" "util" ) type Castle struct { drawbridge_angle int32 drawbridge_closing bool x_pos float64 y_pos float64 z_pos float64 children util.RenderQueue } func NewCastle() Castle { moat := NewXYPlane(glutil.Po...
src/entity/castle.go
0.540924
0.462959
castle.go
starcoder
package vecfc import ( "encoding/binary" "math" "github.com/mugambocoin/mugambo-base/inter/idx" ) /* * Use binary form for optimization, to avoid serialization. As a result, DB cache works as elements cache. */ type ( // LowestAfterSeq is a vector of lowest events (their Seq) which do observe the source event...
vecfc/vector.go
0.70304
0.458894
vector.go
starcoder
package palette import ( "github.com/Lexus123/gamut" colorful "github.com/lucasb-eyer/go-colorful" ) func init() { Resene.AddColors( gamut.Colors{ {"Abbey", colorful.Color{R: 0.298039, G: 0.309804, B: 0.337255}, ""}, {"Acadia", colorful.Color{R: 0.105882, G: 0.078431, B: 0.015686}, ""}, {"Acapulco", col...
palette/resene.go
0.50708
0.57093
resene.go
starcoder
package runtime import ( "fmt" gocolor "image/color" "github.com/lucasb-eyer/go-colorful" "github.com/mitchellh/hashstructure/v2" "go.starlark.net/starlark" "tidbyt.dev/pixlet/render" ) type Plot struct { Widget render.Plot starlarkWidth starlark.Int starlarkHeight starlark.Int } func parseFloatTuple(t...
runtime/plot.go
0.644337
0.417509
plot.go
starcoder
package lmath import ( "fmt" "math" ) // Vec3 represents a 3D vector or point. type Vec3 struct { X, Y, Z float64 } // String returns an string representation of this vector. func (a Vec3) String() string { return fmt.Sprintf("Vec3(X=%f, Y=%f, Z=%f)", a.X, a.Y, a.Z) } // AlmostEquals tells if a == b using the ...
lmath/vec3.go
0.946485
0.694827
vec3.go
starcoder
package types import ( "sort" "github.com/attic-labs/noms/go/d" ) // SetEditor allows for efficient editing of Set-typed prolly trees. Edits // are buffered to memory and can be applied via Build(), which returns a new // Set. Prior to Build(), Get() & Has() will return the value that the resulting // Set would r...
go/types/set_editor.go
0.57069
0.482246
set_editor.go
starcoder
package histogram import ( "sync" "github.com/giantswarm/microerror" ) type Config struct { // BucketLimits is the upper limit of each bucket in the histogram. // See https://godoc.org/github.com/prometheus/client_golang/prometheus#HistogramOpts. BucketLimits []float64 } // Histogram is a data structure suitab...
histogram/histogram.go
0.807992
0.459319
histogram.go
starcoder
package filmore import ( "log" "io/ioutil" "github.com/golang/freetype/truetype" "golang.org/x/image/font" "golang.org/x/image/math/fixed" ) // Scaling constant for going from points to pixels. const DPI = 92 type Op interface { X() float64 Y() float64 ControlX() float64 ControlY() float64 } type op stru...
text.go
0.663996
0.461017
text.go
starcoder
package vec2 import ( "fmt" math "github.com/ungerik/go3d/fmath" "github.com/ungerik/go3d/generic" ) var ( // Zero holds a zero vector. Zero = T{} // UnitX holds a vector with X set to one. UnitX = T{1, 0} // UnitY holds a vector with Y set to one. UnitY = T{0, 1} // UnitXY holds a vector with X and Y set...
vec2/vec2.go
0.914484
0.70304
vec2.go
starcoder
// Copyright ©2013 The bíogo Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package palette provides basic color palette handling. package palette import ( "image/color" "math" ) // Palette is a collection of colors ordered ...
Godeps/_workspace/src/github.com/gonum/plot/palette/palette.go
0.890657
0.518059
palette.go
starcoder
package lbp import ( "errors" "image" _ "image/gif" _ "image/jpeg" _ "image/png" "strconv" ) // getBinaryString function used to get a binary value as a string based on a threshold. // Return "1" if the value is equal or higher than the threshold or "0" otherwise. func getBinaryString(value, threshold int) stri...
lbp/lbp.go
0.76934
0.535827
lbp.go
starcoder
package meta import ( "crypto/sha256" "encoding/json" "fmt" "github.com/pkg/errors" "strings" ) // RowMap is a map of column name to column value. // It is created from a SQL result. type RowMap map[string]interface{} // ExtractPrefixedRowKeys returns a RowKeys with the values for entry in the RowMap // which h...
internal/meta/rows.go
0.656108
0.499756
rows.go
starcoder
package values import "gioui.org/unit" var ( MarginPadding0 = unit.Dp(0) MarginPadding1 = unit.Dp(1) MarginPadding2 = unit.Dp(2) MarginPaddingMinus2 = unit.Dp(-2) MarginPadding3 = unit.Dp(3) MarginPadding4 = unit.Dp(4) MarginPadding5 = unit.Dp(5) MarginPaddingMinus5...
ui/values/dimensions.go
0.53048
0.490907
dimensions.go
starcoder
package square // Represents a service charge applied to an order. type OrderServiceCharge struct { // Unique ID that identifies the service charge only within this order. Uid string `json:"uid,omitempty"` // The name of the service charge. Name string `json:"name,omitempty"` // The catalog object ID referencing ...
square/model_order_service_charge.go
0.868896
0.515803
model_order_service_charge.go
starcoder
package texture import ( "github.com/schidstorm/engine/gls" "time" ) // Animator can generate a texture animation based on a texture sheet type Animator struct { tex *Texture2D // pointer to texture being displayed dispTime time.Duration // disply duration of each tile (default = 1.0/30.0) maxCycles i...
texture/animator.go
0.804598
0.435962
animator.go
starcoder
package flux import ( "context" "fmt" "regexp" "strings" "time" "github.com/influxdata/flux/codes" "github.com/influxdata/flux/internal/errors" "github.com/influxdata/flux/interpreter" "github.com/influxdata/flux/semantic" "github.com/influxdata/flux/values" ) const ( TablesParameter = "tables" tableKind...
compile.go
0.572245
0.431824
compile.go
starcoder
package bit import ( "image" "image/color" ) func (i *Image) Convolution(kernel [][]float64, factor, bias float64) Image { bounds := i.Bounds() newimg := image.NewRGBA(bounds) for x := bounds.Min.X; x < bounds.Max.X; x++ { for y := bounds.Min.Y; y < bounds.Max.Y; y++ { point := image.Point{X: x, Y: y} c...
convolution.go
0.842151
0.627152
convolution.go
starcoder
package datastructure import ( "github.com/gokhantamkoc/go-trading-commons/utils" ) type BinaryTreeNode struct { value interface{} left *BinaryTreeNode right *BinaryTreeNode } type BinaryTree struct { root *BinaryTreeNode } func NewBinaryTree() *BinaryTree { return &BinaryTree{} } func (t *BinaryTree) Inser...
indicator/datastructure/binary_tree.go
0.76934
0.455562
binary_tree.go
starcoder
package aggregation import ( "time" "github.com/m3db/m3/src/aggregator/aggregation/quantile/cm" "github.com/m3db/m3/src/metrics/aggregation" ) // Timer aggregates timer values. Timer APIs are not thread-safe. type Timer struct { lastAt time.Time stream *cm.Stream // Stream o...
src/aggregator/aggregation/timer.go
0.853547
0.457318
timer.go
starcoder
package matrix import "math" /* Finds the sum of two matrices. */ func Sum(A MatrixRO, Bs ...MatrixRO) (C *DenseMatrix) { C = MakeDenseCopy(A) var err error for _, B := range Bs { err = C.Add(MakeDenseCopy(B)) if err != nil { break } } if err != nil { C = nil } return } /* Finds the difference bet...
arithmetic.go
0.671363
0.480357
arithmetic.go
starcoder
package types import ( "sort" "github.com/attic-labs/noms/go/d" ) // MapEditor allows for efficient editing of Map-typed prolly trees. Edits // are buffered to memory and can be applied via Build(), which returns a new // Map. Prior to Build(), Get() & Has() will return the value that the resulting // Map would r...
go/types/map_editor.go
0.550607
0.409634
map_editor.go
starcoder
package unit // Duration represents a SI unit of time (in seconds, s) type Duration Unit // ... const ( // SI Yoctosecond = Second * 1e-24 Zeptosecond = Second * 1e-21 Attosecond = Second * 1e-18 Femtosecond = Second * 1e-15 Picosecond = Second * 1e-12 Nanosecond ...
duration.go
0.884999
0.481698
duration.go
starcoder
package mmc import ( "fmt" "image" "image/color" "image/png" "math" "os" ) // MMC struct takes necessary values to draw a Modular Multiplication Circle type MMC struct { img *image.RGBA size int fg color.RGBA bg color.RGBA pad int rot float64 } // Init attributes of MMC struct func (mmc *MMC) Init...
mmc/mmc.go
0.568655
0.419053
mmc.go
starcoder
package workitem import ( "fmt" "strconv" "strings" "github.com/almighty/almighty-core/criteria" ) const ( jsonAnnotation = "JSON" ) // Compile takes an expression and compiles it to a where clause for use with gorm.DB.Where() // Returns the number of expected parameters for the query and a slice of errors if ...
workitem/expression_compiler.go
0.666062
0.451145
expression_compiler.go
starcoder
package block import ( "fmt" "time" "github.com/m3db/m3/src/query/models" ) // Block represents a group of series across a time bound type Block interface { // StepIter returns a StepIterator StepIter() (StepIter, error) // SeriesIter returns a SeriesIterator SeriesIter() (SeriesIter, error) // Close frees ...
src/query/block/types.go
0.83825
0.441854
types.go
starcoder
package log import ( "errors" "reflect" "github.com/echocat/slf4g/fields" ) // AreEventsEqual is comparing two given Events using DefaultEventEquality. func AreEventsEqual(left, right Event) (bool, error) { if v := DefaultEventEquality; v != nil { return v.AreEventsEqual(left, right) } return false, nil } /...
event_equality.go
0.882637
0.506225
event_equality.go
starcoder
package ast import "reflect" func (n *NilNode) SetType(t reflect.Type) { n.t = t } func (n *NilNode) GetType() reflect.Type { return n.t } func (n *IdentifierNode) SetType(t reflect.Type) { n.t = t } func (n *IdentifierNode) GetType() reflect.Type { return n.t } func (n *IntegerNode) SetType(t reflect.Type) {...
ast/type.go
0.710126
0.787605
type.go
starcoder
package search import ( "github.com/christat/search" "time" ) // IterativeDeepening implements recursive IDS. // It will look for optimal solutions reaching target from origin. // The depth bound is slowly increased until reaching maxDepth. func IterativeDeepening(origin, target search.State, maxDepth int) (path ma...
blind/iterative_deepening.go
0.663887
0.421969
iterative_deepening.go
starcoder
package utils // TSTNode represents the ternary search trie node type TSTNode struct { Value interface{} Cb byte Left, Middle, Right *TSTNode } type TernarySearchTrie struct { Root *TSTNode } func NewTST() *TernarySearchTrie { return &TernarySearchTrie{ // Root: &TSTNode{}, not ...
utils/trie.go
0.587943
0.401512
trie.go
starcoder
package model import "io" import . "aicup2019/stream" type CustomData interface { Write(writer io.Writer) } func ReadCustomData(reader io.Reader) CustomData { switch ReadInt32(reader) { case 0: return ReadCustomDataLog(reader) case 1: return ReadCustomDataRect(reader) ...
srcOriginal/go/model/custom_data.go
0.814053
0.560373
custom_data.go
starcoder
package canvas import "syscall/js" type Context2D struct { value js.Value } // SUBTYPE GETTERS func (context Context2D) Shadow() Shadow { return Shadow(context) } func (context Context2D) Line() Line { return Line(context) } func (context Context2D) Rectangle(x, y, width, height int) Rectangle { return Rectan...
canvas/context2d.go
0.83025
0.471041
context2d.go
starcoder
// This file contains the corresponding structures to the // "Basic JSON Structures" part of the LSP specification. package protocol const ( // CodeRequestCancelled is the error code that is returned when a request is // cancelled early. CodeRequestCancelled = -32800 ) // DocumentURI represents the URI of a docu...
vendor/golang.org/x/tools/internal/lsp/protocol/basic.go
0.776369
0.533154
basic.go
starcoder
package stream import "container/heap" /* 295. 数据流的中位数 https://leetcode-cn.com/problems/find-median-from-data-stream 中位数是有序列表中间的数。如果列表长度是偶数,中位数则是中间两个数的平均值。 例如, [2,3,4] 的中位数是 3 [2,3] 的中位数是 (2 + 3) / 2 = 2.5 设计一个支持以下两种操作的数据结构: void addNum(int num) - 从数据流中添加一个整数到数据结构中。 double findMedian() - 返回目前所有元素的中位数。 示例: addN...
solutions/find-median-from-data-stream/d.go
0.628977
0.587292
d.go
starcoder
package unencrypted_asset import ( "github.com/threagile/threagile/model" ) func Category() model.RiskCategory { return model.RiskCategory{ Id: "unencrypted-asset", Title: "Unencrypted Technical Assets", Description: "Due to the confidentiality rating of the technical asset itself and/or the processed data...
risks/built-in/unencrypted-asset/unencrypted-asset-rule.go
0.6488
0.533884
unencrypted-asset-rule.go
starcoder
package rangechain import ( "errors" "github.com/halprin/rangechain/internal/generator" "github.com/halprin/rangechain/internal/helper" "sort" ) // Map will run the `mapFunction` parameter function parameter against all the values in the chain. In that function, return what you want to change the value into or a...
link_chain.go
0.816113
0.427875
link_chain.go
starcoder
package quantity import ( "fmt" "math" "github.com/snapcore/snapd/i18n" ) // these are taken from github.com/chipaca/quantity with permission :-) func FormatAmount(amount uint64, width int) string { if width < 0 { width = 5 } max := uint64(5000) maxFloat := 999.5 if width < 4 { width = 3 max = 999 ...
vendor/github.com/snapcore/snapd/strutil/quantity/quantity.go
0.512937
0.407216
quantity.go
starcoder
package ir import ( "github.com/llir/llvm/ir/types" "github.com/llir/llvm/ir/value" ) // --- [ Conversion instructions ] --------------------------------------------- // ~~~ [ trunc ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // NewTrunc appends a new trunc instruction to the basic block bas...
ir/block_conversion.go
0.609059
0.412412
block_conversion.go
starcoder
package bigint import "math/big" func dummy() *big.Int { return big.NewInt(0) } func dummyF() *big.Float { return big.NewFloat(0.0) } // Lt determines whether or not big.Int a is less than big.Int b. // Returns true if a is smaller than b. func Lt(a, b *big.Int) bool { return a.Cmp(b) < 0 } // LtE determines wh...
bigint/bigint.go
0.873039
0.465145
bigint.go
starcoder
package query import ( sitter "github.com/smacker/go-tree-sitter" "go.lsp.dev/protocol" "github.com/tilt-dev/starlark-lsp/pkg/document" ) // PositionToPoint converts an LSP protocol file location to a Tree-sitter file location. func PositionToPoint(pos protocol.Position) sitter.Point { return sitter.Point{ Row...
vendor/github.com/tilt-dev/starlark-lsp/pkg/query/location.go
0.818084
0.540257
location.go
starcoder
package fp func (q BoolQueue) NonEmpty() bool { return (*q.in).NonEmpty() || (*q.out).NonEmpty() } func (q StringQueue) NonEmpty() bool { return (*q.in).NonEmpty() || (*q.out).NonEmpty() } func (q IntQueue) NonEmpty() bool { return (*q.in).NonEmpty() || (*q.out).NonEmpty() } func (q Int64Queue) NonEmpty() bool { ...
fp/bootstrap_queue_nonempty.go
0.809653
0.457682
bootstrap_queue_nonempty.go
starcoder
package ipx import ( "errors" b "math/bits" "net" ) var v4InV6Prefix = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff} // SummarizeRange returns a series of networks which combined cover the range between the first and last addresses, // inclusive. func SummarizeRange(first, last net.IP) []*net.IPNet { four := ...
summarize.go
0.689933
0.428771
summarize.go
starcoder
package cc import ( "fmt" ) // Walk traverses the syntax x, calling before and after on entry to and exit from // each Syntax encountered during the traversal. In case of cross-linked input, // the traversal never visits a given Syntax more than once. func Walk(x Syntax, before, after func(Syntax)) { seen := map[S...
cc/walk.go
0.586404
0.570271
walk.go
starcoder
package parse import ( "blockwatch.cc/tzgo/micheline" "github.com/jeanschmitt/tzgen/pkg/ast/types" ) func (p *parser) parseType(t *micheline.Typedef) (types.Type, error) { // Unwrap optional if t.Optional { typ, err := p.parseType(&micheline.Typedef{Name: t.Name, Type: t.Type, Args: t.Args}) if err != nil { ...
internal/parse/type.go
0.519278
0.40486
type.go
starcoder
package master import "github.com/go-gl/mathgl/mgl32" const ( axisWidth = 0 axisHeight = 1 ) // Panel represents a rectangle positioned within a window. // It is provided a set of rules that resolve the rectangles size and // position on screen. type Panel struct { // TopLeft is the computed offset from the top ...
internal/ui/imgui-layouts/master/panel.go
0.83752
0.487124
panel.go
starcoder
package v1_0 func init() { Profile["/tosca/simple-for-nfv/1.0/data.yaml"] = ` tosca_definitions_version: tosca_simple_yaml_1_2 data_types: tosca.datatypes.nfv.L2AddressData: # ERRATUM: TBD metadata: puccini.normative: 'true' specification.citation: '[TOSCA-Simple-Profile-NFV-v1.0-csd04]' ...
tosca/profiles/simple-for-nfv/v1_0/data.go
0.722429
0.472988
data.go
starcoder