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 gom import () // A tree have n root // Each node have children represented by the firstChild followed by nextSiblings // see Encoding general trees as binary trees in http://en.wikipedia.org/wiki/Binary_tree // Each node have a reference to an Element type Node struct { element Element parent *Nod...
tree.go
0.64791
0.403097
tree.go
starcoder
// +build ignore package main import ( "bytes" "go/format" "log" "math" "os" "strings" "text/template" "gonum.org/v1/gonum/unit" ) const ( elementaryCharge = 1.602176634e-19 fineStructure = 7.2973525693e-3 lightSpeed = 2.99792458e8 planck = 6.62607015e-34 ) var constants = []Constan...
unit/constant/generate_constants.go
0.611034
0.469703
generate_constants.go
starcoder
package dataframe import ( "fmt" "sort" "strings" "time" ) // Field represents a column of data with a specific type. type Field struct { Name string Vector Vector } // Fields is a slice of Field pointers. type Fields []*Field // NewField returns a new instance of Field. func NewField(name string, values in...
vendor/github.com/grafana/grafana-plugin-sdk-go/dataframe/dataframe.go
0.682256
0.510252
dataframe.go
starcoder
package pmgen import ( "github.com/t14raptor/pm-gen/rand" ) type Grad3 struct { x, y, z float64 } var grad3Table = [...]Grad3{ {1, 1, 0}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {1, 0, 1}, {-1, 0, 1}, {1, 0, -1}, {-1, 0, -1}, {0, 1, 1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}, } func Dot3(g Grad3, x, y, z fl...
simplex.go
0.60288
0.482734
simplex.go
starcoder
package vtparser import ( "math" "github.com/danielgatis/go-vte/utf8" ) // State represents a state type type State = byte // Action represents a action type type Action = byte const maxIntermediates = 2 const maxOscRaw = 1024 const maxParams = 16 type printCallback func(char rune) type execCallback func(b byte...
vtparser/parser.go
0.574514
0.4184
parser.go
starcoder
package analyzing import ( "fmt" "regexp" "sort" "strconv" log "github.com/sirupsen/logrus" ) const onlyDigits = "\\d+" var numberRegex = regexp.MustCompile(onlyDigits) // GetExactRegexExprForTag creates a regex expression dynamically for the given tag. // It try's to exchange the digits with the onyDigits ex...
pkg/analyzing/tags.go
0.504639
0.464112
tags.go
starcoder
package filter import ( "image" "image/color" "sort" "github.com/fairhive-labs/go-pixelart/internal/colorutils" ) type Filter interface { //Process image transformation from source src to destination dst Process(src *image.Image) *image.RGBA } type basicFilter struct { transform TransformColor } type predic...
internal/filter/filter.go
0.793466
0.421909
filter.go
starcoder
package maroto import ( "github.com/jung-kurt/gofpdf" ) // Math is the abstraction which deals with useful calc type Math interface { GetWidthPerCol(qtdCols float64) float64 GetRectCenterColProperties(imageWidth float64, imageHeight float64, qtdCols float64, colHeight float64, indexCol float64, percent float64) (x...
math.go
0.793906
0.572484
math.go
starcoder
package linalgo type Matrix [][]int func Eye(x int) Matrix{ mat := make([][]int,x) for i := 0 ; i < x ;i++ { mat[i] = make([]int,x) mat[i][i] = 1 } return mat } func Dot(a,b []int ) int{ l := len(a) res := 0 for i := 0; i < l; i++{ res += a[i]*b[i] } return res } func Transpose(a Matrix) Matrix{ ...
linalg.go
0.595257
0.416797
linalg.go
starcoder
package colorgrad import ( "fmt" "image/color" "github.com/lucasb-eyer/go-colorful" "github.com/mazznoer/csscolorparser" ) type BlendMode int const ( BlendHcl BlendMode = iota BlendHsv BlendLab BlendLinearRgb BlendLuv BlendRgb BlendOklab ) type gradientBase interface { // Get color at certain position ...
vendor/github.com/mazznoer/colorgrad/gradient.go
0.757436
0.452838
gradient.go
starcoder
package steering import "math" type Vector []float32 func (v Vector) Len() float32 { ret := float32(0) for _, val := range v { ret += (val * val) } return float32(math.Sqrt(float64(ret))) } func (v Vector) Distance(other Vector) float32 { ret := float32(0) for i, val := range v { ret += (val - other[i]) *...
vector.go
0.777046
0.512754
vector.go
starcoder
package rbt type Tree struct { root *node } func (t *Tree) Add(value int) bool { if t.root == nil { t.root = &node{value: value} return true } var currentNode *node pointer := t.root for { if pointer.value < value { if pointer.right == nil { currentNode = &node {value: value, isRed: true, parent: ...
data-structures/rbt/tree.go
0.524882
0.521776
tree.go
starcoder
package gopacket import ( "fmt" ) // Layer represents a single decoded packet layer (using either the // OSI or TCP/IP definition of a layer). When decoding, a packet's data is // broken up into a number of layers. The caller may call LayerType() to // figure out which type of layer they've received from the pack...
vendor/src/code.google.com/p/gopacket/base.go
0.785555
0.40928
base.go
starcoder
package dataflow import ( "github.com/pkg/errors" "github.com/pulumi/pulumi/sdk/go/pulumi" ) // Creates a job on Dataflow, which is an implementation of Apache Beam running on Google Compute Engine. For more information see // the official documentation for // [Beam](https://beam.apache.org) and [Dataflow](https:/...
sdk/go/gcp/dataflow/job.go
0.593727
0.513181
job.go
starcoder
package msp type Row []FieldElem // NewRow returns a row of length s with all zero entries. func NewRow(s int) Row { out := Row(make([]FieldElem, s)) for i := 0; i < s; i++ { out[i] = NewFieldElem() } return out } // AddM adds two vectors. func (e Row) AddM(f Row) { le, lf := e.Size(), f.Size() if le != lf...
vendor/github.com/cloudflare/redoctober/msp/matrix.go
0.844505
0.403273
matrix.go
starcoder
package mat import ( "fmt" "math" ) //type Set [4]float64 type Set [4]float64 func (s Set) Vector() Set{ s[0] = 0.0 s[1] = 0.0 s[2] = 0.0 s[3] = 0.0 return s } func (s Set) Point() Set{ s[0] = 0.0 s[1] = 0.0 s[2] = 0.0 s[3] = 1.0 return s } func NewColor(r, g, b float64) Set { return Set{r, g, b...
internal/pkg/mat/tuple.go
0.514888
0.52409
tuple.go
starcoder
package explain import ( "fmt" "strings" ) // A Problem is a conjunction of Clauses. // This package does not use solver's representation. // We want this code to be as simple as possible to be easy to audit. // On the other hand, solver's code must be as efficient as possible. type Problem struct { Clauses [][]...
explain/problem.go
0.639849
0.431345
problem.go
starcoder
// Package mpl describes the Mozilla Public License. package mpl import "github.com/creachadair/lice/licenses" func init() { licenses.Register(licenses.License{ Name: "Mozilla Public License, v 2.0", Slug: "mpl2", URL: "https://www.mozilla.org/en-US/MPL/", Text: text, PerFile: perFile, }) } ...
licenses/mpl/mpl.go
0.744656
0.420481
mpl.go
starcoder
package persist import ( "fmt" "time" "github.com/m3db/m3/src/dbnode/storage/namespace" "github.com/m3db/m3/src/dbnode/ts" "github.com/m3db/m3/src/m3ninx/index/segment" "github.com/m3db/m3x/ident" ) // DataFn is a function that persists a m3db segment for a given ID. type DataFn func(id ident.ID, tags ident.T...
src/dbnode/persist/types.go
0.624294
0.435061
types.go
starcoder
package parseutils // human_readable.go maps the adjusted timestamps from the checkin battery history to the cumulative time deltas to match the human readable battery history deltas. import ( "fmt" "strconv" ) type deltaMapping struct { // Total of deltas read so far. cumulativeDelta int64 // The key is the u...
parseutils/human_readable.go
0.737725
0.673667
human_readable.go
starcoder
package protocol import ( "github.com/sandertv/gophertunnel/minecraft/nbt" ) // ItemInstance represents a unique instance of an item stack. These instances carry a specific network ID // that is persistent for the stack. type ItemInstance struct { // StackNetworkID is the network ID of the item stack. If the stack ...
minecraft/protocol/item.go
0.639286
0.400456
item.go
starcoder
package ent import ( "fmt" "strings" "github.com/facebookincubator/ent/dialect/sql" "github.com/thoverik/gobench/ent/histogram" "github.com/thoverik/gobench/ent/metric" ) // Histogram is the model entity for the Histogram schema. type Histogram struct { config `json:"-"` // ID of the ent. ID int `json:"id,o...
ent/histogram.go
0.776199
0.573081
histogram.go
starcoder
package main import ( "github.com/MattSwanson/raylib-go/physics" "github.com/MattSwanson/raylib-go/raylib" ) func main() { screenWidth := int32(800) screenHeight := int32(450) rl.SetConfigFlags(rl.FlagMsaa4xHint) rl.InitWindow(screenWidth, screenHeight, "Physac [raylib] - physics friction") // Physac logo dr...
examples/physics/physac/friction/main.go
0.597256
0.502197
main.go
starcoder
package pathutil import ( "math" "path/filepath" "sort" "strings" ) // Distance is a numerical distance between two paths type Distance uint32 const ( // PreferBase is the zero distance. When passed to SortByDistance(), the // base path is sorted to the top. PreferBase Distance = 0 // PreferChildren is a di...
pathutil/distance.go
0.786295
0.449332
distance.go
starcoder
package geodesic // #cgo LDFLAGS: -lm // #include "geodesic.h" import "C" import ( "github.com/xeonx/geographic" ) //InvertAzimuth invert an azimuth in degree (adds 180° and convert to [0,360[ interval). func InvertAzimuth(azDeg float64) float64 { return azDeg + 180%360 } //Geodesic contains information about the...
geodesic.go
0.841011
0.657793
geodesic.go
starcoder
package knapsack // Item holds single item info, i.e. benefit and weight type Item struct { benefit float64 weight float64 } // MaxUnboundedKnapsackValueF calculates maximum value of knapsack with unlimited number of copies of items used. // Knapsack weight is limited by capacity.. Items are given with their benef...
api.go
0.807157
0.447098
api.go
starcoder
package main import ( "log" "sort" ) type DistanceCandidate struct { Distance float64 Position } func (level Level) getStair(x int, y int) (Stair, bool) { for _, s := range level.stairs { if s.X == x && s.Y == y { return s, true } } return Stair{}, false } func (level Level) GetTile(x int, y int) *Til...
example/muncher/level.go
0.641759
0.40251
level.go
starcoder
package osc import ( "encoding/json" ) // BsuToCreate Information about the BSU volume to create. type BsuToCreate struct { // By default or if set to true, the volume is deleted when terminating the VM. If false, the volume is not deleted when terminating the VM. DeleteOnVmDeletion *bool `json:"DeleteOnVmDeletio...
v2/model_bsu_to_create.go
0.786787
0.421314
model_bsu_to_create.go
starcoder
package other import ( "time" "github.com/kasworld/h4o/_examples/app" "github.com/kasworld/h4o/appwindow" "github.com/kasworld/h4o/eventtype" "github.com/kasworld/h4o/geometry" "github.com/kasworld/h4o/gls" "github.com/kasworld/h4o/graphic" "github.com/kasworld/h4o/gui" "github.com/kasworld/h4o/light" "gith...
_examples/demos/other/pitch.go
0.565059
0.424173
pitch.go
starcoder
package formula import "math" // The following functions are automatically exposed to any formula. // abs ... func abs(params ...float64) float64 { return math.Abs(params[0]) } // acos ... func acos(params ...float64) float64 { return math.Acos(params[0]) } // acosh ... func acosh(params ...float64) float64 { r...
functions.go
0.733452
0.605507
functions.go
starcoder
package tensori import ( "fmt" "math" ) // This file is for the safe versions of any arithmetic functions listed in arith.go and (arith_asm.go or arith_go.go) // A safe version is a version with return values, and does not mutate the underlying data func safeVecAdd(a, b []int, optional ...[]int) (retVal []int) { ...
tensor/i/arith_safe.go
0.579757
0.529203
arith_safe.go
starcoder
Create Eurorack Module Panels */ //----------------------------------------------------------------------------- package main import ( "log" "github.com/deadsy/sdfx/obj" "github.com/deadsy/sdfx/render" "github.com/deadsy/sdfx/sdf" ) //---------------------------------------------------------------------------...
examples/eurorack/main.go
0.639061
0.40204
main.go
starcoder
// Utility methods to calculate percentiles. package summary import ( "fmt" "math" "sort" info "github.com/google/cadvisor/info/v2" ) const secondsToMilliSeconds = 1000 const milliSecondsToNanoSeconds = 1000000 const secondsToNanoSeconds = secondsToMilliSeconds * milliSecondsToNanoSeconds type Uin...
Godeps/_workspace/src/github.com/google/cadvisor/summary/percentiles.go
0.87938
0.510802
percentiles.go
starcoder
package matchers import ( "fmt" "strings" "code.cloudfoundry.org/bbs/models" "github.com/onsi/gomega" "github.com/onsi/gomega/format" ) const NoCrashCount = -1 const AtLeastOneCrashCount = -2 func BeActualLRP(processGuid string, index int) gomega.OmegaMatcher { return &BeActualLRPMatcher{ ProcessGuid: proce...
matchers/be_actual_lrp.go
0.664431
0.40072
be_actual_lrp.go
starcoder
package data import( "fmt" "github.com/wardlem/graphlite/util" ) // Error strings const ( labelCreationFailure = "could not create label" labelWrongDataSize = "wrong data size when creating label" nilLabel = "attempt to operate on a nil label" ) const labelDataSize = 21 // this is the number ...
data/label.go
0.662469
0.571468
label.go
starcoder
package pike import ( "fmt" "strings" ) // Node is a component of the asset graphs. Each node performs an operation on // the files as they pass through, and can be connected to other Nodes. type Node struct { Name string Inputs []*Node Outputs []*Node MinInputs int MaxInputs int MinOutputs int...
node.go
0.700075
0.449211
node.go
starcoder
package xmath import "math" const Epsilon = 0.0000001 func Operator(op string, a, b int) int { if op == "*" { return a * b } else if op == "+" { return a + b } else if op == "-" { return a - b } else if op == "/" { return a / b } else if op == "%" { return a % b } return -1 } func ToRomanNumeral(x ...
xmath/xmath.go
0.70202
0.673373
xmath.go
starcoder
package seaturtle import ( "encoding/binary" ) func cryptBlock(subkeys []uint32, dst, src []byte, decrypt bool) { var t uint64 left := binary.BigEndian.Uint64(src[0:8]) right := binary.BigEndian.Uint64(src[8:16]) if !decrypt { // Input Whitening left = left ^ concatenate32(&subkeys[0], &subkeys[1]) right ...
block.go
0.602179
0.471771
block.go
starcoder
package integration import ( "fmt" "strings" "testing" "github.com/stretchr/testify/assert" ) // HasBody asserts that the request received the specified body func HasBody(t *testing.T, req Request, body string) { assert.Equal(t, body, req.Body, "Should match body") } // HasCookie asserts that the request recei...
test/integration/assertions.go
0.674265
0.528959
assertions.go
starcoder
package main import ( "fmt" "io/ioutil" "log" "math" "os" "strings" "github.com/beefsack/go-astar" ) type Point struct { X int Y int } type Position struct { Loc Point Risk int Neighbors []*Position } func NewPosition(pt Point, risk byte) *Position { return &Position{ Loc: pt, Risk: in...
day15/main.go
0.560253
0.442877
main.go
starcoder
package math type Vector3 struct { X float32 Y float32 Z float32 } func Vec3(x, y, z float32) Vector3 { return Vector3{x, y, z} } func (vec *Vector3) Set(x, y, z float32) Vector3 { vec.X = x vec.Y = y vec.Z = z return *vec } func (vec *Vector3) SetVec2(v Vector2) Vector3 { vec.X = v.X vec.Y = v.Y return ...
vector3.go
0.932184
0.895842
vector3.go
starcoder
package weekCamp type ATM struct { paperCount map[int]int totalCount int paperAmount []int maxIndex int } func Constructor() ATM { return ATM { paperCount : map[int]int { 20 : 0, 50 : 0, 100 : 0, 200 : 0, ...
weekCamp/2022.04.16/3.go
0.540439
0.408572
3.go
starcoder
package value import ( "fmt" "github.com/polyscone/knight/ast" ) // Block is the result of the evaluation of the BLOCK function, and wraps an // expression that is to be used as the argument to CALL. type Block struct { Value Expression } // AsBool is only implemented here so that Block can be used as a value. /...
value/block.go
0.644225
0.438304
block.go
starcoder
package fsm import ( "bytes" "fmt" ) const highlightingColor = "#00AA00" // MermaidDiagramType the type of the mermaid diagram type type MermaidDiagramType string const ( // FlowChart the diagram type for output in flowchart style (https://mermaid-js.github.io/mermaid/#/flowchart) (including current state) Flow...
visualizer_mermaid.go
0.643105
0.542924
visualizer_mermaid.go
starcoder
package algorithm import ( "github.com/zhangxianweihebei/gostl/utils/comparator" "github.com/zhangxianweihebei/gostl/utils/iterator" ) // Count returns the number of elements that their value is equal to value in range [first, last) func Count(first, last iterator.ConstIterator, value interface{}, cmps ...comparato...
algorithm/const_op.go
0.766468
0.420719
const_op.go
starcoder
package gfx import ( "image" "image/color" "image/draw" ) // Draw draws src on dst, at the zero point using draw.Src. func Draw(dst draw.Image, r image.Rectangle, src image.Image) { draw.Draw(dst, r, src, ZP, draw.Src) } // DrawColor draws an image.Rectangle of uniform color on dst. func DrawColor(dst draw.Image...
vendor/github.com/peterhellberg/gfx/draw.go
0.790611
0.623406
draw.go
starcoder
package Utilities import ( "fmt" "image/color" "github.com/hajimehoshi/ebiten" "github.com/hajimehoshi/ebiten/vector" "marvin/SnakeProGo/Utilities/Physics" ) type Points []*Physics.Vector func (ps *Points) Fill(screen *ebiten.Image, col color.Color) { var path vector.Path for i,p := range(*ps) { if i == 0 { ...
GoFiles/Utilities/graph.go
0.532911
0.441131
graph.go
starcoder
package packet import ( "github.com/sandertv/gophertunnel/minecraft/protocol" ) const ( BlockToEntityTransition = iota + 1 EntityToBlockTransition ) // UpdateBlockSynced is sent by the server to synchronise the falling of a falling block entity with the // transitioning back and forth from and to a solid block. I...
minecraft/protocol/packet/update_block_synced.go
0.599368
0.441131
update_block_synced.go
starcoder
package vehicle import ( "go-experiments/common/commoncolor" "go-experiments/voxelli/renderer" "go-experiments/voxelli/roadway" "go-experiments/voxelli/voxelArray" "math" "github.com/go-gl/mathgl/mgl32" ) type Vehicle struct { Position mgl32.Vec2 Orientation float32 Velocity float32 // TODO -- make this...
voxelli/vehicle/vehicle.go
0.663778
0.482612
vehicle.go
starcoder
package ast import ( "errors" "fmt" "io" "github.com/creachadair/jtree" ) // A Parser parses and returns JSON values from a reader. type Parser struct { h *parseHandler st *jtree.Stream } // NewParser constructs a parser that consumes input from r. func NewParser(r io.Reader) *Parser { return &Parser{h: ne...
ast/parser.go
0.749912
0.402333
parser.go
starcoder
package model import ( "errors" "fmt" "github.com/pzduniak/unipdf/common" "github.com/pzduniak/unipdf/core" ) // A PdfPattern can represent a Pattern, either a tiling pattern or a shading pattern. // Note that all patterns shall be treated as colours; a Pattern colour space shall be established with the CS or c...
bot/vendor/github.com/pzduniak/unipdf/model/pattern.go
0.812904
0.434641
pattern.go
starcoder
package foundation // #include "byte_count_formatter.h" import "C" import ( "unsafe" "github.com/hsiafan/cocoa/objc" ) type ByteCountFormatter interface { Formatter StringFromMeasurement(measurement Measurement) string FormattingContext() FormattingContext SetFormattingContext(value FormattingContext) CountSt...
foundation/byte_count_formatter.go
0.642432
0.434521
byte_count_formatter.go
starcoder
package algebra import "fmt" var ( // ℂ (as Complex[float64, Real]) is a field. _ Field[[2]float64] = Complex[float64, Real]{} // ℂ is also a 2-dimensional vector space over ℝ. _ VectorSpace[[2]float64, float64] = Complex[float64, Real]{} // ℤ[𝕚] is a ring. _ Ring[[2]int] = GaussianInteger{} // ℤ[𝕚] is also...
algebra/complex.go
0.816736
0.725199
complex.go
starcoder
package hexutils import ( "bytes" "encoding/hex" "io" ) //Ripped of from standard package 'encoding/hex' and improved // Dump returns a string that contains a hex dump of the given data. The format // of the hex dump matches the output of `hexdump -C` on the command line. func Dump(aStartAddr uint, data []byte) s...
dump.go
0.642769
0.445469
dump.go
starcoder
package corner import ( "bytes" "fmt" ) // A Path is a series of Segments to be joined with rounded corners, along with // parallel offsets along each segment. type Path struct { id string class string segments []*Segment offsets []float64 } // NewPath returns a new Path with a given id, class, list ...
corner/path.go
0.702734
0.418994
path.go
starcoder
package main import ( "fmt" "strconv" "strings" ) /* For example, suppose you have the following list: 1-3 a: abcde 1-3 b: Cdefg 2-9 c: ccccccccc Each line gives the password policy and then the password. The password policy indicates the lowest and highest number of times a given letter must appear for the passw...
2020/day2/main.go
0.603815
0.428174
main.go
starcoder
package main // CorrResult stores a correlation result. type CorrResult struct { Lag int Mean float64 Variance float64 N int Type string } // CorrResults stores a list of CorrResult with an gene ID. type CorrResults struct { ID string Results []CorrResult } // Collector collect correl...
cmd/popsimu/collector.go
0.799521
0.496216
collector.go
starcoder
package query import ( "bytes" "fmt" ) // LabelMatcher represents a single label matcher containing the label name (key), // the matching operator and the value. type LabelMatcher struct { // Type of the label matcher. // This information is used internally and is not required to build the prometheus query. // ...
query/label.go
0.805823
0.537527
label.go
starcoder
package lib // cover.go implements an iterator for hypergraph covers, based on Samer and Gottlob 2009, as used in det-k-decomp import ( "log" "sort" ) // Cover is used to quickly iterate over all valid hypergraph covers for a subset of vertices type Cover struct { k int //maximal size of cover ...
lib/cover.go
0.63273
0.452354
cover.go
starcoder
package cryptypes import "database/sql/driver" // EncryptedRune supports encrypting Rune data type EncryptedRune struct { Field Raw rune } // Scan converts the value from the DB into a usable EncryptedRune value func (s *EncryptedRune) Scan(value interface{}) error { return decrypt(value.([]byte), &s.Raw) } // V...
cryptypes/type_rune.go
0.808105
0.560072
type_rune.go
starcoder
package vox const CubeSize = 1.0 type Mesher interface { Generate(chunk *Chunk, bank *BlockBank) *MeshData } // ---------------------------------------------------------------------------- type CulledMesher struct { } func (cm *CulledMesher) Generate(chunk *Chunk, bank *BlockBank) *MeshData { data := &MeshData{...
mesher.go
0.595963
0.575051
mesher.go
starcoder
package matrix import ( "sync" ) type IMatrix interface { Row() int Col() int GetAt(int, int) float64 SetAt(int, int, float64) } type Matrix struct { row int col int mtx []float64 } func New(mtx [][]float64) IMatrix { row := len(mtx) col := len(mtx[0]) for i := 1; i < row; i++ { if len(mtx[i]) != col ...
matrix/float64/matrix.go
0.706899
0.444143
matrix.go
starcoder
// Package convert provides helper functions to convert data between // various types, e.g. []byte to int, etc. package convert import ( "bytes" "encoding/binary" "net" "strings" ) // IPByteSlice converts a string that contians an IP address into byte slice func IPByteSlice(ip string) []byte { ret := net.ParseI...
convert/convert.go
0.730097
0.418637
convert.go
starcoder
package bls12381 type pair struct { g1 *PointG1 g2 *PointG2 } func newPair(g1 *PointG1, g2 *PointG2) pair { return pair{g1, g2} } // Engine is BLS12-381 elliptic curve pairing engine type Engine struct { G1 *G1 G2 *G2 fp12 *fp12 fp2 *fp2 pairingEngineTemp pairs []pair } // NewEngine creates new pairin...
pairing.go
0.624179
0.569134
pairing.go
starcoder
package main import ( "time" "github.com/ederoyd46/osm/osmformat" ) const nano float64 = 1000000000 //CalculateDegrees calcluates the real coordinate from the delta decoded one func CalculateDegrees(coordinate float64, granularity float64) float64 { return (coordinate * granularity) / nano } //CalculateTime cal...
utils.go
0.777427
0.461441
utils.go
starcoder
package httptestutil import ( "encoding/json" "net/http" "net/http/httptest" "regexp" "strings" "testing" ) type Check func(*testing.T) type ResponseAssertion func(*testing.T, *httptest.ResponseRecorder) type RequestModifier func(req *http.Request) type TestConfig struct { name string method stri...
httptestutil.go
0.632276
0.489259
httptestutil.go
starcoder
package vitotrol import ( "errors" "fmt" "strconv" ) // Singletons matching Vitodata™ types. var ( TypeDouble = (*VitodataDouble)(nil) TypeInteger = (*VitodataInteger)(nil) TypeDate = (*VitodataDate)(nil) TypeString = (*VitodataString)(nil) TypeOnOffEnum = NewEnum([]string{ // 0 -> 1 "off", "...
types.go
0.712832
0.420183
types.go
starcoder
package circularbuffer import ( "fmt" "sort" ) type CircularBuffer struct { records []float64 sortedRecords []float64 minSize int maxSize int index int enoughData bool } // New creates a new buffer and returns the reference. // minSize defines the minimum number of elements until...
circular_buffer.go
0.814938
0.418994
circular_buffer.go
starcoder
package worldfile import ( "bufio" "image" "io" "math" "os" "strconv" "strings" ) //WorldFile allows converting between pixels and map coordinates. //It is not dependent of a specific SRS. type WorldFile struct { A float64 //pixel size in the x-direction in map units/pixel D float64 //rotation about y-axis ...
worldfile.go
0.719482
0.542621
worldfile.go
starcoder
package op import ( . "github.com/coschain/contentos-go/dandelion" "github.com/stretchr/testify/assert" "math" "strings" "testing" ) type TransferTester struct { acc0, acc1, acc2 *DandelionAccount } func (tester *TransferTester) Test(t *testing.T, d *Dandelion) { tester.acc0 = d.Account("actor0") tester.acc1...
tests/op/transfer.go
0.532182
0.461745
transfer.go
starcoder
package main import "fmt" // GraphNode is a node in a graph list type GraphNode struct { name string value float64 } // graph is a data structure which will be holding a graph type graph map[string][]GraphNode // addVertexToGraph adds a vertex to graph func (g graph) addVertexToGraph(vtx string) { if g[vtx] != ...
algorithms/graphs/prims/graph.go
0.562177
0.426919
graph.go
starcoder
package expr import ( "fmt" "math" "time" "github.com/getlantern/goexpr" ) // AVG creates an Expr that obtains its value as the arithmetic mean over the // given value. func AVG(val interface{}) Expr { return WAVG(val, CONST(1)) } // WAVG creates an Expr that obtains its value as the weighted arithmetic mean /...
expr/avg.go
0.745954
0.42477
avg.go
starcoder
package warmup1 import ( "math" "strings" ) /* The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return True if we sleep in. */ func sleep_in(weekday, vacation bool) bool { if vacation { return t...
Go/CodingBat/warmup-1.go
0.61659
0.530236
warmup-1.go
starcoder
package lit import ( "strconv" "github.com/mb0/xelf/bfr" "github.com/mb0/xelf/cor" "github.com/mb0/xelf/typ" ) type ( Num float64 Bool bool Int int64 Real float64 ) func (v Num) Typ() typ.Type { return typ.Num } func (v Bool) Typ() typ.Type { return typ.Bool } func (v Int) Typ() typ.Type { return typ.In...
lit/lit_num.go
0.622
0.513607
lit_num.go
starcoder
package field import ( "fmt" "image/color" _ "image/jpeg" _ "image/png" "github.com/faiface/pixel" "github.com/faiface/pixel/imdraw" "github.com/faiface/pixel/pixelgl" "github.com/faiface/pixel/text" "golang.org/x/image/font/basicfont" ) //rectangles to make the football field 5 yard lines type footballFie...
field/field.go
0.553023
0.434581
field.go
starcoder
package psort import ( "reflect" "sort" "sync" "github.com/grailbio/base/traverse" ) const ( serialThreshold = 128 ) // Slice sorts the given slice according to the ordering induced by the provided // less function. Parallel computation will be attempted, up to the limit imposed by // parallelism. This functio...
psort/mergesort.go
0.597373
0.424293
mergesort.go
starcoder
package sat // A Literal is represented by an identifier (int) and a truth value (bool). type Literal struct { Ident int Truth bool } // A Clause is a disjunction of Literals. In conjunctive normal form (CNF), // the structure implies that the literals are OR'ed together, like (a ∨ b ∨ ¬c). type Clause []Literal /...
cnf.go
0.578329
0.503418
cnf.go
starcoder
package jbtracer import ( "fmt" ) type Intersection struct { Object Shape T float64 } type IntersectionSlice []*Intersection type PreparedComputations struct { T float64 Object Shape Point *Tuple EyeV *Tuple NormalV *Tuple Inside bool OverPoint *Tuple ReflectV *Tupl...
intersections.go
0.677901
0.496765
intersections.go
starcoder
package go_fourier import ( "errors" "math" "math/bits" ) // DFT2Radix1D computes the discrete fourier transform of the given array in the complex number space. // The calculation is done in place using Cooley-Tukey radix-2 algorithm. // The result is stored in the given array. // Assumes the length of the array i...
dft.go
0.801392
0.764342
dft.go
starcoder
package poner import ( "fmt" "sort" ) // Score represents a single cribbage score type Score struct { Name string Value int Pairing Hand } func (score Score) String() string { return fmt.Sprintf("%v for %v %v", score.Name, score.Value, score.Pairing) } // AddPairing adds a pairing to the score func (scor...
scoring.go
0.731251
0.488161
scoring.go
starcoder
package main import ( "fmt" "math" ) func main() { interpolate(0, float64(0), float64(1), 4, int(math.Pow(10, 6))) interpolate(0, float64(0), float64(1), 10, int(math.Pow(10, 6))) interpolate(1, float64(0), float64(1), 4, int(math.Pow(10, 6))) interpolate(1, float64(0), float64(1), 10, int(math.Pow(10, 6))) } ...
interpolate/interpolate.go
0.582016
0.456046
interpolate.go
starcoder
// Package cases contains functions for Maping strings between various // cases (snake, pascal, etc). package cases import ( "bytes" "strings" "unicode" ) // Words are a list of strings. type Words []string // Snake separates and returns the words in s by underscore. func Snake(s string) Words { if s == "" { ...
core/text/cases/cases.go
0.712032
0.53607
cases.go
starcoder
package functions import ( "math" ) var FuncMinInt = Function{ Description: "Will pick the smallest int of the <left> and <right>.", Parameters: Parameters{{ Name: "left", }, { Name: "right", }}, }.MustWithFunc(minInt) var FuncMinInt64 = Function{ Description: "Will pick the smallest int64 of the <left> an...
template/functions/math.go
0.661704
0.519948
math.go
starcoder
package game import ( "errors" "fmt" "strconv" "strings" "github.com/squee1945/threespot/server/pkg/deck" ) // Trick is an in-progress trick of up to 4 cards, one card from each player. type Trick interface { // IsDone returns true if the trick is complete (4 cards played). IsDone() bool // playCard adds a ...
server/pkg/game/trick.go
0.67104
0.512754
trick.go
starcoder
package compare import ( "bytes" xbytes "github.com/xichen2020/eventdb/x/bytes" ) // BoolCompareFn compares two boolean values. type BoolCompareFn func(v1, v2 bool) int // IntCompareFn compares two int values. type IntCompareFn func(v1, v2 int) int // DoubleCompareFn compares two double values. type DoubleCompar...
x/compare/compare.go
0.764364
0.477493
compare.go
starcoder
package decimal import ( "encoding/json" "math" "math/big" ) // Decimal - number with arbitrary decimal precision // defined to work exactly like the decimal type in .NET type Decimal struct { lo uint32 mid uint32 hi uint32 flags uint32 } // FromBool - creates a decimal from a boolean value ...
decimal/decimal.go
0.832169
0.46642
decimal.go
starcoder
package sampler import ( "github.com/mattkimber/gorender/internal/geometry" "image" "image/color" "image/draw" "math/rand" ) type Sample []geometry.Vector2 type Samples [][]Sample func (s Samples) Width() int { return len(s) } func (s Samples) Height() int { return len(s[0]) } func (s Samples) GetImage() (...
internal/sampler/sampler.go
0.767516
0.526586
sampler.go
starcoder
// +build example package sim import ( "fmt" "math" ) type ( Shape interface { Position() (x, y int32) SetPosition(x, y int32) // Size returns the dimensions of the smallest rectangle that will encompass the entirety of the Shape, where // Position is the top left corner Size() (w, h int32) // Center...
examples/tcell-pick-and-place/sim/shape.go
0.812459
0.735737
shape.go
starcoder
package channel import ( "encoding/json" "fmt" "log" "math" "math/rand" "strconv" "time" "github.com/Hucaru/Valhalla/common/opcode" "github.com/Hucaru/Valhalla/mnet" "github.com/Hucaru/Valhalla/mpacket" "github.com/Hucaru/Valhalla/nx" ) type foothold struct { id int16 x1, y1, x2, y2 int1...
channel/field.go
0.648466
0.515254
field.go
starcoder
package model import "io" import . "aicup2019/stream" type Properties struct { MaxTickCount int32 TeamSize int32 TicksPerSecond float64 UpdatesPerTick int32 LootBoxSize Vec2Float64 UnitSize Vec2Float64 UnitMaxHorizontalSpeed float64 UnitFallSpeed float64 UnitJumpTime float64 Un...
srcOriginal/go/model/properties.go
0.696062
0.575349
properties.go
starcoder
package ibs //Charge contains slice of propellants and is designed to manage them type Charge struct { Propellant []Propellant } func (c *Charge) state(s *State) { s.Tmean, s.Pmean = c.thermodynamics(s.Volume, s.EnergyLoss) s.HeatCapacity = c.heatCapacity() s.GasMass = c.gasMass() } func (c *Charge) heatFlux(Vol...
ibs/Charge.go
0.784897
0.5047
Charge.go
starcoder
// Package ecvrf is the Elliptic Curve Verifiable Random Function (VRF) library. package ecvrf import ( "crypto/ecdsa" "crypto/elliptic" "crypto/sha256" "errors" "math/big" ) // VRF is the interface that wraps VRF methods. type VRF interface { // Prove constructs a VRF proof `pi` for the given input `alpha`, ...
vrf.go
0.805364
0.468608
vrf.go
starcoder
package main import ( "fmt" "image/color" "math/rand" "time" "github.com/veandco/go-sdl2/sdl" ) /* Material * Some of these parameters are hard to explain in one or two sentences * (and a couple I made up) so I'll also link you to their corresponding * Wikipedia pages. One object I like to compare fluids wit...
liquid/Liquid.go
0.63114
0.558929
Liquid.go
starcoder
package talib import ( "sync" "sync/atomic" "time" "github.com/shopspring/decimal" ) type TimeSeries struct { data map[uint64]Bar period uint64 latest uint64 capacity uint64 threshold uint64 indicators sync.Map mu sync.RWMutex isCleaning uint32 } func NewSeries(period time.Durat...
time_series.go
0.61832
0.44348
time_series.go
starcoder
package dataframe import ( "fmt" "log" "github.com/ptiger10/pd/internal/values" "github.com/ptiger10/pd/options" "github.com/ptiger10/pd/series" ) // Row returns information about the values and index labels in this row but panics if an out-of-range position is provided. func (df *DataFrame) Row(position int) R...
dataframe/select.go
0.702428
0.409693
select.go
starcoder
package fixture import ( "encoding/json" "io/ioutil" "net/http" "strings" "time" "github.com/newrelic/infrastructure-agent/pkg/backend/inventoryapi" "github.com/newrelic/infrastructure-agent/pkg/config" "github.com/stretchr/testify/assert" ) type Any string type ContainsString string type Nil string const (...
test/fixture/inventory/assert.go
0.631708
0.50415
assert.go
starcoder
package sqle import ( "github.com/dolthub/dolt/go/libraries/doltcore/sqle/index" "github.com/dolthub/go-mysql-server/sql" ) // IndexedDoltTable is a wrapper for a DoltTable and a doltIndexLookup. It implements the sql.Table interface like // DoltTable, but its RowIter function returns values that match the indexL...
go/libraries/doltcore/sqle/indexed_dolt_table.go
0.532668
0.483466
indexed_dolt_table.go
starcoder
package farm // This file provides a 32-bit hash equivalent to CityHash32 (v1.1.1) // and a 128-bit hash equivalent to CityHash128 (v1.1.1). It also provides // a seeded 32-bit hash function similar to CityHash32. func hash32Len13to24Seed(s []byte, seed uint32) uint32 { slen := len(s) a := fetch32(s, -4+(slen>>1))...
sessions/sessiondb/badger/vendor/github.com/dgraph-io/badger/vendor/github.com/dgryski/go-farm/farmhashcc.go
0.66888
0.509825
farmhashcc.go
starcoder
package differ import ( "fmt" "sort" "github.com/turbinelabs/api" "github.com/turbinelabs/rotor/xds/poller" ) // standaloneDiffer produces always produces Create diffs, and the Patch call // takes those create diffs and creates a simple poller.Objects serving "/" // on a specified port for each cluster, with the...
differ/standalone.go
0.560493
0.44553
standalone.go
starcoder
package filter import ( "math" "strconv" "github.com/zimmski/tavor/token" "github.com/zimmski/tavor/token/lists" "github.com/zimmski/tavor/token/primitives" ) // PositiveBoundaryValueAnalysisFilter implements a fuzzing filter for positive boundary-value analysis. // This filter searches the token graph for rang...
fuzz/filter/positiveboundaryvalueanalysis.go
0.833358
0.507995
positiveboundaryvalueanalysis.go
starcoder