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 gofakeit import ( "math" rand "math/rand" "strconv" "strings" "time" "github.com/brianvoe/gofakeit/v6/data" ) // CurrencyInfo is a struct of currency information type CurrencyInfo struct { Short string `json:"short" xml:"short"` Long string `json:"long" xml:"long"` } // Currency will generate a str...
vendor/github.com/brianvoe/gofakeit/v6/payment.go
0.7797
0.401043
payment.go
starcoder
package main import ( "image" "image/color" "math" "sort" ) type byteQuad [4]uint8 type byteQuadPalette []byteQuad func byte2dword(b uint8) uint32 { d := uint32(b) d |= d << 8 return d } func (bq byteQuad) RGBA() (r, g, b, a uint32) { return byte2dword(bq[0]), byte2dword(bq[1]), byte2dword(bq[2]), byte2dwor...
quantize.go
0.558568
0.469399
quantize.go
starcoder
package series import ( "fmt" "math" "strings" ) type boolElement struct { e bool nan bool } func (e *boolElement) Set(value interface{}) { e.nan = false switch value.(type) { case string: if value.(string) == "NaN" { e.nan = true return } switch strings.ToLower(value.(string)) { case "true",...
vendor/github.com/kniren/gota/series/type-bool.go
0.575349
0.519704
type-bool.go
starcoder
// verify is a simple example that shows how a verifiable map can be used to // demonstrate inclusion. package main import ( "bytes" "crypto" "encoding/json" "flag" "fmt" "io/ioutil" "math/big" "path/filepath" "github.com/golang/glog" "github.com/google/trillian/experimental/batchmap" "github.com/google/t...
experimental/batchmap/cmd/verify/verify.go
0.640636
0.501038
verify.go
starcoder
package sudogo // A constraint is an added rule for solving the puzzle. This enables more complex puzzles with fewer givens. // The following basic constraints are supported // - A collection of cells sum up to a value // - Diagonal lines: https://www.youtube.com/watch?v=Vc-FYo_nur4 // - Groups/cages: https://www.yo...
pkg/constraint.go
0.627038
0.582729
constraint.go
starcoder
package mapping import ( "bytes" "errors" "fmt" "math" enc "github.com/bahlo/sketches-go/ddsketch/encoding" ) // A fast IndexMapping that approximates the memory-optimal LogarithmicMapping by extracting the floor value // of the logarithm to the base 2 from the binary representations of floating-point values a...
ddsketch/mapping/linearly_interpolated_mapping.go
0.902332
0.551755
linearly_interpolated_mapping.go
starcoder
package main import ( "fmt" "math" "math/rand" ) func getSigmoid(value float64) float64 { return 1 / (1 + math.Exp(-value)) } func getActivation(weights []float64, x []float64) float64 { var activation = 0.0 for i, _ := range x { activation += weights[i] * x[i] } return getS...
LogisticRegression/logisticregression.go
0.881417
0.518973
logisticregression.go
starcoder
package main import ( "bufio" "fmt" "os" "strconv" "strings" "github.com/olekukonko/tablewriter" ) func main() { // When our program starts let's build the universe. We need a board. board := newBoard() // We'll loop forever. In this version there is no way to end the game. for { // Everytime we iterate...
main.go
0.60871
0.470007
main.go
starcoder
package gconf import "time" // GetAllOpts is equal to Conf.GetAllOpts(). func GetAllOpts() []Opt { return Conf.GetAllOpts() } // RegisterOpts is equal to Conf.RegisterOpts(opts...). func RegisterOpts(opts ...Opt) { Conf.RegisterOpts(opts...) } // UnregisterOpts is equal to Conf.UnregisterOpts(optNames...). func Un...
global.go
0.64232
0.412234
global.go
starcoder
package level // SlopeFactors is a list of multipliers for each direction of a tile. type SlopeFactors [8]float32 // Negated returns the factors multiplied by -1. func (factors SlopeFactors) Negated() SlopeFactors { return SlopeFactors{ factors[0] * -1, factors[1] * -1, factors[2] * -1, factors[3] * -1, factors[...
ss1/content/archive/level/TileTypeInfo.go
0.802633
0.863737
TileTypeInfo.go
starcoder
package core import ( "math" "regexp" "strconv" "strings" "github.com/wingify/vwo-go-sdk/pkg/constants" "github.com/wingify/vwo-go-sdk/pkg/utils" ) // SegmentEvaluator function evaluates segments to get the keys and values and perform appropriate functions func SegmentEvaluator(segments map[string]interface{},...
pkg/core/segmentor.go
0.726329
0.487612
segmentor.go
starcoder
// Package tensorflow provides implementation of Go API for extract data to vector package tensorflow import ( tf "github.com/tensorflow/tensorflow/tensorflow/go" "github.com/vdaas/vald/internal/errors" ) type SessionOptions = tf.SessionOptions type Operation = tf.Operation type TF interface { GetVector(feeds []...
internal/core/converter/tensorflow/tensorflow.go
0.686265
0.402598
tensorflow.go
starcoder
package util import "github.com/go-gl/mathgl/mgl32" // GenerateTangents generates tangents for vertex data func GenerateTangents(points []float32, normals []float32, texCoords []float32) (tangents []float32) { //const vector<vec3> & points, //const vector<vec3> & normals, //const vector<int> & faces, //const vect...
mesh/util/tangents.go
0.589953
0.472014
tangents.go
starcoder
package manifest import ( "fmt" ) // Planner represents an execution planner, returning actions to transition from a src to a target state. type Planner interface { Plan(src, target *Plan) ([]Action, error) } // Action is one operation on the home automation system. type Action interface { Perform(a aha) error } ...
manifest/planner.go
0.761627
0.402862
planner.go
starcoder
package packet import ( "errors" ) // Encode4b6b returns the 4b/6b encoding of the given data. func Encode4b6b(src []byte) []byte { // 2 input bytes produce 3 output bytes. // Odd final input byte, if any, produces 2 output bytes. n := len(src) dst := make([]byte, 3*(n/2)+2*(n%2)) for i, j := 0, 0; i < n; i, j ...
packet/encoding.go
0.649579
0.542682
encoding.go
starcoder
package neuralnetwork import ( "math" "math/rand" "time" "github.com/timothy102/matrix" ) //Layer interface given these 5 functions which every layer must have. type Layer interface { Call() []float64 GetWeights() matrix.Matrix GetBiases() matrix.Vector Name() string TrainableParameters() int } //DenseLaye...
nn/layers.go
0.847936
0.660378
layers.go
starcoder
package mesh import ( "errors" "github.com/EliCDavis/vector" ) // Line2D represents a line segment type Line2D struct { p1 vector.Vector2 p2 vector.Vector2 } // ErrNoIntersection is thrown when Intersection() contains no intersection var ErrNoIntersection = errors.New("No Intersection") // NewLine2D create a n...
line2D.go
0.80765
0.662831
line2D.go
starcoder
package geometry import ( "time" "github.com/kasworld/h4o/_examples/app" "github.com/kasworld/h4o/geometry" "github.com/kasworld/h4o/graphic" "github.com/kasworld/h4o/light" "github.com/kasworld/h4o/material" "github.com/kasworld/h4o/math32" "github.com/kasworld/h4o/util/helper" ) func init() { app.DemoMap[...
_examples/demos/geometry/plane.go
0.687735
0.548129
plane.go
starcoder
package govalid import ( "fmt" "reflect" "strconv" ) // ----------------------------------------------------------------------------- // Number validation function. type NumberOpt func(float64) error // ----------------------------------------------------------------------------- // Construct a number validator...
Godeps/_workspace/src/github.com/gima/govalid/v1/number.go
0.770983
0.511656
number.go
starcoder
package iso20022 // Details of the closing of the securities financing transaction. type SecuritiesFinancing10 struct { // Date/Time at which rate change has taken place. RateChangeDate *ISODateTime `xml:"RateChngDt,omitempty"` // Specifies whether the rate is fixed or variable. RateType *RateType19Choice `xml:"...
SecuritiesFinancing10.go
0.855791
0.478407
SecuritiesFinancing10.go
starcoder
package geom import ( "fmt" ) //const tolerance = 0.000001 const tolerance = 0.000000001 /* // Float64 compares two floats to see if they are within the given tolerance. func cmpFloat(f1, f2 float64) bool { if math.IsInf(f1, 1) { return math.IsInf(f2, 1) } if math.IsInf(f2, 1) { return math.IsInf(f1, 1) } ...
triangle.go
0.793386
0.68925
triangle.go
starcoder
package netpbm import ( "bufio" "errors" "fmt" "image" "image/color" "io" "strings" "unicode" ) // A BW is simply an alias for an image.Paletted. However, it is intended to // represent images containing only white and black in their color palette. type BW struct{ *image.Paletted } // MaxValue returns the ...
pbm.go
0.750187
0.40539
pbm.go
starcoder
package main import ( rl "github.com/chunqian/go-raylib/raylib" "runtime" ) func init() { runtime.LockOSThread() } func main() { screenWidth := int32(800) screenHeight := int32(450) rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze") defer rl.CloseWindow() camera := rl...
examples/models/first_person_maze/first_person_maze.go
0.506347
0.421135
first_person_maze.go
starcoder
package storage import ( "math" "time" "github.com/m3db/m3/src/query/block" "github.com/m3db/m3/src/query/ts" ) // FetchResultToBlockResult converts a fetch result into coordinator blocks func FetchResultToBlockResult(result *FetchResult, query *FetchQuery) (block.Result, error) { alignedSeriesList, err := res...
src/query/storage/block.go
0.626581
0.411761
block.go
starcoder
package bezier import ( "github.com/adamcolton/geom/d2" "github.com/adamcolton/geom/d2/curve/line" "github.com/adamcolton/geom/d2/curve/poly" ) // Blossom point for the control points of a bezier curve func (b Bezier) Blossom(fs ...float64) d2.Pt { // https://en.wikipedia.org/wiki/Blossom_(functional) return b.n...
d2/curve/bezier/intersection.go
0.883066
0.655405
intersection.go
starcoder
package tflite import ( flatbuffers "github.com/google/flatbuffers/go" ) type SparsityParametersT struct { TraversalOrder []int32 BlockMap []int32 DimMetadata []*DimensionMetadataT } func (t *SparsityParametersT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT { if t == nil { return 0 } traversalOrder...
SparsityParameters.go
0.742515
0.403802
SparsityParameters.go
starcoder
package bls import ( "crypto/cipher" "encoding/hex" "io" "github.com/drand/kyber" "github.com/drand/kyber/group/mod" ) var domainG1 = [8]byte{1, 1, 1, 1, 1, 1, 1, 1} // KyberG1 is a kyber.Point holding a G1 point on BLS12-381 curve type KyberG1 struct { p *PointG1 } func nullKyberG1() *KyberG1 { var p Point...
vendor/github.com/drand/bls12-381/kyber_g1.go
0.660501
0.489503
kyber_g1.go
starcoder
// Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed und...
doc.go
0.879703
0.545528
doc.go
starcoder
package temporal import ( "fmt" "math" "time" "github.com/m3db/m3/src/query/executor/transform" "github.com/m3db/m3/src/query/ts" ) const ( // AvgType calculates the average of all values in the specified interval. AvgType = "avg_over_time" // CountType calculates count of all values in the specified inter...
src/query/functions/temporal/aggregation.go
0.768646
0.518729
aggregation.go
starcoder
package samples func init() { sampleDataProposalCreateOperation[44] = `{ "expiration_time": "2016-08-20T14:37:51", "extensions": [], "fee": { "amount": 2318977, "asset_id": "1.3.0" }, "fee_paying_account": "1.2.116522", "proposed_ops": [ { "op": [ 6, { "accoun...
gen/samples/proposalcreateoperation_44.go
0.545286
0.471953
proposalcreateoperation_44.go
starcoder
package calendar import ( "strings" // standard libs only above! "github.com/litesoft-go/utils/enums" "github.com/litesoft-go/utils/strs" ) type Weekday struct { enums.Enum weekdayData } func (wdd *weekdayData) GetDayNumber() int { if wdd == nil { return 0 } return wdd.dayNumber } func (wdd *weekdayDat...
calendar/weekdays.go
0.595257
0.437343
weekdays.go
starcoder
package MySQLProtocol func BuildFixedLengthInteger1(value uint8) (data []byte) { data = make([]byte, 1) data[0] = byte(value >> 0 & 0xFF) return data } func (proto *Proto) GetFixedLengthInteger1() (value uint8) { value |= uint8(proto.data[proto.offset] & 0xFF) proto.offset += 1 return value } func BuildFixedLe...
MySQLProtocol/FixedLengthInteger.go
0.583797
0.591281
FixedLengthInteger.go
starcoder
package main import ( "math/rand" . "github.com/jakecoffman/cp" "github.com/jakecoffman/cp/examples" ) const ( imageWidth = 188 imageHeight = 35 imageRowLength = 24 ) func main() { space := NewSpace() space.Iterations = 1 // The space will contain a very large number of similarly sized objects. //...
examples/logosmash/logosmash.go
0.584983
0.502747
logosmash.go
starcoder
package processor import ( "bytes" "encoding/json" "errors" "fmt" "io/ioutil" "regexp" "time" "github.com/Jeffail/benthos/lib/log" "github.com/Jeffail/benthos/lib/metrics" "github.com/Jeffail/benthos/lib/types" "github.com/Jeffail/gabs" "github.com/benhoyt/goawk/interp" "github.com/benhoyt/goawk/parser"...
lib/processor/awk.go
0.673836
0.630273
awk.go
starcoder
package values import ( "fmt" "math" "github.com/influxdata/flux/ast" "github.com/influxdata/flux/semantic" ) type BinaryFunction func(l, r Value) Value type BinaryFuncSignature struct { Operator ast.OperatorKind Left, Right semantic.Type } // LookupBinaryFunction returns an appropriate binary function th...
values/binary.go
0.648466
0.550909
binary.go
starcoder
package analysis import ( "math" "gonum.org/v1/gonum/stat/distuv" "gonum.org/v1/gonum/stat" "github.com/eseymour/cryptopals/pkg/crypto/xor" ) // BreakXOREncryptByteKey finds the byte key whose plaintext best matches the // distribution of ASCII byte values of English text. PValue represents the // likelihood t...
pkg/crypto/analysis/byteXOR.go
0.554591
0.410195
byteXOR.go
starcoder
package tezos import ( "fmt" ) type OpStatus byte const ( OpStatusInvalid OpStatus = iota // 0 OpStatusApplied // 1 (success) OpStatusFailed OpStatusSkipped OpStatusBacktracked ) func (t OpStatus) IsValid() bool { return t != OpStatusInvalid } func (t OpStatus) IsSuccess() bool { return t ...
tezos/op.go
0.507812
0.412767
op.go
starcoder
package gt import ( "database/sql/driver" "encoding/json" ) /* Variant of `string` where zero value is considered empty in text, and null in JSON and SQL. Use this for fields where an empty string is not allowed, such as enums or text foreign keys. Unlike `string`, encoding/decoding is not always reversible: JSO...
gt_null_string.go
0.776284
0.584805
gt_null_string.go
starcoder
package benchmark import ( "reflect" "testing" ) func isBoolToUintFuncCalibrated(supplier func() bool) bool { return isCalibrated(reflect.Bool, reflect.Uint, reflect.ValueOf(supplier).Pointer()) } func isIntToUintFuncCalibrated(supplier func() int) bool { return isCalibrated(reflect.Int, reflect.Uint, reflect.Va...
common/benchmark/07_to_uint_func.go
0.705886
0.746832
07_to_uint_func.go
starcoder
package game import ( "errors" "fmt" "reflect" ) type Grid [][]byte type Coords struct { Y byte X byte } const ACTION_NONE byte = 0 const ACTION_QUIT byte = 1 const ACTION_MOVE_TOP byte = 2 const ACTION_MOVE_RIGHT byte = 3 const ACTION_MOVE_BOTTOM byte = 4 const ACTION_MOVE_LEFT byte = 5 const ACTION_SHUFFLE b...
src/game/game.go
0.645679
0.473536
game.go
starcoder
package main import ( "encoding/json" "flag" "fmt" "math" "math/rand" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/plotutil" "gonum.org/v1/plot/vg" "github.com/pointlander/anomaly" ) const ( // VectorSize is the size of the JSON document vector VectorSize = 1024 // Samples is the...
cmd/anomaly_bench/main.go
0.616474
0.482246
main.go
starcoder
package arts import ( "fmt" "image/color" "log" "github.com/andrewwatson/generativeart" "github.com/andrewwatson/generativeart/common" ) // ColorMapping maps some parameters to color space. type ColorMapping func(float64, float64, float64) color.RGBA type domainWrap struct { noise *common.PerlinNoi...
arts/domainwrap.go
0.788502
0.474753
domainwrap.go
starcoder
package timeslice import ( "errors" "sort" "time" ) // TimeSlice is used for sorting. e.g. // sort.Sort(sort.Reverse(timeSlice)) // sort.Sort(timeSlice) type TimeSlice []time.Time func (ts TimeSlice) Len() int { return len(ts) } func (ts TimeSlice) Less(i, j int) bool { return ts[i].Before(ts[j]) } func...
time/timeslice/timeslice.go
0.738669
0.487124
timeslice.go
starcoder
package pipescript var LtTransform = &Transform{ Name: "lt", Description: "returns true if the data of the incoming stream is less than the value of the first arg", Args: []TransformArg{ TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, TransformArg{ ...
comparisons.go
0.764012
0.688275
comparisons.go
starcoder
package gofinancial import ( "math" "github.com/razorpay/go-financial/enums/paymentperiod" ) /* Pmt compute the fixed payment(principal + interest) against a loan amount ( fv = 0). It can also be used to calculate the recurring payments needed to achieve a certain future value given an initial deposit, a fixed pe...
reducing_utils.go
0.788176
0.722723
reducing_utils.go
starcoder
package nfa import ( "fmt" "strconv" ) type args struct { str string } type State string type Symbol rune type Delta map[State]map[Symbol]StatesBitMap type StatesBitMap uint64 type nfa struct { states []State alphabet []Symbol delta Delta startingStates StatesBitMap acceptingState...
pkg/flfa/nfa/nfa.go
0.59972
0.422445
nfa.go
starcoder
package interpreter import ( "fmt" "github.com/smackem/ylang/internal/parser" "reflect" "strings" ) type Function struct { ParameterNames []string Body []parser.Statement closure []scope } func (f Function) Compare(other Value) (Value, error) { return nil, nil } func (f Function) Add(other ...
internal/interpreter/function.go
0.773815
0.42477
function.go
starcoder
package eZmaxApi import ( "encoding/json" ) // EzsignsignerRequest An Ezsignsigner Object type EzsignsignerRequest struct { // The unique ID of the Taxassignment. Valid values: |Value|Description| |-|-| |1|No tax| |2|GST| |3|HST (ON)| |4|HST (NB)| |5|HST (NS)| |6|HST (NL)| |7|HST (PE)| |8|GST + QST (QC)| |9|GST ...
model_ezsignsigner_request.go
0.647241
0.465934
model_ezsignsigner_request.go
starcoder
package gocqlmock import ( "fmt" "github.com/gocql/gocql" "reflect" "regexp" ) // Argument interface allows to match // any argument in specific way type Argument interface { Match(interface{}) error } // expectIface represents compatibility interface for the // expectations type expectIface interface { fulfil...
expectations.go
0.735167
0.402774
expectations.go
starcoder
package simplify import ( "github.com/go-spatial/tegola" "github.com/go-spatial/tegola/basic" "github.com/go-spatial/tegola/maths" "github.com/go-spatial/tegola/maths/points" ) // SimplifyGeometry applies the DouglasPeucker simplification routine to the supplied geometry func SimplifyGeometry(g tegola.Geometry, t...
maths/simplify/simplify.go
0.696165
0.567397
simplify.go
starcoder
package delivery /* Conversion code inspired by https://github.com/icza/dyno/blob/master/dyno.go */ import "fmt" type Converter struct { } // Converts given value to string func (c *Converter) ToString(v interface{}) (string, error) { s, ok := v.(string) if !ok { return "", fmt.Errorf("expected string value, g...
delivery/converter.go
0.820037
0.435902
converter.go
starcoder
package docs import ( "bytes" "encoding/json" "strings" "text/template" "github.com/swaggo/swag" ) var doc = `{ "schemes": {{ marshal .Schemes }}, "swagger": "2.0", "info": { "description": "{{escape .Description}}", "title": "{{.Title}}", "contact": { "name": "AP...
services/api/docs/docs.go
0.625438
0.415966
docs.go
starcoder
package n_queen /* 51. N皇后 https://leetcode-cn.com/problems/n-queens n 皇后问题研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。 给定一个整数 n,返回所有不同的 n 皇后问题的解决方案。 每一种解法包含一个明确的 n 皇后问题的棋子放置方案,该方案中 'Q' 和 '.' 分别代表了皇后和空位。 示例: 输入: 4 输出: [ [".Q..", // 解法 1 "...Q", "Q...", "..Q."], ["..Q.", // 解法 2 "Q...", "...Q", ".Q.."] ...
solutions/n-queen/d.go
0.540196
0.529446
d.go
starcoder
package leetcode0622 type MyCircularQueue struct { head, tail, size int queue []int } /** Initialize your data structure here. Set the size of the queue to be k. */ func Constructor(k int) MyCircularQueue { return MyCircularQueue{ head: -1, tail: -1, size: k, queue: make([]int, k), } } // n...
leetcode.0622.design-circular-queue/design_circular_queue.go
0.730963
0.44089
design_circular_queue.go
starcoder
package canvas import ( "image" "golang.org/x/image/draw" "golang.org/x/image/math/f64" "golang.org/x/image/vector" ) type Rasterizer struct { img draw.Image dpm float64 } // NewRasterizer creates a renderer that draws to a rasterized image. func NewRasterizer(img draw.Image, dpm float64) *Rasterizer { retur...
rasterizer.go
0.590779
0.449816
rasterizer.go
starcoder
package sudoku import "fmt" /* Since golang uses a list of lists to support matrices while making operations on the table, we must remember the row column notation as the first for loop will extract the row and the second essentially extracts the element from the row so a Sudoku is [row][column]. Basically, we are us...
sudoku/defines.go
0.64579
0.628878
defines.go
starcoder
package tdigest import ( "math" "sort" ) // TDigest is a data structure for accurate on-line accumulation of // rank-based statistics such as quantiles and trimmed means. type TDigest struct { compression float64 maxProcessed int maxUnprocessed int processed []centroid unprocessed [...
tdigest.go
0.777638
0.681137
tdigest.go
starcoder
package env import ( "os" "time" "github.com/kubecost/cost-model/pkg/util/mapper" ) //-------------------------------------------------------------------------- // EnvVar mapper.Map Implementation //-------------------------------------------------------------------------- // envMap contains Getter and Setter i...
pkg/env/env.go
0.795777
0.437463
env.go
starcoder
package main /* Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considere...
Programs/020Valid Parentheses/020Valid Parentheses.go
0.524638
0.401746
020Valid Parentheses.go
starcoder
package boomer import ( "errors" "math" "strconv" "strings" "sync/atomic" "time" ) // runner uses a rate limiter to put limits on task executions. type rateLimiter interface { start() acquire() bool stop() } // stableRateLimiter uses the token bucket algorithm. // the bucket is refilled according to the ref...
ratelimiter.go
0.579638
0.428652
ratelimiter.go
starcoder
package positionhash import ( "fmt" "github.com/emilyselwood/orbcalc/orbcore" "strings" "time" ) /* Hasher defines a way to create spacial temporal hashes. Inspired by geohash, this extends to 4 dimensions. */ type Hasher interface { Hash(pos *orbcore.Position) (string, error) Box(hash string) (*orbcore.Boundi...
orbcore/positionhash/hasher.go
0.730963
0.447521
hasher.go
starcoder
package osmfile type DataKind int const ( DataKindNodes DataKind = 0 DataKindWays DataKind = 1 DataKindRelations DataKind = 2 ) func (k DataKind) String() string { switch k { case DataKindNodes: return "nodes" case DataKindWays: return "ways" case DataKindRelations: return "relations" default...
block.go
0.509276
0.513059
block.go
starcoder
package kubernetes import ( "regexp" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" ) func affinityFields() map[string]*schema.Schema { return map[string]*schema.Schema{ "node_affinity": { Type: schema.TypeList, Description: ...
vendor/github.com/hashicorp/terraform-provider-kubernetes/kubernetes/schema_affinity_spec.go
0.664214
0.477615
schema_affinity_spec.go
starcoder
package pgsql import ( "database/sql" "database/sql/driver" "encoding/hex" ) // ByteaArrayFromByteSliceSlice returns a driver.Valuer that produces a PostgreSQL bytea[] from the given Go [][]byte. func ByteaArrayFromByteSliceSlice(val [][]byte) driver.Valuer { return byteaArrayFromByteSliceSlice{val: val} } // By...
pgsql/byteaarr.go
0.716615
0.466177
byteaarr.go
starcoder
package gt import ( "database/sql/driver" "encoding/json" "fmt" "time" ) // `gt.NullTime` version of `time.Date`. func NullTimeIn(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) NullTime { return NullTime(time.Date(year, month, day, hour, min, sec, nsec, loc)) } // Shortcut for `g...
gt_null_time.go
0.807347
0.699126
gt_null_time.go
starcoder
package square import ( "fmt" "image/color" log "github.com/Sirupsen/logrus" "github.com/Willyfrog/peano/drawing" "github.com/Willyfrog/peano/point" "github.com/Willyfrog/peano/utils" ) type Square struct { X int Y int Width float32 Points []*point.Point } // fitsIn Given a point.Point, check i...
square/square.go
0.644113
0.400398
square.go
starcoder
package genericcomparator import ( "bytes" "fmt" "strings" ) // Type defines the type of the generic Comparator that compares two values and returns -1 if a is smaller than b, 1 if // a is bigger than b and 0 if both values are equal. type Type func(a interface{}, b interface{}) int // Comparator implements a fun...
datastructure/genericcomparator/genericcomparator.go
0.694095
0.429071
genericcomparator.go
starcoder
package year2021 import ( "sort" "github.com/lanphiergm/adventofcodego/internal/utils" ) // Smoke Basin Part 1 computes the sum of all risk levels for the heightmap func SmokeBasinPart1(filename string) interface{} { data := utils.ReadStrings(filename) sum := 0 for i, row := range data { for j, cell := range ...
internal/puzzles/year2021/day_09_smoke_basin.go
0.540196
0.467757
day_09_smoke_basin.go
starcoder
package internal import ( "fmt" "math" "gopkg.in/yaml.v3" "github.com/lyraproj/dgo/util" "github.com/lyraproj/dgo/dgo" ) type ( // floatVal is a float64 that implements the dgo.Value interface floatVal float64 floatType int exactFloatType float64 floatRangeType struct { min float64 max ...
internal/float.go
0.82994
0.531513
float.go
starcoder
package util import ( "fmt" "math" "sort" ) // BezierCurve stores the derivative curve weights. type BezierCurve struct { Weights [][]float64 WeightsDt [][]float64 WeightsDt2 [][]float64 WeightsDt3 [][]float64 } // NewBezierCurve creates a new BezierCurve with the weights of the first, second // and third...
util/bcroots.go
0.832781
0.678473
bcroots.go
starcoder
package schema /* Okay, so. There are several fun considerations for a "validate" method. --- There's two radically different approaches to "validate"/"reify": - Option 1: Look at the schema.Type info and check if a data node seems to match it -- recursing on the type info. - Option 2: Use the schema.Type{...
vendor/github.com/ipld/go-ipld-prime/schema/validate.go
0.606265
0.775095
validate.go
starcoder
// +build ignore package main import ( "math" "github.com/cpmech/gosl/io" "github.com/cpmech/gosl/la" "github.com/cpmech/gosl/utl" ) // Generator holds data for one generator type Generator struct { a, b, c float64 // cost coefficients α, β, γ, ζ, λ float64 // emission coefficients Pmin, Pmax float...
examples/07-eed/generators.go
0.529993
0.446977
generators.go
starcoder
package conditional // Function execute left if v, else right. func Function(v bool, left, right func()) { if v { left() } else { right() } } // String return left if v, else right. func String(v bool, left, right string) string { if v { return left } return right } // String return left if v, else right...
controlflow/conditional/conditional.go
0.738386
0.604107
conditional.go
starcoder
package gorgonia /* This file holds code for ndarray related reduction Ops. What this means is we take a ndarray, and reduce the dimensions down - typically to 1. For example, summing all the values in a matrix, or finding the max value. There is an additional field in each of these Ops - the 'along' field. This is be...
op_reduction.go
0.644449
0.646014
op_reduction.go
starcoder
package rainsd import ( "fmt" "sort" "sync" log "github.com/inconshreveable/log15" "github.com/netsec-ethz/rains/internal/pkg/section" ) //isAssertionConsistent checks if the incoming assertion is consistent with the elements in the cache. //If not, every element of this zone and context is dropped and it retur...
internal/pkg/rainsd/consistencyChecks.go
0.504394
0.522507
consistencyChecks.go
starcoder
package kernel import ( "math" "github.com/joaowiciuk/matrix" ) // Laplacian generates the laplatian kernel, commonly used for edge detection. func Laplacian() *matrix.Matrix { return &matrix.Matrix{ {1, 1, 1}, {1, -8, 1}, {1, 1, 1}, } } // Sharpen generates the sharpen kernel, used for image enhancement....
kernel/kernel.go
0.792183
0.687442
kernel.go
starcoder
package geos // #cgo LDFLAGS: -lgeos_c // #include "geos.h" import "C" import ( "fmt" "sort" "strings" "unsafe" "github.com/brendan-ward/arrowtiler/tiles" ) // GeometryArray holds GEOS Geometry pointers (to CGO objects) and a tree (STRtree) // that is created as part of Query() calls. // GeometryArray must be m...
geos/array.go
0.54819
0.416441
array.go
starcoder
package utils type endpoint struct { Key string `json:"key"` Value string `json:"value"` } type EndpointPattern struct { Endpoints []*endpoint `json:"endpoints"` } func ACRRegion() *EndpointPattern { ep := &EndpointPattern{ Endpoints: []*endpoint{ {Key: "cn-hangzhou", Value: "https://registry.cn-hangzhou....
utils/typeinfos.go
0.619586
0.406037
typeinfos.go
starcoder
package stargen import ( "math" "github.com/dayaftereh/discover/server/mathf" "github.com/dayaftereh/discover/server/game/persistence/types" ) type HabitableZoneMode string const ( RecentVenus HabitableZoneMode = "recent-venus" RunawayGreenhouse HabitableZoneMode = "runaway-greenhouse" ...
server/game/universe/generator/stargen/habitable.go
0.773644
0.422147
habitable.go
starcoder
package main import ( "fmt" ) func main() { testCases() } func findMedianSortedArrays(nums1 []int, nums2 []int) float64 { totalLength := len(nums1) + len(nums2) isEven := (totalLength % 2) == 0 startIndex := (totalLength - 1) / 2 var currentIndex int = 0 res := &result{isEven: isEven, startIndex: startIndex, ...
leetcode/median-two-sorted-arrays/task.go
0.609292
0.478894
task.go
starcoder
package limiter /* TokenLimiter is the interface that wraps the AcquireToken and ReleaseToken methods, representing the use of a token mechanism to enforce concurrency limits. AcquireToken blocks until a token can be acquired from the limiter's supply. The token must be held for the duration of the activity which nee...
interfaces.go
0.568775
0.497742
interfaces.go
starcoder
package goop2 import ( "fmt" log "github.com/sirupsen/logrus" ) // Sum returns the sum of the given expressions. It creates a new empty // expression and adds to it the given expressions. func Sum(exprs ...Expr) Expr { newExpr := NewExpr(0) for _, e := range exprs { newExpr.Plus(e) } return newExpr } // Su...
util.go
0.787032
0.639609
util.go
starcoder
package config import ( "github.com/Azure/azure-service-operator/v2/tools/generator/internal/astmodel" ) // configurationVisitor is used to facilitate easy walking of the ObjectModelConfiguration hierarchy, abstracting // away traversal logic so that new uses of the hierarchy can concentrate on their specific functi...
v2/tools/generator/internal/config/configuration_visitor.go
0.850577
0.427516
configuration_visitor.go
starcoder
package continuous import ( "github.com/jtejido/stats" "github.com/jtejido/stats/err" "math" "math/rand" ) // Arcsine distribution // https://en.wikipedia.org/wiki/Arcsine_distribution type ArcsineBounded struct { Arcsine min, max float64 } func NewArcsineBounded(min, max float64) (*ArcsineBounded, error) { r...
dist/continuous/arcsine_bounded.go
0.824744
0.424651
arcsine_bounded.go
starcoder
package ent import ( "fmt" "strings" "entgo.io/ent/dialect/sql" "github.com/nint8835/entgql-bug-repro/ent/othertest" ) // OtherTest is the model entity for the OtherTest schema. type OtherTest struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // Test holds the value of the "test" fie...
ent/othertest.go
0.691185
0.441733
othertest.go
starcoder
package layer import tf "github.com/galeone/tensorflow/tensorflow/go" type LZeroPadding1D struct { dtype DataType inputs []Layer name string padding float64 shape tf.Shape trainable bool layerWeights []*tf.Tensor } func ZeroPadding1D() *LZeroPadding1D { return &LZeroPaddin...
layer/ZeroPadding1D.go
0.731634
0.443179
ZeroPadding1D.go
starcoder
package parser import ( "fmt" "strings" ) type NodeType string const ( // ListNode is an array element of a path. ListNode NodeType = "List" // ObjectNode is the final Node in a path, what is being referenced. ObjectNode NodeType = "Object" ) type Node interface { Type() NodeType DeepCopyNode() Node // Str...
pkg/mutation/path/parser/node.go
0.748076
0.424651
node.go
starcoder
package schema import ( "strings" ) // MySQL schema dialect func MySQL(query Query) Dialect { return mysql{ query: query, } } // PostgreSQL schema dialect func PostgreSQL(query Query) Dialect { return postgreSQL{ query: query, } } // SQLite3 schema dialect func SQLite3(query Query) Dialect { return sqlite...
schema/schema.go
0.522933
0.617138
schema.go
starcoder
package llrp import ( "time" ) /* This parameter, LLRPConfigurationStateValue, is a 32-bit value which represents a Reader’s entire LLRP configuration state including: LLRP configuration parameters, vendor extension configuration parameters, ROSpecs, and AccessSpecs. A Reader SHALL change this value only: • Upon suc...
llrp/params_configuration.go
0.767864
0.522811
params_configuration.go
starcoder
package movie import "strings" // Movie parses an IMDB movie record text blob, extracting all metadata about // a movie title. // The core details are extracted from the MOVI entry, but also all the other // entry types; ADPT, NOVL, CRIT, SCRP, etc. type Movie struct { Title string Year int Month string // as Rom...
movie/movie.go
0.61451
0.439386
movie.go
starcoder
package cast import ( "errors" "strconv" ) // Float32 will converts argument to float32 or return a error. func Float32(value interface{}) (float32, error) { switch v := value.(type) { case bool: if v { return float32(1), nil } return float32(0), nil case float32: return float32(v), nil case float64...
vendor/github.com/frozzare/go/cast/float.go
0.785514
0.476032
float.go
starcoder
package ewkb import ( "database/sql/driver" "fmt" "strings" "github.com/twpayne/go-geom" "github.com/twpayne/go-geom/encoding/wkbcommon" ) // ErrExpectedByteSlice is returned when a []byte is expected. type ErrExpectedByteSlice struct { Value interface{} } func (e ErrExpectedByteSlice) Error()...
encoding/ewkb/sql.go
0.668123
0.424651
sql.go
starcoder
package rename import ( "github.com/ozontech/file.d/cfg" "github.com/ozontech/file.d/fd" "github.com/ozontech/file.d/pipeline" ) /*{ introduction It renames the fields of the event. You can provide an unlimited number of config parameters. Each parameter handled as `cfg.FieldSelector`:`string`. When `override` is ...
plugin/action/rename/rename.go
0.76999
0.497192
rename.go
starcoder
package collectors import ( "encoding/json" "fmt" "strconv" "strings" "time" "bosun.org/metadata" "bosun.org/opentsdb" "bosun.org/slog" "bosun.org/util" ) func init() { const interval = time.Minute * 5 collectors = append(collectors, &IntervalCollector{F: c_omreport_chassis, Interval: interval}, &Inte...
cmd/scollector/collectors/dell_hw.go
0.524638
0.488405
dell_hw.go
starcoder
package theory import ( "fmt" "sort" "strings" "github.com/go-audio/midi" ) // Chords is a slice of chords type Chords []*Chord // ToBytes compresses a slice of chords where each chord is represented by a // byte. A dictionary is also returned so a byte can be converted back to a // chord (but the octave and re...
theory/chords.go
0.713931
0.409693
chords.go
starcoder
package compactor import ( "time" "github.com/cockroachdb/cockroach/pkg/settings" "github.com/pkg/errors" ) func validateFraction(v float64) error { if v >= 0 && v <= 1 { // handles +-Inf, Nan return nil } return errors.Errorf("value %v not between zero and one", v) } var enabled = settings.RegisterBoolSet...
pkg/storage/compactor/settings.go
0.656878
0.475727
settings.go
starcoder
package canvas import ( "image/color" "github.com/jesseduffield/fyne" ) // Declare conformity with CanvasObject interface var _ fyne.CanvasObject = (*Circle)(nil) // Circle describes a colored circle primitive in a Fyne canvas type Circle struct { Position1 fyne.Position // The current top-left position of the C...
canvas/circle.go
0.859162
0.400075
circle.go
starcoder
package google_graph import ( "fmt" "github.com/keep94/toolbox/http_util" "net/url" "strings" ) const ( kGoogleAlphabet = "<KEY>" ) // GraphData represents a dataset to be graphed. type GraphData interface { // The number of data points. Len() int // The title Title() string // The label of the 0-based idx...
google_graph/google.go
0.654674
0.458773
google.go
starcoder
package camera import ( "github.com/eriklupander/pathtracer-ocl/internal/app/geom" "math" ) type Camera struct { Width int Height int Fov float64 Transform geom.Mat4x4 Inverse geom.Mat4x4 PixelSize float64 HalfWidth float64 HalfHeight float64 Aperture float64 FocalLength f...
internal/app/camera/camera.go
0.817392
0.564519
camera.go
starcoder
package unit import ( "errors" "io" "reflect" "strconv" "strings" "github.com/coreos/go-systemd/unit" ) // Definition of a unit matching the fields found in unit-file type Definition struct { Unit struct { Description string Documentation string ...
unit/definition.go
0.699049
0.426142
definition.go
starcoder