code
stringlengths
114
1.05M
path
stringlengths
3
312
quality_prob
float64
0.5
0.99
learning_prob
float64
0.2
1
filename
stringlengths
3
168
kind
stringclasses
1 value
package main import ( "fmt" "gopkg.in/yaml.v3" ) const ( // Filename for the template file in any directory. templateFile = "template.yml" // prefix added to the filename to indicate a query has // been moved to it's own file. queryPrefix = "file://" ) // An object is the basic type for all templates. // We...
types.go
0.674694
0.435181
types.go
starcoder
package tally // UTally is a counter of type uint. type UTally uint // Cur returns the current uint value of this UTally. func (t UTally) Cur() uint { return uint(t) } // Add increases this counter by the given value, returning the previous // uint value of this UTally. func (t *UTally) Add(i uint) (cur uint) { cu...
v1/tally/uints.go
0.790004
0.638765
uints.go
starcoder
package geojson import ( "github.com/tidwall/tile38/pkg/geojson/geo" "github.com/tidwall/tile38/pkg/geojson/geohash" "github.com/tidwall/tile38/pkg/geojson/poly" ) // Point is a geojson object with the type "Point" type Point struct { Coordinates Position BBox *BBox bboxDefined bool } func fillSimplePoi...
pkg/geojson/point.go
0.846483
0.553204
point.go
starcoder
package processor import ( "time" "github.com/Jeffail/benthos/v3/internal/docs" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/message" "github.com/Jeffail/benthos/v3/lib/metrics" "github.com/Jeffail/benthos/v3/lib/response" "github.com/Jeffail/benthos/v3/lib/types" ) //-----------...
lib/processor/split.go
0.778691
0.501953
split.go
starcoder
package tree import ( "fmt" "github.com/sidheart/algorithms/util" ) // An AVLTreeNode represents a leaf or internal node in an AVL tree type AVLTreeNode struct { key util.Comparable balanceFactor int8 data interface{} leftChild, rightChild, parent *AVLTreeNode } // An AVLTree is a kind of...
datastructures/tree/avltree.go
0.744656
0.434821
avltree.go
starcoder
package cbor import ( "encoding/json" "fmt" "math" "net" ) // AppendNil inserts a 'Nil' object into the dst byte array. func (Encoder) AppendNil(dst []byte) []byte { return append(dst, byte(majorTypeSimpleAndFloat|additionalTypeNull)) } // AppendBeginMarker inserts a map start into the dst byte array. func (Enc...
vendor/github.com/rs/zerolog/internal/cbor/types.go
0.697403
0.451145
types.go
starcoder
package variable import ( "fmt" "github.com/LindsayBradford/crem/internal/pkg/model/planningunit" assert "github.com/LindsayBradford/crem/pkg/assert/debug" "github.com/LindsayBradford/crem/pkg/math" "github.com/LindsayBradford/crem/pkg/strings" "sort" strings2 "strings" ) var currencyConverter = strings.NewCo...
internal/pkg/model/variable/EncodableDecisionVariable.go
0.639736
0.405596
EncodableDecisionVariable.go
starcoder
package flow import ( . "github.com/shnifer/magellan/v2" "math" "math/rand" ) func LinearLifeTime(a, b float64) func(point Point) float64 { return func(point Point) float64 { return a + (b-a)*point.lifeTime/point.maxTime } } func SinLifeTime(med, dev, period float64) func(p Point) float64 { return func(p Poi...
graph/flow/funcs.go
0.749087
0.678943
funcs.go
starcoder
package hexgrid import ( "fmt" "math" ) type direction int const ( directionSE = iota directionNE directionN directionNW directionSW directionS ) var directions = []hex{ NewHex(1, 0), NewHex(1, -1), NewHex(0, -1), NewHex(-1, 0), NewHex(-1, +1), NewHex(0, +1), } // hex describes a regular hexagon with...
hex.go
0.861887
0.421909
hex.go
starcoder
Package configurator supports configuration management and dynamic generation by manipulating a graph of network entities. Entity graph Configurator manages a directed acyclic graph (DAG) of network-partitioned entities. Callers can define their graph via the following three types - Network - Network-level ...
orc8r/cloud/go/services/configurator/doc.go
0.580709
0.517754
doc.go
starcoder
// +build ignore // printgraphs allows us to generate a consistent directed view of // a set of edges that follows a reasonably real-world-meaningful // graph. The interpretation of the links in the resulting directed // graphs are either "suggests" in the context of a Page Ranking or // possibly "looks up to" in the...
vendor/github.com/gonum/graph/community/printgraphs.go
0.510252
0.404096
printgraphs.go
starcoder
package json import ( "fmt" "reflect" ) // Transition functions for recognizing NumberInt and NumberLong. // Adapted from encoding/json/scanner.go. // stateUpperNu is the state after reading `Nu`. func stateUpperNu(s *scanner, c int) int { if c == 'm' { s.step = generateState("Number", []byte("ber"), stateUpper...
common/json/number.go
0.758153
0.401688
number.go
starcoder
package go_fourier import ( "errors" "math" "math/bits" "math/cmplx" ) // DCT1D computes the discrete cosine transform of the given array in the complex number space. // Assumes the length of the array is a power of 2 // Returns the result in real number space. func DCT1D(signals []float64) ([]float64, error) { ...
dct.go
0.809464
0.735428
dct.go
starcoder
package pop3processor import "github.com/vjeantet/bitfan/processors/doc" func (p *processor) Doc() *doc.Processor { return &doc.Processor{ Name: "pop3processor", ImportPath: "github.com/vjeantet/bitfan/processors/pop3", Doc: "Periodically scan an POP3 mailbox for new emails.", DocShort: "Read ...
processors/pop3/docdoc.go
0.613584
0.42662
docdoc.go
starcoder
package graph // VertexType is a type for specific vertices. type VertexType byte const ( // VertexTypeBackupBucket is a constant for a 'BackupBucket' vertex. VertexTypeBackupBucket VertexType = iota // VertexTypeBackupEntry is a constant for a 'BackupEntry' vertex. VertexTypeBackupEntry // VertexTypeBastion is...
pkg/admissioncontroller/webhooks/auth/seed/graph/vertices.go
0.648689
0.570331
vertices.go
starcoder
package datadog import ( "encoding/json" "time" ) // UsageLogsHour Hour usage for logs. type UsageLogsHour struct { // Contains the number of billable log bytes ingested. BillableIngestedBytes *int64 `json:"billable_ingested_bytes,omitempty"` // The hour for the usage. Hour *time.Time `json:"hour,omitempty"` ...
api/v1/datadog/model_usage_logs_hour.go
0.724481
0.402392
model_usage_logs_hour.go
starcoder
package incrdelaunay import ( "math" ) // Triangle stores the vertices of a triangle as well as its circumcircle. type Triangle struct { A, B, C Point Circumcircle Circumcircle } // NewTriangle return a new Triangle and calculates its circumcircle given three points. func NewTriangle(a, b, c Point) Triangle ...
triangulation/incrdelaunay/geom.go
0.904313
0.618291
geom.go
starcoder
package fseval import ( "io" "os" "path/filepath" "time" "github.com/openSUSE/umoci/pkg/unpriv" "github.com/vbatts/go-mtree" "golang.org/x/sys/unix" ) // RootlessFsEval is an FsEval implementation that uses "umoci/pkg/unpriv".* // functions in order to provide the ability for unprivileged users (those // with...
vendor/github.com/openSUSE/umoci/pkg/fseval/fseval_rootless.go
0.524151
0.434761
fseval_rootless.go
starcoder
package sqlds import ( "errors" "fmt" "regexp" "strings" "time" ) var ( // ErrorBadArgumentCount is returned from macros when the wrong number of arguments were provided ErrorBadArgumentCount = errors.New("unexpected number of arguments") ) // MacroFunc defines a signature for applying a query macro // Query ...
macros.go
0.7586
0.404537
macros.go
starcoder
package datapoint import ( "bytes" "encoding/json" "fmt" "time" ) // Documentation taken from http://metrics20.org/spec/ // MetricType define how to display the Value. It's more metadata of the series than data about the // series itself. See target_type of http://metrics20.org/spec/ type MetricType int const...
vendor/github.com/signalfx/golib/datapoint/datapoint.go
0.759671
0.517571
datapoint.go
starcoder
package ch4 import ( "math" ) func FindMaxCrossingSubarray(input []int, low int, mid int, high int) (maxLeft int, maxRight int, sum int) { leftSum := 0 rightSum := 0 for iter := mid; iter >= low; iter-- { sum = sum + input[iter] if sum > leftSum || iter == mid { leftSum = sum maxLeft = iter } } sum ...
src/ch4/maximum_sub_array.go
0.604516
0.442817
maximum_sub_array.go
starcoder
package sparsetable type fuzzyState struct { lev, next int state State } // FuzzyStack keeps track of the active states during the apporimxate search. type FuzzyStack struct { stack []fuzzyState dfa *DFA str string max int } func (f *FuzzyStack) empty() bool { return len(f.stack) == 0 } func (f *Fu...
fuzzydfa.go
0.755727
0.45042
fuzzydfa.go
starcoder
package binvox import ( "math" gl "github.com/fogleman/fauxgl" ) const ( iso = 0.5 ) type gridCell struct { p [8]gl.Vector val [8]float64 } type mcManifoldMap map[Key]struct{} type voxelLookupMap map[Key]float64 func (b *BinVOX) MarchingCubes() *gl.Mesh { // create lookup table lookup := make(voxelLooku...
binvox/marching-cubes.go
0.635449
0.550668
marching-cubes.go
starcoder
package lcs import ( "context" "reflect" ) // Lcs is the interface to calculate the LCS of two arrays. type Lcs interface { // Values calculates the LCS value of the two arrays. Values() (values []interface{}) // ValueContext is a context aware version of Values() ValuesContext(ctx context.Context) (values []in...
vendor/github.com/yudai/golcs/golcs.go
0.707101
0.401277
golcs.go
starcoder
package legacydata import ( "strconv" "time" "github.com/vectordotdev/go-datemath" ) type DataTimeRange struct { From string To string Now time.Time } func NewDataTimeRange(from, to string) DataTimeRange { return DataTimeRange{ From: from, To: to, Now: time.Now(), } } func (tr DataTimeRange) Ge...
pkg/tsdb/legacydata/time_range.go
0.704668
0.596756
time_range.go
starcoder
package msgraph // RatingUnitedStatesTelevisionType undocumented type RatingUnitedStatesTelevisionType int const ( // RatingUnitedStatesTelevisionTypeVAllAllowed undocumented RatingUnitedStatesTelevisionTypeVAllAllowed RatingUnitedStatesTelevisionType = 0 // RatingUnitedStatesTelevisionTypeVAllBlocked undocumente...
v1.0/RatingUnitedStatesTelevisionTypeEnum.go
0.590071
0.505737
RatingUnitedStatesTelevisionTypeEnum.go
starcoder
package binary_pack import ( "strings" "strconv" "errors" "encoding/binary" "bytes" "fmt" ) type BinaryPack struct {} // Return a byte slice containing the values of msg slice packed according to the given format. // The items of msg slice must match the values required by the format exactly. func (bp *BinaryP...
binary-pack/binary_pack.go
0.749637
0.416678
binary_pack.go
starcoder
package graph import ( i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization" ) // ColumnDefinition type ColumnDefinition struct { Entity // This column stores boolean values. boolean *BooleanColumn; // This column's data is ca...
models/microsoft/graph/column_definition.go
0.685529
0.432243
column_definition.go
starcoder
package gomfa func Ldn(n int, b []LDBODY, ob *[3]float64, sc *[3]float64, sn *[3]float64) { /* ** - - - - ** L d n ** - - - - ** ** For a star, apply light deflection by multiple solar-system bodies, ** as part of transforming coordinate direction into natural direction. ** ** Given: ** ...
ldn.go
0.885977
0.73473
ldn.go
starcoder
package tilegraphics import "image/color" // TileSize is the size (width and height) of a tile. A tile will take up // TileSize*TileSize*4 bytes of memory during rendering. const TileSize = 8 // engineDebug can be set to true for extra logging. const engineDebug = false // Displayer is the display interface require...
engine.go
0.762689
0.605449
engine.go
starcoder
package num import ( "math" "github.com/cpmech/gosl/chk" "github.com/cpmech/gosl/fun" ) // The algorithms below are based on [1] // REFERENCES: // [1] Press WH, Teukolsky SA, Vetterling WT, Fnannery BP (2007) Numerical Recipes: The Art of // Scientific Computing. Third Edition. Cambridge University Press. 12...
num/quadElementary.go
0.725454
0.491151
quadElementary.go
starcoder
package gen import ( "math" "reflect" "github.com/leanovate/gopter" ) // Float64Range generates float64 numbers within a given range func Float64Range(min, max float64) gopter.Gen { d := max - min if d < 0 || d > math.MaxFloat64 { return Fail(reflect.TypeOf(float64(0))) } return func(genParams *gopter.GenP...
vendor/github.com/leanovate/gopter/gen/floats.go
0.74158
0.401629
floats.go
starcoder
package docgen import ( "reflect" "regexp" "strings" "github.com/byte-power/jsexpr/conf" ) // Kind can be any of array, map, struct, func, string, int, float, bool or any. type Kind string // Identifier represents variable names and field names. type Identifier string // TypeName is a name of type in types map...
docgen/docgen.go
0.586168
0.407274
docgen.go
starcoder
package main import "math" //Vector2d Basic 2d Vector struct type Vector2d struct { X float64 `json:"x"` Y float64 `json:"y"` } //NewVector2d Create 2d vector func NewVector2d(x float64, y float64) Vector2d { v := Vector2d{x, y} return v } //FromScalar Create 2d vector from scalar func FromScalar(v float64) Vec...
service/src/vector.go
0.925664
0.871803
vector.go
starcoder
package binary import ( "errors" ) // Tree is the binary tree structure type Tree struct { root *node } // New will create a new binary search tree with the root node func New(root Comparor) *Tree { return &Tree{ root: &node{ data: root, }, } } // SubTree will return true if the passed tree is a sub tree...
tree/binary/tree.go
0.811153
0.403273
tree.go
starcoder
package imageutil import ( "image" "image/color" "image/color/palette" "image/draw" ) func ImageToPaletted(src image.Image, p color.Palette) *image.Paletted { if dst, ok := src.(*image.Paletted); ok { return dst } dst := image.NewPaletted(src.Bounds(), p) draw.Draw(dst, dst.Rect, src, src.Bounds().Min, draw...
image/imageutil/convert.go
0.875295
0.514705
convert.go
starcoder
package binary // Endian is a ByteOrder specifies how to convert byte sequences into // 16-, 32-, or 64-bit unsigned integers. type Endian interface { Uint16([]byte) uint16 Uint32([]byte) uint32 Uint64([]byte) uint64 PutUint16([]byte, uint16) PutUint32([]byte, uint32) PutUint64([]byte, uint64) String() string }...
endian.go
0.653348
0.601008
endian.go
starcoder
package birnn import ( "encoding/gob" "sync" "github.com/nlpodyssey/spago/ag" "github.com/nlpodyssey/spago/nn" ) // MergeType is the enumeration-like type used for the set of merging methods // which a BiRNN model Processor can perform. type MergeType int const ( // Concat merging method: the outputs are conc...
nn/birnn/birnn.go
0.705379
0.42925
birnn.go
starcoder
package types type EncryptionStatus string // Enum values for EncryptionStatus const ( EncryptionStatusUpdating EncryptionStatus = "UPDATING" EncryptionStatusActive EncryptionStatus = "ACTIVE" ) // Values returns all known values for EncryptionStatus. Note that this can be // expanded in the future, and so it i...
service/xray/types/enums.go
0.813387
0.414662
enums.go
starcoder
package values import "fmt" //Period is class of time scope type Period struct { Start Date End Date } //NewPeriod function creates new Period instance func NewPeriod(from, to Date) Period { if from.IsZero() || to.IsZero() { return Period{Start: from, End: to} } if from.After(to) { return Period{Start: to...
values/period.go
0.774413
0.488527
period.go
starcoder
package configuration import ( "fmt" "gopkg.in/go-playground/validator.v9" "os" "strconv" "github.com/spf13/viper" ) /* Config schema All values: - may be set in revere.yaml, see cmd/root.go: ```yaml client: redirects: 2 ``` Some values: - may be overridden via command line flags, noted below. - may...
internal/configuration/config.go
0.669637
0.449755
config.go
starcoder
package main import "time" const ( // TypeExcitatory the enum representing the excitatory neural type TypeExcitatory = iota // TypeInhibitory the enum representing the inhibitory neural type TypeInhibitory = iota ) // Neuron the basic building block of the neural network structure type Neuron struct { FiredAt ...
neuron.go
0.820254
0.482002
neuron.go
starcoder
package table import "github.com/asukakenji/go-benchmarks" // LeadingZeros returns the number of leading zero bits in x; the result is the size of uint in bits for x == 0. func LeadingZeros(x uint) int { if x == 0 { return benchmarks.SizeOfUintInBits } n := uint8(0) shift := benchmarks.SizeOfUintInBits - 8 nFo...
math/bits/impl/leadingzeros/table/bits.go
0.645008
0.44083
bits.go
starcoder
package native import "math" // Dlanv2 computes the Schur factorization of a real 2×2 matrix: // [ a b ] = [ cs -sn ] * [ aa bb ] * [ cs sn ] // [ c d ] [ sn cs ] [ cc dd ] * [-sn cs ] // If cc is zero, aa and dd are real eigenvalues of the matrix. Otherwise it // holds that aa = dd and bb*cc < 0, and aa ± sq...
vendor/github.com/gonum/lapack/native/dlanv2.go
0.700075
0.610163
dlanv2.go
starcoder
package telerik import ( "reflect" log "github.com/helmutkemper/seelog" ) type KendoSchema struct{ /* @see https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/schema#schema.aggregates The field from the response which contains the aggregate results. Can be set to a function which...
kendoSchema.go
0.767603
0.53607
kendoSchema.go
starcoder
package ggassert import ( "reflect" "testing" "golang.org/x/exp/constraints" ) // Equal asserts that two any values are equal. func Equal[T any](t testing.TB, expected, actual T, format string, args ...any) { if reflect.DeepEqual(expected, actual) { return } t.Errorf(format, args...) } // LessThan asserts t...
assert.go
0.757346
0.708692
assert.go
starcoder
package geoserver // CreateDatastoreRequest represents the properties that are required in order to create a datastore type CreateDatastoreRequest struct { // Name is the name of the datastore to create Name string // Description is the description of the datastore to create Description string // Type is the ty...
geoserver/datastore.go
0.757346
0.528594
datastore.go
starcoder
package main import ( "fmt" "git.maze.io/go/math32" "image" "image/color" "image/png" "math/rand" "os" . "ray/core" "time" ) func toRGBA(x Vector3) color.RGBA { r := uint8(255.99 * x.X) g := uint8(255.99 * x.Y) b := uint8(255.99 * x.Z) return color.RGBA{r, g, b, 0xFF} } func color32ToRGBA(c Color32) col...
main.go
0.693992
0.428712
main.go
starcoder
package main import ( "encoding/json" "strings" "time" "github.com/containers/buildah" "github.com/containers/buildah/docker" buildahcli "github.com/containers/buildah/pkg/cli" "github.com/containers/buildah/pkg/parse" "github.com/mattn/go-shellwords" "github.com/pkg/errors" "github.com/sirupsen/logrus" "g...
cmd/buildah/config.go
0.548915
0.41117
config.go
starcoder
package probably import ( "fmt" "hash/fnv" "math" "sort" ) // Sketch is a count-min sketcher. type Sketch struct { sk [][]uint32 rowCounts []uint32 } // NewSketch returns new count-min sketch with the given width and depth. // Sketch dimensions must be positive. A sketch with w=⌈ ℯ/𝜀 ⌉ and // d=⌈ln (1...
count.go
0.553505
0.408985
count.go
starcoder
package blorb import ( "bytes" "encoding/binary" "fmt" "io" ) type Archive struct { r io.ReaderAt size int64 Pics []File Snds []File Datas []File Execs []File Gluls []File } type File struct { r io.ReaderAt id int format string offset int64 size int64 } func (f *File) ID() int { re...
blorb/blorb.go
0.616705
0.421671
blorb.go
starcoder
package lmath import ( "gonet/base" "math" "unsafe" ) type( Point2F struct { X float32 Y float32 } IPoint2F interface { Set(float32 , float32) SetF([] float32) SetMin(Point2F) SetMax(Point2F) Interpolate(Point2F, Point2F, float32) Zero() IsZero() bool Len() float32 LenSquared() float32 ...
server/game/lmath/point2f.go
0.658308
0.718385
point2f.go
starcoder
package datastructures import ( "fmt" "sync" ) type WeightedVertex struct { Val string Edges map[string]*WeightedEdge } type WeightedEdge struct { Vertex *WeightedVertex Weight int } type WeightedGraph struct { Vertices map[string]*WeightedVertex lock sync.RWMutex } type Verte...
datastructures/graph.go
0.559049
0.451266
graph.go
starcoder
package model import ( "math" "strconv" "time" "github.com/uncharted-distil/distil-compute/metadata" "github.com/uncharted-distil/distil-compute/model" ) // NullableFloat64 is float64 with custom JSON marshalling to allow for NaN values // to be handled gracefully. type NullableFloat64 float64 // MarshalJSON ...
api/model/storage.go
0.815269
0.577138
storage.go
starcoder
package sema import "github.com/onflow/cadence/runtime/ast" func (checker *Checker) VisitArrayExpression(expression *ast.ArrayExpression) ast.Repr { // visit all elements, ensure they are all the same type expectedType := UnwrapOptionalType(checker.expectedType) var elementType Type var resultType ArrayType ...
runtime/sema/check_array_expression.go
0.635788
0.483648
check_array_expression.go
starcoder
package elasticsearch // ElasticSearch mapping definition. const mapping = `{ "settings": { "analysis": { "analyzer": { "folding": { "tokenizer": "standard", "filter": ["lowercase", "asciifolding"] } }, "normalizer": { "keyword_normalizer": { "type": "custom", "filter": ["lowe...
vendor/github.com/alerting/alerts/pkg/alerts/elasticsearch/mapping.go
0.549399
0.457682
mapping.go
starcoder
package stats import ( "time" "golang.org/x/net/context" ) // Stats provides an interface for generating instruments, like guages and // counts. type Stats interface { Inc(name string, value int64, rate float32, tags []string) error Timing(name string, value time.Duration, rate float32, tags []string) error Gau...
stats/stats.go
0.859664
0.480174
stats.go
starcoder
package mlpack /* #cgo CFLAGS: -I./capi -Wall #cgo LDFLAGS: -L. -lmlpack_go_hoeffding_tree #include <capi/hoeffding_tree.h> #include <stdlib.h> */ import "C" import "gonum.org/v1/gonum/mat" type HoeffdingTreeOptionalParam struct { BatchMode bool Bins int Confidence float64 InfoGain bool InputMo...
hoeffding_tree.go
0.730963
0.55652
hoeffding_tree.go
starcoder
package goptuna // StudyOption to pass the custom option type StudyOption func(study *Study) error // StudyOptionDirection change the direction of optimize func StudyOptionDirection(direction StudyDirection) StudyOption { return func(s *Study) error { s.direction = direction return nil } } // StudyOptionLogger...
study_option.go
0.568655
0.401043
study_option.go
starcoder
package syntax import ( "log" "sort" "sync" "github.com/grailbio/base/digest" "github.com/grailbio/reflow" "github.com/grailbio/reflow/flow" "github.com/grailbio/reflow/types" "github.com/grailbio/reflow/values" ) var forceDigest = reflow.Digester.FromString("grail.com/reflow/syntax.Eval.Force") // Force p...
syntax/force.go
0.543348
0.531331
force.go
starcoder
package lex import ( "bytes" "fmt" "strings" "unicode/utf8" ) const ( eof = -1 // Dot is not included and must be checked individually. operatorRunes = "!#%&*+-/;<=>?@^`|~" // \v is a vertical tab whitespaceRunes = " \t\n\r\f\v" ) // The state of the scanner as a function that returns the next state. type...
internal/lex/lex.go
0.654564
0.464051
lex.go
starcoder
package value import ( "runtime" "strings" "sync" ) type valueType int const ( intType valueType = iota charType bigIntType bigRatType bigFloatType vectorType matrixType numType ) var typeName = [...]string{"int", "char", "big int", "rational", "float", "vector", "matrix"} func (t valueType) String() s...
value/eval.go
0.599368
0.513668
eval.go
starcoder
package value import ( "fmt" "robpike.io/ivy/config" ) func NewComplex(r, i Value) Value { return Complex{real: r, imag: i}.shrink() } func newComplexReal(r Value) Complex { return Complex{real: r, imag: Int(0)} } func newComplexImag(i Value) Complex { return Complex{real: Int(0), imag: i} } type Complex st...
value/complex.go
0.83471
0.540196
complex.go
starcoder
package geolocate import "math" // Point represents a Physical Point in geographic notation [lat, lng] // The different possible LocationTypes are documented here: // https://developers.google.com/maps/documentation/geocoding/intro#Results // It can for example be "ROOFTOP". type Point struct { Lat float64 ...
point.go
0.910416
0.722025
point.go
starcoder
package main import ( "github.com/google/gxui" "github.com/google/gxui/drivers/gl" "github.com/google/gxui/math" "github.com/google/gxui/themes/dark" omath "math" "time" ) //Two pendulums animated //Top: Mathematical pendulum with small-angle approxmiation (not appropiate with PHI_ZERO=pi/2) //Bottom: Simulated...
tasks/Animate-a-pendulum/animate-a-pendulum.go
0.589244
0.407451
animate-a-pendulum.go
starcoder
package rex import ( "github.com/g3n/engine/geometry" "github.com/g3n/engine/gls" "github.com/g3n/engine/math32" "github.com/roboticeyes/gorexfile/encoding/rexfile" ) // MeshGeometry contains the geometry information for a REX mesh datablock type MeshGeometry struct { geometry.Geometry Name string Ma...
loader/rex/meshgeometry.go
0.600071
0.532911
meshgeometry.go
starcoder
package plausible // AggregateQuery represents an API query for aggregate information over a period of time for a given list of metrics. // In an aggregate query, the Period field and the Metrics field are mandatory, all the others are optional. type AggregateQuery struct { // Period to consider for the aggregate que...
plausible/aggregate_query.go
0.931205
0.572783
aggregate_query.go
starcoder
package frdrpc import ( "errors" "fmt" "sort" "time" "github.com/lightninglabs/faraday/fiat" ) // granularityFromRPC gets a granularity enum value from a rpc request, // defaulting getting the best granularity for the period being queried. func granularityFromRPC(g Granularity, disableFiat bool, duration time....
frdrpc/exchange_rate.go
0.725162
0.404449
exchange_rate.go
starcoder
package graphics import ( "github.com/go-gl/mathgl/mgl32" "github.com/go-gl/mathgl/mgl64" "github.com/maxfish/gojira2d/pkg/utils" "math" ) const MinZoom float64 = 0.01 const MaxZoom float64 = 20 // Camera2D a Camera based on an orthogonal projection type Camera2D struct { x float64 y ...
pkg/graphics/camera_2d.go
0.874185
0.623148
camera_2d.go
starcoder
package resolver import "github.com/google/gapid/gapil/semantic" func implicit(lhs semantic.Type, rhs semantic.Type) bool { if lhs == semantic.AnyType { return true } return false } func assignable(lhs semantic.Type, rhs semantic.Type) bool { if isInvalid(lhs) || isInvalid(rhs) { return true // Don't snowba...
gapil/resolver/rules.go
0.730482
0.458712
rules.go
starcoder
package model import ( "fmt" "math" "regexp" "strconv" "strings" "time" ) const ( minimumTick = time.Millisecond second = int64(time.Second / minimumTick) nanosPerTick = int64(minimumTick / time.Nanosecond) Earliest = Time(math.MinInt64) Latest = Time(math.MaxInt64) ) type Time int64 type Interval s...
vendor/github.com/prometheus/common/model/time.go
0.671901
0.428413
time.go
starcoder
package tree import ( "fmt" "io" "os" "reflect" "sort" ) // Tree is a generic tree. type Tree[T any] struct { data T parent *Tree[T] children []*Tree[T] } // New initializes a new tree for use. func New[T any](data T) *Tree[T] { return &Tree[T]{ data: data, } } // Parent returns the parent of t. f...
tree.go
0.76454
0.478529
tree.go
starcoder
package locales import ( "fmt" ) var attrDesc = map[string]string{ "json": `Attributes are JSON format.`, "selector": `Filter used to select on which nodes should the automation be executed. Basic ex: @identity='{node_id}'.`, "run-id": ...
locales/locales.go
0.609524
0.475301
locales.go
starcoder
package value // String holds a single string value. type String struct { valPtr *string } // NewString makes a new String with the given string value. func NewString(val string) *String { valPtr := new(string) *valPtr = val return &String{valPtr: valPtr} } // NewStringFromPtr makes a new String with the given ...
value/string.go
0.85183
0.472562
string.go
starcoder
package psarf import ( "time" ) const ( // These are the Acceleration values used in the standard Psar formula AFIncrement = 0.02 AFMax = 0.20 ) // before is a utility func that checks if time a is before time b // Note, hours are reset (this is daily only) // FIXME allow this to be used with other timefra...
Psar.go
0.526586
0.584212
Psar.go
starcoder
package xtime import ( "strconv" "time" ) // CreateFromTimestamp creates a Xtime instance from a given timestamp, second, millisecond, microsecond and nanosecond are supported. // 从给定的时间戳创建 Xtime 实例,支持秒、毫秒、微秒和纳秒 func (c Xtime) CreateFromTimestamp(timestamp int64, timezone ...string) Xtime { if len(timezone) > 0 { ...
xtime/creator.go
0.64713
0.502136
creator.go
starcoder
package functional // Curry accepts a function that receives a parameter and the value of the parameter // and returns a function that accepts no parameters but returns the result of // applying the function to the given parameter. func Curry[T, R any](f func(T) R, input T) func() R { return func() R { return f(inp...
curry.go
0.852951
0.953579
curry.go
starcoder
package quaternion import ( "fmt" "math" "github.com/ungerik/go3d/float64/vec3" "github.com/ungerik/go3d/float64/vec4" ) var ( // Zero holds a zero quaternion. Zero = T{} // Ident holds an ident quaternion. Ident = T{0, 0, 0, 1} ) // T represents a orientatin/rotation as a unit quaternion. // See http://en...
float64/quaternion/quaternion.go
0.916829
0.69901
quaternion.go
starcoder
package geo import ( "math" "math/rand" "github.com/Bredgren/wrand" ) // Vec is a 2D vector. Many of the functions for Vec have two versions, one that modifies // the Vec and one that returns a new Vec. Their names follow a convention that is hopefully // inuitive. For example, when working with Vec as a value yo...
geo/vec.go
0.928587
0.659021
vec.go
starcoder
package base import ( sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/persistenceOne/persistenceSDK/constants/errors" "github.com/persistenceOne/persistenceSDK/schema/types" "github.com/persistenceOne/persistenceSDK/utilities/meta" ) var _, _ types.Data = (*Data_DecData)(nil), (*DecData)(nil) func (dec...
schema/types/base/decData.go
0.663451
0.430387
decData.go
starcoder
package circleToPolygon // version 1.0.3 import ( "encoding/json" "math" ) const ( defaultEarthRadius float64 = 6378137 // equatorial Earth radius defaultCount float64 = 32 ) // create new circle func NewCircle(latitude float64, longtitude float64, radius float64) CircleToPolygon { return &circleToPolygo...
circleToPolygon.go
0.77552
0.717222
circleToPolygon.go
starcoder
package timepb import ( "fmt" "time" durpb "google.golang.org/protobuf/types/known/durationpb" tspb "google.golang.org/protobuf/types/known/timestamppb" ) // IsZero returns true only when t is nil func IsZero(t *tspb.Timestamp) bool { return t == nil } // Commpare t1 and t2 and returns -1 when t1 < t2, 0 when ...
support/timepb/cmp.go
0.696784
0.416559
cmp.go
starcoder
The implementation is based on the public domain code available at http://www.johndcook.com/skewness_kurtosis.html . The linear regression code is from http://www.johndcook.com/running_regression.html . */ package onlinestats import "math" type Running struct { n int m1, m2, m3, m4 float64 } func N...
vendor/github.com/dgryski/go-onlinestats/stats.go
0.861931
0.562597
stats.go
starcoder
package minheap // MinHeap struct is a heap binary tree (in slice) such that the minimum value is always at the root // provides Add / Peek / Pop semantics type MinHeap struct { data []int length int } // Add new value to a heap - O(logN) func (heap *MinHeap) Add(value int) { if heap.length == len(heap.data) {...
DataStruct/MinHeap/go/minheap.go
0.865948
0.448306
minheap.go
starcoder
package geometry // Line is a open series of points type Line struct { baseSeries } // Valid ... func (line *Line) Valid() bool { if !WorldPolygon.ContainsLine(line) { return false } return true } // NewLine creates a new Line func NewLine(points []Point, opts *IndexOptions) *Line { line := new(Line) line.b...
geometry/line.go
0.79534
0.500549
line.go
starcoder
package vm import ( "math" "strconv" ) var ( integerClass *RInteger ) // RInteger is integer class type RInteger struct { *BaseClass } // IntegerObject represents integer instances type IntegerObject struct { Class *RInteger Value int } func (i *IntegerObject) objectType() objectType { return integerObj } ...
vm/integer.go
0.641422
0.409103
integer.go
starcoder
package xmath import ( "fmt" "math" "math/rand" "strconv" "strings" "time" ) type N interface { Op(op Op) N Dop(dop Dop) N } // Check checks if the given number is a valid one. func Check(v float64) { if math.IsNaN(v) || math.IsInf(v, 0) { panic(fmt.Sprintf("%v is not a valid number", v)) } } // pp is t...
oremi/vendor/github.com/drakos74/go-ex-machina/xmath/algebra.go
0.8059
0.648383
algebra.go
starcoder
package types import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // Validator represents a single validator. // This is defined as an interface so that we can use the SDK types // as well as database types properly. type Validator interface { GetConsAddr...
x/staking/types/validator.go
0.76366
0.430686
validator.go
starcoder
package spher import "fmt" import "math" import "runtime" import "sort" import "sync" // Precisions for float64. const ( FLOAT64_COARSER_PRECISION = 9 FLOAT64_NORMAL_PRECISION = 12 ) // This can be get as follows: math.Float64Bits(math.NaN()). const FLOAT64_NAN_BITS = 0x7ff8000000000001 // Round float64 x to the...
float64.go
0.806548
0.490785
float64.go
starcoder
package klash import ( "errors" "fmt" "reflect" ) type Params struct { Mapping map[string]*Parameter Listing []*Parameter } // Params store the mapping of ParamName -> Parameter for the given structure. // Since multiple names can be affected to a single parameter, multiple // keys can be associated with a sing...
vendor/github.com/mota/klash/params.go
0.682997
0.41182
params.go
starcoder
package commands import ( "fmt" "sort" "strings" tbw "text/tabwriter" "time" "github.com/agnivade/levenshtein" ) // LevenshteinDistance contains the computed levenshtein // between Str1 and Str2 type LevenshteinDistance struct { Str1 string Str2 string Distance int } // Compute computes (or recompu...
commands/utils.go
0.710929
0.669599
utils.go
starcoder
package bebop import ( "github.com/hybridgroup/gobot" ) var _ gobot.Driver = (*BebopDriver)(nil) // BebopDriver is gobot.Driver representation for the Bebop type BebopDriver struct { name string connection gobot.Connection gobot.Eventer } // NewBebopDriver creates an BebopDriver with specified name. func ...
vendor/github.com/hybridgroup/gobot/platforms/bebop/bebop_driver.go
0.819713
0.520131
bebop_driver.go
starcoder
package collections import "fmt" // Zipper represents a pair of ordered collections that can be zipped together. // Elements of each collection are assumed to be sorted in ascending order. type Zipper interface { // Comparable must compare the left and right collection elements at i and // j respectively, returning...
zip.go
0.774071
0.721817
zip.go
starcoder
package types func IsZeroString(a string) bool { return a == "" } func IsZeroStringOptional(a *string) bool { if a == nil { return true } return false } func IsZeroStringMultiples(a, b []string) bool { if len(a) == 0 { return true } return false } func IsZeroMapStringString(a map[string]string) bool { ...
vendor/yunion.io/x/ovsdb/types/atomic_gen_iszero_zz_generated.go
0.665737
0.610889
atomic_gen_iszero_zz_generated.go
starcoder
package main import ( "../ahrs" "errors" "github.com/skelterjohn/go.matrix" "math" "math/rand" "sort" ) const ( Pi = math.Pi Deg = Pi / 180 Small = 1e-6 ) var TimeError = errors.New("requested time is outside of scenario") // Situation defines a scenario by piecewise-linear interpolation type Situatio...
sim/situationSim.go
0.583915
0.403479
situationSim.go
starcoder
package temporal import "time" // Season holds the name and starting and ending times for the season in a given year. type Season struct { Name string Start time.Time End time.Time } // Seasons holds a year and a list of Seasons for that year type Seasons struct { Year int List []Season } ...
season.go
0.531939
0.412294
season.go
starcoder
package ratelimit import ( "fmt" "sync" "time" ) // Limit defines the maximum number of requests per second. type Limit float64 // Every converts a time interval between requests to a Limit. func Every(interval time.Duration) Limit { if interval <= 0 { panic("ratelimit: invalid time interval for Every") } re...
pkg/ratelimit/ratelimit.go
0.8586
0.461684
ratelimit.go
starcoder
package fd import "sync" // Laplacian computes the Laplacian of the multivariate function f at the location // x. That is, Laplacian returns // ∆ f(x) = ∇ · ∇ f(x) = \sum_i ∂^2 f(x)/∂x_i^2 // The finite difference formula and other options are specified by settings. // The order of the difference formula must be 2 ...
vendor/gonum.org/v1/gonum/diff/fd/laplacian.go
0.721253
0.451992
laplacian.go
starcoder
package plaid import ( "encoding/json" "time" ) // WalletTransaction The transaction details type WalletTransaction struct { // A unique ID identifying the transaction TransactionId string `json:"transaction_id"` // A reference for the transaction Reference string `json:"reference"` // The type of of the tran...
plaid/model_wallet_transaction.go
0.737631
0.437343
model_wallet_transaction.go
starcoder
package xxh3 import ( "math/bits" "unsafe" ) // Uint128 is a 128 bit value. // The actual value can be thought of as u.Hi<<64 | u.Lo. type Uint128 struct { Hi, Lo uint64 } // Bytes returns the uint128 as an array of bytes in canonical form (big-endian encoded). func (u Uint128) Bytes() [16]byte { return [16]byte...
vendor/github.com/zeebo/xxh3/utils.go
0.608245
0.407569
utils.go
starcoder