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 main // Animations, matching the animation interface, are added to the animator. // The animator ensures regular callbacks to Animate() ending with a call // to Wrap(). // Animation provides regular callbacks to motion updaters. // An animation is expected to run for a bit and then finish as opposed // to th...
animate.go
0.799951
0.530662
animate.go
starcoder
// Package arraylist implements the array list. // Structure is not concurrent safe. // Reference: https://en.wikipedia.org/wiki/Dynamic_array package arraylist import ( "errors" ) var ( // ErrIndex is returned when the index is out of the list ErrIndex = errors.New("index is out of the list") // ErrIndexOf is r...
list/arraylist/arraylist.go
0.759671
0.452596
arraylist.go
starcoder
package sync import ( "github.com/pkg/errors" ) // EnsureValid ensures that Cache's invariants are respected. func (c *Cache) EnsureValid() error { // A nil cache is considered valid (though obviously that requires using // the GetEntries accessor). if c == nil { return errors.New("nil cache") } // Technical...
pkg/sync/cache.go
0.713032
0.456834
cache.go
starcoder
package main import "math" const defaultSurvivalLevelOne = 30 const defaultSurvivalLevelBase = 1.5 // SurvivalDifficulty controls how the game difficulty scales with the player's score. type SurvivalDifficulty interface { // NumBugInit returns the number of bugs to initializer the game with. NumBugInit() int // ...
survival.go
0.576542
0.439928
survival.go
starcoder
package forGraphBLASGo func MatrixReduceBinaryOp[D any](w *Vector[D], mask *Vector[bool], accum, op BinaryOp[D, D, D], A *Matrix[D], desc Descriptor) error { nrows, ncols, err := A.Size() if err != nil { return err } isTran, err := desc.Is(Inp0, Tran) if err != nil { panic(err) } if isTran { nrows, ncols ...
api_Reduce.go
0.689515
0.667629
api_Reduce.go
starcoder
package packets import ( "encoding/binary" "fmt" ) type BodyMatrix struct { Point Point Residual float32 Rotation [9]float32 } func (b BodyMatrix) String() string { return fmt.Sprintf( "x:%v y:%v z:%v r:%v [[%v %v %v][%v %v %v][%v %v %v]]", b.Point.X, b.Point.Y, b.Point.Z, b.Residual, b.Rotation[0], b...
pkg/packets/objects.go
0.566738
0.44903
objects.go
starcoder
// Package day07 solves AoC 2021 day 7. package day07 import ( "math" "sort" "github.com/fis/aoc/glue" "github.com/fis/aoc/util" ) func init() { glue.RegisterSolver(2021, 7, glue.IntSolver(solve)) } func solve(input []int) ([]string, error) { _, p1 := align1MedianQS(input) _, p2 := align2Mean(input) return...
2021/day07/day07.go
0.616012
0.402363
day07.go
starcoder
package util import ( "compress/gzip" "github.com/itchio/go-brotli/enc" "io" "strings" ) type Recompression struct { Add CompressionType Remove CompressionType } type CompressionType int const ( CompressionTypeNone CompressionType = 0 CompressionTypeGzip CompressionType = 1 CompressionTypeBrotli Com...
util/compress.go
0.598899
0.446253
compress.go
starcoder
package spell import ( "fmt" "strings" "unicode" "github.com/PaulioRandall/scarlet-go/scarlet/value" ) type ( // Spell represents a builtin function. Spell func(env Runtime, in []value.Value, out *Output) // Output is a container for spell return arguments. Output struct { size int out []value.Value }...
scarlet/spell/book.go
0.709925
0.441613
book.go
starcoder
package main import ( "crypto/tls" "net" ) // Generate is the third step of the algorithm. Given the // observed round trips, we generate measurement targets and // execute those measurements so the probe has a benchmark. // URLMeasurement is a measurement of a given URL that // includes connectivity measurement f...
generate.go
0.586049
0.414425
generate.go
starcoder
package circuit import ( "encoding/json" "fmt" "math" "github.com/heustis/tsp-solver-go/model" ) // ClosestGreedy is an O(n^2) greedy algorithm that performs the following steps: // 1. builds a convex hull surrounding the points _(optimum for 2D, an approximation for 3D and graphs)_, // a. Compute the midpoi...
circuit/closestgreedy.go
0.761937
0.71768
closestgreedy.go
starcoder
package model import ( "github.com/alexhans1/certainty_poker/helpers" ) // MoneyInQuestionRound returns the amount that the player has in the pot of the current question round func (p *Player) MoneyInQuestionRound() int { var m int = 0 for _, b := range p.Game.CurrentQuestionRound().BettingRounds { for _, bet :=...
server/graph/model/player.go
0.699254
0.406509
player.go
starcoder
package fixtures // MessageA is type used as a dogma.Message in tests. type MessageA struct { Value interface{} } // Validate returns m.Value if it is an error. func (m MessageA) Validate() error { err, _ := m.Value.(error) return err } var ( // MessageA1 is an instance of MessageA with a distinct value. Messag...
fixtures/message.go
0.711732
0.52208
message.go
starcoder
package responses type Operation struct { D struct { Results []struct { Metadata struct { ID string `json:"id"` URI string `json:"uri"` Type string `json:"type"` Etag string `json:"etag"` } `json:"__metadata"` InspectionPlanGroup string `json:"InspectionPlanGroup"` BOOOpera...
SAP_API_Caller/responses/operation.go
0.510252
0.412353
operation.go
starcoder
package graph import "time" type DataMap map[string]interface{} /* Function specified by user to define the computational work of the node. The node function is called each time a complete set of node inputs is received. Args: in contains a mapping of the port name to the actual data. params contains a mapping ...
node.go
0.803019
0.659007
node.go
starcoder
package docs import ( "github.com/swaggo/swag" ) var doc = `{ "swagger": "2.0", "info": { "description": "This is a temporarily centralized directory/PKI/metrics API to allow us to get the other Nym node types running. Its functionality will eventually be folded into other parts of Nym.", "t...
docs/docs.go
0.672009
0.437643
docs.go
starcoder
package palettegen import ( "fmt" "math" "math/rand" "github.com/shasderias/ilysa/colorful" ) // The algorithm works in L*a*b* color space and converts to RGB in the end. // L* in [0..1], a* and b* in [-1..1] type lab_t struct { L, A, B float64 } type SoftPaletteSettings struct { // A function which can be u...
colorful/palettegen/soft_palettegen.go
0.810254
0.546012
soft_palettegen.go
starcoder
package pulse import ( "fmt" "strings" "time" "github.com/insolar/insolar/network/consensus/common/longbits" ) const InvalidPulseEpoch uint32 = 0 const EphemeralPulseEpoch = InvalidPulseEpoch + 1 var _ DataReader = &Data{} type Data struct { PulseNumber Number DataExt } type DataExt struct { // ByteSize=4...
network/consensus/common/pulse/pulse_data.go
0.665737
0.4575
pulse_data.go
starcoder
package synth // Z-order curve utility methods. A z-order number represents a single value // of a global x,y positioning. The number of bits in the z-order number // indicate the zoom level. Also known as Morton codes. // https://en.wikipedia.org/wiki/Z-order_curve // https://fgiesen.wordpress.com/2009/12/13...
synth/zorder.go
0.778144
0.572723
zorder.go
starcoder
package rtp /** This class is used by the transmission component to store the incoming RTP and RTCP data in. */ type RawPacket struct { packetdata []byte receivetime *RTPTime senderaddress Address isrtp bool } /** Creates an instance which stores data from \c data with length \c datalen. * Creates ...
rtp/rawpacket.go
0.712332
0.440409
rawpacket.go
starcoder
package physics import ( "encoding/gob" "io" "math" "github.com/egonelbre/exp/bit" ) const ( HistorySize = 16 UnitsPerMeter = 512 UnitsPerQuat = 1024 PositionUnit = 1.0 / UnitsPerMeter QuatUnit = 1.0 / UnitsPerQuat ) type State struct { History [HistorySize]*Frame FrameIndex int } type Frame s...
physicscompress2/physics/state.go
0.741768
0.427755
state.go
starcoder
package hbook import ( "errors" "sort" ) // Indices for the under- and over-flow 1-dim bins. const ( UnderflowBin1D = -1 OverflowBin1D = -2 ) var ( errInvalidXAxis = errors.New("hbook: invalid X-axis limits") errEmptyXAxis = errors.New("hbook: X-axis with zero bins") errShortXAxis = errors.New("hb...
hbook/binning1d.go
0.606732
0.484014
binning1d.go
starcoder
package assertions import ( "fmt" "github.com/particle-iot/particle-cli-wrapper/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers" ) // ShouldBeGreaterThan receives exactly two parameters and ensures that the first is greater than the second. func ShouldBeGreaterThan(actual interface{...
Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go
0.832577
0.748076
quantity.go
starcoder
package learning import ( "github.com/amirblum/SynergyAI/model" ) type DeltaCalcer interface { CalcDelta(float64) (float64, bool) } // Just returns the difference type SimpleDelta struct { eta float64 } func CreateSimpleDelta(eta float64) *SimpleDelta { return &SimpleDelta{eta} } func (delta *SimpleDelta) Calc...
learning/reinforcementLearning.go
0.775222
0.598547
reinforcementLearning.go
starcoder
package flat import ( "go-simulate-a-city/common/commonopengl" "time" "go-simulate-a-city/sim/config" "go-simulate-a-city/sim/core/gamegrid" "go-simulate-a-city/sim/input" "github.com/go-gl/glfw/v3.2/glfw" "github.com/go-gl/mathgl/mgl32" ) type Camera struct { mouseMoves chan mgl32.Vec2 mouseScrolls ...
sim/ui/flat/camera.go
0.613121
0.503784
camera.go
starcoder
// Package ristretto wraps "github.com/gtank/ristretto255" and exposes a simple prime-order group API with hash-to-curve. package ristretto import ( "crypto" "github.com/gtank/ristretto255" "github.com/bytemare/crypto/group/hash2curve" "github.com/bytemare/crypto/group/internal" ) const ( ristrettoInputLength...
group/ristretto/ristretto.go
0.880938
0.408926
ristretto.go
starcoder
package bls import ( "crypto/cipher" "crypto/sha256" "encoding/hex" "io" "github.com/drand/kyber" "github.com/drand/kyber/group/mod" ) var domainG2 = [8]byte{2, 2, 2, 2, 2, 2, 2, 2} // KyberG2 is a kyber.Point holding a G2 point on BLS12-381 curve type KyberG2 struct { p *PointG2 } func nullKyberG2() *Kyber...
vendor/github.com/drand/bls12-381/kyber_g2.go
0.683314
0.572842
kyber_g2.go
starcoder
package generator var pairIndexes = [][2]uint8{ {0, 1}, {0, 2}, {0, 3}, {0, 6}, {1, 2}, {1, 4}, {1, 7}, {2, 5}, {2, 8}, {3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 7}, {5, 8}, {6, 7}, {6, 8}, {7, 8}, } // exocet removes candidates. When 2 of the 3 cells in a box-line intersection together contain 3 or 4 can...
generator/exocet.go
0.59749
0.561034
exocet.go
starcoder
package indicators import ( "errors" "github.com/thetruetrade/gotrade" ) // A Plus Directional Indicator (PlusDi), no storage, for use in other indicators type PlusDiWithoutStorage struct { *baseIndicatorWithFloatBounds // private variables periodCounter int previousHigh float64 previousLow flo...
indicators/plusdi.go
0.669529
0.457076
plusdi.go
starcoder
package fiat import ( "context" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "time" "github.com/shopspring/decimal" ) const ( // coinCapHistoryAPI is the endpoint we hit for historical price data. coinCapHistoryAPI = "https://api.coincap.io/v2/assets/bitcoin/history" // coinCapDefaultCurrency is...
fiat/coincap_api.go
0.664758
0.422207
coincap_api.go
starcoder
package rapid type ( Pointer uint32 EntryPoint struct { Head Pointer Tail Pointer } Iterator[T any] struct { Ptr Pointer PrevPtr Pointer NextPtr Pointer Data T } ) func (this *Iterator[T]) Reset() { this.Ptr = 0 this.NextPtr = 0 } type Rapid[T any] struct { Length int Serial uin...
rapid/rapid.go
0.50952
0.5169
rapid.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // PlannerRoster type PlannerRoster struct { Entity // Retrieves the members of the plannerRoster. members []PlannerRosterMemberable // Retrieves ...
models/planner_roster.go
0.648911
0.431285
planner_roster.go
starcoder
// this file was take from https://github.com/prometheus/alertmanager/pull/2393 package timeinterval import ( "errors" "fmt" "regexp" "strconv" "strings" "time" ) // TimeInterval describes intervals of time. ContainsTime will tell you if a golang time is contained // within the interval. type TimeInterval str...
timeinterval/timeinterval.go
0.788502
0.468426
timeinterval.go
starcoder
package extract import ( "bufio" "strconv" "strings" "github.com/pkg/errors" "github.com/gvso/ddjj/parser/declaration" ) var stateTwoLines = []string{ "EXPLOTACION", "TERRENO SIN", "EDIFICACIONES", "EDIFICACION PARA", "ADJUDICACION SEGUN", } var totalState int64 var stateItemNumber int var skipState = ...
parser/extract/state.go
0.514888
0.543469
state.go
starcoder
package command import ( "encoding/json" "fmt" "testing" "github.com/infracloudio/botkube/pkg/execute" "github.com/infracloudio/botkube/test/e2e/env" "github.com/nlopes/slack" "github.com/stretchr/testify/assert" ) type kubectlCommand struct { command string expected string channel string } type contex...
test/e2e/command/kubectl.go
0.624523
0.653182
kubectl.go
starcoder
package build import ( "flag" "os" "github.com/mmcloughlin/avo/attr" "github.com/mmcloughlin/avo/buildtags" "github.com/mmcloughlin/avo/gotypes" "github.com/mmcloughlin/avo/operand" "github.com/mmcloughlin/avo/reg" ) // ctx provides a global build context. var ctx = NewContext() // TEXT starts building a ne...
build/global.go
0.520984
0.442275
global.go
starcoder
package sarama import ( "hash" "hash/fnv" "math/rand" "time" ) // Partitioner is anything that, given a Kafka message and a number of partitions indexed [0...numPartitions-1], // decides to which partition to send the message. RandomPartitioner, RoundRobinPartitioner and HashPartitioner are provided // as simple ...
vendor/github.com/Shopify/sarama/partitioner.go
0.732305
0.415432
partitioner.go
starcoder
package constant import ( "fmt" "github.com/umaumax/llvm/ir/types" ) // --- [ Conversion expressions ] ---------------------------------------------- // ~~~ [ trunc ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ExprTrunc is an LLVM IR trunc expression. type ExprTrunc struct { // Value bef...
ir/constant/expr_conversion.go
0.810966
0.457803
expr_conversion.go
starcoder
package data import ( "fmt" "io/ioutil" ) // A Segment is a block of memory divided into uint8s. type Segment struct { Mem []uint8 smap *SoftMap } type SegmentReader interface { UseReadSegment(*Segment) } type SegmentWriter interface { UseWriteSegment(*Segment) } // A Getter can return a byte from a given a...
pkg/data/segment.go
0.800887
0.463748
segment.go
starcoder
package nn import ( "github.com/nlpodyssey/spago/pkg/ml/ag" "reflect" ) // ProcessingMode regulates the different usage of some operations (e.g. Dropout, BatchNorm, etc.) inside a Processor, // depending on whether you're doing training or inference. // Failing to set the right mode will yield inconsistent inferen...
pkg/ml/nn/processor.go
0.824321
0.521776
processor.go
starcoder
package showdown import ( "github.com/JohnnyS318/RoyalAfgInGo/services/poker/models" ) //rankSpecificHand generates a rank identification number for 5 card array out of the 7 cards. func rankSpecificHand(cards []models.Card) int { // 1 Byte Number: // 4 MSB: Describe Hand State (0: High Card - 8: Straight Flush) ...
services/poker/showdown/rankHand.go
0.562417
0.437343
rankHand.go
starcoder
// Copyright 2021 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. package pkgbits import ( "bytes" "crypto/md5" "encoding/binary" "go/constant" "io" "math/big" "runtime" ) // A PkgEncoder provides methods for encodin...
src/internal/pkgbits/encoder.go
0.681303
0.421611
encoder.go
starcoder
package longbits import ( "math/bits" ) func NewBitBuilder(expectedLen int) BitBuilder { if expectedLen == 0 { return BitBuilder{} } return BitBuilder{bytes: make([]byte, 0, expectedLen)} } type BitBuilder struct { bytes []byte accumulator uint16 } func (p BitBuilder) IsZero() bool { return p.accumu...
longbits/bit_builder.go
0.565059
0.430147
bit_builder.go
starcoder
package errors import "errors" // IsUnavailable determines if err is an error which indicates a unavailable error. // It supports wrapped errors. func IsUnavailable(err error) bool { if se := new(Error); errors.As(err, &se) { return se.Code == 14 } return false } // IsDataLoss determines if err is an error whic...
errors/code.go
0.776199
0.429489
code.go
starcoder
package parse import ( "text/template/parse" "github.com/powerpuffpenguin/goja" ) func (f *factory) register() { f.Set(`IsEmptyTree`, parse.IsEmptyTree) f.Set(`Parse`, parse.Parse) f.Set(`NewIdentifier`, parse.NewIdentifier) f.Set(`Mode`, Mode) f.Accessor(`ParseComments`, f.getParseComments, nil) f.Accessor...
stdgo/text/template/parse/register.go
0.50293
0.44565
register.go
starcoder
package googlemaps import ( //"../common" "github.com/mitroadmaps/gomapinfer/common" "math" ) const ORIGIN_SHIFT = 2 * math.Pi * 6378137 / 2.0 // convert latitude/longitude to Spherical Mercator EPSG:900913 // source: http://gis.stackexchange.com/questions/46729/corner-coordinates-of-google-static-map-tile func ...
googlemaps/coords.go
0.767777
0.479626
coords.go
starcoder
package optional import "time" /* Bool map functions */ // Map applies mapping function on optional value if it presents func (b Bool) Map(f func(bool) bool) Bool { if f == nil || !b.IsPresent() { return Bool{} } return OfBool(f(b.value)) } // MapToInt applies mapping function on optional value if it prese...
map.go
0.756627
0.455986
map.go
starcoder
package twodimensionpacking type Point struct { X int Y int } func PointNew(x, y int) *Point { return &Point{x, y} } type Line struct { P1, P2 *Point } func LineNew(p1, p2 *Point) *Line { return &Line{p1, p2} } // VerticalIntersect checks if the two horizontal lines intersect in the vertical // direction, an...
twodimensionpacking/type.go
0.901833
0.500183
type.go
starcoder
package bot import ( "math/rand" "time" "github.com/beefsack/go-astar" "github.com/chingkamhing/grpc-game-example/pkg/backend" "github.com/google/uuid" ) // bot controls a player in the game. type bot struct { playerID uuid.UUID } // Bots controls all bots added to a game. type Bots struct { bots []*bot gam...
pkg/bot/bot.go
0.669421
0.470128
bot.go
starcoder
package nats import ( "errors" "fmt" "time" natsgo "github.com/nats-io/nats.go" "github.com/simpleiot/simpleiot/data" ) // SendNodePointCreate sends a node point using the nats protocol and // creates the node if it does not already exist func SendNodePointCreate(nc *natsgo.Conn, nodeID string, point data.Point...
nats/point.go
0.61555
0.449211
point.go
starcoder
package ring import ( "math" "math/bits" "unsafe" ) // BasisExtender stores the necessary parameters for RNS basis extension. // The used algorithm is from https://eprint.iacr.org/2018/117.pdf. type BasisExtender struct { ringQ *Ring ringP *Ring paramsQtoP []modupParams paramsPto...
ring/ring_basis_extension.go
0.709321
0.407039
ring_basis_extension.go
starcoder
package ilium type RadianceMeter struct { description string ray Ray sampleCount int radiometer Radiometer } func MakeRadianceMeter( config map[string]interface{}, shapes []Shape) *RadianceMeter { description := config["description"].(string) if len(shapes) != 1 { panic("Radiance meter must have exa...
ilium/radiance_meter.go
0.855761
0.432483
radiance_meter.go
starcoder
package core import ( "bytes" "crypto/rand" "errors" "fmt" "io/ioutil" "log" "strconv" "strings" ) const datasetSeparator = "," // Dataset struct represents a dataset object. type Dataset struct { id string path string header []string data []DatasetTuple } // NewDataset is the constructor for th...
core/dataset.go
0.714827
0.401658
dataset.go
starcoder
package origins // Buffer holds a slice of facts. The buffer dynamically grows as facts // are written to it. The position is maintained across reads. type Buffer struct { buf Facts // Contents are buf[off : len(buf)] off int } // grow grows the buffer to guarantee space for n more facts. // It returns the index w...
buffer.go
0.804367
0.576542
buffer.go
starcoder
<tutorial> Getting started example of using 51Degrees device detection. The example shows how to: <ol> <li>Instantiate the 51Degrees device detection provider. <p><pre class="prettyprint lang-go"> var provider = FiftyOneDegreesPatternV3.NewProvider(dataFile) </pre></p> <li>Produce a match for a single HTTP User-Agent h...
StronglyTyped.go
0.576661
0.556339
StronglyTyped.go
starcoder
package assert import ( "testing" "github.com/ppapapetrou76/go-testing/internal/pkg/values" ) // AssertableInt is the assertable structure for int values. type AssertableInt struct { t *testing.T actual values.IntValue } // ThatInt returns an AssertableInt structure initialized with the test reference and ...
assert/int.go
0.830113
0.834677
int.go
starcoder
package types import ( "sort" "github.com/attic-labs/noms/go/d" ) func MakePrimitiveType(k NomsKind) *Type { switch k { case BoolKind: return BoolType case NumberKind: return NumberType case StringKind: return StringType case BlobKind: return BlobType case ValueKind: return ValueType case TypeKin...
go/types/make_type.go
0.617628
0.557002
make_type.go
starcoder
package taxjar // Rate defines the returned object for rate requests type Rate struct { Zip string `json:"zip"` State string `json:"state"` StateRate float64 `json:"state_rate,string"` County string `json:"county"` CountyRate float64 `json...
rate.go
0.806052
0.417925
rate.go
starcoder
package gist import ( "fmt" "image" "image/color" "github.com/goki/ki/kit" "github.com/goki/mat32" "github.com/srwiley/rasterx" ) // Color defines a standard color object for GUI use, with RGBA values, and // all the usual necessary conversion functions to / from names, strings, etc // ColorSpec fully speci...
gist/colorspec.go
0.772187
0.411347
colorspec.go
starcoder
package executetest import ( "math" "sort" "testing" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/influxdata/flux" "github.com/influxdata/flux/execute" "github.com/influxdata/flux/plan" "gonum.org/v1/gonum/floats" ) // Two floating point values are considered // equal if...
execute/executetest/transformation.go
0.605333
0.422862
transformation.go
starcoder
package utils import "time" // - a < b // + a > b // 0 a == b type Comparator func(a, b interface{}) int func StringComparator(a, b interface{}) int { s1 := a.(string) s2 := b.(string) // 获取遍历长度 min := len(s2) if len(s1) < len(s2) { min = len(s1) } diff := 0 for i := 0; i < min && diff == 0; i++ { diff ...
estl/utils/comparator.go
0.518302
0.606964
comparator.go
starcoder
package bzip2 // moveToFrontDecoder implements a move-to-front list. Such a list is an // efficient way to transform a string with repeating elements into one with // many small valued numbers, which is suitable for entropy encoding. It works // by starting with an initial list of symbols and references symbols by th...
src/pkg/compress/bzip2/move_to_front.go
0.816443
0.547222
move_to_front.go
starcoder
package ipv4cidr import ( "errors" "regexp" "strconv" "strings" "github.com/microsoft/go-cidr-manager/ipv4cidr/consts" "github.com/microsoft/go-cidr-manager/ipv4cidr/utils" ) // IPv4CIDR models an IPv4 CIDR range. // @field ip uint32: Holds the IP address // @field mask uint8: Holds the CIDR mask // @field ne...
ipv4cidr/ipv4cidr.go
0.705176
0.450178
ipv4cidr.go
starcoder
package main import ( "bufio" "fmt" "log" "os" "strconv" ) type Coordinate struct { y, x int } // DFS, doesn't scale func Day15_DFS(input [][]int) int { startCoordinate := Coordinate{0, 0} // Create already traversed coordinate map traversedCoordinates := make(map[Coordinate]bool) totalSums := make(map[i...
2021/day15/day15.go
0.729905
0.51562
day15.go
starcoder
package algebra import "fmt" const sqrt2 = 1.414213562373095 // QR2 implements numbers in the algebraic number field ℚ(√2) (the rationals // adjoined with √2). ℚ(√2) = {(a + b√2)/c : a,b,c ∈ ℤ}. type QR2 struct {} var ( // ℚ(√2) is a field (over triples of ints). _ Field[[3]int] = QR2{} // Quaternions over ℚ(√2)...
algebra/qr2.go
0.776114
0.657126
qr2.go
starcoder
package graph import "fmt" // Graph implements a basic, non directed graph. type Graph struct { x, y []float64 // nodes coords legend []string // node legends links map[struct{ x, y int }]bool // edges, encoded with i<j } // NewGraph creates a new, empty Graph. func NewGrap...
graph/graph.go
0.7773
0.457137
graph.go
starcoder
package datadog import ( "encoding/json" ) // UsageCIVisibilityHour CI visibility usage in a given hour. type UsageCIVisibilityHour struct { // The number of spans for pipelines in the queried hour. CiPipelineIndexedSpans *int32 `json:"ci_pipeline_indexed_spans,omitempty"` // The number of spans for tests in the...
api/v1/datadog/model_usage_ci_visibility_hour.go
0.709523
0.415788
model_usage_ci_visibility_hour.go
starcoder
package crypto import ( "crypto/subtle" "fmt" C25519 "github.com/incognitochain/go-incognito-sdk-v2/crypto/curve25519" ) // Point represents an elliptic curve point. It only needs 32 bytes to represent a point. type Point struct { key C25519.Key } // RandomPoint returns a random Point on the elliptic curve. fun...
crypto/point.go
0.868813
0.508422
point.go
starcoder
package crossover import ( in "github.com/RevelesD/GoBasicGA/algorithm/InitialPopulation" "github.com/RevelesD/GoBasicGA/lib" "math/rand" ) /** Note this version of the AGT is going to differ slightly from the one studied on class, this is because it's not clear if elitism happens before or after the crossover...
algorithm/crossover/crossover.go
0.665845
0.476762
crossover.go
starcoder
package parser // line parsers are dispatch calls that parse a single unit of text into a // Node object which contains the whole statement. Dockerfiles have varied // (but not usually unique, see ONBUILD for a unique example) parsing rules // per-command, and these unify the processing in a way that makes it // manag...
specfile/parser/line_parsers.go
0.637821
0.40645
line_parsers.go
starcoder
package store import ( "time" "github.com/Semior001/timetype" ) // Location describes a room or auditory where the ClassDescription is held type Location string // EducationalProgram describes a study level of students type EducationalProgram string // Basic educational levels const ( Bachelor EducationalProgra...
backend/app/store/uni.go
0.65379
0.417034
uni.go
starcoder
package goequals import ( "reflect" ) func Equals(v1, v2 interface{}) bool { switch v := v1.(type) { case int: return equalsInt(int64(v), v2) case int8: return equalsInt(int64(v), v2) case int16: return equalsInt(int64(v), v2) case int32: return equalsInt(int64(v), v2) case int64: return equalsInt(in...
goequals.go
0.532911
0.484136
goequals.go
starcoder
package encoding import ( "crypto/rand" "github.com/OpenWhiteBox/primitives/matrix" ) // EquivalentBytes returns true if two Byte encodings are identical and false if not. func EquivalentBytes(a, b Byte) bool { for x := 0; x < 256; x++ { if a.Encode(byte(x)) != b.Encode(byte(x)) { return false } } retur...
encoding/decompose.go
0.785267
0.539044
decompose.go
starcoder
package iso20022 // Amount of money for which goods or services are offered, sold, or bought. type UnitPrice10 struct { // Type and information about a price. Type *TypeOfPrice10Code `xml:"Tp"` // Type and information about a price. ExtendedType *Extended350Code `xml:"XtndedTp"` // Value of the price, eg, as a...
UnitPrice10.go
0.800419
0.471527
UnitPrice10.go
starcoder
package kurobako import ( "encoding/json" "fmt" "math" ) func isFinite(v float64) bool { return !(math.IsInf(v, 0) || math.IsNaN(v)) } // ContinuousRange represents a numerical continuous range. type ContinuousRange struct { // Low is the lower bound of the range (inclusive). Low float64 `json:"low"` // High...
range.go
0.828384
0.634345
range.go
starcoder
package components import ( "sync" "github.com/go-gl/mathgl/mgl32" ) const ( // TypeTransform represents a transform component's type. TypeTransform = "transform" ) // Transform represents the world position of an entity. type Transform interface { Component // Set sets the transform to a specific matrix. Se...
components/transform.go
0.843412
0.72964
transform.go
starcoder
package text import ( "fmt" "time" "github.com/antonmedv/expr" "github.com/flanksource/commons/duration" ) func MakeExpressionEnvs(envs map[string]interface{}) map[string]interface{} { for name, funcMap := range GetTemplateFuncs() { envs[name] = funcMap } envs["humanizeDuration"] = HumanizeDuration envs["S...
text/expressions.go
0.605799
0.514095
expressions.go
starcoder
package base import ( "time" ) const ( DATETIME_FORMAT = "2006-01-02 15:04:05" DATE_FORMAT = "2006-01-02" TIME_FORMAT = "15:04:05" Day = time.Hour * 24 DaySec = 24 * 3600 ) func Format(t time.Time, layout string) string { return t.Format(layout) } func FormatDateTime(t time.Time) string { return t...
base/systime.go
0.675872
0.411584
systime.go
starcoder
// Package numbers implements various numerical functions. package numbers import ( "image" "math" ) // RoundToNonZeroPlaces rounds the float up, so that it has at least the provided // number of non-zero decimal places. // Returns the rounded float and the number of leading decimal places that // are zero. Return...
internal/numbers/numbers.go
0.873424
0.725308
numbers.go
starcoder
package utils import ( "strings" "unicode" "unicode/utf8" "unsafe" ) //EmptySpace const EmptySpace = " " //EmptyString const EmptyString = "" //分隔符 const Spliter = "/" /** * Tokenize the given {@code String} into a {@code String} array via a * {@link StringTokenizer}. * <p>The given {@code delimiters} string can co...
utils/string_util.go
0.70028
0.401013
string_util.go
starcoder
package weekendraytracer import ( "math" "math/rand" "github.com/go-gl/mathgl/mgl64" ) // Material describes how light reflects off a surface type Material interface { // Scatter describes the surface's response to the ray rIn, // at the intersection point given in hit. // Returns: whether the ray is scattered...
material.go
0.828419
0.614568
material.go
starcoder
package model func predict2(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[6] < 0.0760708675) || (features[6] == -1) { ...
examples/xgboost/XGBRegressor/booster2.go
0.537527
0.484746
booster2.go
starcoder
package inputsample import ( "bufio" "fmt" "io" "os" "strconv" "github.com/pbanos/botanic/feature" "github.com/pbanos/botanic/set" ) /* ReadSample represents a sample whose feature values are retrieved from a reader. A feature value will be requested using a FeatureValueRequester before reading it. */ type re...
set/inputsample/inputsample.go
0.612078
0.517388
inputsample.go
starcoder
package filters import ( "math" "github.com/mattetti/audio/dsp/windows" ) // Sinc represents a sinc function // The sinc function also called the "sampling function," is a function that // arises frequently in signal processing and the theory of Fourier transforms. // The full name of the function is "sine cardina...
dsp/filters/sinc.go
0.832169
0.434641
sinc.go
starcoder
package dendrolog // TreeRenderer provides a type which print arbitrary trees to ASCII-like text. type TreeRenderer struct { main stringBlock collectionResult *collected } type inputNode interface { Children() []inputNode } type collected struct { current interface{} children []*collected } // CollectFromTre...
treeRenderer.go
0.847148
0.500183
treeRenderer.go
starcoder
package math import "math" type Vector3 struct { X, Y, Z float32 } func NewVector3(x, y, z float32) *Vector3 { return &Vector3{X: x, Y: y, Z: z} } func (v *Vector3) Add(x, y, z float32) *Vector3 { return NewVector3(v.X+x, v.Y+y, v.Z+z) } func (v *Vector3) AddFromVector3(vector3 *Vector3) *Vector3 { return NewV...
pkg/math/vector3.go
0.860867
0.825976
vector3.go
starcoder
package keras2go /** * Element-wise sum of several tensors. * * :param output: output tensor. * :param num_tensors: number of tensors being summed. * :param ...: variadic. Tensors to be summed. */ func k2c_add(output *K2c_tensor, inputList ...*K2c_tensor) { output.fillFloat64(0) for _, input := range inputList { f...
merge_layers.go
0.812979
0.640917
merge_layers.go
starcoder
package mop import ( `sort` `strconv` `strings` ) // Sorter gets called to sort stock quotes by one of the columns. The // setup is rather lengthy; there should probably be more concise way // that uses reflection and avoids hardcoding the column names. type Sorter struct { profile *Profile // Pointer to where...
sorter.go
0.515864
0.405096
sorter.go
starcoder
package core //Polygon - Closed Chain Polyline type Polygon []Line // GeomType - Describes geometry type func (Polygon) geomType() string { return "polygon" } // CreatePolygonFromPoints - Creates a Polygon from a slice of Points func CreatePolygonFromPoints(points []Point) Polygon { var p Polygon for i, pt := ran...
core/Polygon.go
0.827689
0.565839
Polygon.go
starcoder
package datatype type DataTypes int const UndefinedDataType DataTypes = 0x0001 const ElementDataType DataTypes = 0x1000 const PrimitiveDataType = ElementDataType + 0x0200 const ComplexDataType = ElementDataType + 0x0400 const ResourceDataType DataTypes = 0x2000 const ( BooleanDataType = iota + PrimitiveDataType ...
datatype/data_type.go
0.620392
0.716851
data_type.go
starcoder
package sync3 import "math" type SliceRanges [][2]int64 func (r SliceRanges) Valid() bool { for _, sr := range r { // always goes from start to end if sr[1] < sr[0] { return false } if sr[0] < 0 { return false } } return true } // Inside returns true if i is inside the range func (r SliceRanges) ...
sync3/range.go
0.675122
0.428712
range.go
starcoder
package similarities import ( "fmt" "github.com/jtejido/golucene/core/search" "math" ) /** * TwoStageLM is a class for ranking documents that explicitly captures the different influences of the query and document * collection on the optimal settings of retrieval parameters. * It involves two steps. Estimate a d...
core/search/similarities/lmTwoStage.go
0.884189
0.473718
lmTwoStage.go
starcoder
package data import ( "github.com/wardlem/graphlite/util" ) const ( nilEdge = "attempt to operate on a nil edge" ) const edgeDataSize = 22 type Edge struct { Id uint32 // The Id of the Edge label uint16 // The Id of the Label for the Edge from uint32 // The Id of the origin Vertex of the ...
data/edge.go
0.605916
0.519765
edge.go
starcoder
package set // BitSet data structure type BitSet struct { data []uint64 } // NewBitSet returns a pointer to new BitSet func NewBitSet(size int) *BitSet { b := &BitSet{ data: make([]uint64, size/8+1), } return b } // Clone returns a copy of a BitSet func (b *BitSet) Clone() *BitSet { t := &BitSet{} t.data = a...
set/bitset.go
0.772917
0.441071
bitset.go
starcoder
package n // Char wraps the Go rune providing a way to distinguish it from an int32 // where as a rune is indistinguishable from an int32. Provides convenience // methods on par with rapid development languages. type Char rune // // C is an alias to NewChar for brevity // func C(obj interface{}) *Str { // return New...
char.go
0.751283
0.480722
char.go
starcoder
package aestest import ( "log" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/inklabs/rangedb/pkg/crypto" "github.com/inklabs/rangedb/pkg/crypto/aes" ) const ( PlainText = "lorem ipsum" ValidAES256Base64Key = "<KEY> ValidAESGCMBase6...
pkg/crypto/aes/aestest/verify_aes_encryption.go
0.530966
0.402069
verify_aes_encryption.go
starcoder
package board import ( "sort" "strings" ) // PositionEvent describes the causes of a unit's position type PositionEvent int const ( // UnitPlaced unit added to the board at the beginning of the phase UnitPlaced PositionEvent = iota // TODO: decide better name for this // Held unit has been held by player Held ...
game/order/board/manager.go
0.568655
0.50293
manager.go
starcoder
package trie // This is an opaque wrapper type to abstract over a ternary search trie. type Trie struct { root *trieNode } type trieNode struct { val rune terminal bool left *trieNode right *trieNode next *trieNode } // Insert a key, which is a slice of rune's (chars). func (t *Trie) Insert(key []rune)...
pkg/trie/trie.go
0.772788
0.582283
trie.go
starcoder
package sort // partition return partition index of pivot func partition(data []int, low int, high int) int { pivot := data[high] partitionIndex := low for i := low; i < high; i++ { if data[i] <= pivot { data[i], data[partitionIndex] = data[partitionIndex], data[i] partitionIndex++ } } data[high], data[...
Go/sort/quick.go
0.779741
0.664826
quick.go
starcoder
package main import ( "encoding/binary" "github.com/gwaylib/errors" ) type AxpertWorkingStatus struct { data [20]byte data1 [20]byte } func ParseAxpertWorkingStatus(data, data1 []byte) (*AxpertWorkingStatus, error) { if len(data) < 20 { return nil, errors.New("need data len >= 20") } if len(data1) < 20 { ...
examples/blesh/axpert_working_status.go
0.686475
0.412353
axpert_working_status.go
starcoder