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 model import ( "encoding/json" "fmt" "go.etcd.io/bbolt" "reflect" "strconv" "strings" ) // Encapsulates all persistence operations for a particular data type represented by a struct. type table struct { bolt *bbolt.DB recordType reflect.Type name string bucketKey []byte idFiel...
model/table.go
0.666171
0.439868
table.go
starcoder
package v2dot0 import ( "encoding/json" "fmt" "testing" dtoErrorV2dot0 "github.com/edgexfoundry/edgex-go/internal/pkg/v2/application/dto/v2dot0/common/error" dtoV2dot0 "github.com/edgexfoundry/edgex-go/internal/pkg/v2/application/dto/v2dot0/common/metrics" "github.com/edgexfoundry/edgex-go/internal/pkg/v2/infra...
internal/pkg/v2/ui/http/acceptance/common/metrics/v2dot0/assert.go
0.564819
0.440951
assert.go
starcoder
package czml // Polyline is a line in the scene composed of multiple segments. // https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Polyline type Polyline struct { Show *bool `json:"show,omitempty"` Positions *PositionList `json:"positions"` ...
polyline.go
0.835685
0.415492
polyline.go
starcoder
package advent var _ Problem = &lanternFish{} type lanternFish struct { dailyProblem } func NewLanternFish() Problem { return &lanternFish{ dailyProblem{ day: 6, }, } } func (l *lanternFish) Solve() interface{} { input := l.GetInputLines() var results []int results = append(results, l.fishCount80(input...
internal/advent/day6.go
0.644896
0.505737
day6.go
starcoder
package internal import ( "math" "github.com/go-gl/mathgl/mgl32" ) const order = mgl32.ZXY func Clamp(value, min, max float64) float64 { return math.Max(min, math.Min(max, value)) } func Euler(eulers mgl32.Vec3) mgl32.Quat { switch order { case mgl32.ZXY: return mgl32.AnglesToQuat(mgl32.DegToRad(eulers.Z())...
gameplay/internal/quatutil.go
0.779364
0.781289
quatutil.go
starcoder
package is import ( "errors" "fmt" "reflect" "strings" "testing" "github.com/go-test/deep" ) // Is is provides helpers for writing tests. type Is func(cond bool, msg string, i ...interface{}) // Equal checks if the given values are equal func (is Is) Equal(v1, v2 interface{}, msg string, i ...interface{}) { ...
is.go
0.561215
0.400515
is.go
starcoder
package disruptor // Cursors should be a party of the same backing array to keep them as close together as possible: // https://news.ycombinator.com/item?id=7800825 type ( Wireup struct { capacity int64 groups [][]Consumer cursors []*Cursor // backing array keeps cursors (with padding) in contiguous memory ...
vendor/github.com/smartystreets-prototypes/go-disruptor/wireup.go
0.740644
0.41745
wireup.go
starcoder
package neptune import ( "strings" "sync" ) // batchProcessor defines a generic function type to process a batch and may return a result and an error. type batchProcessor = func(map[string]string) (map[string]string, error) // processInConcurrentBatches splits the provided items in batches and calls processBatch f...
neptune/utils.go
0.660172
0.420659
utils.go
starcoder
package osgb import ( "fmt" "math" ) const ( degreeInRadians = 180 / math.Pi radianInDegrees = 1 / degreeInRadians ) type direction string const ( north direction = "N" south direction = "S" east direction = "E" west direction = "W" ) // ETRS89Coordinate represents a coordinate position in // the ETRS89 ...
coordinates.go
0.853027
0.515498
coordinates.go
starcoder
package strings import ( "io" "unicode/utf8" "unsafe" ) // A Builder is used to efficiently build a string using Write methods. It // minimizes memory copying. The zero value is ready to use. Do not copy a non- // zero Builder. type Builder struct { addr *Builder // of receiver, to detect copies by value buf...
builder.go
0.518059
0.434101
builder.go
starcoder
package bst import ( "github.com/Kaiser925/algorithms4go/base" ) type node struct { key interface{} value interface{} left *node right *node n int //The total number of nodes in the subtree Rooted at this node. } // BST is a binary search tree. type BST struct { Root *node Comparator base.Compar...
tree/bst/bst.go
0.747155
0.419588
bst.go
starcoder
package birthday import ( "errors" "time" "github.com/hyperjiang/php" ) // Birthday is the birthday detail type Birthday struct { Date time.Time Year int Month time.Month Day int Age int Constellation string } // ParseFromTime parse birthday from given time fun...
birthday.go
0.704872
0.412234
birthday.go
starcoder
package platform import ( "context" "reflect" "strconv" "strings" "chromiumos/tast/errors" "chromiumos/tast/local/croshealthd" "chromiumos/tast/testing" ) func init() { testing.AddTest(&testing.Test{ Func: CrosHealthdProbeCPUInfo, Desc: "Check that we can probe cros_healthd for CPU info", Contacts: []...
src/chromiumos/tast/local/bundles/cros/platform/cros_healthd_probe_cpu_info.go
0.55929
0.405861
cros_healthd_probe_cpu_info.go
starcoder
package quantile const ( agentBufCap = 512 ) var agentConfig = Default() // An Agent sketch is an insert optimized version of the sketch for use in the // datadog-agent. type Agent struct { Sketch Sketch Buf []Key CountBuf []KeyCount } // IsEmpty returns true if the sketch is empty func (a *Agent) IsEmpt...
pkg/quantile/agent.go
0.6488
0.406626
agent.go
starcoder
package vaa import ( "bytes" "crypto/ecdsa" "encoding/binary" "encoding/hex" "fmt" "io" "strings" "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" ) type ( // VAA is a verifiable action approval of the Wormhole protocol VAA struct { // Version of the VAA schema ...
node/pkg/vaa/structs.go
0.580947
0.416559
structs.go
starcoder
package dirtrally import ( "bytes" "encoding/binary" "encoding/json" "github.com/grafana/grafana-plugin-sdk-go/backend/log" "github.com/grafana/grafana-plugin-sdk-go/data" "time" ) type TelemetryFrame struct { Time float32 LapTime float32 LapDistance float32 TotalDistance ...
pkg/dirtrally/packet.go
0.589126
0.419291
packet.go
starcoder
package transaction import ( "fmt" "math/big" "Chain3Go/lib/common/hexutil" "Chain3Go/lib/crypto" "Chain3Go/lib/log" ) type bytesBacked interface { Bytes() []byte } const ( // BloomByteLength represents the number of bytes used in a header log bloom. BloomByteLength = 256 // BloomBitLength represents the...
Chain3Go/lib/transaction/bloom9.go
0.793706
0.552359
bloom9.go
starcoder
package tsdbutil import ( "math" "github.com/prometheus/tsdb" ) // BufferedSeriesIterator wraps an iterator with a look-back buffer. type BufferedSeriesIterator struct { it tsdb.SeriesIterator buf *sampleRing lastTime int64 } // NewBuffer returns a new iterator that buffers the values within the time range /...
tsdbutil/buffer.go
0.826327
0.477311
buffer.go
starcoder
package delphix_dct_api import ( "encoding/json" "time" ) // DataPointByTimestampParameters struct for DataPointByTimestampParameters type DataPointByTimestampParameters struct { // The point in time from which to execute the operation. Mutually exclusive with timestamp_in_database_timezone. If the timestamp is n...
model_data_point_by_timestamp_parameters.go
0.82176
0.415551
model_data_point_by_timestamp_parameters.go
starcoder
package framework import pkgFramework "github.com/stackrox/rox/pkg/compliance/framework" // A Check is a single piece of logic executed as part of a compliance run. It usually corresponds to one or multiple // controls in a compliance standard. type Check interface { // ID returns an ID uniquely identifying a check....
central/compliance/framework/check.go
0.788583
0.507507
check.go
starcoder
package datadog import ( "encoding/json" ) // LogsRetentionAggSumUsage Object containing indexed logs usage aggregated across organizations and months for a retention period. type LogsRetentionAggSumUsage struct { // Total indexed logs for this retention period. LogsIndexedLogsUsageAggSum *int64 `json:"logs_index...
api/v1/datadog/model_logs_retention_agg_sum_usage.go
0.70912
0.421105
model_logs_retention_agg_sum_usage.go
starcoder
package canvas import ( "image" "fyne.io/fyne" ) // ImageFill defines the different type of ways an image can stretch to fill its space. type ImageFill int const ( // ImageFillStretch will scale the image to match the Size() values. // This is the default and does not maintain aspect ratio. ImageFillStretch Im...
canvas/image.go
0.810479
0.496704
image.go
starcoder
package benchmark import ( "reflect" "testing" ) func isBoolToInt32FuncCalibrated(supplier func() bool) bool { return isCalibrated(reflect.Bool, reflect.Int32, reflect.ValueOf(supplier).Pointer()) } func isIntToInt32FuncCalibrated(supplier func() int) bool { return isCalibrated(reflect.Int, reflect.Int32, reflec...
common/benchmark/05_to_int32_func.go
0.699254
0.804866
05_to_int32_func.go
starcoder
package goexpression import ( "math" ) type Floater interface { Float64() float64 } type expression struct { ast *TreeNode context map[string]interface{} } // Bug(zdebeer): functions is eval from right to left instead from left to right. func Eval(input string, context map[string]interface{}) float64 { nod...
eval.go
0.506347
0.476823
eval.go
starcoder
// Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Copyright ©1984, ©1987, ©1995 by <NAME> // Portions Copyright ©2017 The Gonum Authors. All rights reserved. package cephes import "math" // IgamI computes the inverse of the incomplete Gamma function. That is,...
mathext/internal/cephes/igami.go
0.725162
0.449211
igami.go
starcoder
package datebin import ( "time" ) // 设置一周的开始日期 func (this Datebin) SetWeekStartsAt(day string) Datebin { if this.IsInvalid() { return this } // 判断周几 switch day { case WeekMonday: this.weekStartAt = time.Monday case WeekTuesday: this.weekStartAt = ti...
pkg/lakego-pkg/go-datebin/datebin/set.go
0.581541
0.462716
set.go
starcoder
package async import ( "sort" "sync" ) // IterAsync executes the given function f up to n times concurrently. // Each call is done in a separate goroutine. On each iteration, the function f // will be called with a unique sequential index i such that the index can be // used to reference an element in an array or ...
pkg/util/async/async.go
0.703549
0.420957
async.go
starcoder
package processor import ( "reflect" "github.com/twitchscience/aws_utils/logger" ) var ( // CriticalPercentage is the percentage of events that a property must be seen in in order to be considered part of the schema for an event. CriticalPercentage = 0.0 // CriticalThreshold is the number of events of a specif...
schema_suggestor/processor/processor.go
0.71602
0.425725
processor.go
starcoder
package native import ( "reflect" "unsafe" "github.com/pkg/errors" . "gorgonia.org/tensor" ) func checkNativeSelectable(t *Dense, axis int, dt Dtype) error { if !t.IsNativelyAccessible() { return errors.New("Cannot select on non-natively accessible data") } if axis >= t.Shape().Dims() && !(t.IsScalar() && ...
native/iterator_native2.go
0.770119
0.444927
iterator_native2.go
starcoder
package iso20022 // Specifies the billing adjustments for a specific service. type BillingServiceAdjustment1 struct { // Identifies the type of adjustment. Type *ServiceAdjustmentType1Code `xml:"Tp"` // Free-form description and clarification of the adjustment. Description *Max140Text `xml:"Desc"` // Amount of...
BillingServiceAdjustment1.go
0.773644
0.427994
BillingServiceAdjustment1.go
starcoder
package config import ( "encoding/json" "os" temperature "github.com/turing-complete/temperature/analytic" ) // Config is a configuration of a problem. type Config struct { Inherit string // The system System System // The quantity of interest Quantity Quantity // The probability model Uncertainty Uncerta...
src/internal/config/main.go
0.750278
0.438966
main.go
starcoder
package function import ( "errors" "fmt" ) const ( _SRT_HEADER_SIZE = 4 * 256 // freqs ) // SRT Sorted Ranks Transform // Sorted Ranks Transform is typically used after a BWT to reduce the variance // of the data prior to entropy coding. type SRT struct { } // NewSRT creates a new instance of SRT func NewSRT() (...
function/SRT.go
0.796807
0.422445
SRT.go
starcoder
package tensor import ( "errors" "github.com/dereklstinson/gocunets/devices/gpu/nvidia/cudnn" gocudnn "github.com/dereklstinson/gocudnn" ) /* cudnnOpTensor from the cudnn sdk documentation This function implements the equation C = op ( alpha1[0] * A, alpha2[0] * B ) + beta[0] * C, given tensors A, B, and C and sc...
devices/gpu/nvidia/cudnn/tensor/ops.go
0.687945
0.652075
ops.go
starcoder
package main import ( "log" "runtime" "time" ) type Transaction struct { TxID string Address string InputTxID string Value uint } type TestData struct { Txs []Transaction } // Analyze a block of transactions from a Bitcoin family blockchain and, given 2 addresses, // find all transaction chains th...
bitcoin_transactions/bitcoin_transactions.go
0.645232
0.453322
bitcoin_transactions.go
starcoder
package parser import ( "strconv" "strings" "github.com/alecthomas/participle" "github.com/alecthomas/participle/lexer" "github.com/alecthomas/participle/lexer/stateful" ) var ( Lexer = stateful.MustSimple([]stateful.Rule{ {"Whitespace", `\s+`, nil}, {"Bool", `(?i)\b(TRUE|FALSE)\b`, nil}, {"Type", `(?i)\...
parser/parser.go
0.510008
0.416025
parser.go
starcoder
package vme import ( "fmt" "reflect" ) func BoolType() reflect.Type { return reflect.TypeOf(false) } func Int8Type() reflect.Type { return reflect.TypeOf(int8(0)) } func Int16Type() reflect.Type { return reflect.TypeOf(int16(0)) } func Int32Type() reflect.Type { return reflect.TypeOf(int32(0)) } func Int64Type(...
common/encoding/vme/type.go
0.617743
0.564158
type.go
starcoder
package iso20022 // Provides the details of the security pledge as collateral. type Collateral14 struct { // Provides the values of the security pledged as collateral. Valuation *SecuredCollateral2Choice `xml:"Valtn"` // Risk control measure applied to underlying collateral whereby the value of that underlying co...
Collateral14.go
0.708011
0.508056
Collateral14.go
starcoder
package shp // shapes var tet4, tet10 Shape // register shapes func init() { // tet4 tet4.Type = "tet4" tet4.Func = Tet4 tet4.FaceFunc = Tri3 tet4.BasicType = "tet4" tet4.FaceType = "tri3" tet4.Gndim = 3 tet4.Nverts = 4 tet4.VtkCode = VTK_TETRA tet4.FaceNverts = 3 tet4.FaceLocalV = [][]int{{0, 3, 2}, {0,...
shp/tets.go
0.568056
0.461441
tets.go
starcoder
package topojson import geojson "github.com/paulmach/go.geojson" func (t *Topology) ToGeoJSON() *geojson.FeatureCollection { fc := geojson.NewFeatureCollection() for _, obj := range t.Objects { switch obj.Type { case geojson.GeometryCollection: for _, geometry := range obj.Geometries { feat := geojson.N...
vendor/github.com/rubenv/topojson/geojson.go
0.648021
0.470615
geojson.go
starcoder
package main import ( "bytes" "encoding/binary" "fmt" "log" "unsafe" "github.com/lukeroth/gdal" ) type NdvSlab struct { RangeByBand [][2]float64 } func (self *NdvSlab) Empty() bool { return len(self.RangeByBand) == 0 } func contains_templated(interval [2]float64, p interface{}) bool { switch p.(type) { c...
ndv.go
0.58059
0.536252
ndv.go
starcoder
package iso20022 // Chain of parties involved in the settlement of a transaction, including receipts and deliveries, book transfers, treasury deals, or other activities, resulting in the movement of a security or amount of money from one account to another. type DeliveringPartiesAndAccount13 struct { // Party that s...
DeliveringPartiesAndAccount13.go
0.650134
0.431884
DeliveringPartiesAndAccount13.go
starcoder
Package srp Secure Remote Password protocol The principle interface provided by this package is the SRP type. The end aim of the caller is to to have an SRP server and SRP client arrive at the same Key. See the documentation for the SRP structure and its methods for the nitty gritty of use. BUG(jpg): This does not us...
doc.go
0.639286
0.831656
doc.go
starcoder
package webrtc import ( "fmt" "github.com/pion/ice" ) func supportedNetworkTypes() []NetworkType { return []NetworkType{ NetworkTypeUDP4, NetworkTypeUDP6, // NetworkTypeTCP4, // Not supported yet // NetworkTypeTCP6, // Not supported yet } } // NetworkType represents the type of network type NetworkType ...
networktype.go
0.620277
0.432723
networktype.go
starcoder
package datasetAPI import ( "encoding/json" "time" "github.com/globalsign/mgo/bson" "github.com/ONSdigital/dp-api-tests/testDataSetup/mongo" datasetAPI "github.com/ONSdigital/dp-dataset-api/models" ) var alert = mongo.Alert{ Date: "2017-12-10", Description: "A correction to an observation for males of...
publishing/datasetAPI/json.go
0.515864
0.504272
json.go
starcoder
package untyped import ( "github.com/liquidata-inc/dolt/go/libraries/doltcore/row" "github.com/liquidata-inc/dolt/go/libraries/doltcore/schema" "github.com/liquidata-inc/dolt/go/libraries/doltcore/table/typed" "github.com/liquidata-inc/dolt/go/store/types" ) // NewUntypedSchema takes an array of field names and ...
go/libraries/doltcore/table/untyped/untyped_rows.go
0.680772
0.443058
untyped_rows.go
starcoder
package ggrenderer import ( "unsafe" "github.com/EngoEngine/glm" "github.com/oyberntzen/gogame/ggdebug" ) const ( maxQuads uint32 = 10_000 maxVertices uint32 = maxQuads * 4 maxIndices uint32 = maxQuads * 6 maxTextureSlots uint32 = 32 ) var ( quadVertexArray VertexArray quadVertexBuffer Ver...
ggrenderer/renderer2D.go
0.588416
0.406096
renderer2D.go
starcoder
package phys import ( "fmt" "math" ) // Point represents a point in traditional Cartesian space. // X is the primary axis, Y is the secondary axis. // X>0 => right // X<0 => left // Y>0 => up // Y<0 => down type Point struct { X Meters Y Meters } func (p Point) String() string { return fmt.Sprintf("Poi...
goverdrive/phys/coord.go
0.756897
0.451085
coord.go
starcoder
package animagi import ( "errors" "reflect" ) const ( dstError = "dst must be settable" unsupportedTransformation = "could not transform to dst" ) type typeDescription struct { FieldType reflect.Type FieldValue reflect.Value } /* Transform will map the data from src into dst by calculating t...
animagi.go
0.61451
0.416025
animagi.go
starcoder
package main import "fmt" // Bus carries Passengers from A to B if they have a valid bus ticket. type Bus struct { Company BusCompany name string passengers Passengers stops []*BusStop currentStop int16 } // NewBus returns a new Bus with an empty passenger set. func NewBus(name string) Bus { ...
bus-service/bus.go
0.670608
0.442877
bus.go
starcoder
package mock import ( "fmt" "strconv" "strings" testing "github.com/mitchellh/go-testing-interface" "github.com/hashicorp/nomad/nomad/structs" "github.com/stretchr/testify/assert" ) // StateStore defines the methods required from state.StateStore but avoids a // circular dependency. type StateStore interface ...
vendor/github.com/hashicorp/nomad/nomad/mock/acl.go
0.714329
0.410756
acl.go
starcoder
package gaia import ( "fmt" "time" "github.com/globalsign/mgo/bson" "github.com/mitchellh/copystructure" "go.aporeto.io/elemental" ) // GraphEdgeDestinationTypeValue represents the possible values for attribute "destinationType". type GraphEdgeDestinationTypeValue string const ( // GraphEdgeDestinationTypeEx...
graphedge.go
0.773901
0.509215
graphedge.go
starcoder
package tree import ( "sort" "testing" . "github.com/stretchr/testify/assert" ) // VRaw holds the unsorted value for basic tree tests var VRaw = []interface{}{5, 3, 1, 4, 6, 2} // V holds the sorted value for basic tree tests var V = []interface{}{1, 2, 3, 4, 5, 6} // VLen is the length of V var VLen = len(V) ...
tree/treeTest.go
0.611846
0.683378
treeTest.go
starcoder
package math // CartesianToSpherical converts 3-dimensional cartesian coordinates (x,y,z) to // spherical coordinates with radius r, inclination theta, and azimuth phi. func CartesianToSpherical(coord Vec3) (r, theta, phi float32) { r = coord.Len() theta = Acos(coord[2] / r) phi = Atan2(coord[1], coord[0]) return ...
math/conv.go
0.907021
0.894283
conv.go
starcoder
package uitext // StarSep provides a 75 character star separator for terminal output const StarSep = "*****************************************************************" // DashSep provides a 75 character dash separator for terminal output const DashSep = "--------------------------------------------------------------...
internal/uitext/uitext.go
0.728652
0.446133
uitext.go
starcoder
package geo import ( "math" "github.com/edwindvinas/bleve/numeric" ) // GeoBits is the number of bits used for a single geo point // Currently this is 32bits for lon and 32bits for lat var GeoBits uint = 32 var minLon = -180.0 var minLat = -90.0 var geoTolerance = 1E-6 var lonScale = float64((uint64(0x1)<<GeoBit...
geo/geo.go
0.781164
0.54583
geo.go
starcoder
package levels import ( "math" mgl "github.com/go-gl/mathgl/mgl32" "github.com/inkyblackness/hacked/editor/graphics" "github.com/inkyblackness/hacked/editor/render" "github.com/inkyblackness/hacked/ss1/content/archive/level" "github.com/inkyblackness/hacked/ui/opengl" ) var mapTexturesVertexShaderSource = ` #...
editor/levels/MapTextures.go
0.727879
0.527195
MapTextures.go
starcoder
package cellular import ( "bytes" "encoding/base64" "encoding/json" //"fmt" "log" "math/rand" //"time" ) // Field represents a two-dimensional field of cells. type Field struct { s [][]uint8 w, h int } // Neighborhood represents the total color counts in the surrounding cells. func NewNeighborhood() map[...
cellular/special-cells.go
0.696268
0.415729
special-cells.go
starcoder
package eval import ( "math/big" "golang.org/x/xerrors" "github.com/mmcloughlin/ec3/efd/op3/ast" "github.com/mmcloughlin/ec3/internal/errutil" ) type Evaluator struct { state map[ast.Variable]*big.Int m *big.Int } // NewEvaluator builds an evaluator using arithmetic modulo m. func NewEvaluator(m *big.Int...
efd/op3/eval/eval.go
0.605682
0.441553
eval.go
starcoder
package neo4j import ( "fmt" "time" ) // Date represents a date value, without a time zone and time related components. type Date struct { epochDays int64 } // LocalTime represents a local time value. type LocalTime struct { nanosOfDay time.Duration } // OffsetTime represents a time value with a UTC offset. typ...
neo4j/temporaltypes.go
0.932476
0.516108
temporaltypes.go
starcoder
package trader // CurrencyInformation contains all the information relevant to a currency type CurrencyInformation struct { // Number is the iso 4217 number of the currency Number uint // Places is the number of places after decimal separator Places int // FullName is the full name of the currency FullName strin...
currency-list.go
0.695441
0.515437
currency-list.go
starcoder
package db type DBDescriptor struct { ID string `bson:"_id"` FirstObligation string `bson:first_obligation` TotalObligation string `bson:total_obligation` Duration string `bson:duration` InterestRate string `bson:interest_rate` PunitiveInterestRate string `bson:punitive_interest_rate` Frequency string `bson:fre...
db/DAL.go
0.655557
0.64225
DAL.go
starcoder
package sort import ( "github.com/howz97/algorithm/strings/alphabet" ) // Quick3 seems to be a faster string sorting algorithm than the sort.Strings method in the standard library func Quick3(strings []string) { quick3(strings, 0, len(strings)-1, 0) } func quick3(strings []string, lo, hi, depth int) { if lo+1 >= ...
strings/sort/quick3.go
0.553505
0.631552
quick3.go
starcoder
package engine // The orderbook currently uses the four following data structures to store engine // state in mongo // 1. Pricepoints set // 2. Pricepoints volume set // 3. Pricepoints hashes set // 4. Orders map // 1. The pricepoints set is an ordered set that store all pricepoints. // Keys: ~ pair addresses + side ...
engine/orderbook.go
0.638835
0.413714
orderbook.go
starcoder
package numberline import ( "errors" "log" "strconv" ) // Range data type type Range struct { LowerBound, UpperBound int } var ( errInvalidRange error = errors.New("error: invalid range limits") errInvalidValue error = errors.New("error: invalid value") ) // NewRange creates a new instance of type Range func ...
numberline/range.go
0.752377
0.476336
range.go
starcoder
package sliceutil import ( "errors" "reflect" ) // Filter func Filter(slice, function interface{}) interface{} { result, _ := filter(slice, function, false) return result } // FilterInPlace func FilterInPlace(slicePtr, function interface{}) { in := reflect.ValueOf(slicePtr) if in.Kind() != reflect.Ptr { pani...
sliceutil/sliceutil.go
0.591133
0.428054
sliceutil.go
starcoder
package slicez import ( "errors" "github.com/modfin/henry/compare" "github.com/modfin/henry/slicez/sort" "math/rand" "time" ) // Equal takes two slices of that is of the interface comparable. It returns true if they are of equal length and each // element in a[x] == b[x] for every element func Equal[A comparable...
slicez/slices.go
0.844729
0.519217
slices.go
starcoder
package openapi import ( "reflect" ) // setSchemaMax sets the given maximum to the appropriate // schema field based on the given type. func setSchemaMax(schema *Schema, max int, t reflect.Type) { if isNumber(t) { schema.Maximum = max } else if isString(t) { if max >= 0 { schema.MaxLength = max } } else ...
openapi/validation.go
0.697506
0.441432
validation.go
starcoder
package draw import ( "encoding/hex" "fmt" "image/color" "log" "math" "math/rand" "strconv" ) // RandomColorFromArrayWithFreq returns a random color from the given array. // It will return the first color with a specific frequency, // and all the other colors with the complementary frequency. func RandomColorF...
draw/tools.go
0.764628
0.527621
tools.go
starcoder
package neat import "math" // Represents a neural network type Network interface { // Activates the neural network using the inputs. Returns the ouput values. Activate(inputs []float64) (outputs []float64, err error) } type NeuronType byte const ( Bias NeuronType = iota + 1 // 1 Input ...
network.go
0.822546
0.637609
network.go
starcoder
package curves import ( "crypto/elliptic" crand "crypto/rand" "crypto/sha512" "fmt" "io" "math/big" "filippo.io/edwards25519" "github.com/btcsuite/btcd/btcec" "github.com/bwesterb/go-ristretto" "github.com/coinbase/kryptology/internal" "github.com/coinbase/kryptology/pkg/core" "github.com/coinbase/krypt...
pkg/core/curves/ec_scalar.go
0.670285
0.409339
ec_scalar.go
starcoder
package types import ( "bytes" "fmt" "io" "math" "strings" "reflect" "regexp" "github.com/lyraproj/pcore/px" "github.com/lyraproj/pcore/utils" ) type ( // String that is unconstrained stringType struct{} // String constrained to content vcStringType struct { stringType value string } // String ...
types/stringtype.go
0.610918
0.447581
stringtype.go
starcoder
package creature import ( "math" "github.com/karlek/reason/ui" "github.com/karlek/worc/area" "github.com/karlek/worc/coord" ) // DrawFOV draws a field of view around a creature as well as the creatures // memory of already explored areas. func (c Creature) DrawFOV(a *area.Area) { // Clear screen. ui.Clear() ...
creature/fov.go
0.577972
0.41484
fov.go
starcoder
package math3 import ( "fmt" "math" "regexp" "strconv" "github.com/golang/glog" "github.com/rydrman/three.go" ) type Color struct { R float64 G float64 B float64 } func NewColor() *Color { return &Color{ 1, 1, 1, } } func (color *Color) R32() float32 { return float32(color.R) } func (color *Colo...
math3/color.go
0.731922
0.458046
color.go
starcoder
package goroslib import ( "time" ) // TimeNow returns the current time. // It supports simulated clocks provided by ROS clock servers. func (n *Node) TimeNow() time.Time { if !n.simtimeEnabled { return time.Now() } n.simtimeMutex.RLock() defer n.simtimeMutex.RUnlock() return n.simtimeValue } // TimeSleepCh...
nodefuncstime.go
0.787768
0.448487
nodefuncstime.go
starcoder
package calendar /*title: Module State In this file, we'll implement `api.ModuleState`. A module's state will be written to and loaded from the file system and has interfaces to both the module's renderer and the Web Client. */ import ( "github.com/QuestScreen/api/comms" "github.com/QuestScreen/api/modules" "githu...
calendar/state.go
0.8415
0.648605
state.go
starcoder
package logic import ( "math" "time" "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model" ) // TODO: Split the estimator to have a separate estimator object for CPU and memory. // ResourceEstimator is a function from AggregateContainerState to // model.Resources, e.g. a prediction of resources neede...
vertical-pod-autoscaler/pkg/recommender/logic/estimator.go
0.668556
0.477311
estimator.go
starcoder
package graphics2d import "github.com/jphsd/graphics2d/util" // CurveStyle determines how the curve behaves relative to the path points. With Bezier, the // path will intersect the mid-point of each path step. With Catmul, the path will intersect // point. type CurveStyle int // Constants for curve styles. const ( ...
curveproc.go
0.756807
0.500793
curveproc.go
starcoder
package flate import ( "fmt" "math" "math/bits" "github.com/chronos-tachyon/assert" "github.com/chronos-tachyon/huffman" ) type tokenType byte const ( invalidToken tokenType = iota copyToken literalToken stopToken treeLenToken treeDupToken treeSZRToken treeLZRToken ) type token struct { literalOrLeng...
token.go
0.799912
0.493958
token.go
starcoder
package onshape import ( "encoding/json" ) // BTOrFilter167 struct for BTOrFilter167 type BTOrFilter167 struct { BTQueryFilter183 BtType *string `json:"btType,omitempty"` Operand1 *BTQueryFilter183 `json:"operand1,omitempty"` Operand2 *BTQueryFilter183 `json:"operand2,omitempty"` } // NewBTOrFilter167 instantia...
onshape/model_bt_or_filter_167.go
0.709523
0.441372
model_bt_or_filter_167.go
starcoder
package ft232h import ( "fmt" "math" "math/bits" ) // Pin defines the methods required for representing an FT232H port pin. type Pin interface { IsMPSSE() bool // true if DPin (port "D"), false if CPin (GPIO/port "C") Mask() uint8 // the bitmask used to address the pin, equal to 1<<Pos() Pos() uint ...
pin.go
0.632049
0.425665
pin.go
starcoder
package common import ( "fmt" "strconv" ) // ImportFeaturesForLinReg import linear regression features from file func ImportFeaturesForLinReg(fileRows [][]string) ([]*DataFeature, error) { if fileRows == nil { return nil, fmt.Errorf("empty file content") } // read the first row to get all features featureNu...
crypto/core/machine_learning/common/feature_import.go
0.575111
0.462898
feature_import.go
starcoder
package xpath import ( "errors" "strconv" "strings" ) // The XPath function list. func predicate(q query) func(NodeNavigator) bool { type Predicater interface { Test(NodeNavigator) bool } if p, ok := q.(Predicater); ok { return p.Test } return func(NodeNavigator) bool { return true } } // positionFunc i...
vendor/github.com/antchfx/xpath/func.go
0.68215
0.40157
func.go
starcoder
package chess // PieceKind is the type representing for the pieces on the board type PieceKind int const ( // EMPTY_SQUARE aka Empty EMPTY_SQUARE PieceKind = 0 + iota // PAWN (♙, ♟) PAWN // ROOK (♖, ♜) ROOK // KNIGHT (♘, ♞) KNIGHT // BISHOP (♗, ♝) BISHOP // QUEEN (♕, ♛) QUEEN // KING (♔, ♚) KING ) // P...
pieces.go
0.706596
0.573499
pieces.go
starcoder
package loops import ( "fmt" "math" ) type Mat4 [16]float32 func NewIdentityMat4() Mat4 { return Mat4{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, } } func NewTranslateMatrix(tx, ty, tz float32) Mat4 { return Mat4{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, tx, ty, tz, 1, } } func NewScaleMatrix...
loops/matrix.go
0.646014
0.535888
matrix.go
starcoder
package openapi import ( "encoding/json" ) // SchemaField SchemaField defines the properties of a field in the schema. type SchemaField struct { // The name of the field. Name string `json:"name"` // The description of the field. Description *string `json:"description,omitempty"` Type SchemaFiel...
internal/openapi/model_schema_field.go
0.836638
0.514583
model_schema_field.go
starcoder
package challenge43 import ( "crypto/rand" "math/big" ) type DSA struct { P *big.Int Q *big.Int G *big.Int } type UserKey struct { Private *big.Int Public *big.Int } type MessageSignature struct { R *big.Int S *big.Int } func (d *DSA) Initialize() { d.P = new(big.Int).SetBytes(P) d.Q = new(big.Int).Set...
set6/challenge43/43_utility.go
0.502441
0.427516
43_utility.go
starcoder
package rvm import ( "fmt" "math" ) type InvalidRoundingMode RoundingMode func (i InvalidRoundingMode) Error() string { return fmt.Sprintf("invalid rounding mode: %x", i) } type RoundingMode uint const ( RoundTruncate RoundingMode = iota RoundNearest RoundFloor RoundCeil ) func round(v Value, mode Rounding...
rvm/arith.go
0.611266
0.414603
arith.go
starcoder
package levels import ( mgl "github.com/go-gl/mathgl/mgl32" "github.com/inkyblackness/hacked/editor/render" "github.com/inkyblackness/hacked/ui/opengl" ) var highlighterVertexShaderSource = ` #version 150 precision mediump float; in vec3 vertexPosition; uniform mat4 modelMatrix; uniform mat4 viewMatrix; uniform...
editor/levels/Highlighter.go
0.763043
0.538862
Highlighter.go
starcoder
type block struct { signer string // Account that signed this particular block voted string // Optional value if the signer voted on adding/removing someone auth bool // Whether the vote was to authorize (or deauthorize) checkpoint []string // List of authorized signers if this is an epoc...
clique/EIP225.go
0.628635
0.494446
EIP225.go
starcoder
package collect import ( "golang.org/x/exp/constraints" "math" "reflect" ) func IsNumber(v any) bool { switch v.(type) { case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64: return true default: return false } } func NumberCompare[T constraints.Integer | constraints....
comparator.go
0.682891
0.446314
comparator.go
starcoder
package xnumber import ( "strconv" ) // parse // ParseInt parses a string to int using given base. func ParseInt(s string, base int) (int, error) { i, e := strconv.ParseInt(s, base, 0) return int(i), e } // ParseInt8 parses a string to int8 using given base. func ParseInt8(s string, base int) (int8, error) { i,...
xnumber/xnumber_parse.go
0.843219
0.457258
xnumber_parse.go
starcoder
package continuous import ( "github.com/jtejido/ggsl/specfunc" "github.com/jtejido/stats" "github.com/jtejido/stats/err" smath "github.com/jtejido/stats/math" "math" "math/rand" ) // Rice distribution // https://en.wikipedia.org/wiki/Rice_distribution type Rice struct { distance, spread float64 // v, σ src ...
dist/continuous/rice.go
0.757346
0.47591
rice.go
starcoder
package main import ( "log" "os" "sort" "text/template" "github.com/prometheus/client_golang/prometheus" "github.com/percona/rds_exporter/enhanced" ) type Group struct { Name string metrics []Metric } type Metric struct { Group string Name string Help string } func (m Metric) FqName() string { na...
enhanced/generate/main.go
0.580947
0.441372
main.go
starcoder
package indexspace import ( "fmt" "errors" ) /* Matrix represents an [m][n] matrix The Matrix type is intended for small matrix manipulations, and providing a tailored interface to geometric questions that arise in the manipulation of index spaces and domains of computation */ type Matrix [][]float64 // Clone cre...
indexspace/matrix.go
0.827201
0.69298
matrix.go
starcoder
// Package vision wraps the Cloud Vision API and provides an auth method that // allows you to check an input image for an input term. package vision import ( "context" "io" "net/url" "os" "strings" vision "cloud.google.com/go/vision/apiv1" pb "google.golang.org/genproto/googleapis/cloud/vision/v1" ) // Auth...
vision/vision.go
0.762778
0.408336
vision.go
starcoder
package main import ( "fmt" "strconv" "strings" "time" "github.com/google/go-tpm/tpm2" "github.com/google/go-tpm/tpmutil" ) // parseHandle parses a string (typically from the command line) into tpmutil.Handle func parseHandle(s string) (tpmutil.Handle, error) { i, err := strconv.ParseUint(s, 0, 32) return tp...
cmd/tpmk/args.go
0.608478
0.404802
args.go
starcoder
package rules func (this piece) getPawnCoverageFrom(from square, board board) (covered []square) { var captures = whitePawnCaptureOffsets if this.Player() == Black { captures = blackPawnCaptureOffsets } for _, offset := range captures { covered = append(covered, from.Offset(offset)) } return covered } func ...
rules/pieces_pawn.go
0.655887
0.447702
pieces_pawn.go
starcoder
package fastmatch import ( "bytes" "fmt" "math" ) // The maximum allowable state value. Can be overridden for testing. var maxState uint64 = math.MaxUint64 // stateMachine holds the mapping between a match and the intermediate state // changes (runes encountered) leading up to a match. type stateMachine struct ...
state.go
0.570092
0.465995
state.go
starcoder
package vector import ( "github.com/hsiafan/glow/v2/container/optional" "github.com/hsiafan/glow/v2/container/slicex" ) // Vector is a slice but with mutable data-pointer/len/cap. type Vector[T any] []T // Make create a new Vector func Make[T any](values ...T) Vector[T] { return values } // Append add a new valu...
container/vector/vector.go
0.862612
0.591163
vector.go
starcoder
package bst import ( "fmt" //importing required packages ) type Node struct { //Node represents node of a Binary Search Tree value int left *Node right *Node } func Insert(root *Node, key int) *Node { //The following function inserts elements into Binary Search Tree if root == nil { root = &Node{key, nil, ni...
bst/binarySearchTree.go
0.705582
0.603289
binarySearchTree.go
starcoder