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 matrix import ( "errors" "reflect" ) var ( errPositiveNumberRequired = errors.New("positive number required") errIndexOutOfRange = errors.New("index out of range") errDimensionMismatch = errors.New("matrices dimensions do not match") errIsNotSquare = errors.New("must be a n x n m...
matrix.go
0.667473
0.497986
matrix.go
starcoder
package vbo import ( "time" "github.com/golang/geo/s1" "github.com/golang/geo/s2" ) const ( earthRadius float64 = 6367000.0 ) var gateWidth = s1.ChordAngleFromAngle(s1.Angle(12.5 / earthRadius)) func processLaps(f File) (laps []Lap) { startLine := s2.PointFromLatLng(s2.LatLngFromDegrees(f.Start.Lat, f.Start.L...
pkg/vbo/s2.go
0.594434
0.429011
s2.go
starcoder
Package oparse parses simple expressions in orismologer protos. Basic arithmetic, variables, function calls, string literals, nested expressions, and string concatenation are supported. Based on the version originally published at: https://github.com/alecthomas/participle/blob/master/_examples/expr/main.go */ package o...
oparse/parser.go
0.899022
0.656108
parser.go
starcoder
package gps import ( "errors" "strconv" "strings" "time" ) var ( errEmptyNMEASentence = errors.New("cannot parse empty NMEA sentence") errUnknownNMEASentence = errors.New("unsupported NMEA sentence type") errInvalidGGASentence = errors.New("invalid GGA NMEA sentence") errInvalidRMCSentence = errors.New("i...
gps/gpsparser.go
0.644561
0.409044
gpsparser.go
starcoder
package day10 import ( "fmt" "math" "github.com/nlowe/aoc2019/challenge" "github.com/spf13/cobra" ) const symAsteroid = '#' var A = &cobra.Command{ Use: "10a", Short: "Day 10, Problem A", Run: func(_ *cobra.Command, _ []string) { fmt.Printf("Answer: %d\n", a(challenge.FromFile())) }, } type asteroid st...
challenge/day10/a.go
0.696887
0.435181
a.go
starcoder
package q import ( "fmt" "hash/fnv" "github.com/aunum/gold/pkg/v1/common/num" "github.com/aunum/log" "github.com/k0kubun/pp" "gorgonia.org/tensor" ) // Table is the qualtiy table which stores the quality of an action by state. type Table interface { // GetMax returns the action with the max Q value for a give...
pkg/v1/agent/q/table.go
0.724188
0.458227
table.go
starcoder
package sigmo import ( "fmt" "log" ) func Add(a Atom, b Atom) Atom { if (a.t == "int" || a.t == "float") && (b.t == "int" || b.t == "float") { sum := a.AsFloat() + b.AsFloat() if a.t == "int" && b.t == "int" { return Atom{t: "int", value: int(sum)} } return Atom{t: "float", value: sum} } return Atom{t...
util.go
0.557845
0.556038
util.go
starcoder
package typ var ( Void = Type{Kind: KindVoid} Any = Type{Kind: KindAny} Typ = Type{Kind: KindTyp} Num = Type{Kind: KindNum} Bool = Type{Kind: KindBool} Int = Type{Kind: KindInt} Real = Type{Kind: KindReal} Char = Type{Kind: KindChar} Str = Type{Kind: KindStr} Raw = Type{Kind: KindRaw} UUID = Type{Ki...
typ/decl.go
0.515376
0.603786
decl.go
starcoder
// Package table produces a string that represents slice of structs data in a text table package table import ( "errors" "fmt" "reflect" ) type bd struct { H rune // BOX DRAWINGS HORIZONTAL V rune // BOX DRAWINGS VERTICAL VH rune // BOX DRAWINGS VERTICAL AND HORIZONTAL HU rune // BOX DRAWINGS HORIZONTAL AND...
table.go
0.664214
0.428054
table.go
starcoder
package evaltest import ( "fmt" "math" "reflect" "regexp" "src.elv.sh/pkg/eval" ) // ApproximatelyThreshold defines the threshold for matching float64 values when // using Approximately. const ApproximatelyThreshold = 1e-15 // Approximately can be passed to Case.Puts to match a float64 within the // threshold ...
pkg/eval/evaltest/matchers.go
0.703957
0.416144
matchers.go
starcoder
package memmetrics import ( "fmt" "time" hdrhistogram "github.com/HdrHistogram/hdrhistogram-go" //"github.com/codahale/hdrhistogram" "github.com/mailgun/timetools" ) // HDRHistogram is a tiny wrapper around github.com/codahale/hdrhistogram that provides convenience functions for measuring http latencies type HD...
src/github.com/mailgun/oxy/memmetrics/histogram.go
0.754915
0.489809
histogram.go
starcoder
package model func predict1(features []float64) float64 { if (features[2] < 0.5) || (features[2] == -1) { if (features[1] < 0.5) || (features[1] == -1) { if (features[0] < 0.5) || (features[0] == -1) { if (features[7] < 0.108870044) || (features[7] == -1) { ...
examples/xgboost/XGBRegressor/booster1.go
0.518546
0.479077
booster1.go
starcoder
package main import ( "flag" "fmt" "strings" "github.com/alexchao26/advent-of-code-go/util" ) func main() { var part int flag.IntVar(&part, "part", 1, "part 1 or 2") flag.Parse() fmt.Println("Running part", part) if part == 1 { ans := part1(util.ReadFile("./input.txt")) fmt.Println("Output:", ans) } e...
2018/day21/main.go
0.522202
0.432303
main.go
starcoder
package goconsider // Settings contain all the parameters for the analysis. type Settings struct { // Phrases describe all the texts the linter should look for Phrases []Phrase } // Phrase describes an expression, with optional alternatives, that the linter flags. type Phrase struct { // Synonyms are one or more e...
settings.go
0.698124
0.450843
settings.go
starcoder
package gozxing type EncodeHintType int const ( /** * Specifies what degree of error correction to use, for example in QR Codes. * Type depends on the encoder. For example for QR codes it's type * {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}. * For Aztec it is of type {@l...
encode_hint_type.go
0.874774
0.595669
encode_hint_type.go
starcoder
package cmd import ( "fmt" "github.com/jaredbancroft/aoc2020/pkg/helpers" "github.com/spf13/cobra" ) // day6Cmd represents the day6 command var day6Cmd = &cobra.Command{ Use: "day6", Short: "Advent of Code 2020 - Day 6: Custom Customs", Long: ` Advent of Code 2020 --- Day 6: Custom Customs --- As your ...
cmd/day6.go
0.647575
0.538194
day6.go
starcoder
package mods import ( "image" "image/color" "github.com/oakmound/oak/render/mod" ) func HighlightOff(c color.Color, thickness, xOff, yOff int) mod.Mod { return func(img image.Image) *image.RGBA { bds := img.Bounds() w := bds.Max.X + thickness*2 + xOff h := bds.Max.Y + thickness*2 + yOff newRgba := imag...
entities/x/mods/highlight.go
0.535341
0.536434
highlight.go
starcoder
package querier import ( "math" "sort" "github.com/pkg/errors" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb/chunkenc" "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/corte...
vendor/github.com/cortexproject/cortex/pkg/querier/block.go
0.705785
0.404302
block.go
starcoder
package idxfile /* == Original (version 1) pack-*.idx files have the following format: - The header consists of 256 4-byte network byte order integers. N-th entry of this table records the number of objects in the corresponding pack, the first byte of whose object name is less than or equal to N. This...
vendor/srcd.works/go-git.v4/plumbing/format/idxfile/doc.go
0.539711
0.6602
doc.go
starcoder
package ode // #cgo LDFLAGS: -lode // #define dDOUBLE // #include <ode/ode.h> import "C" import ( "unsafe" ) // Initialization flags const ( ManualThreadCleanupIFlag = C.dInitFlagManualThreadCleanup ) // Allocation flags const ( BasicDataAFlag = C.dAllocateFlagBasicData CollisionDataAFlag = C.dAllocateFlagC...
ode.go
0.690455
0.452173
ode.go
starcoder
package gol import ( "strconv" "sync" "time" "uk.ac.bris.cs/gameoflife/util" ) type distributorChannels struct { events chan<- Event ioCommand chan<- ioCommand ioIdle <-chan bool ioFileName chan<- string ioOutput chan<- uint8 ioInput <-chan uint8 keyPresses <-chan rune } // Sends the file na...
gol/distributor.go
0.593845
0.44083
distributor.go
starcoder
package packet /* Motion Packet The motion packet gives physics data for all the cars being driven. There is additional data for the car being driven with the goal of being able to drive a motion platform setup. N.B. For the normalised vectors below, to convert to float values divide by 32767.0f – 16-bit signed value...
golang/pkg/common/packet/motion.go
0.5083
0.564158
motion.go
starcoder
package types import ( "fmt" "strconv" ) // PlmnID is a globally unique network identifier (Public Land Mobile Network) type PlmnID uint32 // EnbID is an eNodeB Identifier type EnbID uint32 // CellID is a node-local cell identifier type CellID uint8 // ECI is a E-UTRAN Cell Identifier type ECI uint32 // GEnbID...
go/onos/ransim/types/types.go
0.63861
0.516778
types.go
starcoder
package collections import ( "fmt" "sync" ) type Vector struct { sync.Mutex elementCount int capacityIncrement int elementData []interface{} } func NewVector() *Vector { inst := &Vector{ elementData: make([]interface{}, 0), } return inst } func (v *Vector) Size() int { return v.elementCount } fu...
collections/vector.go
0.517327
0.474144
vector.go
starcoder
package main import ( "fmt" "image/color" "math" "os" "p4l/gifhelper" "p4l/vec" "strconv" ) // Universe holds our bodies and the universe's parameters and type Universe struct { bodies []Body width float64 g float64 // Universal gravitational constant = 6.674E-11 Nm^2/kg^2 } // Body represents any ma...
gravity/model.go
0.640636
0.494751
model.go
starcoder
package tests import ( "fmt" "reflect" ) type numberTest struct { expected float64 } func (nt *numberTest) Run(input interface{}) error { castedNumber, ok := castNumber(input) if !ok { return fmt.Errorf("input (%#v %v) isn't a number", input, reflect.TypeOf(input)) } if castedNumber != nt.expected { retu...
number.go
0.819244
0.446495
number.go
starcoder
package forecast type AttributeType string // Enum values for AttributeType const ( AttributeTypeString AttributeType = "string" AttributeTypeInteger AttributeType = "integer" AttributeTypeFloat AttributeType = "float" AttributeTypeTimestamp AttributeType = "timestamp" ) func (enum AttributeType) Marsh...
service/forecast/api_enums.go
0.732496
0.442757
api_enums.go
starcoder
package horizon import ( "fmt" ) // FindShortestPath Find shortest path between two obserations (not necessary GPS points). /* NOTICE: this function snaps point to nearest edges simply (without multiple 'candidates' for each observation) gpsMeasurements - Two observations statesRadiusMeters - maximum radius to se...
map_matcher_simple_sp.go
0.67822
0.537588
map_matcher_simple_sp.go
starcoder
package block import ( "github.com/df-mc/dragonfly/server/block/cube" "github.com/df-mc/dragonfly/server/block/model" "github.com/df-mc/dragonfly/server/item" "github.com/df-mc/dragonfly/server/world" "github.com/df-mc/dragonfly/server/world/sound" "github.com/go-gl/mathgl/mgl64" ) // WoodDoor is a block that c...
server/block/wood_door.go
0.623606
0.416559
wood_door.go
starcoder
package hermit2 import ( "fmt" "github.com/ungerik/go3d/vec2" ) // PointTangent contains a point and a tangent at that point. // This is a helper sub-struct for T. type PointTangent struct { Point vec2.T Tangent vec2.T } // T holds the data to define a hermit spline. type T struct { A PointTangent B PointTan...
hermit2/hermit2.go
0.841858
0.663546
hermit2.go
starcoder
package aws import ( "bytes" "context" "fmt" "net/url" "sort" "strings" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3/s3manager" "github.com/benthosdev/benthos/v4/internal/batch/policy" "github.com/benthosdev/benthos/v4/internal/blobl...
internal/impl/aws/output_s3.go
0.658198
0.414484
output_s3.go
starcoder
package bigtable import ( "cloud.google.com/go/bigtable" "github.com/wolffcm/flux/ast" "github.com/wolffcm/flux/plan" "github.com/wolffcm/flux/semantic" "github.com/wolffcm/flux/stdlib/universe" "time" ) func AddFilterToNode(queryNode plan.Node, filterNode plan.Node) (plan.Node, bool) { querySpec := queryNode....
stdlib/experimental/bigtable/bigtable_rewrite.go
0.595728
0.446193
bigtable_rewrite.go
starcoder
package types import ( "bytes" "fmt" "io" "strings" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" "k8s.io/kubernetes/pkg/kubectl/cmd/templates" kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "k8s.io/kubernetes/pkg/kubectl/genericclioptions" ) type concept struct { Name string Abbre...
pkg/oc/cli/types/types.go
0.636353
0.550849
types.go
starcoder
package unit import ( "fmt" "math" "reflect" "strings" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" ) type NumericDeltaOption struct { Value float64 } type SameTypeOption struct { Value bool } type SamePointerOption struct { Value bool } type UseEqualMethodOption struct { Value ...
unit/equal_comparator.go
0.594787
0.456289
equal_comparator.go
starcoder
package datadog import ( "encoding/json" "fmt" ) // Series A metric to submit to Datadog. See [Datadog metrics](https://docs.datadoghq.com/developers/metrics/#custom-metrics-properties). type Series struct { // The name of the host that produced the metric. Host *string `json:"host,omitempty"` // If the type of...
api/v1/datadog/model_series.go
0.876291
0.468122
model_series.go
starcoder
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "log" "os" "strings" "time" "github.com/arran4/golang-ical" "github.com/avast/retry-go" "github.com/kelvins/sunrisesunset" ) var version = "<dev>" // ProductID identifies this software in User-Agents and iCal fields. const ProductID = "github...
main.go
0.674694
0.434941
main.go
starcoder
package proto import ( "encoding/binary" "fmt" "github.com/pkg/errors" "time" ) var ErrNotFound = errors.New("not found") //PutStringWithUInt8Len converts the string to slice of bytes. The first byte of resulting slice contains the length of the string. func PutStringWithUInt8Len(buf []byte, s string) { sl := u...
pkg/proto/common.go
0.754553
0.534916
common.go
starcoder
package io import ( "encoding/binary" "math" ) func NewBuffer(cap int) *Buffer { return &Buffer{ buf: make([]byte, cap), pos: 0, } } func NewBufferWithData(data []byte) *Buffer { return &Buffer{ buf: data, pos: 0, } } type Buffer struct { buf []byte pos int } func (b *Buffer) Cap() int { return l...
internal/storage/io/buffer.go
0.613005
0.493653
buffer.go
starcoder
package advent import ( "fmt" "github.com/davidparks11/advent2021/internal/coordinate" ) type seaCucumber struct { dailyProblem } func NewSeaCumber() Problem { return &seaCucumber{ dailyProblem{ day: 25, }, } } func (s *seaCucumber) Solve() interface{} { input := s.GetInputLines() var results []int ...
internal/advent/day25.go
0.717903
0.42471
day25.go
starcoder
package jsonschema import ( "github.com/json-iterator/go" "strconv" ) // AllOf MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema. // An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value. type AllOf []*Sch...
keywords_booleans.go
0.767472
0.406744
keywords_booleans.go
starcoder
package mocks import ( "io" "github.com/stretchr/testify/mock" "github.com/ZupIT/ritchie-cli/pkg/api" "github.com/ZupIT/ritchie-cli/pkg/env" "github.com/ZupIT/ritchie-cli/pkg/formula" "github.com/ZupIT/ritchie-cli/pkg/formula/creator/template" "github.com/ZupIT/ritchie-cli/pkg/git" "github.com/ZupIT/ritchie-...
internal/mocks/mocks.go
0.651798
0.411525
mocks.go
starcoder
package waveform import ( "bytes" "errors" "fmt" "image/color" "io" "math" "time" svg "github.com/ajstarks/svgo/float" "github.com/go-audio/audio" "github.com/go-audio/wav" "github.com/hajimehoshi/go-mp3" ) // Option image option type Option struct { // Resolution specifies the resolution of the // Req...
image.go
0.707708
0.407687
image.go
starcoder
package ewgraph import ( "math" ipq "github.com/DmitryBogomolov/algorithms/indexpriorityqueue" ) func scanMinimumSpanningTreeVertexPrim( wgr EdgeWeightedGraph, marked []bool, edgeTo []int, distTo []float64, verticesQueue ipq.IndexPriorityQueue, vertexID int, ) { marked[vertexID] = true weights := wgr.AdjacentW...
graph/ewgraph/minimum_spanning_tree_prim.go
0.742515
0.404978
minimum_spanning_tree_prim.go
starcoder
package project import "github.com/Smadarl/orb" // Geometry is a helper to project any geomtry. func Geometry(g orb.Geometry, proj orb.Projection) orb.Geometry { if g == nil { return nil } switch g := g.(type) { case orb.Point: return Point(g, proj) case orb.MultiPoint: return MultiPoint(g, proj) case or...
project/helpers.go
0.798108
0.498657
helpers.go
starcoder
package sliceop // Prefill - prefil array with values func Prefill(size int, symbol string) (output []string) { output = make([]string, size) for i := 0; i < size; i++ { output[i] = symbol } return output } // Map - maps array of strings with func func Map(f func(input string) string, input ...string) (output [...
sliceop.go
0.684053
0.409398
sliceop.go
starcoder
package statistics import ( "math" ) type PearsonIIIDistribution struct { Mean float64 `json:"mean"` StandardDeviation float64 `json:"standarddeviation"` Skew float64 `json:"skew"` } func (d PearsonIIIDistribution) InvCDF(probability float64) float64 { if probability > 1 { panic("nop...
statistics/pearsonIIIDistribution.go
0.832543
0.45302
pearsonIIIDistribution.go
starcoder
package gokalman import ( "errors" "github.com/gonum/matrix/mat64" "github.com/gonum/stat" ) // NewChiSquare runs the Chi square tests from the MonteCarlo runs. These runs // and the KF used are the ones tested via Chi square. The KF provided must be a // pure predictor Vanilla KF and will be used to compute the ...
chisquare.go
0.584627
0.6305
chisquare.go
starcoder
package unionfind type UnionFind struct { data map[interface{}]*Node } func NewUnionFind() *UnionFind { union := UnionFind{data: make(map[interface{}]*Node)} return &union } // Get parent node of the union searching by value of its member // Return union's parent Node // O(m) time, O(1) space (in the worst case O...
unionfind/unionfind.go
0.835819
0.430806
unionfind.go
starcoder
package main import "strings" /* iven an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than o...
golang/algorithms/others/word_search/main.go
0.592431
0.429728
main.go
starcoder
// Package parser contains logic for parsing Herd-style observations. package parser import ( "bufio" "fmt" "io" "strings" "github.com/c4-project/c4t/internal/subject/obs" ) // Parse parses an observation from r into o using i. func Parse(i Impl, r io.Reader, o *obs.Obs) error { p := parser{impl: i, o: o} re...
internal/serviceimpl/backend/herdstyle/parser/parser.go
0.6705
0.459561
parser.go
starcoder
package utils // IncludesString if the list contains the string func IncludesString(list []string, a string) bool { for _, b := range list { if b == a { return true } } return false } // IncludesInt if the list contains the Int func IncludesInt(list []int, a int) bool { for _, b := range list { if b == a...
pkg/utils/slice.go
0.732974
0.435661
slice.go
starcoder
package subsampler import ( "errors" "jpeg2000/data" ) type Subsampler interface { Subsample(y, u, v data.Layer) (data.Layer, data.Layer, data.Layer) Supersample(y, u, v data.Layer) (data.Layer, data.Layer, data.Layer) ToProtobuf() data.Subsampling } func ScaleLayers(y1, u1, v1 data.Layer, xScale, yScale int) (...
labo-2/jpeg2000/subsampler/subsampler.go
0.541894
0.426023
subsampler.go
starcoder
package continuous import ( "github.com/jtejido/stats" "github.com/jtejido/stats/err" "math" "math/rand" ) // Johnson SL Distribution (Semi-bounded) // https://reference.wolfram.com/language/ref/JohnsonDistribution.html type JohnsonSL struct { gamma, delta, location, scale float64 // γ, δ, location μ, and scale ...
dist/continuous/johnson_sl.go
0.808899
0.455683
johnson_sl.go
starcoder
package cache import ( "fmt" "math" "columbia.github.com/privatekube/dpfscheduler/pkg/scheduler/util" columbiav1 "columbia.github.com/privatekube/privacyresource/pkg/apis/columbia.github.com/v1" "k8s.io/klog" ) type StreamingCounter struct { LaplaceNoise float64 Budget *columbiav1.PrivacyBudget T ...
system/dpfscheduler/pkg/scheduler/cache/counter.go
0.78016
0.409516
counter.go
starcoder
// http://play.golang.org/p/xy-wyPrsjz // Declare a struct type that represents a request for a customer invoice. Include a CustomerID and InvoiceID field. Define // tags that can be used to validate the request. Define tags that specify both the length and range for the ID to be valid. // Declare a function named va...
12-reflection/exercises/exercise1/exercise1.go
0.662906
0.429429
exercise1.go
starcoder
package maps import ( "fmt" "github.com/mbark/advent-of-code-2021/util" ) type Cuboid struct { From Coordinate3D To Coordinate3D } func (c Cuboid) Coordinates() []Coordinate3D { var coordinates []Coordinate3D for x := c.From.X; x <= c.To.X; x++ { for y := c.From.Y; y <= c.To.Y; y++ { for z := c.From.Z; ...
maps/cube.go
0.690663
0.487124
cube.go
starcoder
package unencrypted_asset import ( "github.com/threagile/threagile/model" ) func Category() model.RiskCategory { return model.RiskCategory{ Id: "unencrypted-asset", Title: "Unencrypted Technical Assets", Description: "Devido à classificação de confidencialidade do próprio ativo técnico e / ou os ativos de ...
risks/built-in/unencrypted-asset/unencrypted-asset-rule.go
0.557364
0.47658
unencrypted-asset-rule.go
starcoder
package math import ( "math" ) // Pi is math.Pi but as a float32 type const Pi = float32(math.Pi) const Pi2 = Pi * 2 const Sqrt2 = float32(math.Sqrt2) const MaxFloat32 = math.MaxFloat32 const RadiansToDegrees = 180 / Pi const DegreeToRadians = Pi / 180 const RadFull = Pi * 2 const DegFull = 360 const NanoToSec = 1 /...
math.go
0.827689
0.797596
math.go
starcoder
package schema const RUMV3Schema = `{ "$id": "docs/spec/rum_v3_metadata.json", "title": "Metadata", "description": "Metadata concerning the other objects in the stream.", "type": [ "object" ], "properties": { "se": { "$id": "docs/spec/rum_v3_service.json", ...
model/metadata/generated/schema/rum_v3_metadata.go
0.709019
0.510802
rum_v3_metadata.go
starcoder
package loco import ( "math" "strconv" "github.com/golang/geo/s2" ) func FindCellIDs(area s2.Rect) (cellUnion s2.CellUnion) { cellQueue := make([]s2.CellID, 0) c := s2.CellIDFromFacePosLevel(0, 0, 0).ChildBeginAtLevel(0) endCellId := s2.CellIDFromFacePosLevel(5, 0, 0).ChildEndAtLevel(0) for c != endCellId { ...
loco/helpers.go
0.717606
0.467089
helpers.go
starcoder
package design import ( design "goa.design/goa/design" ) const ( // FormatDate describes RFC3339 date values. FormatDate = design.FormatDate // FormatDateTime describes RFC3339 date time values. FormatDateTime = design.FormatDateTime // FormatUUID describes RFC4122 UUID values. FormatUUID = design.FormatUUID ...
http/design/aliases.go
0.611498
0.413181
aliases.go
starcoder
package slippy import ( "math" "errors" "github.com/go-spatial/geom" ) // MaxZoom is the lowest zoom (furthest in) const MaxZoom = 22 // NewTile returns a Tile of Z,X,Y passed in func NewTile(z, x, y uint) *Tile { return &Tile{ Z: z, X: x, Y: y, } } // Tile describes a slippy tile. type Tile struct { ...
vendor/github.com/go-spatial/geom/slippy/tile.go
0.789153
0.51312
tile.go
starcoder
package data import ( "regexp" "github.com/go-playground/validator" ) func (user *User) Validate() error { validate := validator.New() err1 := validate.RegisterValidation("email", validateEmail) err2 := validate.RegisterValidation("dateofbirth", validateDateOfBirth) err3 := validate.RegisterValidation("isStat...
pkg/data/validate.go
0.525856
0.498718
validate.go
starcoder
package techan import "github.com/sdcoffey/big" type relativeVigorIndexIndicator struct { numerator Indicator denominator Indicator } // NewRelativeVigorIndexIndicator returns an Indicator which returns the index of the relative vigor of the prices of // a sercurity. Relative Vigor Index is simply the difference...
indicator_relative_vigor_index.go
0.769167
0.612947
indicator_relative_vigor_index.go
starcoder
package method import ( "log" "math" "gonum.org/v1/gonum/optimize" ) // Linear prototype of Linear regression // this could be used for either Linear regression // and logistic regression type Linear struct { Features [][]float64 Theta []float64 Output []float64 LearningRate float64 Hypothes...
method/linear.go
0.674372
0.617743
linear.go
starcoder
package gohome import ( "github.com/PucklaMotzer09/GLSLGenerator" "strings" ) // 3D const ( ShaderVersion = "110" ) var ( Attributes3D = []glslgen.Variable{ glslgen.Variable{"vec3", "highp", "vertex"}, glslgen.Variable{"vec3", "highp", "normal"}, glslgen.Variable{"vec2", "highp", "texCoord"}, glslgen.Va...
src/gohome/shadermodules3dopengl.go
0.552298
0.610773
shadermodules3dopengl.go
starcoder
package heap type Heap[T comparable] struct { nodes []T // The array that stores the heap's nodes. orderCriteria func(T, T) bool // Determines how to compare two nodes in the heap. } /* Creates an empty heap. The sort function determines whether this is a min-heap or max-heap. For comparable dat...
Heap/heap.go
0.846768
0.700011
heap.go
starcoder
package rabbitmonit import ( "strconv" "github.com/c-datculescu/rabbit-hole" ) /* QueueProperties offers a broader set of operations than rabbithole.QueueInfo including warnings, errors and statistics */ type QueueProperties struct { Stats QueueStat Error QueueAlert Warning QueueAlert QueueInfo rabbi...
queue.go
0.52074
0.432243
queue.go
starcoder
package turfgo // LineDiff take two lines and gives an array of lines by subracting second from first. Single coordinate overlaps are ignored. // Line should not have duplicate values. func LineDiff(firstLine *LineString, secondLine *LineString) []*LineString { diffSegments := []*LineString{} fPoints := firstLine.Po...
transformation.go
0.730963
0.61341
transformation.go
starcoder
package redis import ( "context" "fmt" "strconv" "time" "github.com/go-redis/redis/v7" "github.com/benthosdev/benthos/v4/internal/bloblang/field" "github.com/benthosdev/benthos/v4/internal/bundle" "github.com/benthosdev/benthos/v4/internal/component/processor" "github.com/benthosdev/benthos/v4/internal/docs...
internal/impl/redis/processor.go
0.730097
0.592195
processor.go
starcoder
package main // Window : Sliding Window data type type Window struct { length int // length of the stack mirror []int // unordered list of values size int // size of the sliding window stack []int // ordered list of values } // AddDelay : adds a delay value to the stack func (w *Window) AddDelay(delay int)...
sliding-window.go
0.693265
0.433981
sliding-window.go
starcoder
package meetingtime import ( "errors" "time" ) // Schedule defines a regular schedule for a meeting type Schedule struct { Type ScheduleType // Type of recurrence First time.Time // Time and date of first meeting Frequency uint // How frequently this meeting occurs. For a daily meeting, 2 wou...
schedule.go
0.673192
0.686697
schedule.go
starcoder
package walk // Kata (Japanese) is a form of movement (in martial arts) type Kata []GoTo // Japanese // ======================================================== // From returns the Here (or nil) reached from e by steps func (steps Kata) From(e *Here) (*Here, Distance) { var dist, dnow Distance goal := e for _, ...
walk/kata.go
0.675336
0.460653
kata.go
starcoder
package table import ( "encoding/json" "fmt" "reflect" "sort" "github.com/go-gota/gota/dataframe" gota "github.com/go-gota/gota/series" "github.com/gojek/merlin/pkg/transformer/spec" "github.com/gojek/merlin/pkg/transformer/types/series" ) type Table struct { dataFrame *dataframe.DataFrame } func NewTable...
api/pkg/transformer/types/table/table.go
0.71123
0.449272
table.go
starcoder
import hp "container/heap" /* 1. Priority Queue Using Heap 2. Graph and dijkstra algorithm 3. Represent cell (i,j) as a node with id = i*C + j, 4. Map relationship between cell(i,j) to cell(i+1,j) and cell(i,j+1) as diff of heights 5. Use Dijkstra's algorithm to find the short parth between 0 to R*C...
submissions/1631.Path_With_Minimum_Effort.go
0.572962
0.506469
1631.Path_With_Minimum_Effort.go
starcoder
package series import ( "fmt" "math" "strconv" "strings" ) type stringElement struct { e string valid bool } // Strings with NaN will be treated as just strings with NaN func (e *stringElement) Set(value interface{}) error { e.valid = true if value == nil { e.valid = false return nil } switch value...
series/type-string.go
0.66628
0.519399
type-string.go
starcoder
package main import ( "math" ) func lines(car *Car, newAngle float32) [4][2]float32 { relx1 := car.width / 2.0 rely1 := float32(0) relx3 := float32(0) rely3 := car.height / 2.0 relx2 := -relx1 rely2 := -rely1 relx4 := -relx3 rely4 := -rely3 vectors := [4]*Vector{ {relx1, rely1}, {relx2, rely2}, {...
collision.go
0.657428
0.487124
collision.go
starcoder
package crypto // Go/crypto/elliptic only supports NIST curves. This file implements the SECG // curve secp256k1 as described in https://www.secg.org/sec2-v2.pdf. The API in this // implementation is consistent with the crypto/elliptic package API. // This implementation is Go based and is not using optimized methods...
crypto/internal/crypto/secg.go
0.921397
0.645399
secg.go
starcoder
package impl import ( "fmt" "github.com/gdamore/tcell" ) //GradientRaySampler sample a ray given it depth and some other properties //TODO: remove outOfRangeStyle property type GradientRaySampler struct { //styles to be used to render a wall (i.e: the color used in a range of distance). wallStyles []tcell.Style ...
client/render/impl/raysampler_default.go
0.522446
0.541227
raysampler_default.go
starcoder
package mathgl import ( "math" ) type Vec2d [2]float64 type Vec3d [3]float64 type Vec4d [4]float64 func (v1 Vec2d) Add(v2 Vec2d) Vec2d { return Vec2d{v1[0] + v2[0], v1[1] + v2[1]} } func (v1 Vec3d) Add(v2 Vec3d) Vec3d { return Vec3d{v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]} } func (v1 Vec4d) Add(v2 Vec4d) Ve...
vectord.go
0.767298
0.714111
vectord.go
starcoder
package outputs import ( "sort" "time" "barista.run/bar" "barista.run/timing" ) // Repeat creates a TimedOutput from a function by repeatedly calling it at // different times. type Repeat func(time.Time) bar.Output // Every repeats the output at a fixed interval. func (r Repeat) Every(interval time.Duration) b...
outputs/timed.go
0.764628
0.559952
timed.go
starcoder
package interpolation import ( "fmt" "sort" "github.com/hashicorp/hil" "github.com/hashicorp/hil/ast" ) // interpolationFuncHas returns if the key exists in the provided map func interpolationFuncHas() ast.Function { return ast.Function{ ArgTypes: []ast.Type{ast.TypeMap, ast.TypeString}, ReturnType: ast....
internal/interpolation/maps.go
0.773815
0.401336
maps.go
starcoder
package cron import ( "fmt" "math" "strconv" "strings" ) var ( allYears = [3]uint64{math.MaxUint64, math.MaxUint64, math.MaxUint64} ) // MustParse returns a new Expression pointer. // It expects a well-formed cron expression. // If a malformed cron expression is supplied, it will `panic`. func MustParse(spec s...
cron/parser.go
0.695855
0.403361
parser.go
starcoder
package main import ( "korok.io/korok/game" "korok.io/korok" "korok.io/korok/engi" "korok.io/korok/gfx" "korok.io/korok/asset" "korok.io/korok/hid/input" "korok.io/korok/math/f32" ) // A face surround with 4 blocks! type Block struct { engi.Entity } func NewBlock() Block { e := korok.Entity.New() b := Bloc...
src/demo/node/main.go
0.536556
0.413181
main.go
starcoder
package model import ( "time" "github.com/GoogleCloudPlatform/heapster/store" ) // latestTimestamp returns its largest time.Time argument func latestTimestamp(first time.Time, second time.Time) time.Time { if first.After(second) { return first } return second } // newInfoType is an InfoType Constructor, whi...
model/util.go
0.759315
0.455683
util.go
starcoder
package ratingutil import ( "time" "github.com/mashiike/rating" ) //RatingPeriod constants //can multiple float64 // PeriodDay * 3.0 => 3 days const ( PeriodDay time.Duration = 24 * time.Hour PeriodWeek = 7 * PeriodDay PeriodMonth = 30 * PeriodDay PeriodYear = 36...
ratingutil/config.go
0.765681
0.431285
config.go
starcoder
package file import ( "fmt" "io" "path/filepath" "github.com/turbinelabs/api" "github.com/turbinelabs/cli/command" "github.com/turbinelabs/codec" tbnflag "github.com/turbinelabs/nonstdlib/flag" "github.com/turbinelabs/rotor" ) const fileDescription = `Watches the given JSON or YAML file and updates Clusters ...
plugins/file/file.go
0.587943
0.442938
file.go
starcoder
package nulldate import ( "time" "github.com/lovung/date" ) // NullDate is the nullable type for Date only. // Support UTC timezone only // Null if valid is true type NullDate struct { Date date.Date Valid bool } // New creates a new Date func New(t time.Time, valid bool) NullDate { return NullDate{ Date: ...
nulldate/null_date.go
0.72487
0.431704
null_date.go
starcoder
package day12 import "math" import "fmt" var pairs = [][]int{ {0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}, } type Position struct { X int Y int Z int } func NewPosition(x, y, z int) Position { return Position{X: x, Y: y, Z: z} } type Velocity struct { X int Y int Z int } func NewVelocity(x, y, z i...
day12/day12.go
0.707809
0.425068
day12.go
starcoder
package model // Options defines possible square values when enumerating valid grids. var options = []Square{ SquareDragon, SquareFire, SquareAir, } type gridPredicate func(*Grid) bool type gridsPredicate func([]*Grid) bool // Enumerate enumerates all possible successors from a given grid. func Enumerate(g *Grid)...
pkg/model/enumerate.go
0.828245
0.445349
enumerate.go
starcoder
package mesh import ( "github.com/galaco/kero/framework/graphics/adapter" "github.com/go-gl/mathgl/mgl32" ) type Mesh adapter.Mesh // BasicMesh type BasicMesh struct { vertices []float32 normals []float32 uvs []float32 lightmapUVs []float32 tangents []float32 indices []uint32 } // AddV...
framework/graphics/mesh/mesh.go
0.625209
0.459197
mesh.go
starcoder
package bytefmt // from: github.com/cloudfoundry/bytefmt by Apache License import ( "errors" "strconv" "strings" "unicode" ) const ( sizeByte = 1 << (10 * iota) sizeKilo sizeMega sizeGiga sizeTera sizePeta sizeExa ) var errInvalidByteQuantity = errors.New("byte quantity must be a positive integer with a ...
bytefmt/bytefmt.go
0.628977
0.439026
bytefmt.go
starcoder
package tree type BinarySearchTreeNode struct { Value int64 Times int64 Left *BinarySearchTreeNode Right *BinarySearchTreeNode } type BinarySearchTree struct { Root *BinarySearchTreeNode } func NewBinarySearchTree() *BinarySearchTree { return new(BinarySearchTree) } func (tree *BinarySearchTree) Add(value in...
basic_ds/tree/BinarySearchTree.go
0.705278
0.420659
BinarySearchTree.go
starcoder
package main import ( "fmt" ) // tag::board[] // Code in this file likely performs quite a few unnecessary copy operations on data. Performance // doesn't matter much here, though. // Field is a field of a bingo board. type Field struct { val int marked bool } // Board is a bingo board. type Board struct { ...
day04/go/razziel89/board.go
0.69285
0.466056
board.go
starcoder
// Interface to ws2811 chip (neopixel driver). Make sure that you have // ws2811.h and pwm.h in a GCC include path (e.g. /usr/local/include) and // libws2811.a in a GCC library path (e.g. /usr/local/lib). // See https://github.com/jgarff/rpi_ws281x for instructions package ws2811 import ( "os" "os/signal" "syscal...
ws2811.go
0.587943
0.419648
ws2811.go
starcoder
package pb import ( "fmt" "github.com/golang/protobuf/ptypes/wrappers" "reflect" "strings" ) // Strips a pointer, or pointer(-to-pointer)^* to base object if needed func indirect(reflectValue reflect.Value) reflect.Value { for reflectValue.Kind() == reflect.Ptr { reflectValue = reflectValue.Elem() } return r...
pb/converter.go
0.594434
0.452475
converter.go
starcoder
package MCTS import ( "math/rand" "sort" ) // Uct is an Upper Confidence Bound Tree search through game stats for an optimal move, given a starting game state. func Uct(state GameState, iterations uint, simulations uint, ucbC float64, playerId uint64, scorer Scorer) Move { // Find the best move given a fixed numb...
uct.go
0.736874
0.631395
uct.go
starcoder
package ldclient import ( "log" "os" "sync" ) // FeatureStore is an interface describing a structure that maintains the live collection of features and related objects. // It is used by LaunchDarkly when streaming mode is enabled, and stores data returned // by the streaming API. Custom FeatureStore implementation...
vendor/gopkg.in/launchdarkly/go-client.v4/feature_store.go
0.672654
0.41253
feature_store.go
starcoder
package longpalsubstr // Don't want to convert to float64, so let's avoid using math.Min. // Instead, we'll create our own min() that will return lowest value between two integers. func min(x, y int) int { if x < y { return x } else { return y } } // Return an output similiar to Python's enumerate(). // Return...
longpalsubstr/longpalsubstr.go
0.790449
0.58347
longpalsubstr.go
starcoder
package talibcdl type candleSetting struct { rangeType rangeType avgPeriod int factor float64 } var ( // real body is long when it's longer than the average of the 10 previous // candles' real body settingBodyLong = candleSetting{rangeTypeRealBody, 10, 1.0} // real body is very long when it's longer than 3 ...
global.go
0.502197
0.51251
global.go
starcoder