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 g2d import ( "github.com/angelsolaorbaiceta/inkgeom/nums" ) // A Segment is a straignt line defined between two points. type Segment struct { start, end *Point } // MakeSegment creates a new segment defined between the given start and end points. func MakeSegment(start, end *Point) *Segment { return &Segm...
g2d/segment.go
0.85186
0.592166
segment.go
starcoder
package filter import ( "fmt" "gorm.io/gorm" "goyave.dev/goyave/v4/helper" ) // Operator used by filters to build the SQL query. // The operator function modifies the GORM statement (most of the time by adding // a WHERE condition) then returns the modified statement. // Operators may need arguments (e.g. "$eq", ...
operator.go
0.695545
0.453504
operator.go
starcoder
package envelopes import ( "bytes" "errors" "fmt" "math/big" "regexp" "sort" "strings" ) // AssetType is a character code the uniquely identifies a type of asset. For currencies, that is a three-letter code. // For securities like stocks, it will be the set of characters that are used to trade shares of those...
balance.go
0.766818
0.531513
balance.go
starcoder
package layers import ( "github.com/google/gopacket" ) // TLSType defines the type of data after the TLS Record type TLSHandshakeType uint8 // TLSType known values. const ( TLSHandshakeUnknown TLSHandshakeType = 0 TLSHandshakeClientHello TLSHandshakeType = 1 TLSHandshakeServerHello TLSHandshakeType = 2 ) t...
layers/tls_handshake.go
0.615435
0.429429
tls_handshake.go
starcoder
package gophertags import ( "crypto/rand" "math/big" "math/bits" r255 "github.com/gtank/ristretto255" "golang.org/x/crypto/sha3" ) // SecretKey is the secret key held by the ultimate recipient of the messages. // It is used to derive public keys and detection keys for distribution. // Internally, it's a vector ...
tags.go
0.579757
0.418935
tags.go
starcoder
package dag import ( "github.com/goombaio/dag" "github.com/darkowlzz/operator-toolkit/operator/v1/operand" ) // OperandDAG is a directed acyclic graph representation of the opereand // dependencies. This is used to resolve the dependencies of the operands on // each other and find an optimal execution path. type O...
operator/v1/dag/dag.go
0.746786
0.557243
dag.go
starcoder
package compare import "fmt" // Path represents a path from the root of an object hierarchy type Path []Fragment // Fragment is an entry in a Path type Fragment struct { // Operation holds the operation occurring at this level in the path. Operation interface{} // Reference holds the entry in the reference hiera...
core/data/compare/path.go
0.765769
0.544014
path.go
starcoder
package resolv import "fmt" /*A Space represents a collection that holds Shapes for collision detection in the same common space. A Space is arbitrarily large - you can use one Space for a single level, room, or area in your game, or split it up if it makes more sense for your game design. Technically, a Space is jus...
resolv/space.go
0.884133
0.632616
space.go
starcoder
package iso20022 // Specifies rates related to a corporate action option. type CorporateActionRate47 struct { // Rate proposed in a remarketing of variable rate notes. ProposedRate *PercentageRate `xml:"PropsdRate,omitempty"` // Rate of allowed over-subscription. OversubscriptionRate *RateAndAmountFormat5Choice ...
CorporateActionRate47.go
0.787073
0.459015
CorporateActionRate47.go
starcoder
package square // Defines the parameters that can be included in the body of a request to the [Charge](#endpoint-charge) endpoint. Deprecated - recommend using [CreatePayment](#endpoint-payments-createpayment) type ChargeRequest struct { // A value you specify that uniquely identifies this transaction among transact...
square/model_charge_request.go
0.787319
0.455259
model_charge_request.go
starcoder
package game import ( "github.com/oakmound/lowrez17/game/forceSpace" "github.com/oakmound/oak/collision" "github.com/oakmound/oak/physics" "github.com/oakmound/oak/render" ) // We keep track of all anchors and walls, and run an initialization on said anchors and walls // once they are all tracked var ( anchors ...
game/walls.go
0.518302
0.4081
walls.go
starcoder
package sudoku import ( "fmt" "math/rand" "time" ) // Get a Sudoku square (9x9) based on complexity sent in the input func newSudoku(numbersToFill int) Sudoku { var mySudoku Sudoku var randNum int for i := 0; i < RowLength; i++ { // generate a brand new Row with all zeros and append to Sudoku mySudoku = ap...
sudoku/sudokugen.go
0.591251
0.430806
sudokugen.go
starcoder
package gene import ( "errors" "github.com/vertgenlab/gonomics/dna" ) type Feature int32 type MutationType byte const ( Intron Feature = -1 UtrThree Feature = -3 UtrFive Feature = -5 // All positive values refer to cDNA position Silent MutationType = 0 Missense MutationType = 1 Nonsens...
gene/gene.go
0.614278
0.623348
gene.go
starcoder
package main import "fmt" // Given a 2D board containing 'X' and 'O' (the letter O), // capture all regions surrounded by 'X'. // A region is captured by flipping all 'O's into 'X's in that surrounded region. // Example: // X X X X // X O O X // X X O X // X O X X // After running your function, the board sho...
130.surrounded-regions/main.go
0.61682
0.522689
main.go
starcoder
package learners import ( "github.com/PaddlePaddle/PaddleDTX/dai/mpc/learners/linear_reg_vl" "github.com/PaddlePaddle/PaddleDTX/dai/mpc/learners/logic_reg_vl" pbCom "github.com/PaddlePaddle/PaddleDTX/dai/protos/common" pb "github.com/PaddlePaddle/PaddleDTX/dai/protos/mpc" ) // Learner is assigned with a specific...
dai/mpc/learners/learners.go
0.611962
0.511656
learners.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/servicegroup.go
0.636127
0.448306
servicegroup.go
starcoder
package geom import "fmt" // ApplyToPoints applys the given function to each point in the geometry and any sub geometries, return a new transformed geometry. func ApplyToPoints(geometry Geometry, f func(coords ...float64) ([]float64, error)) (Geometry, error) { switch geo := geometry.(type) { default: return nil,...
utils.go
0.779112
0.638046
utils.go
starcoder
package slices import "fmt" // slice capacity vs slice length: https://tour.golang.org/moretypes/11 // The length of a slice is the number of elements it contains. // The capacity of a slice is the number of elements in the underlying array, counting from the first element in the slice. func Slices() { // declare s...
slices/slices.go
0.60778
0.435121
slices.go
starcoder
package table import ( "reflect" "github.com/aclements/go-gg/generic" ) // Pivot converts rows of g into columns. label and value must name // columns in g, and the label column must have type []string. Pivot // returns a Grouping with a new column named after each distinct // value in the label column, where the...
vendor/github.com/aclements/go-gg/table/pivot.go
0.706494
0.57081
pivot.go
starcoder
package iso20022 // Specifies rates of a corporate action. type CorporateActionRate3 struct { // Annual rate of a financial instrument. Interest *RateAndAmountFormat3Choice `xml:"Intrst,omitempty"` // Percentage of securities the offeror/issuer will purchase or redeem under the terms of the event. This can be a n...
CorporateActionRate3.go
0.824638
0.574335
CorporateActionRate3.go
starcoder
package tinystat import ( "math" "gonum.org/v1/gonum/stat" "gonum.org/v1/gonum/stat/distuv" ) // A Summary is a statistical summary of a normally distributed data set. type Summary struct { N float64 // N is the number of measurements in the set. Mean float64 // Mean is the arithmetic mean of the mea...
tinystat.go
0.933764
0.812607
tinystat.go
starcoder
package geotools import ( "bytes" "encoding/binary" "encoding/hex" "fmt" "googlemaps.github.io/maps" ) const ( defaultSRID = 4326 // https://en.wikipedia.org/wiki/World_Geodetic_System ) type pointEWKB struct { Endiness byte Type uint32 SRID uint32 X float64 Y float64 } // LatLnger...
shapes.go
0.859987
0.474875
shapes.go
starcoder
package geoutil import ( "encoding/json" "fmt" "regexp" "strings" "github.com/PerformLine/go-stockutil/rxutil" "github.com/PerformLine/go-stockutil/typeutil" ) var rxDistanceExtract = regexp.MustCompile(`^(?P<number>\d+(?:\.\d+)?)\s*(?P<unit>[\w\s]+)\W*$`) type Distance float64 const ( Meter = 1 Kil...
geoutil/distance.go
0.709523
0.411406
distance.go
starcoder
package v1alpha1 import ( internalinterfaces "kubeform.dev/provider-aws-api/client/informers/externalversions/internalinterfaces" ) // Interface provides access to all the informers in this group version. type Interface interface { // ByteMatchSets returns a ByteMatchSetInformer. ByteMatchSets() ByteMatchSetInfor...
client/informers/externalversions/wafregional/v1alpha1/interface.go
0.80651
0.40116
interface.go
starcoder
package util type Set struct { values map[string]struct{} } // Create a new empty set func NewSet() *Set { set := &Set{} set.values = make(map[string]struct{}) return set } // Create a new set from the array func CreateSet(values []string) *Set { set := &Set{} set.values = make(map[string]struct{}) for _, val...
pkg/util/set.go
0.764892
0.452113
set.go
starcoder
package events import ( "bytes" "fmt" "strings" "text/template" "github.com/Masterminds/sprig" ) // MarkdownRenderer renders responses as markdown. type MarkdownRenderer struct{} // CommonData is data that all responses have. type CommonData struct { Command string Verbose bool Log string } // ErrData ...
server/events/markdown_renderer.go
0.570571
0.404155
markdown_renderer.go
starcoder
package scimark2 import ( "math" "math/rand" "time" ) func fft_num_flops(N int) float64 { Nd := float64(N) logN := float64(fft_log2(N)) return (5.0*Nd-2)*logN + 2*(Nd+1) } func fft_transform(data []float64) { fft_transform_internal(data, -1) } func fft_inverse(data []float64) { fft_transform_internal(data,...
src/go/entityfx/scimark2/fft.go
0.54819
0.401805
fft.go
starcoder
package hashdict import ( "math/bits" "github.com/peterzeller/go-fun/dict" "github.com/peterzeller/go-fun/iterable" "github.com/peterzeller/go-fun/reducer" "github.com/peterzeller/go-fun/zero" ) // a sparse array with at most 32 entries type sparseArray[T any] struct { // bitmap has a bit value of 1 where the ...
dict/hashdict/sparese-array.go
0.625095
0.577078
sparese-array.go
starcoder
package gruff import ( "fmt" "github.com/jinzhu/gorm" ) /* * Arguments are described in detail in the Canonical Debate White Paper: https://github.com/canonical-debate-lab/paper#312_Argument An Argument connects a Claim to another Claim or Argument That is: a Claim can be used as an ARGUMENT to either ...
gruff/argument.go
0.57821
0.65379
argument.go
starcoder
// Package zero provides facilities for efficiently zeroing Go values. package zero import ( "reflect" "sync" "unsafe" ) var cache sync.Map // map[reflect.Type]func(ptr uintptr, n int) // Slice zeroes the elements 0 <= i < v.Len() of the provided slice. // Slice panics if the value is not a slice. f func Slice(v...
internal/zero/zero.go
0.586996
0.583144
zero.go
starcoder
package main import ( "fmt" "github.com/go-gl/gl" glmath "github.com/go-gl/mathgl/mgl64" "math" ) const ( red = iota blue = iota green = iota ) type Block struct { active bool blockType int } func (block *Block) draw() { if block.active { gl.Begin(gl.QUADS) switch block.blockType { case red: ...
model.go
0.592195
0.499451
model.go
starcoder
package dht import ( "machine" "time" ) type device struct { pin machine.Pin measurements DeviceType temperature int16 humidity uint16 } func (t *device) Temperature() int16 { return t.temperature } func (t *device) TemperatureFloat(scale TemperatureScale) float32 { return scale.convertToFloat(t.temper...
dht/thermometer.go
0.687315
0.4474
thermometer.go
starcoder
package trie import ( "unicode/utf8" ) // Trie represents a trie and contains a pointer to the root node type Trie struct { Root *Node `json:"root,omitempty"` } // Node represents a single node in a trie, usually representing a character type Node struct { Data string `json:"data,omitempty"` Prefix...
trie/trie.go
0.680348
0.545467
trie.go
starcoder
package lexer type regularExpressionOperator int const ( union regularExpressionOperator = iota concat star ) func (r regularExpressionOperator) length() int { switch r { case union: return 1 case star: return 1 default: return 0 } } // RegularExpression represents the string representation of regular...
lexer/regular_expression.go
0.697403
0.503723
regular_expression.go
starcoder
package data import ( "reflect" ) // Sequence is an ordered collection of values. type Sequence []interface{} // Map is an unordered collection of values associated with key values. type Map map[interface{}]interface{} // AsBool converts an untyped value to a boolean. func AsBool(data interface{}) (b bool, ok bool...
data/values.go
0.7874
0.571109
values.go
starcoder
package main import ( "fmt" "strconv" "github.com/theatlasroom/advent-of-code/go/utils" ) /** --- Day 3: Binary Diagnostic --- The submarine has been making some odd creaking noises, so you ask it to produce a diagnostic report just in case. The diagnostic report (your puzzle input) consists of a list of binary...
go/2021/3.go
0.761006
0.691868
3.go
starcoder
package types import ( "errors" "fmt" "reflect" "strconv" ) func Byte(value interface{}) byte { return Uint8(value) } func Int(value interface{}) int { return int(Int32(value)) } func Int8(value interface{}) int8 { if value == nil { return 0 } switch value := value.(type) { case bool: if value { r...
internal/utils/types/types.go
0.513181
0.412175
types.go
starcoder
package tpe import ( "math" "gonum.org/v1/gonum/floats" ) // ParzenEstimatorParams holds the parameters of ParzenEstimator type ParzenEstimatorParams struct { ConsiderPrior bool ConsiderMagicClip bool ConsiderEndpoints bool Weights FuncWeights PriorWeight float64 // optional } // ParzenEs...
tpe/parzen_estimator.go
0.7181
0.452234
parzen_estimator.go
starcoder
package dice import ( "fmt" "math/rand" "strings" "time" ) var rng = rand.New(rand.NewSource(time.Now().UnixNano())) // Dice represents a set of 1 type of dice, i.e: 3d20 OR 2d4 OR 1d6 type Dice struct { number, sides int } // NewDice takes the common notation "nds" where n is the number of dice and s is the n...
dice.go
0.8059
0.417212
dice.go
starcoder
package generators import ( "math" "github.com/go-gl/gl/v4.5-core/gl" ) // These shape generators define vertices and indices that represent // unit-sized vector shapes. These shapes are then loaded into an Atlas. // GenerateUnitHLineVectorShape builds a horizontal unit length line. func GenerateUnitHLineVectorSh...
extras/generators/vector_shape_builder.go
0.819099
0.626238
vector_shape_builder.go
starcoder
package es_array import ( "github.com/watermint/toolbox/essentials/collections/es_number" "github.com/watermint/toolbox/essentials/collections/es_value" "os" "sort" ) type Array interface { // Returns first entry of the array. // Returns Null es_value.Value (not nil) when the array is empty. First() es_value.V...
essentials/collections/es_array/array.go
0.792384
0.490663
array.go
starcoder
package num import ( "github.com/cpmech/gosl/fun" "github.com/cpmech/gosl/la" ) // LineSolver finds the scalar λ that zeroes or minimizes f(x+λ⋅n) type LineSolver struct { // configuration UseDeriv bool // use Jacobian function [default = true if Jfcn is provided] // internal ffcn fun.Sv // scalar func...
num/linesolver.go
0.706596
0.552359
linesolver.go
starcoder
package pt import "math" type Cube struct { Min Vector Max Vector Material Material Box Box } func NewCube(min, max Vector, material Material) *Cube { box := Box{min, max} return &Cube{min, max, material, box} } func (c *Cube) Compile() { } func (c *Cube) BoundingBox() Box { return c.Box } f...
pt/cube.go
0.795857
0.456834
cube.go
starcoder
package generator import ( "fmt" "strings" ) type ( group struct { name string unit } unit [rows][cols]point uint128 struct { ms, ls uint64 } ) var ( box = group{name: "box"} // These are all of the coordinates in a box (first dimension). col = group{name: "col"} // These are all of the coordinates ...
generator/group.go
0.535341
0.511229
group.go
starcoder
package sgf import ( "strconv" "github.com/dgf/gotv/model" ) type decode func(g *model.Game, p string) // see https://en.wikipedia.org/wiki/Smart_Game_Format#About_the_format var decoder = map[string]decode{ // Add Black: locations of Black stones to be placed on the board prior to the first move //"AB": func(...
sgf/decode.go
0.599954
0.402392
decode.go
starcoder
通过提高精度来生成更多级别的分形。使用四种不同精度类型的数字实现相同的分形:complex64、complex128、big.Float和big.Rat。(后面两种类型在math/big包声明。Float是有指定限精度的浮点数;Rat是无限精度的有理数。)它们间的性能和内存使用对比如何?当渲染图可见时缩放的级别是多少? */ // ref: https://github.com/torbiak/gopl/blob/master/ex3.8/main.go package main import ( "image" "image/color" "image/png" "math/cmplx" "os" "time" ...
ch3/ex3.8/main.go
0.610221
0.709126
main.go
starcoder
package powersoftau import ( "bytes" "encoding/binary" "github.com/FiloSottile/powersoftau/bls12" "github.com/FiloSottile/powersoftau/internal/chacha20" ) /* The Rust hash_to_g2 implementation, which we have to match to pass verification, uses the Rand trait as implemented by ChaChaRng. Here is a reversed spec...
powersoftau/hash_to_g2.go
0.680454
0.558688
hash_to_g2.go
starcoder
package predictor import ( "image" "image/png" "os" "runtime" "runtime/debug" "github.com/pkg/errors" imagetypes "github.com/rai-project/image/types" tf "github.com/tensorflow/tensorflow/tensorflow/go" "github.com/tensorflow/tensorflow/tensorflow/go/op" gotensor "gorgonia.org/tensor" ) func disableFramewor...
predictor/utils.go
0.633864
0.435781
utils.go
starcoder
package eval import ( "fmt" "github.com/dikaeinstein/monkey/ast" "github.com/dikaeinstein/monkey/object" "github.com/dikaeinstein/monkey/token" ) // Eval evaluates walks the code by walking the parsed AST //gocyclo:ignore func Eval(node ast.Node, env *object.Environment) object.Object { switch node := node.(typ...
eval/eval.go
0.694613
0.435181
eval.go
starcoder
package set import ( . "github.com/noxer/nox/dot" "github.com/noxer/nox/maps" "github.com/noxer/nox/slice" ) // Set offers set functionality. A set is a data structure that only contains unique, unsorted values. type Set[T comparable] map[T]struct{} // New creates a new set from a list of values. func New[T compa...
set/set.go
0.708213
0.409693
set.go
starcoder
// Package cc describes Creative Commons software licenses. package cc import "github.com/creachadair/lice/licenses" func init() { licenses.Register(licenses.License{ Name: "Creative Commons CC0", Slug: "cc0", URL: "https://creativecommons.org/publicdomain/zero/1.0/legalcode", Text: cc0text, ...
licenses/cc/cc0.go
0.617628
0.633566
cc0.go
starcoder
package metadata const AtaSmartAttributeDisplayTypeRaw = "raw" const AtaSmartAttributeDisplayTypeNormalized = "normalized" const AtaSmartAttributeDisplayTypeTransformed = "transformed" type AtaAttributeMetadata struct { ID int64 `json:"-"` DisplayName string `json:"-"` Ideal string `json:"ideal"` ...
webapp/backend/pkg/metadata/ata_attribute_metadata.go
0.71602
0.426142
ata_attribute_metadata.go
starcoder
package exchange import "github.com/mattkanwisher/cryptofiend/currency/pair" // ILimits provides information about the limits placed by an exchange on numbers representing // order/trade price and amount. type ILimits interface { // Returns max number of decimal places allowed in the trade price for the given curren...
exchanges/exchange_limits.go
0.840423
0.408336
exchange_limits.go
starcoder
package pid import ( "math" ) type Pid struct { integral float64 last float64 max_output float64 kp float64 ki float64 kd float64 gain float64 Scale_kp float64 Scale_ki float64 Scale_kd float64 Scale_gain float64 } // the computation factors are predefind after running some PID tuning and use to cr...
pid/pid.go
0.786787
0.484136
pid.go
starcoder
package hitables import ( "math" "github.com/go-gl/mathgl/mgl64" "github.com/markzuber/zgotrace/raytrace" "github.com/markzuber/zgotrace/raytrace/vectorextensions" ) type RotateY struct { hitable raytrace.Hitable angle float64 sintheta float64 costheta float64 boundingbox *raytrace.AABB } f...
raytrace/hitables/rotatey.go
0.774839
0.41478
rotatey.go
starcoder
package movie const ( // Label holds the string label denoting the movie type in the database. Label = "movie" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldTitle holds the string denoting the title field in the database. FieldTitle = "title" // FieldOriginalTitle ho...
src/ent/movie/movie.go
0.500732
0.430088
movie.go
starcoder
package primitives import ( "github.com/alexandreLamarre/Golang-Ray-Tracing-Renderer/pkg/algebra" "github.com/alexandreLamarre/Golang-Ray-Tracing-Renderer/pkg/canvas" "math" ) //SmoothTriangle datastructure that handles calculations for SmoothTriangle Shape type SmoothTriangle struct { Parent Shape transform ...
pkg/geometry/primitives/smoothTriangle.go
0.661704
0.670096
smoothTriangle.go
starcoder
package reactor import ( "aoc2021/pkg/io" "aoc2021/pkg/numbers" "strconv" "strings" ) type Cuboid struct { from, to numbers.Vector3 toggle bool } func (c *Cuboid) Volume() int { return (c.to.X - c.from.X + 1) * (c.to.Y - c.from.Y + 1) * (c.to.Z - c.from.Z + 1) } func (c *Cuboid) Intersect(other Cuboid) *Cu...
pkg/reactor/reactor.go
0.508788
0.405566
reactor.go
starcoder
package inventory func (x *Accelerator) Clone() *Accelerator { if x == nil { return nil } return &Accelerator{ AcceleratorType: x.AcceleratorType, } } func (x *Accelerator) Equal(c *Accelerator) bool { return x.GetAcceleratorType() == c.GetAcceleratorType() } func (x *BladeCapacity) Clone() *BladeCapacity ...
simulation/pkg/protos/inventory/capacity.Helpers.go
0.654895
0.540803
capacity.Helpers.go
starcoder
package factory import ( "github.com/Yiling-J/carrier/examples/ent_recipe/ent" "context" ) type EntRecipeIngredientMutator struct { Ingredient *ent.Ingredient IngredientID int Quantity float32 Unit string } type entRecipeIngredientMutation struct { ingredientType int ingredientFunc func(ctx context.Conte...
examples/ent_recipe/carrier/factory/ent_recipeingredient.go
0.506103
0.455562
ent_recipeingredient.go
starcoder
package _542_01_Matrix /* https://leetcode.com/problems/01-matrix/ Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: Input: 0 0 0 0 1 0 0 0 0 Output: 0 0 0 0 1 0 0 0 0 Example 2: Input: 0 0 0 0 1 0 1 1 1 Output: 0 0 0 0 1 ...
542_01_Matrix/solution.go
0.865423
0.602032
solution.go
starcoder
package aws import ( "github.com/infracost/infracost/internal/resources" "github.com/infracost/infracost/internal/schema" "github.com/infracost/infracost/internal/usage" "github.com/shopspring/decimal" ) type Route53Record struct { Address string IsAlias bool MonthlyLaten...
internal/resources/aws/route53_record.go
0.57081
0.441312
route53_record.go
starcoder
package pkg import ( "fmt" "github.com/lanl/clp" "math" "math/bits" "reflect" "sort" "strings" ) // ExprSet describes a set of Expr. type ExprSet = map[Expr]bool // NodeSet describes a set of Node. type NodeSet = map[Node]bool // ExprOperator that wraps the Add and Multiply methods needed to build a quorum f...
pkg/expr.go
0.692538
0.442757
expr.go
starcoder
package geo3d import ( "fmt" "strconv" "strings" "aoc/internal/util" ) // Tranform is a 3D rotation matrix. type Transform [9]int // Rotations contains all possible 3D rotations with increments of 90 degrees. // Courtesy: https://www.euclideanspace.com/maths/algebra/matrix/transforms/examples/index.htm var Rota...
go/internal/geo3d/pos.go
0.629091
0.594904
pos.go
starcoder
package database import ( "errors" "fmt" "strconv" "strings" "time" ) // Date is the struct for MySQL DATE type type Date struct { Year int16 Month, Day byte } func (dd Date) String() string { return fmt.Sprintf("%04d-%02d-%02d", dd.Year, dd.Month, dd.Day) } // IsZero is the fu...
database/types.go
0.689933
0.547162
types.go
starcoder
package gofa // Earth Rotation and Sidereal Time /* Ee00 Equation of the equinoxes, IAU 2000 The equation of the equinoxes, compatible with IAU 2000 resolutions, given the nutation in longitude and the mean obliquity. Given: date1,date2 float64 TT as a 2-part Julian Date (Note 1) epsa float64 ...
erast.go
0.908696
0.788217
erast.go
starcoder
package tuple type Tuple2[T1 any, T2 any] struct { v1 T1 v2 T2 } func N2[T1 any, T2 any](v1 T1, v2 T2) Tuple2[T1, T2] { return Tuple2[T1, T2]{ v1: v1, v2: v2, } } func (t Tuple2[T1, T2]) T1() T1 { return t.v1 } func (t Tuple2[T1, T2]) T2() T2 { return t.v2 } type Tuple3[T1 any, T2 any, T3 any] struct { ...
types/tuple/tuple.go
0.613815
0.517876
tuple.go
starcoder
package aoc2021 import ( "fmt" "strconv" "strings" "github.com/simonski/aoc/utils" ) /* --- Day 4: Giant Squid --- You're already almost 1.5km (almost a mile) below the surface of the ocean, already so deep that you can't see any sunlight. What you can see, however, is a giant squid that has attached itself to t...
app/aoc2021/aoc2021_04.go
0.531696
0.472562
aoc2021_04.go
starcoder
package token //This file contains legacy code, //With updates this file will keep shrinking until being eliminated //Type rappresent a type of token type Type int //Types definition //They can rapresent the rapresented char but it is not mandatory const ( //TypeUndefined is an undefined token TypeUndefined = iota...
token/type.go
0.628635
0.442998
type.go
starcoder
package maybe import ( "errors" "fmt" "reflect" ) // AoAoX implements the Maybe monad for a 2-D slice of empty interfaces. An AoAoX is // considered 'valid' or 'invalid' depending on whether it contains a 2-D // slice of empty interfaces or an error value. A zero-value AoAoX is invalid and Unbox() // will return...
aoaox.go
0.728941
0.439026
aoaox.go
starcoder
package statext import ( "github.com/argusdusty/gofft" "golang.org/x/exp/rand" "gonum.org/v1/gonum/stat/sampleuv" "math" ) // PoissonBinomial represents a random variable whose value is the sum of // independent Bernoulli trials that are not necessarily identically distributed. // The value of entries in P must b...
poissonbinomial.go
0.794863
0.530845
poissonbinomial.go
starcoder
package values import ( "fmt" "reflect" "strings" ) // StringSliceValue is a struct that holds a string slice value type StringSliceValue struct { value []string } // IsEqualTo returns true if the value is equal to the expected value, else false func (s StringSliceValue) IsEqualTo(expected interface{}) bool { r...
internal/pkg/values/string_slice_value.go
0.842378
0.547404
string_slice_value.go
starcoder
package rel type ExistsNode FunctionNode func NewExistsNode(v Visitable) *ExistsNode { return &ExistsNode{ Expressions: []Visitable{v}, } } func (node ExistsNode) Desc() *DescendingNode { return orderingDesc(node) } func (node ExistsNode) Asc() *AscendingNode { return orderingAsc(node) } func (node ExistsNod...
exists_node.go
0.756717
0.630116
exists_node.go
starcoder
Copyright 2019 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the NOTICE.md file. */ package remote // region is HTTP-range-request-compliant range. // "b" is beginning byte of the range and "e" is the end. // "e" is must be inclusive alon...
fs/remote/util.go
0.683314
0.469338
util.go
starcoder
package quickunion import ( "fmt" "github.com/ivanlemeshev/algorithms-go/unionfind" ) // WeightedQuickUnion is an implementation of union–find data type. This // implementation uses weighted quick union by size (without path compression). // The constructor takes O(n), where n is the number of elements. The union ...
unionfind/weightedquickunion/weightedquickunion.go
0.823044
0.537041
weightedquickunion.go
starcoder
func (r receiver) identifier(parameters) (return(s)){...}. 6. Function as a expression 7. function return type, means function returning a function type. As function are normal return types like Int in GOLANG Q: how to read (r reciever ) identifier(parameter) -- Identfier(parameter) func have access to the value of ...
28_kk-src/Functions/Func.go
0.588889
0.450057
Func.go
starcoder
package griddlersolver import "github.com/yinonavraham/go-griddlersolver/grid" // Solution is an iterator over states - from the initial (empty) state to the last solved state type Solution interface { // Next returns the next state in the solution and an indicator whether there are more states Next() (state grid.G...
solution.go
0.71113
0.470554
solution.go
starcoder
package display var Bits2 = &Ind2Bit{ Threshold1_5: 0.15, Threshold2: 0.3, Threshold2_5: 0.45, Threshold3: 0.55, Threshold3_5: 0.7, Threshold4: 0.8, } type Ind2Bit struct { Threshold1_5 float64 Threshold2 float64 Threshold2_5 float64 Threshold3 float64 Threshold3_5 float64 Threshold4 float64 }...
pkg/display/bit-shader.go
0.66072
0.470128
bit-shader.go
starcoder
package main import ( "fmt" // The "math" package is new. We need to use it because it contains a very // accurate value for Pi "math" ) func main() { // First the variables for the Earths radius and time of the ISS orbit. // These are floating point types to keeps things accruate - we want to ...
orbits/orbits.go
0.572364
0.516717
orbits.go
starcoder
package sim import ( "github.com/flowmatters/openwater-core/data" ) const ( DIMP_PARAMETER int = 0 DIMP_CELL int = 1 DIMI_CELL int = 0 DIMI_INPUT int = 1 DIMI_TIMESTEP int = 2 DIMS_CELL int = 0 DIMS_STATE int = 1 DIMO_CELL int = 0 DIMO_OUTPUT int = 1 DIMO_TIMESTEP int = 2 ) type Mode...
sim/runnable.go
0.553747
0.432543
runnable.go
starcoder
package geometry import "github.com/gopherd/three/core" type Plane struct { Normal core.Vector3 Constant core.Float } func (plane *Plane) Set(normal core.Vector3, constant core.Float) *Plane { plane.Normal = normal plane.Constant = constant return plane } func (plane *Plane) SetComponents(x, y, z, w core.Flo...
geometry/plane.go
0.868896
0.751032
plane.go
starcoder
package note import "fmt" type SpecialType int const ( SpecialTypeEmpty = SpecialType(iota) SpecialTypeRelease SpecialTypeStop SpecialTypeNormal SpecialTypeStopOrRelease SpecialTypeInvalid ) // Note is a note or special effect related to the channel's voice playback system type Note interface { fmt.Stringer ...
internal/song/note/note.go
0.817938
0.420838
note.go
starcoder
package compression import ( "context" ) // EncodedFrame contains the streams of one compressed frame. type EncodedFrame struct { Bitstream []byte Maskstream []byte } type tileDelta [PixelPerTile]byte type frameDelta struct { tiles []tileDelta } // SceneEncoder encodes an entire scene of bitmaps sharing the s...
ss1/content/movie/internal/compression/SceneEncoder.go
0.71721
0.46478
SceneEncoder.go
starcoder
package shape import ( "fmt" "math" "github.com/fogleman/gg" ) // Rectangle represents a rectangular shape. type Rectangle struct { X1, Y1 int X2, Y2 int } func NewRectangle() *Rectangle { return &Rectangle{} } func (r *Rectangle) Init(plane *Plane) { rnd := plane.Rnd r.X1 = rnd.Intn(plane.W) r.Y1 = rnd.I...
primitive/shape/rectangle.go
0.86674
0.650772
rectangle.go
starcoder
package entity import ( "github.com/go-gl/mathgl/mgl32" ) // Transform Represents the transformation of an entity in // a 3-dimensional space: position, rotation and scale. // Note: Rotation is measured in degrees type Transform struct { Position mgl32.Vec3 Rotation mgl32.Vec3 Scale mgl32.Vec3 prevPosition m...
entity/transform.go
0.751466
0.749866
transform.go
starcoder
package dfs import ( "fmt" "github.com/wangyoucao577/algorithms_practice/graph" ) type dfsTopologicalSort struct { Dfs sorted []graph.NodeID acyclic bool } // NewTopologicalSort execute the DFS search on a directed acyclic graph, // traversing all nodes to get topological sort func NewTopologicalSort(g graph....
dfs/topological_sort.go
0.652241
0.407422
topological_sort.go
starcoder
package reflecth import ( "go/token" "reflect" ) // UnaryOp performs unary operation <op><y> as Go language specification describes. // Supported operations: + - ^ ! & <- . // If operation cannot be performed then error will be returned. // Special note for token.AND (&) operation: if passed y is not addressable (r...
back/vendor/github.com/apaxa-go/helper/reflecth/op-unary.go
0.700485
0.589864
op-unary.go
starcoder
package point import ( "github.com/ClickHouse-Ninja/ninjato/src/atime" ) const magicNumber = 146 func New(label string, value float64) *Point { return &Point{ Label: label, Value: value, timestamp: int32(atime.Now().Unix()), magicNumber: magicNumber, } } type ( Tags = map[string]string ...
src/point/point.go
0.646349
0.474936
point.go
starcoder
package images import ( "fmt" "io" "reflect" "github.com/mitchellh/mapstructure" "github.com/rackspace/gophercloud" "github.com/rackspace/gophercloud/pagination" ) // Image model // Does not include the literal image data; just metadata. // returned by listing images, and by fetching a specific image. type Ima...
vendor/github.com/rackspace/gophercloud/openstack/imageservice/v2/images/results.go
0.716417
0.401424
results.go
starcoder
An Image Copy algorithm. Supports both, single threaded and multithreaded operations. */ package copier import ( "image" //"image/color" "image/draw" "errors" ) var ESizeMismatch = errors.New("Size-Mismatch") func iterate(r image.Rectangle, pchan chan <- image.Point) { xb,yb,xe,ye := r.Min.X,r.Min.Y,r.Max.X,r....
copier/copier.go
0.595728
0.548432
copier.go
starcoder
package slice /* Apply a function to slice Sample usage: multiply each element by 2 l := []int64{0, 7, 8} slice.ApplyToInt64Slice(l, func(i int64) int64 { return i * 2 }) fmt.Println(l) Expected out: [0, 14, 16] */ // ApplyStrings ... Apply a function to each element in string slice func ApplyStrings(l []stri...
slice/apply.go
0.745306
0.427695
apply.go
starcoder
package berlingo // NodeType declares the type of a node (re-usable characteristics) type NodeType struct { Name string Points int Soldiers_Per_Turn int } // Map represents the map and the nodes in it type Map struct { Game *Game Directed bool NodeTypes map[string]*NodeType Nodes ...
map.go
0.604049
0.516595
map.go
starcoder
package pattern import ( "math" "github.com/calbim/ray-tracer/src/color" "github.com/calbim/ray-tracer/src/matrix" "github.com/calbim/ray-tracer/src/tuple" ) //Pattern interface type Pattern interface { GetTransform() *matrix.Matrix SetTransform(m *matrix.Matrix) PatternAt(point tuple.Tuple) *color.Color } ...
src/pattern/pattern.go
0.898869
0.618204
pattern.go
starcoder
package graph import ( tf "github.com/tensorflow/tensorflow/tensorflow/go" ) // DataType holds the type for a scalar value. E.g., one slot in a tensor. type DataType tf.DataType const ( Unknown DataType = DataType(0) Float DataType = DataType(tf.Float) Double DataType = DataType(tf.Double) Int32 ...
graph/type.go
0.62498
0.751192
type.go
starcoder
package gm64 import ( "fmt" "math" ) type Vec2 [2]float64 func (v Vec2) Len() float64 { return math.Hypot(v[0], v[1]) } func (v Vec2) Normalize() Vec2 { l := 1.0 / v.Len() return Vec2{v[0] * l, v[1] * l} } func (v1 Vec2) Dot(v2 Vec2) float64 { return v1[0]*v2[0] + v1[1]*v2[1] } func (v1 Vec2) Cross(v2 Vec2)...
gm64/vec.go
0.746601
0.588682
vec.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" ) // BoxModel represents a shape that has been encoded as a set of boxes. type BoxModel inter...
d2/shape/boxmodel/boxmodel.go
0.740831
0.519521
boxmodel.go
starcoder
package carbon import ( "time" ) // CreateFromTimestamp creates a Carbon instance from a given timestamp with second. // 从给定的秒级时间戳创建 Carbon 实例 func (c Carbon) CreateFromTimestamp(timestamp int64, timezone ...string) Carbon { if len(timezone) > 0 { c.loc, c.Error = getLocationByTimezone(timezone[len(timezone)-1]) ...
creator.go
0.692226
0.557364
creator.go
starcoder
package vat import ( "fmt" "regexp" ) // ErrInvalidVATRegion implements the error interface and is returned when // ValidInRegion fails to find the requested region. Blank "" regions will not // fail the region lookup type ErrInvalidVATRegion struct { region string } func (e ErrInvalidVATRegion) Error() string {...
region.go
0.541894
0.628379
region.go
starcoder
package compiler type nfa2dfa struct { // The reference NFA. nfa *NFA // Map of subset key to subset. subsetMap map[string]*intset // All subsets in order of creation. subsetList []*intset // Maps subset key to map of symbols to destination subset key. trans map[string]map[int]string subsetToDFA map[st...
compiler/nfa2dfa.go
0.531696
0.415136
nfa2dfa.go
starcoder
package csv import ( "encoding/csv" "fmt" "io" "sort" "strconv" "github.com/attic-labs/noms/go/d" "github.com/attic-labs/noms/go/types" ) // StringToKind maps names of valid NomsKinds (e.g. Bool, Number, etc) to their associated types.NomsKind var StringToKind = func(kindMap map[types.NomsKind]string) map[st...
samples/go/csv/read.go
0.562177
0.427098
read.go
starcoder