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 money import ( "fmt" "strconv" "strings" "libs.altipla.consulting/errors" ) var ( EUR = FormatConfig{ Symbol: "\u20ac", Thousand: ",", } USD = FormatConfig{ Symbol: "$", Prefix: true, Thousand: ",", } GBP = FormatConfig{ Symbol: "\u00a3", Prefix: true, Thousand: ",", } ...
money/money.go
0.701815
0.412116
money.go
starcoder
package check import ( "fmt" "time" ) // Duration is the type of a check function which takes a time.Duration // parameter and returns an error or nil if the check passes type Duration func(d time.Duration) error // DurationGT returns a function that will check that the value is // greater than the limit func Dura...
check/duration.go
0.73678
0.53965
duration.go
starcoder
package mapz // Keys returns all keys in a map in a none deterministic order func Keys[K comparable, V any](m map[K]V) []K { r := make([]K, 0, len(m)) for k := range m { r = append(r, k) } return r } // Values returns all values in a map in a none deterministic order func Values[K comparable, V any](m map[K]V) ...
mapz/maps.go
0.870817
0.472136
maps.go
starcoder
package xlsx import ( "fmt" ) // Row represents a single Row in the current Sheet. type Row struct { Hidden bool // Hidden determines whether this Row is hidden or not. Sheet *Sheet // Sheet is a reference back to the Sheet that this Row is within. height float64 // Height is the current he...
xlsx/v3/row.go
0.766468
0.46873
row.go
starcoder
package geo import "time" type RangeInterface interface { Start() float64 End() float64 } type OverlapOutcome int const( Undefined OverlapOutcome = iota // These two apply to linear (range) overlaps (including altitude), where we have an ordering DisjointR2ComesAfter DisjointR2ComesBefore OverlapR2StraddlesSt...
range.go
0.762866
0.557484
range.go
starcoder
package internal import ( "bytes" "errors" "fmt" "io" "os" "reflect" "regexp" "strings" "time" "github.com/pterm/pterm" ) // IsKind returns if an object is kind of a specific kind. func IsKind(expectedKind reflect.Kind, value interface{}) bool { return reflect.TypeOf(value).Kind() == expectedKind } // Is...
internal/assertion_helper.go
0.700895
0.606877
assertion_helper.go
starcoder
package rf import r "reflect" // Flags constituting the return value of `rf.Filter`. // Unknown bits will be ignored. const ( // Don't visit self or descendants. Being zero, this is the default. VisNone = 0b_0000_0000 // Visit self. VisSelf = 0b_0000_0001 // Visit descendants. VisDesc = 0b_0000_0010 // Visi...
rf_walk.go
0.86681
0.67197
rf_walk.go
starcoder
package datadog import ( "encoding/json" ) // AuditLogsQueryOptions Global query options that are used during the query. Note: Specify either timezone or time offset, not both. Otherwise, the query fails. type AuditLogsQueryOptions struct { // Time offset (in seconds) to apply to the query. TimeOffset *int64 `jso...
api/v2/datadog/model_audit_logs_query_options.go
0.791821
0.420005
model_audit_logs_query_options.go
starcoder
package interval import ( "fmt" "sort" "strings" "time" "github.com/grokify/gocharts/data/timeseries" "github.com/grokify/simplego/time/timeutil" "github.com/grokify/simplego/type/maputil" "github.com/pkg/errors" ) type SeriesType int const ( Source SeriesType = iota Output OutputAggregate ) // TimeSeri...
data/timeseries/interval/data_series_set_interval.go
0.670608
0.416263
data_series_set_interval.go
starcoder
package gogl /* Edge interfaces */ // A graph's behaviors are primarily a product of the constraints and // capabilities it places on its edges. These constraints and capabilities // determine whether certain types of operations are possible on the graph, as // well as the efficiencies for various operations. // gog...
edge.go
0.886193
0.578835
edge.go
starcoder
package mdedit type buffer struct { lines []line cursor position vision vision } type line struct { text []byte } type position struct { row int col int } type vision struct { x, y int w, h int } func (b *buffer) currentLine() *line { return &b.lines[b.cursor.row] } func (b *buffer) cursorRight() { b.c...
buffer.go
0.552057
0.456228
buffer.go
starcoder
This hack completes the other sub-processor that add storageclass/local-data custom resources requests to pods requesting local-data. Use case being addressed here is: when a node with local-storage just joined, its PV isn't immediately available, and pods that triggered the upscale will remain pending for a...
cluster-autoscaler/processors/datadog/pods/transform_nodes_local_data.go
0.584034
0.458652
transform_nodes_local_data.go
starcoder
package draw import "math" // Vector represents a two-dimensional vector. type Vector struct { Dx float64 Dy float64 } // NewVector returns a new vector with the direction specified by dx and dy. func NewVector(dx, dy float64) Vector { v := Vector{} v.Dx = dx v.Dy = dy return v } // NewVectorBetween returns a...
bot/vendor/github.com/pzduniak/unipdf/contentstream/draw/vector.go
0.944536
0.807878
vector.go
starcoder
package textures import "github.com/fileformats/graphics/jt/model" // Texture Vers-1 Data format is stored in JT file if the Texture Image Element is a vanilla/basic texture image type TextureV1 struct { // Texture Type specifies the type of texture // = 0 None. // = 1 One-Dimensional. A one-dimensional texture ha...
jt/segments/textures/TextureV1.go
0.719088
0.606877
TextureV1.go
starcoder
package delta import ( "bytes" "fmt" "sort" "github.com/segmentio/parquet-go/encoding" "github.com/segmentio/parquet-go/encoding/plain" "github.com/segmentio/parquet-go/format" ) const ( maxLinearSearchPrefixLength = 64 // arbitrary ) type ByteArrayEncoding struct { encoding.NotSupported } func (e *ByteArr...
encoding/delta/byte_array.go
0.609408
0.42054
byte_array.go
starcoder
package main import "fmt" type elem struct { val int next *elem } // Returns the intersecting element (same reference) of lists // l1 and l2, if exists; otherwise nil, using a hashmap // Example: // l1: a -> b -> c -> d // l2: d -> e -> ... // intersecting element: d func intersect(l1, l2 *elem) *elem { var x *e...
apps/linkedlist/intersect/intersect.go
0.777342
0.410284
intersect.go
starcoder
package vector import ( "bufio" "encoding/json" "fmt" "io" "io/ioutil" "math" "os" "strings" ) type VectorPair struct { Vector1 *Vector Vector2 *Vector } func NewVectorPair(v1, v2 *Vector) *VectorPair { return &VectorPair{Vector1: v1, Vector2: v2} } func putAll(to, from map[string]int) { for key, value ...
vector/vector.go
0.622804
0.528777
vector.go
starcoder
package event import ( "sort" "github.com/percona/go-mysql/log" ) // Metrics encapsulate the metrics of an event like Query_time and Rows_sent. type Metrics struct { TimeMetrics map[string]*TimeStats `json:",omitempty"` NumberMetrics map[string]*NumberStats `json:",omitempty"` BoolMetrics map[string]*Bool...
event/metrics.go
0.769254
0.467879
metrics.go
starcoder
package arrowutil import ( "fmt" "github.com/apache/arrow/go/v7/arrow/memory" "github.com/influxdata/flux/array" ) // CopyTo will copy the contents of the array into a new array builder. func CopyTo(b array.Builder, arr array.Array) { switch arr := arr.(type) { case *array.Int: CopyIntsTo(b.(*array.IntBuild...
internal/arrowutil/copy.gen.go
0.671255
0.655433
copy.gen.go
starcoder
package BrodalOkasakiHeap import "fmt" /* "BOHeap" is a wrapper around "BONode". This structure is defines an entrypoint for a Brodal-Okasaki heap and implements the priority queue interface using operations defined for "BONode" structure. */ type BOHeap struct { root *BONode size int } /* Create a new Br...
boheap.go
0.780035
0.454291
boheap.go
starcoder
package stationxml import ( "fmt" ) // This type represents a Station epoch. // It is common to only have a single station epoch with the station's creation // and termination dates as the epoch start and end dates. type Station struct { BaseNode Latitude Latitude `xml:"Latitude"` Longitude Longitude `xml:"Lon...
vendor/github.com/ozym/fdsn/stationxml/station.go
0.810066
0.45538
station.go
starcoder
package set import ( "sort" ) // Strings represents the classic "set" data structure, and contains strings. type Strings map[string]bool // NewStrings creates and initializes a Strings and populates it with // initial values as specified in the parameters. func NewStrings(initial ...string) Strings { result := ma...
vendor/github.com/juju/utils/set/strings.go
0.826817
0.456349
strings.go
starcoder
package b1t6 import ( "errors" "fmt" "math" "strings" "github.com/loveandpeople/lp.go/consts" "github.com/loveandpeople/lp.go/trinary" ) const ( tritsPerByte = 6 trytesPerByte = tritsPerByte / consts.TritsPerTryte ) // EncodedLen returns the trit-length of an encoding of n source bytes. func EncodedLen(n i...
encoding/b1t6/b1t6.go
0.690559
0.402539
b1t6.go
starcoder
package xml import ( "context" "fmt" "github.com/benthosdev/benthos/v4/internal/bundle" "github.com/benthosdev/benthos/v4/internal/component/processor" "github.com/benthosdev/benthos/v4/internal/docs" "github.com/benthosdev/benthos/v4/internal/interop" "github.com/benthosdev/benthos/v4/internal/log" "github.c...
internal/impl/xml/processor.go
0.728555
0.591546
processor.go
starcoder
package onshape import ( "encoding/json" ) // BTPStatementReturn281AllOf struct for BTPStatementReturn281AllOf type BTPStatementReturn281AllOf struct { BtType *string `json:"btType,omitempty"` SpaceAfterReturn *BTPSpace10 `json:"spaceAfterReturn,omitempty"` Value *BTPExpression9 `json:"value,omitempty"` } // New...
onshape/model_btp_statement_return_281_all_of.go
0.772316
0.404008
model_btp_statement_return_281_all_of.go
starcoder
package tentsuyu import ( "fmt" "math" ) //Vector2d represents a 2 dimensional vector type Vector2d struct { X, Y float64 } //Add other vector to the vector func (v *Vector2d) Add(other Vector2d) { v.X += other.X v.Y += other.Y } //Sub (tract) other vector from the vector func (v *Vector2d) Sub(other Vector2d)...
vectors.go
0.906341
0.778565
vectors.go
starcoder
package discovery import "fmt" type Fan struct { // A list of MQTT topics subscribed to receive availability (online/offline) updates. Must not be used together with `availability_topic` // Default: <no value> Availability []Availability `json:"availability,omitempty"` // When `availability` is configured, this...
fan.go
0.837985
0.428712
fan.go
starcoder
package replacer import ( "context" "strconv" "strings" "sync" "time" "github.com/inverse-inc/wireguard-go/dns/plugin/metadata" "github.com/inverse-inc/wireguard-go/dns/plugin/pkg/dnstest" "github.com/inverse-inc/wireguard-go/dns/request" "github.com/miekg/dns" ) // Replacer replaces labels for values in s...
dns/plugin/pkg/replacer/replacer.go
0.610337
0.422147
replacer.go
starcoder
package helpers import ( "fmt" "strings" ) type StringMatrix struct { Matrix [][]string } func (m *StringMatrix) InitSquare(size int, def string) { m.InitEmpty(size, size, def) } func (m *StringMatrix) InitEmpty(height, width int, def string) { ret := [][]string{} for y := 0; y < width; y++ { ret = append(r...
2021/go/helpers/matrix.go
0.61451
0.414484
matrix.go
starcoder
package integration // ServiceNowIntegration specifies the properties of a notification service integration between ServiceNow and Observability Cloud, in the form of a JSON object type ServiceNowIntegration struct { // The creation date and time for the integration object, in Unix time UTC-relative. This value is "r...
integration/model_service_now_integration.go
0.805938
0.539772
model_service_now_integration.go
starcoder
package io import ( "math" "math/rand" "unsafe" ) // Rander wraps the Rand method. type Rander interface { // Rand returns a random sample drawn from the distribution. Rand() float64 } // Exponential represents the exponential distribution (https://en.wikipedia.org/wiki/Exponential_distribution). type Exponent...
benchmark/io/exponential.go
0.843154
0.550366
exponential.go
starcoder
package output import ( "github.com/Jeffail/benthos/v3/internal/docs" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/message/batch" "github.com/Jeffail/benthos/v3/lib/metrics" "github.com/Jeffail/benthos/v3/lib/output/writer" "github.com/Jeffail/benthos/v3/lib/types" "github.com/Jeff...
lib/output/aws_kinesis_firehose.go
0.727782
0.486941
aws_kinesis_firehose.go
starcoder
package needle import ( "crypto/subtle" "fmt" "math" "github.com/nomasters/haystack/errors" "golang.org/x/crypto/blake2b" ) // Hash represents an array of length HashLength type Hash [32]byte // Payload represents an array of length PayloadLength type Payload [160]byte const ( // HashLength is the length in ...
needle/needle.go
0.770378
0.446495
needle.go
starcoder
package assert import ( "bytes" "fmt" "reflect" "runtime" "strconv" "strings" "testing" ) type Assert struct { *testing.T goon bool } // Nil asserts the actual value is nil. func (a *Assert) Nil(actual interface{}, logs ...interface{}) { if !IsNil(actual) { logCaller() fmt.Printf("expect nil, got %#v. ...
assert.go
0.64646
0.427217
assert.go
starcoder
package main import ( "bytes" "fmt" "math/rand" "time" ) // Field represents a two-dimensional field of cells. type Grid struct { s [][]bool w, h int } // NewField returns an empty field of the specified width and height. func NewGrid(w, h int) *Grid { s := make([][]bool, h) for i := range s { s[i] = ma...
code/golang/game_errorless.go
0.814607
0.442637
game_errorless.go
starcoder
package day3 import ( "errors" "ryepup/advent2021/utils" ) /* Both the oxygen generator rating and the CO2 scrubber rating are values that can be found in your diagnostic report - finding them is the tricky part. Both values are located using a similar process that involves filtering out values until only one rema...
day3/part2.go
0.712832
0.785103
part2.go
starcoder
package dot import ( "golang.org/x/exp/constraints" ) // Optional allows functions to return an optional result. This is useful for situations where the result may not exist but the absence is not an error. type Optional[T any] struct { val T set bool } // Success creates a new Optional with the result set. func ...
dot/dot.go
0.880328
0.555073
dot.go
starcoder
package dynamic import ( "reflect" "log" "strconv" ) type Dynamic struct { Type reflect.Type data interface {} } func (d *Dynamic) Init() *Dynamic { d.Type = nil return d } func (d *Dynamic) Data(data interface {}) *Dynamic { d.data = data d.Type = reflect.TypeOf(d.data) return d } func (d *Dynamic) SetD...
src/statistic/dynamic/dynamic.go
0.733452
0.537406
dynamic.go
starcoder
package hexit import ( "fmt" ) // Board encoding: 0 = blank, 1 = Player 1, 2 = Player 2 // First index is the number of rows from the top // Second index is the number of columns from the left type Board = [5][5]byte // BoardLocation is a location on a board type BoardLocation struct { Row uint Col uint } // Mov...
src/hex.go
0.623148
0.402451
hex.go
starcoder
package repere import "math" //go:generate ../../../../../structgen/structgen -source=repere.go -mode=dart:../../../../eleve/lib/exercices/repere.gen.dart // Coord is a coordinate pair, in the usual mathematical plan, // where X and Y must be between 0 and the dimension of the figure type Coord struct { X, Y float6...
server/src/maths/repere/repere.go
0.654564
0.482246
repere.go
starcoder
package docs // ReferenceShort contains short help text. const ReferenceShort = `Overview of mpdev commands` // ReferenceLong contains expanded help text. const ReferenceLong = `mpdev contains commands to both configure and construct artifacts needed for publishing to the Google Cloud Marketplace. ` // ReferenceEx...
mpdev/internal/docs/docs.go
0.78572
0.408572
docs.go
starcoder
package graphbox import ( "fmt" "strings" "github.com/ajstarks/svgo" ) type GraphboxItem interface { // Defines a constraint. It is provided with the coordinates // of the item. Constraint(r, c int, applier ConstraintApplier) // Call to draw this box Draw(ctx DrawContext, point Point) } type ConstraintAp...
seqdiagram/graphbox/basetypes.go
0.826467
0.403714
basetypes.go
starcoder
package binarysearchtree // AVLNode avl node type AVLNode struct { Left *AVLNode Right *AVLNode Value int Height int } // leftRotate left rotate func leftRotate(root *AVLNode) *AVLNode { node := root.Right root.Right = root.Left root.Left = root root.Height = max(height(root.Left), height(root.Right)) + ...
binarysearchtree/avl.go
0.743075
0.412116
avl.go
starcoder
package hlt import ( "fmt" "math" "strconv" ) // DockingStatus represents possible ship.DockingStatus values type DockingStatus int const ( // UNDOCKED ship.DockingStatus value UNDOCKED DockingStatus = iota // DOCKING ship.DockingStatus value DOCKING // DOCKED ship.DockingStatus value DOCKED // UNDOCKING s...
airesources/Go/src/hlt/entity.go
0.688364
0.532182
entity.go
starcoder
package pacers import ( "errors" "fmt" "strings" "time" vegeta "github.com/tsenart/vegeta/v12/lib" ) // combinedPacer is a Pacer that combines multiple Pacers and runs them sequentially when being used for attack. type combinedPacer struct { // pacers is a list of pacers that will be used sequentially for atta...
test/vegeta/pacers/combined_pacer.go
0.653901
0.416975
combined_pacer.go
starcoder
package easing import ( "math" ) /* Linear -----------------------------------------------*/ func Linear(t float64) float64 { return t } /* Quad -----------------------------------------------*/ func QuadEaseIn(t float64) float64 { return t * t } func QuadEaseOut(t float64) float64 { return -(t * (t - 2)) } ...
easing.go
0.72086
0.507202
easing.go
starcoder
package assets import ( "fmt" "math" "strconv" "time" "github.com/goledgerdev/cc-tools/errors" ) // DataType is the struct defining a primitive data type. type DataType struct { // AcceptedFormats is a list of "core" types that can be accepted (string, number, integer, boolean, datetime) AcceptedFormats []str...
assets/dataType.go
0.785966
0.484258
dataType.go
starcoder
package aoc2020 import ( "strings" ) func init() { registerFun("11", SolveDay11) } func SolveDay11(input string) (interface{}, interface{}) { return simulateDay11(input, simulateRoundPart1), simulateDay11(input, simulateRoundPart2) } func countOccupiedSeatsInSight(sm [][]rune, x int, y int) int { count := 0 f...
aoc2020/day11.go
0.595375
0.416856
day11.go
starcoder
// Package whirlpool implements the ISO/IEC 10118-3:2004 whirlpool // cryptographic hash. Whirlpool is defined in // http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html package whirlpool import ( "encoding/binary" "hash" ) // whirlpool represents the partial evaluation of a checksum. type whirlpool struct { bitLe...
whirlpool.go
0.727685
0.401512
whirlpool.go
starcoder
package main import ( "fmt" "strconv" ) // A Graph is the interface implemented by graphs that // this algorithm can run on. type Graph interface { Vertices() []Vertex Neighbors(v Vertex) []Vertex Weight(u, v Vertex) int } // Nonnegative integer ID of vertex type Vertex int // ig is a graph of integer...
go/graph_algorithms/Floyd_warshall.go
0.547948
0.428293
Floyd_warshall.go
starcoder
package polygol import ( "math" ) // func Intersection(v1, v2 []float64, pt1, pt2 []float64) []float64 { func intersection(v1, v2 []float64, pt1, pt2 []float64) []float64 { // take some shortcuts for vertical and horizontal lines // this also ensures we don't calculate an intersection and then discover // it's ac...
vector.go
0.659186
0.468304
vector.go
starcoder
package iterator import ( "sync/atomic" "github.com/apache/arrow/go/arrow" "github.com/apache/arrow/go/arrow/array" "github.com/go-bullseye/bullseye/internal/debug" ) // StepValue holds the value for a given step. type StepValue struct { Values []interface{} Exists []bool Dtypes []arrow.DataType } // Value r...
iterator/stepiterator.go
0.684475
0.400925
stepiterator.go
starcoder
package edges import ( "decompose/helper" "decompose/layer" "image" "image/color" ) type Edges [][]bool func NewEdges(sizeX, sizeY uint) Edges { data := make([][]bool, sizeY) for j := uint(0); j < sizeY; j++ { data[j] = make([]bool, sizeX) } return data } func FromLayer(l layer.Layer, crop float64) Edges...
labo-3/decompose/edges/edges.go
0.613005
0.557243
edges.go
starcoder
package dutil import ( "fmt" "reflect" ) // Dataset represents a set of samples and // how to access a sample by its index by implementing // `Item()` method. type Dataset interface { Item(idx int) (interface{}, error) DType() reflect.Type Len() int } type DatasetKind int const ( SliceDKind DatasetKind = iota...
dutil/dataset.go
0.860266
0.536495
dataset.go
starcoder
package assert import ( "io/ioutil" "os" "runtime/debug" "strings" "testing" ) // IntsAreEqual compares an expected int value and an actual int value for equality. func IntsAreEqual(t *testing.T, expected int, actual int) { if expected != actual { debug.PrintStack() t.Fatalf("Expected: %d; Actual: %d", expe...
pkg/assert/common.go
0.603581
0.729158
common.go
starcoder
package sets type Empty struct{} // Set is a set of strings, implemented via map[string]struct{} for minimal memory consumption. type Set[T comparable] map[T]Empty // New creates a String from a list of values. func New[T comparable](items ...T) Set[T] { ss := Set[T]{} ss.Insert(items...) return ss } // Insert a...
set.go
0.830009
0.511656
set.go
starcoder
package math type Vector2 struct { X float32 Y float32 } func Vec2(x, y float32) Vector2 { return Vector2{X: x, Y: y} } func (vec Vector2) Cpy() Vector2 { return Vector2{X: vec.X, Y: vec.Y} } // The euclidian length func (vec Vector2) Len() float32 { return Sqrt(vec.X*vec.X + vec.Y*vec.Y) } // The squared euc...
vector2.go
0.936066
0.912319
vector2.go
starcoder
Empty Memory This memory region is a backstop to empty areas in the memory map. When accessed it returns default values and a memory error. */ //----------------------------------------------------------------------------- package mem //----------------------------------------------------------------------------- ...
mem/empty.go
0.798698
0.582907
empty.go
starcoder
package transform import ( "image" "net/url" "strconv" "strings" "github.com/disintegration/imaging" "github.com/sirupsen/logrus" ) // RotateImage implements the rotating scheme described on: // https://docs.fastly.com/api/imageopto/orient func RotateImage(m image.Image, orient string) image.Image { switch or...
internal/image/transform/transform.go
0.788868
0.471345
transform.go
starcoder
package muxgo import ( "encoding/json" ) // RealTimeHistogramTimeseriesDatapoint struct for RealTimeHistogramTimeseriesDatapoint type RealTimeHistogramTimeseriesDatapoint struct { Timestamp *string `json:"timestamp,omitempty"` Sum *int64 `json:"sum,omitempty"` P95 *float64 `json:"p95,omitempty"` Median *float64...
model_real_time_histogram_timeseries_datapoint.go
0.862815
0.499146
model_real_time_histogram_timeseries_datapoint.go
starcoder
package types import ( "fmt" "io" "github.com/lyraproj/pcore/utils" "github.com/lyraproj/pcore/px" ) type TypeAliasType struct { name string typeExpression *DeferredType resolvedType px.Type loader px.Loader } var TypeAliasMetaType px.ObjectType func init() { TypeAliasMetaType = newOb...
types/typealiastype.go
0.579638
0.473292
typealiastype.go
starcoder
package syntaxtree import ( "bytes" "strings" "github.com/manishmeganathan/tunalang/lexer" ) // A structure that represents a prefix expression node on the syntax tree type PrefixExpression struct { // Represents the prefix operator token Token lexer.Token // Represents the operator literal string Operator s...
syntaxtree/expressions.go
0.83545
0.412294
expressions.go
starcoder
package mathu import ( "fmt" "math" "math/rand" "strconv" ) // Float represents a wrapper around float64 that provides some // convenience functions arounf the math package, and some fuzzy // tests for zero. type Float float64 // ParseFloat parses a string into a Float, just like // strconv.ParseFloat(s, 64). fu...
float.go
0.904681
0.660525
float.go
starcoder
package busservice import ( "fmt" "strconv" "time" ) // SeniorAge is the minimum age from which a Passenger is considered a senior to the BusCompany. const SeniorAge = 65 // Passenger represents a bus passenger, uniquely identified by their SSN. type Passenger struct { SSN string SeatNumber uint8...
busservice/busservice.go
0.705886
0.584212
busservice.go
starcoder
package main import ( "fmt" "math" "math/rand" "os" "time" ) type Vec [3]float64 func (u Vec) add(v Vec) Vec { return Vec{u[0] + v[0], u[1] + v[1], u[2] + v[2]} } func (u Vec) sub(v Vec) Vec { return Vec{u[0] - v[0], u[1] - v[1], u[2] - v[2]} } func (u Vec) dot(v Vec) float64 { return u[0]*...
samples/raytracer.go
0.732209
0.461259
raytracer.go
starcoder
package renderer import ( "github.com/PucklaMotzer09/GoHomeEngine/src/gohome" gl "github.com/PucklaMotzer09/android-go/gles2" "github.com/PucklaMotzer09/mathgl/mgl32" "strconv" "sync" "unsafe" ) type valueTypeIndexOffset struct { valueType int index int offset int } type indexValueType struct { inde...
src/renderers/OpenGLES2/opengles2instancedmesh3d.go
0.514644
0.444625
opengles2instancedmesh3d.go
starcoder
package board import ( "fmt" "strings" ) // Placement defines a piece placement. type Placement struct { Square Square Color Color Piece Piece } func (p Placement) String() string { return fmt.Sprintf("%v@%v", printPiece(p.Color, p.Piece), p.Square) } // Position represents a board position suitable for mov...
pkg/board/position.go
0.82963
0.417271
position.go
starcoder
package golarm func setMetric(a *Alarm, v float64, m metric) { a.value = value{value: v, percentage: false} a.stats.metric = m } func setComparison(a *Alarm, v float64, c comparison) { a.value = value{value: v, percentage: false} a.comparison = c } func isMetricCorrect(a *Alarm, v float64, m metric) bool { if a...
operations.go
0.844922
0.468061
operations.go
starcoder
package trees import ( "fmt" ) type BinaryTreeNode struct { value int left *BinaryTreeNode right *BinaryTreeNode } type BinaryTree struct { root *BinaryTreeNode } // InorderDFS traverses a tree using depth first search, in an inorder manner. func (b *BinaryTree) InorderDFS() []*BinaryTreeNode { if b.root == n...
datastructures/trees/binary/binary-tree.go
0.764804
0.486454
binary-tree.go
starcoder
package bls12381 import ( "fmt" "github.com/cloudflare/circl/ecc/bls12381/ff" ) type isogG2Point struct{ x, y, z ff.Fp2 } func (p isogG2Point) String() string { return fmt.Sprintf("x: %v\ny: %v\nz: %v", p.x, p.y, p.z) } // IsOnCurve returns true if g is a valid point on the curve. func (p *isogG2Point) IsOnCurve...
ecc/bls12381/g2Isog.go
0.685529
0.443902
g2Isog.go
starcoder
package entropy import ( "math" "gonum.org/v1/gonum/mat" "gonum.org/v1/gonum/stat" ) // Shannon returns the Shannon-entropy. The function takes a probability // distribution p(x) as input. // H(X) = -\sum_x p(x) log(p(x)) func Shannon(p mat.Vector) float64 { var r float64 for i := 0; i < p.Len(); i++ { v :=...
stat/entropy/entropy.go
0.848345
0.564759
entropy.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // UserExperienceAnalyticsBatteryHealthOsPerformance type UserExperienceAnalyticsBatteryHealthOsPerformance struct { Entity // Number of active devices fo...
models/user_experience_analytics_battery_health_os_performance.go
0.761184
0.512937
user_experience_analytics_battery_health_os_performance.go
starcoder
package dmc import ( "log" "strconv" "github.com/lucasb-eyer/go-colorful" ) func (d *DmcColors) HexToDmc(hex string) (string, string) { var previousDistance float64 var dmc string var floss string // Search for hex in d.HexMap to check for exact matches. If it exists, loop through // d.ColorBank for the co...
hex.go
0.698844
0.428532
hex.go
starcoder
package stream import "golang.org/x/exp/slices" type sliceComparableStream[Elem comparable] struct { sliceStream[Elem] } // NewSliceByComparable new stream instance, generics constraints based on comparable func NewSliceByComparable[Elem comparable](v []Elem) sliceComparableStream[Elem] { return sliceComparableSt...
slice_comparable.go
0.872998
0.452838
slice_comparable.go
starcoder
package wq import ( "html" "sync" "github.com/manvalls/wit" ) // Node represents one or more HTML nodes type Node struct { Send func(wit.Delta) // Send will be called as a result of this node's methods } // Selector encapsulates a CSS selector. Must be initialised by Node.S() type Selector struct { selector wi...
wq.go
0.751375
0.458773
wq.go
starcoder
package rango import "math" const FARPLANE = 1 << 30 type Ray struct { Src Vector Dir Vector } type Hit struct { Position Vector /* Position of the ray hit point */ Normal Vector /* normal at that point */ Ray Ray /* incident ray at the hit point */ ObjectId int32 /* Object id of the hit object...
rango/ray.go
0.732879
0.504089
ray.go
starcoder
package genworldvoronoi import ( "math/rand" opensimplex "github.com/ojrac/opensimplex-go" "github.com/fogleman/delaunay" ) type BaseObject struct { r_xyz []float64 // Point / region xyz coordinates r_latLon [][2]float64 // Point / region latitude and longitude r_elevation []float64...
genworldvoronoi/baseobject.go
0.671363
0.593491
baseobject.go
starcoder
package spogoto // FunctionMap is a map of functions that operate on the DataStack and // other DataStacks accessible through the RunSet. type FunctionMap map[string]func(DataStack, RunSet, Interpreter) // DataStack is a Stack used by the Interpreter // to store data of a specific type and has functions that can mani...
datastack.go
0.643665
0.705531
datastack.go
starcoder
package repository // RootPath is the root Go module path. This path is prefixed in every package // path. const RootPath = "github.com/diamondburned/cchat" var Main = Packages{ MakePath("text"): { Comment: Comment{` Package text provides a rich text API for cchat interfaces to use. Asserting Although i...
repository/main.go
0.703244
0.456955
main.go
starcoder
package mux import ( "io" "net" "sync" "time" ) // Endpoint implements net.Conn. It is used to read muxed packets. Incoming // packets are delivered by the Mux, and placed in a circular queue of buffers. // Readers grab packets from the queue as they become available. type Endpoint struct { mux *Mux // A circu...
internal/mux/endpoint.go
0.674265
0.431105
endpoint.go
starcoder
package gosom import ( "image" "image/color" "github.com/gonum/floats" "github.com/llgcode/draw2d/draw2dimg" "github.com/llgcode/draw2d/draw2dkit" ) // DrawDimensions draws the dimensions of the SOM as images. func DrawDimensions(som *SOM, nodeWidth int) []image.Image { matrix := som.WeightMatrix() images := ...
visualization.go
0.692018
0.540378
visualization.go
starcoder
package hash import ( "crypto/md5" "crypto/sha256" "crypto/sha512" "encoding/hex" "io" "sort" "golang.org/x/crypto/blake2b" "golang.org/x/crypto/blake2s" "golang.org/x/crypto/ripemd160" "golang.org/x/crypto/sha3" ) //define function type var hash_algorithms map[string]func(string) string = map[string]func(...
hash/hash.go
0.59561
0.422743
hash.go
starcoder
package evt import "github.com/shasderias/ilysa/beatsaber" type BaseOpt interface { applyBase(e *Base) } func WithBeat(b float64) withBeatOpt { return withBeatOpt{b} } type withBeatOpt struct{ b float64 } func (o withBeatOpt) apply(e Event) { e.SetBeat(o.b) } func (o withBeatOpt) applyBase(e *Base) { e.SetBea...
evt/base_opt.go
0.740456
0.463687
base_opt.go
starcoder
package graphics2d import ( //"fmt" "image" "image/color" "image/draw" g2dimg "github.com/jphsd/graphics2d/image" "github.com/jphsd/graphics2d/util" "golang.org/x/image/vector" ) // RenderColoredShape renders the supplied shape with the fill color // into the destination image. func RenderColoredShape(dst dra...
render.go
0.766818
0.599778
render.go
starcoder
package gofb import ( "math" "github.com/go-gl/gl/v2.1/gl" ) // Color RGBA byte color type Color struct { R uint8 G uint8 B uint8 A uint8 } // NewColor3 create new Color (without alpha) func NewColor3(r uint8, g uint8, b uint8) Color { return Color{R: r, G: g, B: b, A: 255} } // NewColor4 create new Color w...
types.go
0.852091
0.434461
types.go
starcoder
package geometry import ( "context" "math" "github.com/ironarachne/world/pkg/random" ) // Point is an x, y location type Point struct { X float64 Y float64 } // Centroid returns a point that is in the center of a polygon defined by the given points func Centroid(points []Point) Point { x := 0.0 y := 0.0 fo...
pkg/geometry/points.go
0.893033
0.626553
points.go
starcoder
package compiler import ( "fmt" "regexp" "github.com/influxdata/flux/ast" "github.com/influxdata/flux/semantic" "github.com/influxdata/flux/values" "github.com/pkg/errors" ) type Func interface { Type() semantic.Type Eval(input values.Object) (values.Value, error) EvalString(input values.Object) (string, er...
compiler/runtime.go
0.645232
0.58261
runtime.go
starcoder
package buf import ( "io" ) // Supplier is a writer that writes contents into the given buffer. type Supplier func([]byte) (int, error) // Buffer is a recyclable allocation of a byte array. Buffer.Release() recycles // the buffer into an internal buffer pool, in order to recreate a buffer more // quickly...
common/buf/buffer.go
0.658308
0.416144
buffer.go
starcoder
package vmath import ( "fmt" "github.com/maja42/vmath/math32" "github.com/maja42/vmath/mathi" ) type Vec2i [2]int func (v Vec2i) String() string { return fmt.Sprintf("Vec2i[%d x %d]", v[0], v[1]) } // Format the vector to a string. func (v Vec2i) Format(format string) string { return fmt.Sprintf(format, v[0],...
vec2i.go
0.912974
0.64491
vec2i.go
starcoder
package pvss // Secure Distributed Key Generation for Discrete-Log Based Cryptosystems import ( "math/big" "github.com/torusresearch/torus-common/common" "github.com/torusresearch/torus-common/secp256k1" pcmn "github.com/torusresearch/torus-node/common" ) // Commit creates a public commitment polynomial for the...
pvss/gennaro2006.go
0.734786
0.555556
gennaro2006.go
starcoder
package goment import ( "math" "time" ) // Diff holds a start and end Goment. type Diff struct { Start *Goment End *Goment } // InYears returns the duration in number of years. func (d Diff) InYears() int { return d.monthDiff() / 12 } // InMonths returns the duration in number of months. func (d Diff) InMont...
diff.go
0.823399
0.552057
diff.go
starcoder
// Package physics implements a basic physics engine. package solver import ( "github.com/schidstorm/engine/math32" ) // GaussSeidel equation solver. // See https://en.wikipedia.org/wiki/Gauss-Seidel_method. // The number of solver iterations determines the quality of the solution. // More iterations yield a better...
experimental/physics/solver/gs.go
0.874104
0.811116
gs.go
starcoder
package nucular import ( "image" "strings" nstyle "github.com/aarzilli/nucular/style" "golang.org/x/image/font" "golang.org/x/mobile/event/mouse" "github.com/aarzilli/nucular/rect" "github.com/hashicorp/golang-lru" ) type Heading int const ( Up Heading = iota Right Down Left ) func min(a, b int) int ...
vendor/github.com/aarzilli/nucular/util.go
0.639061
0.516535
util.go
starcoder
package utils import ( "testing" "reflect" ) func AssertStringEquals(name string, actual string, expected string, t *testing.T) bool { if actual != expected { t.Errorf("%s = %s; expected: %s", name, actual, expected) return false } return true } func AssertStringNotEquals(name string, actual string...
utils/asserts.go
0.711531
0.624236
asserts.go
starcoder
package broadlinkrm type deviceCharacteristics struct { known bool name string supported bool ir bool rf bool power bool } type knownDevice struct { deviceType int name string supported bool ir bool rf bool power bool } var knownDevices = []knownDevi...
src/knowndevices.go
0.501465
0.441673
knowndevices.go
starcoder
// gitdiff is an adaptation of https://github.com/sourcegraph/go-diff/blob/master/diff/print.go that prints popular diffmatchpatch.Diff diffs. package gitdiff import ( "bytes" "fmt" "strings" "unsafe" "github.com/sergi/go-diff/diffmatchpatch" ) type Diff struct { diffs []diffmatchpatch.Diff aFn, bFn stri...
pkg/gitdiff/print.go
0.528533
0.438905
print.go
starcoder
package geography import ( "database/sql/driver" "encoding/binary" "errors" "fmt" "strconv" "github.com/go-courier/geography/encoding/mvt" "github.com/go-courier/geography/encoding/wkb" "github.com/go-courier/geography/encoding/wkt" ) type Point [2]float64 func (p Point) IsZero() bool { return p[0] == 0 &&...
geom_point.go
0.692018
0.414425
geom_point.go
starcoder
package max7219 import ( "github.com/tinygo-org/tinygo/src/machine" ) // Uses a 3-wire serial interface type Device struct { Data machine.Pin // DIN Load machine.Pin // Can also be labeled CS Clock machine.Pin // CLK MaxInUse int // Number of daisy chained MAX units } // Initialize the pins f...
max7219/max7219.go
0.680879
0.456591
max7219.go
starcoder
package utils import ( "fmt" "math" "github.com/vorduin/nune" ) func Equal1D[T nune.Number](a, b nune.Tensor[T], eq func(a, b T) bool) bool { if a.Size(0) != b.Size(0) { return false } for i := 0; i < a.Size(0); i++ { if !eq(a.Index(i).Scalar(), b.Index(i).Scalar()) { return false } } return true } ...
utils/nn_functions.go
0.536313
0.537284
nn_functions.go
starcoder
// Package rla provides an implementation of RLA (Recurrent Linear Attention). // See: "Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention" by Katharopoulos et al., 2020. package rla import ( "encoding/gob" "github.com/nlpodyssey/spago/ag" "github.com/nlpodyssey/spago/mat" "github.com/...
nn/recurrent/rla/rla.go
0.786213
0.623033
rla.go
starcoder