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 period import ( "sort" "time" cabiriaTime "github.com/liampulles/cabiria/pkg/time" ) // Periods is a slice of Period. It can itself be considered a Period (and we // implement Period for Periods)... see below. type Periods []Period // Valid is true for Periods when there is at least one element, and all...
pkg/time/period/periods.go
0.747063
0.465752
periods.go
starcoder
package processing import ( "image" "log" "math" "sync" "github.com/alevinval/fingerprints/internal/helpers" "github.com/alevinval/fingerprints/internal/matrix" "github.com/alevinval/fingerprints/internal/types" ) const ( black = 0 white = 255 ) // BinarizeSegmented runs binarization with an optimized thre...
internal/processing/binarize.go
0.580709
0.526282
binarize.go
starcoder
package gohorizon import ( "encoding/json" ) // NetworkLabelData Information related to a network label. type NetworkLabelData struct { // The network label name. NetworkLabelName *string `json:"network_label_name,omitempty"` // The network interface name NicName *string `json:"nic_name,omitempty"` } // NewNet...
model_network_label_data.go
0.727685
0.435721
model_network_label_data.go
starcoder
package period import ( "time" cabiriaTime "github.com/liampulles/cabiria/pkg/time" ) // TimeFunction must return a time value for a given Period. // Generally, this will be Period.Start or Period.End. type TimeFunction func(Period) time.Time // DoesOverlap returns true if a and b overlap, otherwise false. // a...
pkg/time/period/common.go
0.883211
0.492127
common.go
starcoder
package expectations import ( "strings" "dawn.googlesource.com/dawn/tools/src/cts/result" ) const ( tagHeaderStart = `BEGIN TAG HEADER` tagHeaderEnd = `END TAG HEADER` ) // Parse parses an expectations file, returning the Content func Parse(body string) (Content, error) { // LineType is an enumerator classi...
tools/src/cts/expectations/parse.go
0.604516
0.415195
parse.go
starcoder
package bfv import ( "errors" "github.com/ldsec/lattigo/ring" ) type Operand interface { Element() *bfvElement Degree() uint64 } // bfvElement is a common struct between plaintexts and ciphertexts. It stores a value // as a slice of polynomials, and an isNTT flag indicatig if the element is in the NTT domain. ty...
bfv/operand.go
0.768212
0.413773
operand.go
starcoder
package value import ( "math/big" ) func sinh(c Context, v Value) Value { if u, ok := v.(Complex); ok { if !isZero(u.imag) { return complexSinh(c, u) } v = u.real } return evalFloatFunc(c, v, floatSinh) } func cosh(c Context, v Value) Value { if u, ok := v.(Complex); ok { if !isZero(u.imag) { ret...
value/sinh.go
0.742141
0.427815
sinh.go
starcoder
package chpp // MatchRating ... type MatchRating uint // List of MatchRating constants. const ( MatchRatingVeryLowDisastrous MatchRating = 1 MatchRatingLowDisastrous MatchRating = 2 MatchRatingHighDisastrous MatchRating = 3 MatchRatingVeryHighDisastrous MatchRating = 4 MatchRati...
chpp/type_match_rating.go
0.665628
0.407569
type_match_rating.go
starcoder
package md import ( "os" "strings" "text/template" "github.com/mh-cbon/testndoc" ) // Export the documentation to MD format. func Export(recorded testndoc.APIDoc, dest string) error { os.Remove(dest) f, err2 := os.OpenFile(dest, os.O_RDWR|os.O_CREATE, 0755) if err2 != nil { return err2 } defer f.Close() ...
md/exporter.go
0.543833
0.423041
exporter.go
starcoder
package vast const ( /** * not to be confused with an impression, this event indicates that an individual creative * portion of the ad was viewed. An impression indicates the first frame of the ad was displayed; however * an ad may be composed of multiple creative, or creative that only play on some platforms a...
event_type.go
0.504883
0.448789
event_type.go
starcoder
package doubly import "fmt" type LinkedList[T any] struct { header *Node[T] // header is a sentinel node. header.Next is the first element in the list. trailer *Node[T] // trailer is a sentinel node. trailer.Prev is the last element in the list. Size int } // New constructs and returns an empty doubly linked ...
linkedlist/doubly/doubly_linked_list.go
0.830732
0.521654
doubly_linked_list.go
starcoder
package cpu import ( "encoding/binary" "fmt" ) // Opcode represents a single CHIP-8 operation. type Opcode uint16 // Bytes splits the opcode into its respective bytes and returns them. func (o Opcode) Bytes() (firstByte, secondByte byte) { return byte(o >> 8), byte(o) } // OpcodeFromBytes takes in a slice of byt...
go/internal/cpu/opcode.go
0.601125
0.427217
opcode.go
starcoder
package grid import "errors" var deltaMap map[string]delta func NewGrid(rows int, cols int) *Grid { deltaMap = map[string]delta{ "tl": {-1, -1}, "tc": {-1, 0}, "tr": {-1, 1}, "l": {0, -1}, "r": {0, 1}, "bl": {1, -1}, "bc": {1, 0}, "br": {1, 1}, } grid := &Grid{ grid: make([][]GridCell, rows),...
src/grid/grid.go
0.807385
0.758332
grid.go
starcoder
package config // InputFixture corresponds with the data structure of unmarshalled config values. // It shouldn't be used directly and instead marshalled via it's parse method. type InputFixture struct { DockerCompose *struct { Output string `yaml:"output"` } `yaml:"docker-compose"` Imports interface{} `yaml:"i...
config.v1/config.go
0.604516
0.42185
config.go
starcoder
package container import ( "fmt" "math" ) // DenseArray is an array in in which elements are packed with a width of // b < 64 bits. It allows for space-efficient storage when integers have // well-knownvalue ranges that don't correspond to exactly 64, 32, 16, or 8 // bits. type DenseArray struct { Length int Bits...
container/dense_array.go
0.621426
0.453685
dense_array.go
starcoder
package dtoa import ( "math" ) type DiyFp struct { f uint64 e int } func DiyFpDouble(d float64) DiyFp { //u64 := *(*uint64)(unsafe.Pointer(&d)) u64 := math.Float64bits(d) biased_e := int((u64 & kDpExponentMask) >> uint64(kDpSignificandSize)) significand := (u64 & kDpSignificandMask) if biased_e != 0 { ret...
diyfp.go
0.547464
0.449151
diyfp.go
starcoder
package cryptypes import "database/sql/driver" // EncryptedUint64 supports encrypting Uint64 data type EncryptedUint64 struct { Field Raw uint64 } // Scan converts the value from the DB into a usable EncryptedUint64 value func (s *EncryptedUint64) Scan(value interface{}) error { return decrypt(value.([]byte), &s....
cryptypes/type_uint64.go
0.806662
0.571587
type_uint64.go
starcoder
Rate limiting is an important mechanism for controlling resource utilisation and maintaining quality of service. Go elegantly supports rate limiting with goroutines, channnels and tickers */ package main import ( "fmt" "time" ) func main() { // NOTE: First, we'll look at basic rate limiting. // NOTE: Suppose we ...
036-ratelimiting.go
0.540681
0.585812
036-ratelimiting.go
starcoder
package singly import ( "fmt" ) type LinkedList[T any] struct { Head *Node[T] Tail *Node[T] Size int } // New constructs and returns an empty singlt linked list. func New[T any]() *LinkedList[T] { return &LinkedList[T]{} } // IsEmpty returns true if the linked list doesn't have any nodes. func (s *LinkedList[T...
linkedlist/singly/singly_linked_list.go
0.79732
0.436022
singly_linked_list.go
starcoder
package gateway import "strconv" // ConvertStringToFloat64 converts string to float64. func ConvertStringToFloat64(s string) (float64, error) { return strconv.ParseFloat(s, 64) } // ConvertStringToFloat32 converts string to float32. func ConvertStringToFloat32(s string) (float32, error) { v, err := strconv.ParseFl...
gateway/convert.go
0.766031
0.442637
convert.go
starcoder
package hamming import "strconv" // References: check out Hacker's Delight, about p. 70 var table = [256]uint8{ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2...
vendor/github.com/steakknife/hamming/popcount.go
0.525612
0.681208
popcount.go
starcoder
package cherry_pickup import "math" /* 741. 摘樱桃 https://leetcode-cn.com/problems/cherry-pickup 一个N x N的网格(grid) 代表了一块樱桃地,每个格子由以下三种数字的一种来表示: 0 表示这个格子是空的,所以你可以穿过它。 1 表示这个格子里装着一个樱桃,你可以摘到樱桃然后穿过它。 -1 表示这个格子里有荆棘,挡着你的路。 你的任务是在遵守下列规则的情况下,尽可能的摘到最多樱桃: 从位置 (0, 0) 出发,最后到达 (N-1, N-1) ,只能向下或向右走,并且只能穿越有效的格子(即只可以穿过值为0或者1的格子); 当到达 ...
solutions/cherry-pickup/d.go
0.518546
0.509459
d.go
starcoder
package binarytree // TreeNode 二叉树结点 type TreeNode struct { Value int Height int Left *TreeNode Right *TreeNode } // PreOrder 前序遍历 DFS func (root *TreeNode) PreOrder() []int { var ( stack []*TreeNode order []int ) if root == nil { return order } for stack = append(stack, root); len(stack) != 0; {...
tree/binarytree/binarytree.go
0.524882
0.420719
binarytree.go
starcoder
package tfgo import ( tf "github.com/tensorflow/tensorflow/tensorflow/go" "github.com/tensorflow/tensorflow/tensorflow/go/op" ) // Batchify creates a batch of tensors, concatenating them along the first dimension func Batchify(scope *op.Scope, tensors []tf.Output) tf.Output { s := scope.SubScope("batchify") // Ba...
ops.go
0.879871
0.490785
ops.go
starcoder
package bindings import "log" // Mapping is a stack of map[string]string for CMake variables. type Mapping struct { vs []map[string]string cache map[string]string } // New returns a new, empty, variable stack. func New() *Mapping { m := &Mapping{cache: make(map[string]string)} m.Push() return m } // Push pu...
cmakelib/bindings/bindings.go
0.770594
0.416203
bindings.go
starcoder
package analyzers import ( summarypb "github.com/GoogleCloudPlatform/testgrid/pb/summary" "github.com/GoogleCloudPlatform/testgrid/pkg/summarizer/common" ) const analyzerName = "flipanalyzer" // FlipAnalyzer implements functions that calculate flakiness as a ratio of failed tests to total tests type FlipAnalyzer s...
pkg/summarizer/analyzers/flipanalyzer.go
0.708717
0.416737
flipanalyzer.go
starcoder
package expect import ( "fmt" "reflect" "regexp" "testing" ) // Negation is a negated expectation type Negation struct { *testing.T inverse *ExpectedValue } // To returns the current Expectation func (not *Negation) To() Expectation { return not } // Be returns the current Expectation func (not *Negation) B...
expect/negation.go
0.842151
0.496155
negation.go
starcoder
package treemap // template type TreeMap(Key, Value) // Key is a generic key type of the map type Key interface{} // Value is a generic value type of the map type Value interface{} // TreeMap is the red-black tree based map type TreeMap struct { endNode *node beginNode *node count int // Less returns a < ...
treemap/treemap.go
0.869853
0.553626
treemap.go
starcoder
package big import ( "math/big" "github.com/ALTree/bigfloat" ) // Matrix is a matrix type Matrix struct { Prec uint Values [][]Rational } // NewMatrix make a new matrix func NewMatrix(prec uint) Matrix { return Matrix{ Prec: prec, } } // Add adds two matricies func (m *Matrix) Add(a, b *Matrix) *Matrix ...
complex.go
0.748444
0.653652
complex.go
starcoder
package sk import "github.com/ContextLogic/cldr" var calendar = cldr.Calendar{ Formats: cldr.CalendarFormats{ Date: cldr.CalendarDateFormat{Full: "EEEE, d. MMMM y", Long: "d. MMMM y", Medium: "d. M. y", Short: "dd.MM.yy"}, Time: cldr.CalendarDateFormat{Full: "H:mm:ss zzzz", Long: "H:mm:ss z", Medium: "H:...
resources/locales/sk/calendar.go
0.50415
0.42674
calendar.go
starcoder
package femto import ( "time" dmp "github.com/sergi/go-diff/diffmatchpatch" ) const ( // Opposite and undoing events must have opposite values // TextEventInsert represents an insertion event TextEventInsert = 1 // TextEventRemove represents a deletion event TextEventRemove = -1 // TextEventReplace represen...
femto/eventhandler.go
0.601945
0.403508
eventhandler.go
starcoder
package report import ( "github.com/vitessio/arewefastyet/go/storage" "strconv" "strings" "github.com/vitessio/arewefastyet/go/storage/influxdb" "github.com/vitessio/arewefastyet/go/tools/microbench" "github.com/jung-kurt/gofpdf" "github.com/vitessio/arewefastyet/go/tools/git" "github.com/vitessio/arewefast...
go/tools/report/compare_report.go
0.609873
0.416203
compare_report.go
starcoder
package molecule import ( "errors" "regexp" "sort" "strconv" "github.com/524D/galms/elements" ) // This package parses chemical formula // AtomsCount contains an atom index and atom count type AtomsCount struct { idx int // Element index count int // Number of atoms of this element } // Molecule represen...
molecule/molecule.go
0.759939
0.619788
molecule.go
starcoder
package util // Traversal defines a basic interface to perform traversals. type Traversal interface { // Edges should return the neighbours of node "u". Edges(u T) []T // Visited should return true if node "u" has already been visited in this // traversal. If the same traversal is used multiple times, the state...
vendor/github.com/open-policy-agent/opa/util/graph.go
0.813942
0.446193
graph.go
starcoder
package cache import "math" // bloomFilter is Bloom Filter implementation used as a cache admission policy. // See http://billmill.org/bloomfilter-tutorial/ type bloomFilter struct { numHashes uint32 // number of hashes per element bitsMask uint32 // size of bit vector bits []uint64 // filter bit vector ...
filter.go
0.800731
0.544983
filter.go
starcoder
package onshape import ( "encoding/json" ) // BTPStatementIf276 struct for BTPStatementIf276 type BTPStatementIf276 struct { BTPStatement269 BtType *string `json:"btType,omitempty"` Condition *BTPExpression9 `json:"condition,omitempty"` ElseBody *BTPStatement269 `json:"elseBody,omitempty"` SpaceAfterIf *BTPSpac...
onshape/model_btp_statement_if_276.go
0.670716
0.408513
model_btp_statement_if_276.go
starcoder
package comptop // NewSimplex adds a Simplex to c. // All lower dimensional faces of the new Simplex are computed and automatically added to c. func (c *Complex) NewSimplex(base ...Index) *Simplex { if c.chainGroups == nil { c.chainGroups = ChainGroups{} } dim := Dim(len(base)) - 1 if dim > c.dim { c.dim = d...
newSimplex.go
0.829561
0.636946
newSimplex.go
starcoder
package onshape import ( "encoding/json" ) // BTEditingLogic2350 struct for BTEditingLogic2350 type BTEditingLogic2350 struct { FunctionName *string `json:"functionName,omitempty"` WantsHiddenBodies *bool `json:"wantsHiddenBodies,omitempty"` WantsIsCreating *bool `json:"wantsIsCreating,omitempty"` WantsSpecified...
onshape/model_bt_editing_logic_2350.go
0.725551
0.438485
model_bt_editing_logic_2350.go
starcoder
package main import ( "log" "time" "github.com/fogleman/gg" "github.com/rosshemsley/kalman" "github.com/rosshemsley/kalman/models" "gonum.org/v1/gonum/mat" ) const W = 600 const H = 600 type Observation struct { Time time.Time Point mat.Vector } func NewObservation(secondsOffset float64, x, y float64) Obse...
examples/trajectory-example/main.go
0.650134
0.618924
main.go
starcoder
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Semi-exhaustive test for append() package main import ( "fmt" "reflect" ) func verify(name string, result, expected interface{}) { if !reflect.DeepEq...
test/append.go
0.556882
0.449755
append.go
starcoder
package docs import ( "bytes" "fmt" "reflect" "strings" "text/template" "github.com/Jeffail/benthos/v3/lib/util/config" "github.com/Jeffail/gabs/v2" "gopkg.in/yaml.v3" ) // ComponentSpec describes a Benthos component. type ComponentSpec struct { // Name of the component Name string // Type of the compone...
lib/x/docs/component.go
0.646572
0.577495
component.go
starcoder
package archs import ( "github.com/skyhookml/skyhookml/skyhook" "github.com/skyhookml/skyhookml/exec_ops" ) func init() { type TrainParams struct { skyhook.PytorchTrainParams Resize skyhook.PDDImageOptions NumClasses int ValPercent int } type InferParams struct { Resize skyhook.PDDImageOptions } ty...
exec_ops/pytorch/archs/unet.go
0.547706
0.437523
unet.go
starcoder
package geo import ( "math" "github.com/dadadamarine/orb" ) // Distance returns the distance between two points on the earth. func Distance(p1, p2 orb.Point) float64 { dLat := deg2rad(p1[1] - p2[1]) dLon := deg2rad(p1[0] - p2[0]) dLon = math.Abs(dLon) if dLon > math.Pi { dLon = 2*math.Pi - dLon } // fast...
geo/distance.go
0.889882
0.767102
distance.go
starcoder
package iso20022 // Provides the details of each individual un // secured market transaction. type UnsecuredMarketTransaction3 struct { // Defines the status of the reported transaction, that is details on whether the transaction is a new transaction, an amendment of a previously reported transaction, a cancellati...
UnsecuredMarketTransaction3.go
0.826817
0.64058
UnsecuredMarketTransaction3.go
starcoder
package comparator // Comparator Should return a number: // -1 , if a < b // 0 , if a == b // 1 , if a > b type Comparator func(a, b interface{}) int // BuiltinTypeComparator compare a with b // -1 , if a < b // 0 , if a == b // 1 , if a > b // make sure a and b are both builtin type func Builti...
utils/comparator/comparator.go
0.651244
0.416144
comparator.go
starcoder
package main // Structs // States holds time and a list of states(not sure if this is important or not) type States struct { Time int `json:"time"` States []State `json:"states"` } // State is a struct witch stores states of data type State struct { Icao24 string `json:"Icao24"` // Unique ICAO...
data.go
0.662141
0.646209
data.go
starcoder
package simplebuffer // This file contains a buffer for use in testing, walker, and uploader. // Some interface functions are only briefly implemented with a dummy return value. import ( "fmt" "github.com/aristanetworks/quantumfs" "github.com/aristanetworks/quantumfs/encoding" "github.com/aristanetworks/quantum...
utils/simplebuffer/simplebuffer.go
0.774413
0.413714
simplebuffer.go
starcoder
package main import ( "cbdeep/data" "errors" "fmt" "math/rand" ) type dataExample struct { } func (t dataExample) GetSchedule() string { return "manual" } func (t dataExample) GetGroup() string { return "examples" } func (t dataExample) GetName() string { return "data" } func (t dataExample) Run() error { ...
examples/data.go
0.643553
0.498596
data.go
starcoder
package main import ( "fmt" "strings" "github.com/rolfschmidt/advent-of-code-2021/helper" ) func main() { fmt.Println("Part 1", Part1()) fmt.Println("Part 2", Part2()) } func Part1() int { return Run(false) } func Part2() int { return Run(true) } func AddPoint(matrix map[int]map[int]boo...
day13/main.go
0.600657
0.460228
main.go
starcoder
package data import ( "github.com/grafana/grafana-plugin-sdk-go/data" "time" ) // Table is a convenience structure to create tables to response to SimpleJSON Table Queries type Table struct { Frame *data.Frame } // Column is used by New to specify the columns to create type Column struct { // Name of the column...
data/table.go
0.697918
0.521106
table.go
starcoder
package saes import ( "github.com/OpenWhiteBox/primitives/matrix" "github.com/OpenWhiteBox/primitives/number" ) // Powers of x mod M(x). var powx = [16]byte{0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f} type Construction struct { // A 16-byte AES key. Key []byte ...
constructions/saes/saes.go
0.604165
0.445107
saes.go
starcoder
package modules import ( "github.com/bbuck/dragon-mud/logger" "github.com/bbuck/dragon-mud/scripting/lua" "github.com/bbuck/dragon-mud/text/tmpl" ) // Tmpl is the templating module accessible in scripts. This module consists of // two accessible methods: // register(name, body) // @param name: string = the n...
scripting/modules/tmpl.go
0.505859
0.404155
tmpl.go
starcoder
package mathh // Min2Uint returns minimum of two passed uint. func Min2Uint(a, b uint) uint { if a <= b { return a } return b } // Max2Uint returns maximum of two passed uint. func Max2Uint(a, b uint) uint { if a >= b { return a } return b } // Min2Uint8 returns minimum of two passed uint8. func Min2Uint8...
back/vendor/github.com/apaxa-go/helper/mathh/minmax-gen.go
0.853776
0.453988
minmax-gen.go
starcoder
package nanovgo4 import ( "math" ) // The following functions can be used to make calculations on 2x3 transformation matrices. // TransformMatrix is a 2x3 matrix is represented as float[6]. type TransformMatrix [6]float32 // IdentityMatrix makes the transform to identity matrix. func IdentityMatrix() TransformMatr...
transform.go
0.892463
0.914023
transform.go
starcoder
package wordvector import ( "math" "os" "github.com/7phs/fastgotext/vector" "github.com/7phs/fastgotext/wrapper/array" "github.com/7phs/fastgotext/wrapper/emd" ) var ( mfPool = array.NewFloatMatrixPool() ) type WordVectorDictionary interface { Find(string) int } type WordVectorModel interface { GetDictiona...
wordvector/wordvector.go
0.514888
0.452899
wordvector.go
starcoder
package cpu import ( "github.com/robherley/go-gameboy/internal/bits" "github.com/robherley/go-gameboy/pkg/cartridge" errs "github.com/robherley/go-gameboy/pkg/errors" ) // https://gbdev.io/pandocs/CPU_Registers_and_Flags.html#registers type Registers struct { A byte F byte B byte C byte D byte E byte H byt...
pkg/cpu/registers.go
0.618435
0.417509
registers.go
starcoder
// Package ads implements controlling the A/D and reading sampled values for the ADS1115 A/D Converter package ads import ( "github.com/sconklin/go-i2c" ) // SensorType identify which Bosch Sensortec // temperature and pressure sensor is used. // BMP180 and BMP280 are supported. type SensorType int // Implement St...
ads.go
0.76454
0.436682
ads.go
starcoder
package types import "fmt" // CanAssign checks if right can be assigned to left // and whether cast is needed. func CanAssign(left, right T) (canAssign bool, needCast bool) { if c, ok := right.(*Const); ok { if _, ok := c.Type.(Number); ok { ret := InRange(c.Value.(int64), left) return ret, ret } right =...
pl/types/same.go
0.674694
0.41739
same.go
starcoder
package log import ( "sort" "github.com/prometheus/prometheus/pkg/labels" ) var ( emptyLabelsResult = NewLabelsResult(labels.Labels{}, labels.Labels{}.Hash()) ) // LabelsResult is a computed labels result that contains the labels set with associated string and hash. // The is mainly used for caching and returnin...
pkg/logql/log/labels.go
0.794624
0.407392
labels.go
starcoder
package main import ( "bytes" "fmt" "io" "strings" "text/template" ) // This file contains the templates for the code generation // These are the template for each table // CreateQbModel creates the models template func CreateQbModel(m Model, wr io.Writer) { temp := template.Must(template.New(`qb-model`). F...
template.go
0.511229
0.535766
template.go
starcoder
package p384 import ( "fmt" "math/big" ) // affinePoint represents an affine point of the curve. The point at // infinity is (0,0) leveraging that it is not an affine point. type affinePoint struct{ x, y fp384 } func (ap affinePoint) String() string { return fmt.Sprintf("x: %v\ny: %v", ap.x, ap.y) } func newAff...
ecc/p384/point.go
0.713432
0.482246
point.go
starcoder
package giso import ( "math" "sort" ) type Shape struct { paths []*Path } func NewShape(paths []*Path) *Shape { res := &Shape{paths: paths} if res.paths == nil { res.paths = make([]*Path, 0) } return res } // Push append a path at the end of the shape. func (sh *Shape) Push(pat *Path) *Shape { sh.paths = ...
shape.go
0.792785
0.499817
shape.go
starcoder
package schelpers import ( "fmt" scapiv1alpha2 "github.com/operator-framework/operator-sdk/pkg/apis/scorecard/v1alpha2" ) // TestSuitesToScorecardOutput takes an array of test suites and // generates a v1alpha2 ScorecardOutput object with the provided suites and log func TestSuitesToScorecardOutput(suites []TestS...
internal/scorecard/helpers/helpers.go
0.626353
0.423279
helpers.go
starcoder
package channel import ( "math" ) /* Binary Input Stationary Memoryless Channel input is {0, 1}, and output is Log likelihood ratio (ln(W(y|0)/W(y|1)), y is channel output). */ type BinaryMemorylessChannel interface { Channel([]int) []float64 /* Evaluate error probability via density evolution length is code l...
pkg/channel/binary_memoryless_channel.go
0.569134
0.439627
binary_memoryless_channel.go
starcoder
package interval import ( "net/http" "time" "github.com/zalando/skipper/predicates" "github.com/zalando/skipper/routing" ) type spec int const ( between spec = iota before after ) const rfc3339nz = "2006-01-02T15:04:05" // RFC3339 without numeric timezone offset type predicate struct { typ spec begin...
predicates/interval/interval.go
0.6137
0.407333
interval.go
starcoder
package packets // The lap data packet gives details of all the cars in the session. // Frequency: Rate as specified in menus // Size: 1190 bytes // Version: 1 type LapData struct { LastLapTimeInMS uint32 // Last lap time in milliseconds CurrentLapTimeInMS uint32 // Current time around the l...
pkg/packets/lap.go
0.514888
0.425247
lap.go
starcoder
package testing // simple testing library from https://github.com/qiniu/x import ( "reflect" "strings" "testing" ) // ---------------------------------------------------------------------------- // Testing represents a testing object. type Testing struct { t *testing.T } // New creates a testing object. func N...
testing/ts.go
0.708616
0.419945
ts.go
starcoder
package version100 const JsonSchema100 = `{ "meta:license": [ " Copyright (c) 2012-2019 Red Hat, Inc.", " This program and the accompanying materials are made", " available under the terms of the Eclipse Public License 2.0", " which is available at https://www.eclipse.org/legal/epl-...
pkg/devfile/parser/data/1.0.0/devfileJsonSchema100.go
0.856197
0.444625
devfileJsonSchema100.go
starcoder
package onshape import ( "encoding/json" ) // BTAllowEdgePointFilter2371 struct for BTAllowEdgePointFilter2371 type BTAllowEdgePointFilter2371 struct { BTQueryFilter183 AllowsEdgePoint *bool `json:"allowsEdgePoint,omitempty"` BtType *string `json:"btType,omitempty"` } // NewBTAllowEdgePointFilter2371 instantiate...
onshape/model_bt_allow_edge_point_filter_2371.go
0.698946
0.479077
model_bt_allow_edge_point_filter_2371.go
starcoder
package utl import "gosl/chk" // Deep3alloc allocates a slice of slice of slice func Deep3alloc(n1, n2, n3 int) (a [][][]float64) { a = make([][][]float64, n1) for i := 0; i < n1; i++ { a[i] = make([][]float64, n2) for j := 0; j < n2; j++ { a[i][j] = make([]float64, n3) } } return } // Deep4alloc alloc...
utl/deepslices.go
0.658308
0.403596
deepslices.go
starcoder
package dwarfgen import ( "cmd/compile/internal/base" "cmd/compile/internal/ir" "cmd/internal/src" ) // A ScopeMarker tracks scope nesting and boundaries for later use // during DWARF generation. type ScopeMarker struct { parents []ir.ScopeID marks []ir.Mark } // checkPos validates the given position and ret...
src/cmd/compile/internal/dwarfgen/marker.go
0.537041
0.425068
marker.go
starcoder
package strcmp // Natural compares two strings naturally. func Natural(left, right string) int { leftLen := len(left) rightLen := len(right) minLen := leftLen if minLen > rightLen { minLen = rightLen } for idx := 0; idx < minLen; idx++ { l := left[idx] r := right[idx] if l != r { return innerCompare...
natural.go
0.806167
0.513851
natural.go
starcoder
package compile import "github.com/raviqqe/lazy-ein/command/ast" type freeVariableFinder struct { variables map[string]struct{} } func newFreeVariableFinder(vs map[string]struct{}) freeVariableFinder { return freeVariableFinder{vs} } func (f freeVariableFinder) Find(e ast.Expression) []string { switch e := e.(ty...
command/compile/free_variable_finder.go
0.592077
0.478346
free_variable_finder.go
starcoder
package a import ( "fmt" ) // Represents a point in 3D space only in integer values type IntVector3 struct { X, Y, Z int } func (v IntVector3) SetXYZ(x, y, z int) { v.X = x v.Y = y v.Z = z } func NewIntVector3(x, y, z int) IntVector3 { return IntVector3{ X: x, Y: y, Z: z, } } func (v IntVector3) ToMap...
common/a/intVector.go
0.873026
0.77907
intVector.go
starcoder
package tsm1 // ReadFloatBlock reads the next block as a set of float values. func (c *KeyCursor) ReadFloatBlock(tdec *TimeDecoder, vdec *FloatDecoder, buf *[]FloatValue) ([]FloatValue, error) { // No matching blocks to decode if len(c.current) == 0 { return nil, nil } // First block is the oldest block contai...
tsdb/engine/tsm1/file_store.gen.go
0.719876
0.645371
file_store.gen.go
starcoder
package gft import ( "math" "github.com/infastin/gul/gm32" ) // This is a filter used for combining by using CombineColorhanFilters. // Must be a pointer. type ColorchanFilter interface { // Returns changed color channel. Fn(x float32) float32 // Returns true, if it is possible to create a lookup table usign F...
gft/colorchan.go
0.901271
0.435902
colorchan.go
starcoder
package cmscal import ( "crypto/sha1" "encoding/hex" "fmt" "time" ics "github.com/arran4/golang-ical" ) var ScheduleSixth = GradeSchedule{ Name: "CMS Sixth Grade 2020-2021", Description: "Block schedule for CMS Sixth Grade 2020-2021", ScheduleMap: map[BlockDayType]DaySchedule{ BlueDay: { {StartHo...
sched.go
0.624064
0.405096
sched.go
starcoder
package pterm import ( "strconv" "strings" "github.com/gookit/color" "github.com/pterm/pterm/internal" ) // RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. // The name of the model comes from the initials of ...
rgb.go
0.803212
0.617974
rgb.go
starcoder
package types import ( "github.com/attic-labs/noms/go/d" ) // SetIterator defines methods that can be used to efficiently iterate through a set in 'Noms-defined' // sorted order. type SetIterator interface { // Next returns subsequent values from a set. It returns nil, when no objects remain. Next() Value // Sk...
go/types/set_iterator.go
0.714927
0.437343
set_iterator.go
starcoder
package openapi import ( "encoding/json" "time" ) // AnyWorkflowRunStepState struct for AnyWorkflowRunStepState type AnyWorkflowRunStepState struct { // The set of decorators for a workflow step Decorators *[]WorkflowRunStepDecorator `json:"decorators,omitempty"` // Time at which the step execution ended Ended...
client/pkg/client/openapi/model_any_workflow_run_step_state.go
0.755547
0.421195
model_any_workflow_run_step_state.go
starcoder
package plan import ( "fmt" "time" "github.com/influxdata/flux" ) type Administration interface { Now() time.Time } // CreateProcedureSpec creates a ProcedureSpec from an OperationSpec and Administration type CreateProcedureSpec func(flux.OperationSpec, Administration) (ProcedureSpec, error) var createProcedur...
vendor/github.com/influxdata/flux/plan/registration.go
0.581422
0.475605
registration.go
starcoder
package matrix import "math" type Matrix []float64 func identiyOrOutMatrix(out []Matrix) Matrix { var mat Matrix if len(out) > 0 { mat = out[0] } else { mat = NewIdentityMatrix() } return mat } func NewMatrix() Matrix { return Matrix{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, } } func Ne...
math/matrix/matrix.go
0.707809
0.600774
matrix.go
starcoder
package spec3 // SecurityScheme defines a security scheme that can be used by the operations. // Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), OAuth2's common flows (implicit, password, application and access code) as defined in RFC6749, and Ope...
security_scheme.go
0.609524
0.409693
security_scheme.go
starcoder
package golisp2 import ( "fmt" "math" "strings" ) type ( // Value represents any arbitrary value within the lisp interpreting // environment. While it just extends "expr", the implicit contract is that no // work is actually performed at eval time; it just returns itself. Value interface { // InspectStr retu...
values.go
0.645567
0.440048
values.go
starcoder
package metric import ( "fmt" "runtime" ) func newGoMetricCollector() *Collector { golang := &golang{ goRoutineMetric: goMetric{ Name: "go_goroutines", Help: "Number of goroutines that currently exist.", GetFunc: func() float64 { return float64(runtime.NumGoroutine()) }, }, goProcessMetric: go...
src/common/metric/go-metric.go
0.558568
0.406509
go-metric.go
starcoder
package solid import ( "github.com/adamcolton/geom/d3" "github.com/adamcolton/geom/d3/curve/line" ) // Edge between two points. Edge should be ordered by calling Sort. Edge is used // as a map key to emulate a set. type Edge [2]d3.Pt // NewEdge from 2 points in the correct order func NewEdge(a, b d3.Po...
d3/solid/edge.go
0.69181
0.431045
edge.go
starcoder
package bitmatrix type BitMatrix interface { // New returns a new BitMatrix. It does not change the receiver. New(size int) BitMatrix // None sets all the bits of the receiver matrix to 0. // It returns the receiver matrix to support chaining. None() BitMatrix // Size returns the size of the matrix size x size...
bitmatrix_interface.go
0.81457
0.741791
bitmatrix_interface.go
starcoder
package main import "fmt" func sortArray(nums []int) []int { if len(nums) <= 1 { return nums } // quickSort(nums, 0, len(nums)-1) countSort(nums) return nums } // quickSort sorts the elements in nums in [l, r] (r included) // time: O(nlogn) ~ O(n^2) // space: O(logn) ~ O(n) func quickSort(nums []int, l, r i...
leetcode/0912_sort-an-array/main.go
0.505371
0.50531
main.go
starcoder
package models import ( "fmt" "github.com/astaxie/beego/orm" "strings" "time" ) type DtuRowOfDay struct { DTU_no string `orm:"column(dtu_no)"` MeterAddress int `orm:"column(meter_address)"` //MeterTypeNO string `orm:"column(meter_type_no)"` //MeterType string `orm:"column(meter_type)"` //...
models/CollectBaseInfo.go
0.634996
0.513546
CollectBaseInfo.go
starcoder
package ent import ( "context" "errors" "fmt" "github.com/facebookincubator/ent/dialect/sql/sqlgraph" "github.com/facebookincubator/ent/schema/field" "github.com/thoverik/gobench/ent/histogram" "github.com/thoverik/gobench/ent/metric" ) // HistogramCreate is the builder for creating a Histogram entity. type ...
ent/histogram_create.go
0.677047
0.478224
histogram_create.go
starcoder
package layout import ( "math" ) // "Fast and Simple Horizontal Coordinate Assignment" by <NAME> and <NAME>, 2002 // Computes horizontal coordinate in layered graph, given ordering within each layer. // Produces result such that neighbors are close and long edges cross Layers are straight. // Works on fully connecte...
layout/brandeskopf.go
0.615897
0.5144
brandeskopf.go
starcoder
package digitalocean import ( "context" "fmt" "github.com/digitalocean/godo" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-digitalocean/internal/datalist" ) func dataSourceDigitalOceanSizes() *schema.Resource { dataListConfig := &datalist.ResourceC...
vendor/github.com/terraform-providers/terraform-provider-digitalocean/digitalocean/datasource_digitalocean_sizes.go
0.644449
0.457803
datasource_digitalocean_sizes.go
starcoder
package assert import ( "github.com/tinyhubs/et/et" "testing" ) // Equal is used to check if exp equals to got. func Equal(t *testing.T, exp, got interface{}) { et.AssertInner(t, "", &et.Equal{exp, got}, 2) } // Equali is same with Equal but a need msg to express your intention. func Equali(t *testing.T, msg stri...
assert/assert.go
0.592195
0.567757
assert.go
starcoder
package httpc import "net/http" // StatusFn is func for comparing expected status code against // an expected status code. type StatusFn func(statusCode int) bool // StatusIn checks whether the response's status code matches at least 1 // of the input status codes provided. func StatusIn(status int, others ...int) S...
http/httpc/status.go
0.674479
0.451145
status.go
starcoder
package gfx import ( "fmt" "image/color" ) // A Font is a bitmapped font which can represent glyphs, or renderings of a // single character, as FrameBuffers that can then be blitted onto a larger // FrameBuffer. type Font struct { // GlyphWidth is the width of a certain glyph within the font GlyphWidth uint // ...
pkg/gfx/font.go
0.787727
0.468
font.go
starcoder
package optional import "errors" var ( // ErrNoneValueTaken represents the error that is raised when None value is taken. ErrNoneValueTaken = errors.New("none value taken") ) // Option is a data type that must be Some (i.e. having a value) or None (i.e. doesn't have a value). type Option[T any] struct { value T ...
option.go
0.807916
0.476823
option.go
starcoder
package feature import ( "fmt" "math" ) /* Criterion represents a constraint on a feature Its SatisfiedBy method takes a sample and returns a boolean indicating if the given value satisfies the feature criterion. Its Feature method returns the feature on which the criterion is applied. */ type Criterion interface...
feature/criterion.go
0.879981
0.563018
criterion.go
starcoder
package policyv1 import ( hash "hash" ) // HashPB computes a hash of the message using the given hash function // The ignore set must contain fully-qualified field names (pkg.msg.field) that should be ignored from the hash func (m *Policy) HashPB(hasher hash.Hash, ignore map[string]struct{}) { if m != nil { cerb...
api/genpb/cerbos/policy/v1/policy_hashpb.pb.go
0.802517
0.404713
policy_hashpb.pb.go
starcoder
package mapping import "fmt" func V2SuggestMapping(shards, replicas int) string { shards, replicas = setDefaults(shards, replicas) return fmt.Sprintf( v2SuggestMapping, shards, replicas, ) } // v2Mapping is the default mapping for the RDF records enabled by hub3 var v2SuggestMapping = `{ "settings": { ...
ikuzo/driver/elasticsearch/internal/mapping/v2suggest.go
0.505127
0.404331
v2suggest.go
starcoder
package parser import ( "fmt" "sort" "strings" ) // DecodeToNode converts the labels to a tree of nodes. // If any filters are present, labels which do not match the filters are skipped. func DecodeToNode(labels map[string]string, rootName string, filters ...string) (*Node, error) { sortedKeys := sortKeys(labels,...
pkg/config/parser/labels_decode.go
0.665302
0.404919
labels_decode.go
starcoder