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 crop import ( "image" "image/color" "math" "hawx.me/code/img/utils" ) // cropTo draws a new Image with pixels that have coordinates that when passed // to the given function returns true. func cropTo(img image.Image, in func(x, y int) bool) image.Image { return cropToValue(img, func(x, y int) float64 { ...
crop/crop.go
0.844537
0.545407
crop.go
starcoder
package arith import "math/big" // Mul128 returns the 128-bit multiplication of x and y. func Mul128(x, y uint64) (z1, z0 uint64) // Add sets z to x + y and returns z. func Add(z, x *big.Int, y uint64) *big.Int { zw := z.Bits() xw := x.Bits() yw := big.Word(y) neg := x.Sign() < 0 switch { case len(xw) == 0: ...
vendor/src/github.com/ericlagergren/decimal/internal/arith/arith_amd64.go
0.760295
0.628721
arith_amd64.go
starcoder
package golist import ( "fmt" "math/rand" "time" ) // SliceComplex64 is a slice of type complex64. type SliceComplex64 struct { data []complex64 } // NewSliceComplex64 returns a pointer to a new SliceComplex64 initialized with the specified elements. func NewSliceComplex64(elems ...complex64) *SliceComplex64 { ...
slice_complex64.go
0.816809
0.497131
slice_complex64.go
starcoder
package ahocorasick const ( rootState int64 = 1 nilState int64 = 0 ) // Trie represents a trie of patterns with extra links as per the Aho-Corasick algorithm. type Trie struct { dict []int64 trans [][256]int64 failLink []int64 dictLink []int64 pattern []int64 } // Walk calls this function on any matc...
trie.go
0.696475
0.454654
trie.go
starcoder
package clusters import ( "math" "math/rand" "time" "gonum.org/v1/gonum/floats" ) type kmeansEstimator struct { iterations, number, max int // variables keeping count of changes of points' membership every iteration. User as a stopping condition. changes, oldchanges, counter, threshold int distance Distanc...
kmeans_estimator.go
0.708313
0.517876
kmeans_estimator.go
starcoder
package wingedGrid import ( _ "log" "math" ) func normalizedForceVectorWithDistance(vectorFrom [3]float64, vectorTo [3]float64) ([3]float64, float64) { var forceVector [3]float64 forceVector[0] = vectorTo[0] - vectorFrom[0] forceVector[1] = vectorTo[1] - vectorFrom[1] forceVector[2] = vectorTo[2] - vectorFrom[2...
winged_uniform.go
0.697506
0.807309
winged_uniform.go
starcoder
package pixbuilder import ( "image" "image/color" "math/rand" ) // Pattern provide a color for each point, and repeats itself horizontally and vertically. // A Pattern is also an image.Image. type Pattern struct { xperiod, yperiod int // Horizontal and vertical periods image.Image // The image that is r...
pattern.go
0.770465
0.619989
pattern.go
starcoder
package ring const bufferInitialSize = 8 // Buffer is a deque maintained over a ring buffer. Note: it is backed by // a slice (unlike container/ring one that is backed by a linked list). type Buffer struct { buffer []interface{} head int // the index of the front of the deque. tail int // the index of the fir...
pkg/util/ring/ring_buffer.go
0.793386
0.532243
ring_buffer.go
starcoder
package stages import ( "fmt" "strconv" "strings" "time" ) const ( ErrTimestampContainsYear = "timestamp '%s' is expected to not contain the year date component" ) // convertDateLayout converts pre-defined date format layout into date format func convertDateLayout(predef string, location *time.Location) parser ...
pkg/logentry/stages/util.go
0.595845
0.515376
util.go
starcoder
package flow import ( "encoding/binary" "github.com/google/gopacket" "github.com/google/gopacket/layers" ) // LayerTypeInGRE creates a layer type, should be unique and high, so it doesn't conflict, // giving it a name and a decoder to use. var LayerTypeInGRE = gopacket.RegisterLayerType(55555, gopacket.LayerTypeM...
flow/decoder.go
0.652684
0.405272
decoder.go
starcoder
package filters import ( "encoding/json" "testing" "github.com/infracloudio/botkube/pkg/notify" "github.com/infracloudio/botkube/test/e2e/env" "github.com/infracloudio/botkube/test/e2e/utils" "github.com/nlopes/slack" "github.com/stretchr/testify/assert" v1 "k8s.io/api/core/v1" networkV1beta1 "k8s.io/api/ne...
test/e2e/filters/filters.go
0.61555
0.626281
filters.go
starcoder
package graph import ( "github.com/miguelfrde/image-segmentation/utils" "image" "image/color" "math" ) /** * Used to compute the weight of an edge when generating a graph * from an image */ type Pixel struct { X, Y int Color color.Color } /** * Type of the functions that are used to compute the weight of ...
graph/graph.go
0.809615
0.581125
graph.go
starcoder
package pulsar import ( "context" "errors" "fmt" "strconv" "sync" "time" "github.com/Jeffail/benthos/v3/internal/bundle" "github.com/Jeffail/benthos/v3/internal/docs" "github.com/Jeffail/benthos/v3/internal/impl/pulsar/auth" "github.com/Jeffail/benthos/v3/internal/shutdown" "github.com/Jeffail/benthos/v3/l...
internal/impl/pulsar/input.go
0.651909
0.467089
input.go
starcoder
package schema import ( "database/sql/driver" "reflect" ) var isZeroerType = reflect.TypeOf((*isZeroer)(nil)).Elem() type isZeroer interface { IsZero() bool } type IsZeroerFunc func(reflect.Value) bool func zeroChecker(typ reflect.Type) IsZeroerFunc { if typ.Implements(isZeroerType) { return isZeroInterface ...
schema/zerochecker.go
0.575588
0.452234
zerochecker.go
starcoder
package geo import ( "math" "math/cmplx" ) // Intersection finds the intersection of two straight lines (a1x+b1y+c1, a2x+b2y+c2) func Intersection(a1, b1, c1, a2, b2, c2 float64) (float64, float64) { return (b1*c2 - b2*c1) / (a1*b2 - a2*b1), (-a1*c2 + a2*c1) / (a1*b2 - a2*b1) } // Distance obtains the distance be...
geo/geo.go
0.819026
0.649398
geo.go
starcoder
package expression import ( "errors" "github.com/dolthub/go-mysql-server/sql" ) // TransformExprWithNodeFunc is a function that given an expression and the node that contains it, will return that // expression as is or transformed along with an error, if any. type TransformExprWithNodeFunc func(sql.Node, sql.Expr...
sql/expression/transform.go
0.75037
0.580203
transform.go
starcoder
package mlpack /* #cgo CFLAGS: -I./capi -Wall #cgo LDFLAGS: -L. -lmlpack_go_preprocess_split #include <capi/preprocess_split.h> #include <stdlib.h> */ import "C" import "gonum.org/v1/gonum/mat" type PreprocessSplitOptionalParam struct { InputLabels *mat.Dense NoShuffle bool Seed int TestRatio float...
preprocess_split.go
0.647352
0.508727
preprocess_split.go
starcoder
package schema import ( "encoding/json" "errors" "fmt" "reflect" ) // Query defines an expression against a schema to perform a match on schema's data. type Query []Expression // Expression is a query or query component that can be matched against a payoad. type Expression interface { Match(payload map[string]i...
wuisrv/vendor/github.com/rs/rest-layer/schema/query.go
0.682045
0.562717
query.go
starcoder
Vitess Vitess is an SQL middleware which turns MySQL/MariaDB into a fast, scalable and highly-available distributed database. For more information, visit http://www.vitess.io. Example Using this SQL driver is as simple as: import ( "time" "github.com/youtube/vitess/go/vt/vitessdriver" ) func main() ...
go/vt/vitessdriver/doc.go
0.829837
0.702017
doc.go
starcoder
package materials import ( "github.com/thescripted/sandbox-raytracing/geom" "github.com/thescripted/sandbox-raytracing/hitables" "math" "math/rand" ) type Material interface { Scatter(ray geom.Ray, record hitables.HitRecord) (scattered geom.Ray, attenuation geom.Vec3, ok bool) } type Metal struct { Albedo geom....
raytracing/materials/material.go
0.720467
0.512449
material.go
starcoder
package model // Accessdown. Use Layer 2 mode to bridge the packets sent to this service if it is marked as DOWN. If the service is DOWN, and this parameter is disabled, the packets are dropped.<br>Default value: NO<br>Possible values = YES, NO. // All. Display both user-configured and dynamically learned services....
model/service.go
0.659295
0.528168
service.go
starcoder
package svgslides import ( "bytes" "fmt" "math" ) const arrowHeadLength = 21 type Point struct { x, y float64 } // Connector type Connector struct { Id int `json:"id"` ShapeId1 int `json:"shapeId1"` ShapeId2 int `json:"shapeId2"` } func arrowHeadXLength(slope float64) float64 { return arrowHeadLength...
connector.go
0.592902
0.46873
connector.go
starcoder
package quality import "fmt" // Evaluator calcuates a quality metric given search results and a corpus. type Evaluator func(results Results, corpus Corpus) (float64, error) // Evaluators is a set of evaluators keyed by their metric name. type Evaluators map[string]Evaluator // MRR is the Mean Reciprocal Rank; that ...
evaluate.go
0.901444
0.496094
evaluate.go
starcoder
package twelve import ( "strings" ) const testVersion = 1 // Song returns the whole twelve days song. func Song() string { return `On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree. On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear T...
twelve-days/twelve_days.go
0.502441
0.637807
twelve_days.go
starcoder
package strings import ( "regexp" "strings" "github.com/yistabraq/qframe/qerrors" ) type Matcher interface { Matches(s string) bool } type CIStringMatcher struct { matchString string //nolint:structcheck buf []byte //nolint:structcheck } type CIPrefixMatcher CIStringMatcher func (m *CIPrefixMatcher)...
internal/strings/match.go
0.623148
0.418994
match.go
starcoder
// AzureStore is a storage backend that uses the AzService interface in order to store uploads in Azure Blob Storage. // It stores the uploads in a container specified in two different BlockBlob: The `[id].info` blobs are used to store the fileinfo in JSON format. The `[id]` blobs without an extension contain the raw ...
pkg/azurestore/azureservice.go
0.806815
0.404331
azureservice.go
starcoder
package vm import ( "fmt" "math" "reflect" ) type Call struct { Name string Size int } type Scope map[string]interface{} func fetch(from interface{}, i interface{}) interface{} { v := reflect.ValueOf(from) switch v.Kind() { case reflect.Array, reflect.Slice, reflect.String: index := int(cast(i)) value ...
test/fixtures/gomod-small/vm/runtime.go
0.58747
0.443962
runtime.go
starcoder
package faker // The movr workload uses this library and is built into the cockroach binary. // The common case is that someone won't be using movr, so avoid the allocations // by using functions instead of static dicts. func words() *weightedEntries { return makeWeightedEntries( `a`, 1.0, `ability`, 1.0, `ab...
pkg/workload/faker/dict.go
0.641871
0.747178
dict.go
starcoder
package countersmodule import ( "fmt" "strconv" "strings" bot "../sweetiebot" "github.com/erikmcclure/discordgo" ) // CountersModule manages incrementable counters type CountersModule struct { } // New instance of CountersModule func New() *CountersModule { return &CountersModule{} } // Name of the module fu...
countersmodule/CountersModule.go
0.698021
0.478224
CountersModule.go
starcoder
package dac import ( "encoding/asn1" "fmt" "github.com/ndss-2020-anonymized/fabric-amcl/amcl" "github.com/ndss-2020-anonymized/fabric-amcl/amcl/FP256BN" ) // NymSignature is signature / NIZK proof of knowledge of pseudonym's // secret key sk and randomness skNym type NymSignature struct { resSk *FP256BN.BI...
dac/pseudonym.go
0.748995
0.408395
pseudonym.go
starcoder
package vox import "fmt" import "math" const ( ChunkWidth = 16 ChunkDepth = 16 ChunkHeight = 16 ChunkXZ = ChunkWidth * ChunkDepth ChunkXYZ = ChunkXZ * ChunkHeight ) type ChunkPosition struct { X, Y, Z int } func (p *ChunkPosition) Set(x, y, z int) *ChunkPosition { p.X = x p.Y = y p.Z = z return ...
chunk.go
0.698946
0.466359
chunk.go
starcoder
package main // XXX this is a bad version of b_final.go that uses channels instead of an // unsynchronized iterator type, for microbenchmarking the synch overhead imposed // by channels. buffering helps a little but i'm still seeing a 5x-10x slowdown import ( "bufio" "fmt" "os" ) const ( // this is fully paramet...
2020/17/b_channels.go
0.617859
0.427576
b_channels.go
starcoder
package lucene41 import ( "github.com/gzg1984/golucene/core/codec/compressing" ) // lucene41/Lucene41StoredFieldsFormat.java /* Lucene 4.1 stored fields format. Principle This StoredFieldsFormat compresses blocks of 16KB of documents in order to improve the compression ratio compared to document-level compression...
core/codec/lucene41/storedFieldsFormat.go
0.70069
0.558026
storedFieldsFormat.go
starcoder
package layout import ( "image" "gioui.org/op" ) // Stack lays out child elements on top of each other, // according to an alignment direction. type Stack struct { // Alignment is the direction to align children // smaller than the available space. Alignment Direction } // StackChild represents a child for a ...
layout/stack.go
0.608129
0.444987
stack.go
starcoder
package assert import ( "bytes" "fmt" "reflect" "strings" "testing" "github.com/d5/tengo/compiler" "github.com/d5/tengo/compiler/source" "github.com/d5/tengo/compiler/token" "github.com/d5/tengo/objects" ) // NoError asserts err is not an error. func NoError(t *testing.T, err error, msg ...interface{}) bool...
assert/assert.go
0.657098
0.57687
assert.go
starcoder
package iso20022 // Describes the type of product and the assets to be transferred. type PEPISATransfer5 struct { // Unique and unambiguous identifier for a group of individual transfers as assigned by the instructing party. This identifier links the individual transfers together. MasterReference *Max35Text `xml:"M...
PEPISATransfer5.go
0.735262
0.553686
PEPISATransfer5.go
starcoder
package tuple import ( "math" "github.com/calbim/ray-tracer/src/util" ) // Tuple is set of coordinates type Tuple struct { X float64 Y float64 Z float64 W float64 } // Point returns a new point func Point(x, y, z float64) Tuple { return Tuple{x, y, z, 1} } // Vector returns a new vector func Vector(x, y, z ...
src/tuple/tuple.go
0.913802
0.66371
tuple.go
starcoder
package xeval import ( "github.com/juju/errors" "github.com/pingcap/tidb/util/types" "github.com/pingcap/tipb/go-tipb" ) // evalLogicOps computes LogicAnd, LogicOr, LogicXor results of two operands. func (e *Evaluator) evalLogicOps(expr *tipb.Expr) (types.Datum, error) { if expr.GetTp() == tipb.ExprType_Not { ...
distsql/xeval/eval_logic_ops.go
0.540924
0.436082
eval_logic_ops.go
starcoder
// Buffered reading and decoding of DWARF data streams. package util import ( "debug/dwarf" "fmt" ) // Data buffer being decoded. type buf struct { dwarf *dwarf.Data format dataFormat name string off dwarf.Offset data []byte Err error } // Data format, other than byte order. This affects the ha...
pkg/dwarf/util/buf.go
0.608129
0.482856
buf.go
starcoder
package mat import ( "github.com/eriklupander/rt/internal/pkg/calcstats" "math/rand" "sort" ) func NewCSG(operation string, left, right Shape) *CSG { m1 := New4x4() inv := New4x4() c := &CSG{Id: rand.Int63(), Transform: m1, Inverse: inv, Left: left, Right: right, Operation: ...
internal/pkg/mat/csg.go
0.756717
0.449634
csg.go
starcoder
package geojson_to_shape import ( "github.com/skyhookml/skyhookml/skyhook" "github.com/skyhookml/skyhookml/exec_ops" "fmt" "github.com/paulmach/go.geojson" ) func ShapeToGeoJson(url string, outputDataset skyhook.Dataset, task skyhook.ExecTask) error { // Helper function to convert shape to GeoJSON geometries g...
exec_ops/geojson_to_shape/to_geojson.go
0.724968
0.568955
to_geojson.go
starcoder
package quantise import ( "image" "image/color" ) type Strategy int const ( // Merge the colours representing the fewest pixels LEAST Strategy = iota // Merge the colours representing the greatest pixels MOST ) type OctreeQuantiser struct { Size int Depth uint8 Strategy Strategy } func (q OctreeQu...
octree.go
0.769514
0.406332
octree.go
starcoder
package auth import ( "bytes" "sort" "github.com/coreos/etcd/auth/authpb" "github.com/coreos/etcd/mvcc/backend" ) // isSubset returns true if a is a subset of b. // If a is a prefix of b, then a is a subset of b. // Given intervals [a1,a2) and [b1,b2), is // the a interval a subset of b? func isSubset(a, b *ran...
vendor/github.com/coreos/etcd/auth/range_perm_cache.go
0.706899
0.429968
range_perm_cache.go
starcoder
package common import ( "fmt" ) // RollingIndexMap is a collection of RollingIndexes. type RollingIndexMap struct { name string size int keys []uint32 mapping map[uint32]*RollingIndex } // NewRollingIndexMap creates a new RollingIndexMap where each RollingIndex has // the specified size. func NewRollin...
src/common/rolling_index_map.go
0.75274
0.401834
rolling_index_map.go
starcoder
package lhex import "sort" // Labels provides a mapping from label name to offset. type Labels struct { lmap map[string]int64 // the actual label data // cached derivatives offLabels map[int64][]string offsets []int64 } // NewLabels creates a *Labels instance from the contents of lmap. Future // changes to l...
labels.go
0.688154
0.50116
labels.go
starcoder
package types import "github.com/pingcap/tidb/types/json" // Row is an interface to read columns values. type Row interface { // GetInt64 returns the int64 value and isNull with the colIdx. GetInt64(colIdx int) (val int64, isNull bool) // GetUint64 returns the uint64 value and isNull with the colIdx. GetUint64...
types/row.go
0.750644
0.63641
row.go
starcoder
package main /* (这是一个 交互式问题 ) 给你一个 山脉数组 mountainArr,请你返回能够使得 mountainArr.get(index) 等于 target 最小 的下标 index 值。 如果不存在这样的下标 index,就请返回 -1。 何为山脉数组?如果数组 A 是一个山脉数组的话,那它满足如下条件: 首先,A.length >= 3 其次,在 0 < i < A.length - 1 条件下,存在 i 使得: A[0] < A[1] < ... A[i-1] < A[i] A[i] > A[i+1] > ... > A[A.length - 1] 你将 不能直接访问该山脉数...
src/main/java/leetcode1095/Solution.go
0.573201
0.432003
Solution.go
starcoder
package circuit import ( "fmt" "sort" ) // Circuit represents an Escher circuit. // See the Escher Handbook for a description of circuits. type Circuit struct { Gate map[Name]Value Flow map[Name]map[Name]Vector // gate -> valve -> opposing gate and valve } // Super is the super-gates name. // The super-gate is ...
circuit/circuit.go
0.848062
0.501404
circuit.go
starcoder
package values import ( "fmt" "strings" ) // StringValue value represents a string value type StringValue struct { value string } // IsEqualTo returns true if the value is equal to the expected value, else false func (s StringValue) IsEqualTo(expected interface{}) bool { return s.value == expected } // Value re...
internal/pkg/values/string_value.go
0.892262
0.64937
string_value.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // AttackSimulationTrainingUserCoverage type AttackSimulationTrainingUserCoverage struct { // Stores additional data not described in the OpenAPI description ...
models/attack_simulation_training_user_coverage.go
0.683525
0.457137
attack_simulation_training_user_coverage.go
starcoder
// Package system implements SVG rendering of Lindenmayer systems package system import ( "bytes" "encoding/gob" "fmt" "log" "os" "unicode" ) // A rewriteSet is a set of rules for replacing variables with sequences. type rewriteSet map[byte][]byte // A System is a representation of a Lindenmayer system (L-sys...
system/system.go
0.756088
0.438845
system.go
starcoder
package server import ( pb "github.com/grafeas/grafeas/v1alpha1/proto" opspb "google.golang.org/genproto/googleapis/longrunning" ) // Storager is the interface that a Grafeas storage implementation would provide type Storager interface { // CreateProject adds the specified project CreateProject(pID string) error...
server-go/storage.go
0.608361
0.467332
storage.go
starcoder
package utils import ( "fmt" "math" "gonum.org/v1/gonum/blas/blas64" "gonum.org/v1/gonum/mat" ) type Vector struct { V *mat.VecDense DataP []float64 } func NewVector(n int, dataO ...[]float64) Vector { var ( data []float64 ) if len(dataO) != 0 { data = dataO[0] } v := mat.NewVecDense(n, data) re...
utils/vector_extended.go
0.652241
0.637003
vector_extended.go
starcoder
package apimodel import ( "github.com/alexandre-normand/glukit/app/util" "time" ) const ( CARB_TAG = "Carbs" ) // Meal is the data structure that represents a meal of food intake. Only carbohydrates // are fully supported at the moment. type Meal struct { Time Time `json:"time" datastore:"time,noinde...
app/apimodel/meal.go
0.71103
0.405655
meal.go
starcoder
package collision2d import ( "fmt" "math" ) //Vector is a simple 2D vector/point struct. type Vector struct { X, Y float64 } func (vector Vector) String() string { return fmt.Sprintf("{X:%f, Y:%f}\n", vector.X, vector.Y) } //NewVector create a new vector with the values of x and y func NewVector(x, y float64) V...
vector.go
0.942015
0.869382
vector.go
starcoder
package main /* This is a test module that does the following: 1) Creates an OpenGL window 2) Creates an RGB texture from perlin noise 3) Displays the noise as a texture on a plane in the window It requires the GLFW3 and GLEW libraries as well as the Go wrappers for them: go-gl/gl and go-gl/glfw3. Basic build inst...
examples/noise_builder_gl.go
0.776919
0.454351
noise_builder_gl.go
starcoder
package enumerable import ( "fmt" "reflect" ) // IterFunc represents a function which will be called when iterating through a slice type IterFunc interface{} // AnySlice represents a slice with elements of any type type AnySlice interface{} // AnyValue represents any value type AnyValue interface{} func mustBeFu...
iter_func.go
0.774328
0.417806
iter_func.go
starcoder
package channeldb import ( "bytes" "fmt" "github.com/coreos/bbolt" ) // migrateNodeAndEdgeUpdateIndex is a migration function that will update the // database from version 0 to version 1. In version 1, we add two new indexes // (one for nodes and one for edges) to keep track of the last time a node or // edge was...
channeldb/migrations.go
0.645008
0.461623
migrations.go
starcoder
// Package parser provides a markdown file reader and model package parser import ( "io" "io/ioutil" "os" "path/filepath" "regexp" "strings" ) // Parser is markdown file reader type Parser struct { linkRegex *regexp.Regexp } // New creates new Parser instance func New() *Parser { return &Parser{ linkRegex...
internal/parser/parser.go
0.614047
0.448185
parser.go
starcoder
package xatomic import ( "math" "sync/atomic" ) // AtomicFloat64 is an atomic wrapper around float64. type AtomicFloat64 struct { v uint64 } // NewAtomicFloat64 creates a AtomicFloat64. func NewAtomicFloat64(f float64) *AtomicFloat64 { return &AtomicFloat64{math.Float64bits(f)} } // Load atomically loads the wr...
xsync/xatomic/atomic_float.go
0.880714
0.525125
atomic_float.go
starcoder
package ar3 import ( "fmt" "github.com/trilobio/kinematics" ) // AR3simulate struct represents an AR3 robotic arm interface for testing purposes. type AR3simulate struct { jointVals [7]int jointDirs [7]bool limitSwitchSteps [7]int } // ConnectMock connects to a mock AR3simulate interface. func Co...
mock.go
0.737253
0.560132
mock.go
starcoder
package values import ( "fmt" ) // IntValue is a struct that holds an int value. type IntValue struct { value int } // IsEqualTo returns true if the value is equal to the expected value, else false. func (i IntValue) IsEqualTo(expected interface{}) bool { return i.equals(NewIntValue(expected)) } // IsGreaterThan...
internal/pkg/values/int_value.go
0.825379
0.694872
int_value.go
starcoder
package loader const ( // AnchorContextURIV1 is anchor credential context URI. AnchorContextURIV1 = "https://trustbloc.github.io/did-method-orb/contexts/anchor/v1" // JwsContextURIV1 is jws context. JwsContextURIV1 = "https://w3id.org/jws/v1" ) // AnchorContextV1 is anchor context. const AnchorContextV1 = ` { ...
pkg/context/loader/context.go
0.6137
0.425725
context.go
starcoder
package result import ( "errors" "fmt" ) var nilError = errors.New("no error given") func ensureError(err error) error { if err == nil { return nilError } return err } type Result[T any] struct { value T err error } func From[T any](value T, err error) Result[T] { return Result[T]{value: value, err: er...
monads/result/result.go
0.529507
0.580738
result.go
starcoder
package cronexpr import ( "time" ) type ( Schedule struct { Minute, Hour, Dom, Month, Dow bitset Location *time.Location } ) // Next returns the next time matched with the expression. func (s *Schedule) Next(t time.Time) time.Time { loc := time.UTC if s.Location != nil { loc = s.Location } origLoc := ...
schedule.go
0.529507
0.465995
schedule.go
starcoder
package north import ( "bytes" "fmt" "io" ) type operandType uint8 const ( largeConstantOperand operandType = iota smallConstantOperand variableOperand omittedOperand ) type branchInfo uint16 // Condition returns which boolean value the branch is checking for. func (b branchInfo) Condition() bool { return ...
north/instruction.go
0.651798
0.457379
instruction.go
starcoder
package unsafe // ArbitraryType is here for the purposes of documentation only and is not actually // part of the unsafe package. It represents the type of an arbitrary Go expression. type ArbitraryType int // Pointer represents a pointer to an arbitrary type. There are three special operations // available for typ...
src/pkg/unsafe/unsafe.go
0.633864
0.614278
unsafe.go
starcoder
package day02 import ( "regexp" "strconv" ) type PasswordValidator struct { Char rune Min int Max int Password string } // ValidPart1 checks that the password is valid // by checking the ocurrences of the given character func (pv PasswordValidator) ValidPart1() bool { occurences := make(map[rune...
day02/day2.go
0.669637
0.413714
day2.go
starcoder
package evolution import ( "fmt" "math" ) // Epoch is defined as a coevolutionary step where protagonist and antagonist compete. // For example an epoch could represent a distinct interaction between two parties. // For instance a bug mutated program (antagonist) can be challenged a variety of times ( // specified ...
evolution/competition_roundrobin_epoch.go
0.623606
0.493775
competition_roundrobin_epoch.go
starcoder
package best import ( "context" "sort" "github.com/attestantio/go-eth2-client/spec" "github.com/attestantio/go-eth2-client/spec/phase0" ) // scoreBeaconBlockPropsal generates a score for a beacon block. // The score is relative to the reward expected by proposing the block. func scoreBeaconBlockProposal(ctx con...
strategies/beaconblockproposal/best/score.go
0.653016
0.424233
score.go
starcoder
package mpqtesting import ( "sort" "strings" "sync" "github.com/vburenin/firempq/apis" ) type InMemDBService struct { mutex sync.Mutex mapData map[string][]byte closed bool } func NewInMemDBService() *InMemDBService { return &InMemDBService{ mapData: make(map[string][]byte), } } func (d *InMemDBServi...
mpqtesting/memdbservice.go
0.538255
0.486758
memdbservice.go
starcoder
package parser import ( "fmt" "github.com/benchlab/asteroid/token" "github.com/blang/semver" "github.com/benchlab/asteroid/ast" ) func parseReturnStatement(p *Parser) { start := p.getCurrentTokenLocation() p.parseRequired(token.Return) node := ast.ReturnStatementNode{ Begin: start, Final: p.getLast...
parser/statements.go
0.54577
0.472379
statements.go
starcoder
package godouble import ( "fmt" "reflect" ) //AssertMethodReturnValues fatally fails test t unless returnValues are compatible with method func AssertMethodReturnValues(t T, method reflect.Method, returnValues []interface{}) { t.Helper() returnTypes := make([]reflect.Type, len(returnValues)) for i, v := range re...
godouble/assert.go
0.546496
0.436922
assert.go
starcoder
package continuous import ( "github.com/jtejido/stats" "github.com/jtejido/stats/err" "math" "math/rand" ) // Inverse Gaussian distribution // https://en.wikipedia.org/wiki/Inverse_Gaussian_distribution type InverseGaussian struct { mean, shape float64 // μ (mean), λ (shape) src rand.Source } func NewI...
dist/continuous/inverse_gaussian.go
0.849847
0.455865
inverse_gaussian.go
starcoder
// Package stats contains interfaces and utilities relating to the collection of // statistics from a fleetspeak server. package stats import ( "time" "github.com/google/fleetspeak/fleetspeak/src/common" "github.com/google/fleetspeak/fleetspeak/src/server/db" fspb "github.com/google/fleetspeak/fleetspeak/src/co...
fleetspeak/src/server/stats/collector.go
0.554953
0.464841
collector.go
starcoder
package geom import ( "math" ) // Bounds holds the spatial extent of a geometry. type Bounds struct { Min, Max Point } // Extend increases the extent of b1 to include b2. func (b *Bounds) Extend(b2 *Bounds) { if b2 == nil { return } b.extendPoint(b2.Min) b.extendPoint(b2.Max) } // NewBounds initializes a ne...
bounds.go
0.844505
0.658273
bounds.go
starcoder
package matrix import ( "fmt" "math" "github.com/dabasan/go-dh3dbasis/vector" ) type Matrix struct { M [4][4]float32 } func (m *Matrix) String() string { str := "" for i := 0; i < 4; i++ { str += fmt.Sprintf("%g %g %g %g", m.M[i][0], m.M[i][1], m.M[i][2], m.M[i][3]) if i != 3 { str += "\n" } } re...
matrix/matrix.go
0.709824
0.437523
matrix.go
starcoder
package pkg import ( "github.com/slobdell/basicMatrix" ) /* Although these variables aren't expressive, they're based on existing mathematical conventions and in reality should be completely abstract. The variables in my own words expressed below: H: For our usage, this should just be an identity matrix. In p...
pkg/kalman.go
0.744471
0.754418
kalman.go
starcoder
package types import ( "database/sql/driver" "encoding/hex" "fmt" "math/big" "math/rand" "reflect" "strings" "github.com/xunleichain/tc-wasm/mock/deps/hexutil" ) // Lengths of hashes in bytes. const ( // HashLength is the expected length of the hash HashLength = 32 ) var ( EmptyHash = Hash{} hashT ...
mock/types/hash.go
0.744749
0.451327
hash.go
starcoder
package goptuna import ( "encoding/json" "errors" "math" ) var ( // ErrUnknownDistribution returns the distribution is unknown. ErrUnknownDistribution = errors.New("unknown distribution") ) // Distribution represents a parameter that can be optimized. type Distribution interface { // ToExternalRepr to convert ...
distribution.go
0.873754
0.517388
distribution.go
starcoder
package main import ( "advent/utils" "bufio" "flag" "fmt" "os" "sort" "strconv" "strings" svg "github.com/ajstarks/svgo" ) type opts struct { filePath string debug bool draw bool } var _o opts type vector2 struct { x int y int } func (a *vector2) add(b vector2) vector2 { return vector2{a.x +...
03.01/main.go
0.510252
0.41117
main.go
starcoder
package solution import ( "container/heap" "math" ) /* leetcode: https://leetcode.com/problems/network-delay-time/ */ /* We use dijkstra to solve this problem. First, we go from node K and update cost for nodes that node K can connected to. Then we choose next node that has min cost and do the same as node K. ...
lesson-13/dijkstra/743-network-delay-time/solution.go
0.807726
0.418994
solution.go
starcoder
// Package model provides the complete representation of the model for a given GEP problem. package model import ( "fmt" "log" "math/rand" "runtime" "github.com/gmlewis/gep/functions" "github.com/gmlewis/gep/gene" "github.com/gmlewis/gep/genome" ) // Generation represents one complete generation of the model...
model/model.go
0.7011
0.583025
model.go
starcoder
package geom import "fmt" // extractGeometry converts the DECL into a Geometry that represents it. func (d *doublyConnectedEdgeList) extractGeometry(include func([2]label) bool) (Geometry, error) { areals, err := d.extractPolygons(include) if err != nil { return Geometry{}, err } linears, err := d.extractLineSt...
geom/dcel_extract.go
0.732783
0.509276
dcel_extract.go
starcoder
package factom import ( "encoding/hex" "fmt" ) // Bytes32 implements encoding.TextMarshaler and encoding.TextUnmarshaler to // encode and decode hex strings with exactly 32 bytes of data, such as // ChainIDs and KeyMRs. type Bytes32 [32]byte // Bytes implements encoding.TextMarshaler and encoding.TextUnmarshaler ...
bytes.go
0.829596
0.412708
bytes.go
starcoder
package classic import ( "go/ast" "go/token" r "reflect" . "github.com/cosmos72/gomacro/base" "github.com/cosmos72/gomacro/base/genimport" "github.com/cosmos72/gomacro/base/reflect" etoken "github.com/cosmos72/gomacro/go/etoken" ) func (env *Env) evalExprsMultipleValues(nodes []ast.Expr, expectedValuesN int) ...
vendor/github.com/cosmos72/gomacro/classic/expr.go
0.514156
0.40869
expr.go
starcoder
package tetra3d import "strings" type NodeFilter []INode func newNodeFilter(nodes ...INode) NodeFilter { return NodeFilter(nodes) } // First returns the first Node in the NodeFilter; if the NodeFilter is empty, this function returns nil. func (nf NodeFilter) First() INode { if len(nf) > 0 { return nf[0] } ret...
nodefilter.go
0.820073
0.420659
nodefilter.go
starcoder
ERROR: type should be string, got "https://codeforces.com/blog/entry/72593 */\npackage main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"math/big\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// lcf represents a linear congruential function in the form f(x) = ax + b mod m\ntype lcf struct {\n\ta *big.Int\n\tb *big.Int\n\tm *big.Int // modulo\n}\n\n// compose two functions f(x) and g(x). First apply f(x), then apply g(x). g(f(x)).\nfunc (f *lcf) compose(g lcf) lcf {\n\t//(a, b) ; (c, d) = (ac mod m, bc+d mod m)\n\n\tif f.m.Cmp(g.m) != 0 {\n\t\tpanic(\"cannot compose functions with different modulos\")\n\t}\n\n\tnewA := big.NewInt(1)\n\tnewA.Mul(f.a, g.a)\n\tnewA.Mod(newA, f.m)\n\n\tnewB := big.NewInt(1)\n\tnewB.Mul(f.b, g.a)\n\tnewB.Add(newB, g.b)\n\tnewB.Mod(newB, f.m)\n\treturn lcf{a: newA, b: newB, m: f.m}\n}\n\n// operate returns the position of the card x after the shuffle represented by this lcf.\nfunc (f *lcf) operate(x *big.Int) *big.Int {\n\t// f(x) = ax + b mod m\n\tfx := big.NewInt(-1)\n\tfx.Mul(f.a, x)\n\tfx.Add(fx, f.b)\n\tfx.Mod(fx, f.m)\n\treturn fx\n}\n\nfunc getInput(path string) []string {\n\tdata, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\tpanic(\"Can't read input file.\")\n\t}\n\n\ttxt := string(data)\n\tinstructions := strings.Split(txt, \"\\n\")\n\treturn instructions\n}\n\n// instr2Lcf converts an instruction in text form into its lcf representation.\n// deal into new stack: f(x) = -x - 1 mod m\n// cut N: f(x) = x - n mod m\n// deal with increment N: f(x) = nx mod m\nfunc instr2Lcf(instruction string, deckSize *big.Int) lcf {\n\tif instruction == \"deal into new stack\" {\n\t\treturn lcf{a: big.NewInt(-1), b: big.NewInt(-1), m: deckSize}\n\t}\n\n\tif instruction[:4] == \"cut \" {\n\t\tval, err := strconv.Atoi(instruction[4:])\n\t\tif err != nil {\n\t\t\tpanic(\"Can't parse number\")\n\t\t}\n\t\tn := int64(val)\n\t\treturn lcf{a: big.NewInt(1), b: big.NewInt(-n), m: deckSize}\n\t}\n\n\tif instruction[:20] == \"deal with increment \" {\n\t\tval, err := strconv.Atoi(instruction[20:])\n\t\tif err != nil {\n\t\t\tpanic(\"Can't parse number.\")\n\t\t}\n\t\tn := int64(val)\n\n\t\treturn lcf{a: big.NewInt(n), b: big.NewInt(0), m: deckSize}\n\t}\n\tpanic(\"bad instruction\")\n}\n\n// convertInstrToLcf converts a slice of instructions in raw text form\n// into their lcf representations and returns a slice of lcfs\nfunc convertInstrToLcf(instructions []string, deckSize *big.Int) []lcf {\n\tlcfs := make([]lcf, len(instructions))\n\tfor i, instr := range instructions {\n\t\tlcfs[i] = instr2Lcf(instr, deckSize)\n\t}\n\treturn lcfs\n}\n\n// compose a series of shuffle operations into a single lcf\nfunc compose(lcfs []lcf) lcf {\n\tf := lcfs[0]\n\tfor i := 1; i < len(lcfs); i++ {\n\t\tf = f.compose(lcfs[i])\n\t}\n\treturn f\n}\n\n// powCompose composes a function f(x) into itself k times\nfunc powCompose(f lcf, k int64) lcf {\n\tg := lcf{a: big.NewInt(1), b: big.NewInt(0), m: f.m}\n\tfor k > 0 {\n\t\tif k%2 == 1 {\n\t\t\tg = g.compose(f)\n\t\t}\n\t\tk /= 2\n\t\tf = f.compose(f)\n\t}\n\treturn g\n}\n\nfunc part1(instr []string) {\n\tdeckSize := big.NewInt(10007)\n\tlcfs := convertInstrToLcf(instr, deckSize)\n\tf := compose(lcfs) // f(x) represents a single shuffle of the deck\n\tres := f.operate(big.NewInt(2019))\n\tfmt.Println(\"[PART 1]: Card 2019 is at position\", res)\n}\n\nfunc part2(instr []string) {\n\tm := big.NewInt(119315717514047) // deck size\n\tlcfs := convertInstrToLcf(instr, m) // shuffle sequence\n\tk := int64(101741582076661) // no. of shuffles\n\tf := compose(lcfs) // f(x) represents a single shuffle of the deck\n\tf = powCompose(f, k) // f(x) represents k shuffles of the deck\n\n\t/* f(x) tells us where card x ends up after k shuffles. But the problem asks us which\n\tcard ends up in position 2020. Thus we need to invert f(x).\n\tThe inverse of f(x) must be a function F(x) such that x = aF(x) + b.\n\tThat is to say, F(x) is a function of x that performs the reverse operation of f(x).\n\tAfter rearranging to isolate F(x):\n\t x - b\n\tF(x) = ------- mod m\n\t a\n\t*/\n\tx := big.NewInt(2020)\n\tnumerator := big.NewInt(0)\n\tnumerator.Sub(x, f.b)\n\tdenominator := f.a\n\n\t/*Division in modular arithmetic is done by first finding the modular multiplicative\n\tinverse of the denominator, and then multiplying the numerator by that value.\n\t \tp/q mod m = p・q^-1 mod m\n\t*/\n\tdenominator.ModInverse(denominator, m) // modular multiplicative inverse of a = q^-1\n\tnumerator.Mul(numerator, denominator) // p・q^-1\n\tnumerator.Mod(numerator, m) // p・q^-1 mod m\n\tfmt.Println(\"[PART 2]: The card at position\", x, \"ends up in position\", numerator, \"after\", k, \"shuffles.\")\n}\n\nfunc main() {\n\tinstr := getInput(\"input.txt\")\n\tpart1(instr)\n\tpart2(instr)\n}"
puzzle22/main.go
0.772531
0.452052
main.go
starcoder
package linearsearch // linearSearchIterative takes a sorted/random list of numbers // and uses the `iterative` process to check index by index to // find the target. // - the worst case of this algorithm is O(n). // - the best case of this algorithm is O(1). func linearSearchIterative(list []int, target int) int { i...
topics/go/algorithms/searches/linearsearch/linearsearch.go
0.870831
0.622976
linearsearch.go
starcoder
package api // LittleEndianSwap is the swapping little-endian implementation of binary.ByteOrder. var LittleEndianSwap littleEndianSwap // BigEndianSwap is the swapping big-endian implementation of binary.ByteOrder. var BigEndianSwap bigEndianSwap type littleEndianSwap struct{} func (littleEndianSwap) Uint16(b []by...
octopus/pkg/endian/api/binary.go
0.604632
0.548492
binary.go
starcoder
package graph // NewCompositeGraph returns an ReadOnlyGraph instance that uses the input states as a stack to surface values. // When a request for an id relationship is placed through one of it's functions, it searches down the stack for the // first state that has the desired information, and returns that to the use...
pkg/dackbox/graph/composite.go
0.882889
0.635844
composite.go
starcoder
package boxmodel import ( "github.com/adamcolton/geom/d2" "github.com/adamcolton/geom/d2/affine" "github.com/adamcolton/geom/d2/curve/line" "github.com/adamcolton/geom/d2/shape" "github.com/adamcolton/geom/d2/shape/box" ) type frame struct { node uint32 child byte } // the cursor manages the operation of mov...
d2/shape/boxmodel/cursor.go
0.605682
0.460471
cursor.go
starcoder
package mathutil import ( "math" "math/big" ) // Pow ... func Pow(i, e *big.Int) *big.Int { return new(big.Int).Exp(i, e, nil) } // FromTwos ... func FromTwos(value *big.Int, width int) *big.Int { a := inotn(value, width) b := new(big.Int).Add(a, big.NewInt(1)) return new(big.Int).Neg(b) } // ToTwos ... func ...
util/mathutil/mathutil.go
0.685213
0.47244
mathutil.go
starcoder
package partitioning import ( "encoding/binary" "math" "vitess.io/vitess/go/vt/key" topodatapb "vitess.io/vitess/go/vt/proto/topodata" ) /* EqualKeyRanges returns the list of KeyRanges for a partitioning into a given number of equal parts. If the number of parts is a power of 2, the keyspace will be partitioned...
pkg/operator/partitioning/partitioning.go
0.796174
0.508971
partitioning.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 SettlementParties12 struct { // First party in the set...
SettlementParties12.go
0.682045
0.460471
SettlementParties12.go
starcoder
package main import "log" /** 题目:https://leetcode-cn.com/problems/sort-an-array/solution/kuai-pai-vs-gui-bing-pai-xu-vs-dui-pai-x-44hf/ 快速排序: 快速排序算法通过多次比较和交换来实现排序,其排序流程如下: [2] (1)首先设定一个分界值,通过该分界值将数组分成左右两部分。 [2] (2)将大于或等于分界值的数据集中到数组右边,小于分界值的数据集中到数组的左边。此时,左边部分中各元素都小于或等于分界值,而右边部分中各元素都大于或等于分界值。 [2] (3)然后,左边和右边的数据可以独立排序。对...
algorithm/Sort/quick/twoNumberExchange/sort.go
0.565059
0.630799
sort.go
starcoder
package autocompletion import ( "strings" "text/template" "bytes" "strconv" ) // The kind of recommendation type Type uint const ( // No recommendation NONE Type = iota // Class recommendation CLASS // Predicate recommendation PREDICATE // Path recommendation PATH ...
autocompletion/scope.go
0.683947
0.445409
scope.go
starcoder
package core import ( "math/rand" "sort" ) type PEGASIS struct { Clusters int // A number of clusters in the network. Nodes int // A number of nodes in the network. } type clusterHead struct { hid int64 distanceToBase float64 } // Setup implements Protocol.Setup. func (p *PEGASIS) Setup(net *Net...
core/pegasis.go
0.733643
0.463201
pegasis.go
starcoder
package interpreter // TypeInfo represents metadata about a type. type TypeInfo int const ( // TypeInfoNone says that a type has no associated metadata. TypeInfoNone TypeInfo = 0 // TypeInfoSignedInteger says that a type is a signed integer. TypeInfoSignedInteger TypeInfo = 1 // TypeInfoUnsignedInteger says th...
interpreter/type_data.go
0.856498
0.561816
type_data.go
starcoder
package iso20022 // General characteristics related to a statement which reports information for a precise date. type Statement59 struct { // Specifies the business role of the message sender and, therefore, the business relationship between the sender and the receiver (or the interests represented by them, in those...
Statement59.go
0.849815
0.467514
Statement59.go
starcoder