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 storetest import ( "database/sql" "errors" "testing" "github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/store" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestChannelStoreCategories(t *testing.T, ss store.Store, s SqlSu...
store/storetest/channel_store_categories.go
0.558447
0.497009
channel_store_categories.go
starcoder
package recovery import ( "context" "encoding/json" "testing" "github.com/bxcodec/faker/v3" "github.com/gofrs/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/ory/kratos/driver/config" "github.com/ory/kratos/identity" "github.com/ory/kratos/selfservice/form" "gi...
selfservice/flow/recovery/persistence.go
0.540439
0.457561
persistence.go
starcoder
package k_closest_points_to_origin import ( "math" "sort" ) func KClosest(points [][]int, k int) [][]int { // Precompute the Euclidean distance for each point, // define the initial binary search range, // and create a reference list of point indices distances := make([]float64, len(points)) low, high := 0.0, ...
golang/k_closest_points_to_origin/k_closest.go
0.74872
0.459622
k_closest.go
starcoder
package jit import ( "io" "unsafe" "github.com/damilolarandolph/go-jit/internal/ccall" ) type Type struct { *ccall.Type } type Types []*Type func (t Types) raw() ccall.Types { types := ccall.Types{} for _, tt := range t { types = append(types, tt.Type) } return types } func toType(raw *ccall.Type) *Type...
type.go
0.575827
0.573141
type.go
starcoder
package main import ( "fmt" "io/ioutil" "os" "strings" "github.com/Ullaakut/aoc19/pkg/aocutils" "github.com/Ullaakut/disgo" "github.com/Ullaakut/disgo/style" "github.com/fatih/color" ) var format = map[rune]func(string, ...interface{}) string{ 'o': color.RedString, 'X': color.GreenString, '+': color.White...
Day03/Part2/main.go
0.583797
0.427337
main.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // AccessReviewScheduleSettings type AccessReviewScheduleSettings struct { // Stores additional data not described in the OpenAPI description found when deser...
models/access_review_schedule_settings.go
0.745769
0.466603
access_review_schedule_settings.go
starcoder
package ahrs import ( "log" "math" "fmt" "github.com/skelterjohn/go.matrix" ) type Kalman0State struct { State f *matrix.DenseMatrix z *Measurement y *matrix.DenseMatrix h *matrix.DenseMatrix ss *matrix.DenseMatrix kk *matrix.DenseMatrix } // Initialize the state at the start of the...
ahrs/ahrs_kalman0.go
0.747339
0.661797
ahrs_kalman0.go
starcoder
Package hilbert implements a Hilbert R-tree based on PALM principles to improve multithreaded performance. This package is not quite complete and some optimization and delete codes remain to be completed. This serves as a potential replacement for the interval tree and rangetree. Benchmarks: BenchmarkBulkAddPoints-8...
vendor/src/github.com/Workiva/go-datastructures/rtree/hilbert/tree.go
0.5564
0.509032
tree.go
starcoder
package ximage import ( "image" "image/color" "tawesoft.co.uk/go/ximage/xcolor" ) // RGB is an in-memory image whose At method returns color.RGB values. type RGB struct { // Pix holds the image's pixels, as Red values. The pixel at // (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*2]. Pix...
ximage/rgb.go
0.888105
0.572902
rgb.go
starcoder
package bullet // #cgo pkg-config: bullet // #cgo windows LDFLAGS: -Wl,--allow-multiple-definition // #include "bulletglue.h" import "C" import ( "github.com/fcvarela/gosg/core" "github.com/go-gl/mathgl/mgl64" "github.com/golang/glog" ) func init() { core.SetPhysicsSystem(&PhysicsSystem{}) } // convenience func ...
physics/bullet/physicssystem.go
0.753013
0.543833
physicssystem.go
starcoder
package attacherdetacher import ( "fmt" "github.com/golang/glog" "k8s.io/kubernetes/pkg/controller/volume/cache" "k8s.io/kubernetes/pkg/util/goroutinemap" "k8s.io/kubernetes/pkg/volume" ) // AttacherDetacher defines a set of operations for attaching or detaching a // volume from a node. type AttacherDetacher i...
pkg/controller/volume/attacherdetacher/attacher_detacher.go
0.688573
0.466603
attacher_detacher.go
starcoder
package value import ( "math/big" "robpike.io/ivy/config" ) func power(c Context, u, v Value) Value { x := floatSelf(c, u).(BigFloat) exp := floatSelf(c, v).(BigFloat) if x.Sign() < 0 && exp.Cmp(floatMinusOne) > 0 && exp.Cmp(floatOne) < 0 { // Complex solution when x<0 and exp<1 return newComplexReal(u).Po...
value/power.go
0.651798
0.560433
power.go
starcoder
package block import ( "github.com/df-mc/dragonfly/dragonfly/block/fire" "github.com/df-mc/dragonfly/dragonfly/item" "github.com/df-mc/dragonfly/dragonfly/world" "github.com/go-gl/mathgl/mgl64" ) // Torch are non-solid blocks that emit light. type Torch struct { noNBT transparent empty // Facing is the direc...
dragonfly/block/torch.go
0.678753
0.40204
torch.go
starcoder
package input import ( "context" "errors" "fmt" "io" "sync" "time" "github.com/Jeffail/benthos/v3/internal/codec" "github.com/Jeffail/benthos/v3/internal/docs" "github.com/Jeffail/benthos/v3/internal/interop" sftpSetup "github.com/Jeffail/benthos/v3/internal/service/sftp" "github.com/Jeffail/benthos/v3/lib...
lib/input/sftp.go
0.65368
0.490602
sftp.go
starcoder
package relpos import ( "github.com/goki/gi/mat32" "github.com/goki/ki/kit" ) // Rel defines a position relationship among layers, in terms of X,Y width and height of layer // and associated position within a given X-Y plane, // and Z vertical stacking of layers above and below each other. type Rel struct { Rel ...
relpos/rel.go
0.792143
0.573021
rel.go
starcoder
package bitstring /* unsigned integer get */ // Uint8 interprets the 8 bits at offset off as an uint8 in big endian and // returns its value. Behavior is undefined if there aren't enough bits. func (bs *Bitstring) Uint8(off int) uint8 { bs.mustExist(off + 7) return uint8(bs.uint(uint64(off), 7)) } // Uint16 inter...
int.go
0.682997
0.420005
int.go
starcoder
package vote import ( "context" ) // OpinionGiver gives opinions about the given IDs. type OpinionGiver interface { // Query queries the OpinionGiver for its opinions on the given IDs. // The passed in context can be used to signal cancellation of the query. Query(ctx context.Context, ids []string) (Opinions, err...
packages/vote/opinion.go
0.679604
0.616878
opinion.go
starcoder
package main import ( "image" "image/color" ) // ycc is an in memory YCbCr image. The Y, Cb and Cr samples are held in a // single slice to increase resizing performance. type ycc struct { // Pix holds the image's pixels, in Y, Cb, Cr order. The pixel at // (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Mi...
ycc.go
0.761804
0.548311
ycc.go
starcoder
package bulletproofs import ( "fmt" "github.com/incognitochain/go-incognito-sdk-v2/crypto" ) // InnerProductWitness represents a witness for an inner-product proof, described in the Bulletproofs paper. type InnerProductWitness struct { a []*crypto.Scalar b []*crypto.Scalar p *crypto.Point } // InnerProductProof...
privacy/v1/zkp/bulletproofs/innerproduct.go
0.713831
0.432063
innerproduct.go
starcoder
package decisiontree // A Node represents a splitting decision of the form "x[FeatureIndex] < Threshold ?" in a decision tree type Node struct { // FeatureIndex indicates which feature is used in this splitting decision FeatureIndex int `json:"feature_index"` // Threshold indicates the cutoff value between the left...
kite-golib/decisiontree/tree.go
0.880181
0.645302
tree.go
starcoder
package plural import ( "fmt" "math" "strconv" "strings" ) // Operands is a representation of CLDR Operands, see // http://unicode.org/reports/tr35/tr35-numbers.html#Operands. type Operands struct { N float64 // The absolute value of the source number (integer and decimals). I int64 // The integer digits of ...
internal/plural/operands.go
0.683736
0.401923
operands.go
starcoder
package data import ( "math" "github.com/calummccain/coxeter/vector" ) type GoursatTetrahedron struct { V vector.Vec4 E vector.Vec4 F vector.Vec4 C vector.Vec4 CFE vector.Vec4 CFV vector.Vec4 CEV vector.Vec4 FEV vector.Vec4 CF float64 CE float64 CV float64 FE float64 FV float64 EV float...
data/dataStruct.go
0.540196
0.532243
dataStruct.go
starcoder
The downsampled data maintains the visual characteristics of the original line using considerably fewer data points. This is a translation of the javascript code at https://github.com/sveinn-steinarsson/flot-downsample/ */ package lttb import ( "math" ) // Point is a point on a line type Point struct { X floa...
lttb.go
0.755276
0.673
lttb.go
starcoder
package vm import ( "unsafe" ) // Expression or variable operation semantic const ( SemanticOpNone = iota SemanticOpRead SemanticOpWrite ) // Expression or variable lexical scoping const ( LexicalScopingUnknown = iota LexicalScopingGlobal // Expression or variable in global table LexicalScopingUpvalue // Exp...
Source/vm/SyntaxTree.go
0.604282
0.564939
SyntaxTree.go
starcoder
package iso20022 // Specifies security rate details. type CorporateActionRate28 struct { // Quantity of additional intermediate securities/new equities awarded for a given quantity of securities derived from subscription. AdditionalQuantityForSubscribedResultantSecurities *RatioFormat11Choice `xml:"AddtlQtyForSbcbd...
CorporateActionRate28.go
0.873835
0.460774
CorporateActionRate28.go
starcoder
package idgen import "bytes" // TrieKey is a vector of bits backed by a Go byte slice in big endian byte order and big-endian bit order. type TrieKey []byte func (bs TrieKey) BitAt(offset int) byte { if bs[offset/8]&(1<<(offset%8)) == 0 { return 0 } else { return 1 } } func (bs TrieKey) BitLen() int { retur...
idgen/xortrie.go
0.62223
0.685028
xortrie.go
starcoder
package car import ( "encoding/binary" "io" ) const ( // PragmaSize is the size of the CARv2 pragma in bytes. PragmaSize = 11 // HeaderSize is the fixed size of CARv2 header in number of bytes. HeaderSize = 40 // CharacteristicsSize is the fixed size of Characteristics bitfield within CARv2 header in number of...
v2/car.go
0.657868
0.535402
car.go
starcoder
package column import ( "github.com/ryogrid/SamehadaDB/types" ) type Column struct { columnName string columnType types.TypeID fixedLength uint32 // For a non-inlined column, this is the size of a pointer. Otherwise, the size of the fixed length column variableLength uint32 // For an inlined column, ...
storage/table/column/column.go
0.548432
0.438785
column.go
starcoder
// We represent flips with an array of 0s and 1s. 1 for heads, and 0 for tails. package main import "fmt" import "math/rand" import "time" import "flag" // Return an array of random flips, of the given length func create_flips(number_of_flips int) ([]int) { flips := make([]int, number_of_flips) for ii := range ...
flips.go
0.696475
0.479138
flips.go
starcoder
package clients import ( "errors" "fmt" "strings" "github.com/Kamva/octopus/base" ) // fetchSingleRecord Fetch a single result from rows and set into record data func fetchSingleRecord(rows base.SQLRows, data *base.RecordData) error { if rows.Next() { // Get list of result columns cols, _ := rows.Columns() ...
clients/helpers.go
0.579995
0.403684
helpers.go
starcoder
package knn import ( "fmt" "github.com/gonum/matrix/mat64" "github.com/sjwhitworth/golearn/base" "github.com/sjwhitworth/golearn/metrics/pairwise" "github.com/sjwhitworth/golearn/utilities" ) // A KNNClassifier consists of a data matrix, associated labels in the same order as the matrix, and a distance function....
knn/knn.go
0.760295
0.52275
knn.go
starcoder
// Pointer: The pointer is used to points to the first element of the array that is accessible through the slice. Here, it is not necessary that the pointed element is the first element of the array. // Length: The length is the total number of elements present in the array. // Capacity: The capacity represents the ma...
slices.go
0.622689
0.579757
slices.go
starcoder
package dst // Beta distribution reparametrized using mean (μ) and sample size (ν). // <NAME>. (2011). Doing Bayesian data analysis: A tutorial with R and BUGS. p. 83: Academic Press / Elsevier. ISBN 978-0123814852. // BetaμνPDF returns the PDF of the Beta distribution reparametrized using mean and sample size. fu...
dst/beta-mu-nu.go
0.920115
0.657305
beta-mu-nu.go
starcoder
package plaid import ( "encoding/json" ) // OverrideAccounts Data to use to set values of test accounts. Some values cannot be specified in the schema and will instead will be calculated from other test data in order to achieve more consistent, realistic test data. type OverrideAccounts struct { Type OverrideAccou...
plaid/model_override_accounts.go
0.830078
0.452173
model_override_accounts.go
starcoder
package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // NodeObservabilityRunSpec defines the desired state of NodeObservabilityRun type NodeObservabilityRunSpec struct { // NodeObservabilityRef is the reference to the parent NodeObservability resource NodeObservabilityRef *NodeObservabilityRe...
api/v1alpha1/nodeobservabilityrun_types.go
0.85129
0.42322
nodeobservabilityrun_types.go
starcoder
package tart // The Chande momentum oscillator is a technical momentum // indicator introduced by <NAME> in his 1994 book // The New Technical Trader. The formula calculates the // difference between the sum of recent gains and the sum // of recent losses and then divides the result by the sum // of all price movement...
cmo.go
0.718496
0.431405
cmo.go
starcoder
package avltree type removeData struct { lookingFor interface{} compare CompareFunc } func findPredecessor(node *treeNode) *treeNode { if node != nil { pred := node.left if pred != nil { for pred.right != nil { pred = pred.right } } return pred } return nil } func remLeftSubBalance(node *tr...
vendor/github.com/ancientlore/go-avltree/treeremove.go
0.720762
0.431584
treeremove.go
starcoder
package nvm import ( "math" "strconv" ) // FloatEpsilon represents difference between 1 and the least value greater than 1 that is representable. var FloatEpsilon = 1e-8 // IsNEqual reports whether floats `x` and `y` are equal. // `NaN != NaN`, `(-)Inf != (-)Inf` func IsNEqual(x, y float64) bool { if math.Abs(x-...
nvm/float.go
0.907646
0.628635
float.go
starcoder
package enums import ( "fmt" "io" "strconv" ) // FilterSortDataType defines the various Filter data types type FilterSortDataType string // Note: the constant values should match the table field name const ( // FilterSortDataTypeCreatedAt represents created at Filter data type FilterSortDataTypeCreatedAt Filter...
pkg/mycarehub/application/enums/filter_type.go
0.748812
0.638286
filter_type.go
starcoder
package nodes /* Package nodes provides information and interaction with the nodes API resource in the OpenStack Bare Metal service. // Example to List Nodes with Detail nodes.ListDetail(client, nodes.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) { nodeList, err := nodes.ExtractNodes(page) if er...
pkg/terraform/exec/plugins/vendor/github.com/gophercloud/gophercloud/openstack/baremetal/v1/nodes/doc.go
0.697712
0.557123
doc.go
starcoder
package dungeon import ( "fmt" "geometry" "math" "math/rand" ) // Room is a room in the dungeon type Room struct { Width, Height float64 TopLeft, BottomRight geometry.Point locs []Loc } // NewRoom creates a Room with specified dimensions func NewRoom(x, y, width, height int) *Room { re...
src/dungeon/room.go
0.80969
0.471527
room.go
starcoder
package iso20022 // Cash movements from or to a fund as a result of investment funds transactions, eg, subscriptions or redemptions. type EstimatedFundCashForecast1 struct { // Date and, if required, the time, at which the price has been applied. TradeDateTime *DateAndDateTimeChoice `xml:"TradDtTm"` // Previous d...
EstimatedFundCashForecast1.go
0.84367
0.541773
EstimatedFundCashForecast1.go
starcoder
package crypto // encrypt.go contains functions for encrypting and decrypting data byte slices // and readers. import ( "crypto/cipher" "encoding/json" "errors" "io" "github.com/NebulousLabs/fastrand" "golang.org/x/crypto/twofish" ) const ( // TwofishOverhead is the number of bytes added by EncryptBytes Tw...
crypto/encrypt.go
0.747984
0.447943
encrypt.go
starcoder
package emath // MinInt find and return the minimum item from the specified int func MinInt(nums ...int) int { var ret = nums[0] for i, l := 1, len(nums); i < l; i++ { if ret > nums[i] { ret = nums[i] } } return ret } // MaxInt find and return the maximum item from the specified int func MaxInt(nums ...int...
emath/math_minmax.go
0.662796
0.459501
math_minmax.go
starcoder
package find_all_anagrams_in_a_string /* 242. 有效的字母异位词 https://leetcode-cn.com/problems/valid-anagram 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词。 示例 1: 输入: s = "anagram", t = "nagaram" 输出: true 示例 2: 输入: s = "rat", t = "car" 输出: false 说明: 你可以假设字符串只包含小写字母。 进阶: 如果输入字符串包含 unicode 字符怎么办?你能否调整你的解法来应对这种情况? */ /* 1.借助两个哈希表(...
solutions/find-all-anagrams-in-a-string/d.go
0.588534
0.463505
d.go
starcoder
package gonpy import ( "encoding/binary" "fmt" ) // GetComplex128 returns the array data as a slice of complex128 values. func (rdr *NpyReader) GetComplex128() ([]complex128, error) { if rdr.Dtype != "c16" { return nil, fmt.Errorf("Reader does not contain complex128 data") } data := make([]complex128, rdr.n...
defs_gen.go
0.822688
0.429908
defs_gen.go
starcoder
package skills import ( "github.com/wieku/danser-go/app/beatmap/difficulty" "github.com/wieku/danser-go/app/oppai/preprocessing" "math" "sort" ) type Skill struct { // Strain values are multiplied by this number for the given skill. Used to balance the value of different skills between each other. SkillMultipli...
app/oppai/skills/skill.go
0.696371
0.442155
skill.go
starcoder
package encode import ( "github.com/0987363/go-geobuf/pkg/geojson" "github.com/0987363/go-geobuf/pkg/geometry" "github.com/0987363/go-geobuf/pkg/math" "github.com/0987363/go-geobuf/proto" ) const ( GeometryPoint = "Point" GeometryMultiPoint = "MultiPoint" GeometryLineString = "LineString" ...
pkg/encode/geometry.go
0.725843
0.508239
geometry.go
starcoder
package template var COMMON_GRAPHQLS = ` """ expression to compare columns of type _jsonb. All fields are combined with logical 'AND'. """ input JsonbComparisonExp { _eq: Jsonb _gt: Jsonb _gte: Jsonb _in: [Jsonb!] _is_null: Boolean _lt: Jsonb _lte: Jsonb _neq: Jsonb _nin: [Jsonb!] } """ expression to compare ...
gen/template/common_graphqls.go
0.623377
0.420183
common_graphqls.go
starcoder
package onshape import ( "encoding/json" ) // BTPArgumentDeclaration232 struct for BTPArgumentDeclaration232 type BTPArgumentDeclaration232 struct { BTPNode7 BtType *string `json:"btType,omitempty"` Name *BTPIdentifier8 `json:"name,omitempty"` StandardType *string `json:"standardType,omitempty"` Type *BTPTypeNa...
onshape/model_btp_argument_declaration_232.go
0.716119
0.601711
model_btp_argument_declaration_232.go
starcoder
package main type HealthECGView struct { // Color of the current line Color [3]int // Lines to the left of the current line will have a darker color Gradient [3]int // The first value is the yOffset, the second value is for the line height // We need to add 1 to the line height so that if the height is 0, at lea...
ecg.go
0.70477
0.777849
ecg.go
starcoder
package simulator import ( "time" ) const ( maxUsageRecorded = 50 ) // UsageRecord records which node was considered helpful to which node during pod rescheduling analysis. type UsageRecord struct { usingTooMany bool using map[string]time.Time usedByTooMany bool usedBy map[string]time.Time } /...
simulator/tracker.go
0.613352
0.457924
tracker.go
starcoder
package sudogo import ( "math" ) // The classic 9x9 puzzle with 9 boxes of 3x3 and digits 1-9. var Classic = &Kind{ BoxSize: Size{3, 3}, } // A 4x4 puzzle with 4 boxes of 2x2 and digits 1-4. var Kind2x2 = &Kind{ BoxSize: Size{2, 2}, } // A 6x6 puzzle with 6 boxes of 3x2 and digits 1-6. var Kind3x2 = &Kind{ BoxS...
pkg/kind.go
0.728555
0.514705
kind.go
starcoder
package basic import ( "math" "github.com/starainrt/astro/planet" . "github.com/starainrt/astro/tools" ) func JupiterL(JD float64) float64 { return planet.WherePlanet(4, 0, JD) } func JupiterB(JD float64) float64 { return planet.WherePlanet(4, 1, JD) } func JupiterR(JD float64) float64 { return planet.WherePl...
basic/jupiter.go
0.698432
0.466663
jupiter.go
starcoder
package Euler2D import ( "math" "sort" "github.com/notargets/gocfd/DG2D" "github.com/notargets/gocfd/types" "github.com/notargets/gocfd/utils" ) type EdgeKeySlice []types.EdgeKey func (p EdgeKeySlice) Len() int { return len(p) } func (p EdgeKeySlice) Less(i, j int) bool { // Sorted to produce groups of verte...
model_problems/Euler2D/edges.go
0.699768
0.603523
edges.go
starcoder
package main import ( "bufio" "flag" "fmt" "os" "strconv" "strings" ) func main() { // Use Flags to run a part methodP := flag.String("method", "p2", "The method/part that should be run, valid are p1,p2 and test") flag.Parse() switch *methodP { case "p1": partOne() break case "p2": partTwo() brea...
2019/8-SpaceImage/main.go
0.601594
0.492066
main.go
starcoder
package bls12381 import ( "errors" "math/big" ) type fp2Temp struct { t [4]*fe } type fp2 struct { fp2Temp } func newFp2Temp() fp2Temp { t := [4]*fe{} for i := 0; i < len(t); i++ { t[i] = &fe{} } return fp2Temp{t} } func newFp2() *fp2 { t := newFp2Temp() return &fp2{t} } func (e *fp2) fromBytes(in []b...
fp2.go
0.512693
0.444203
fp2.go
starcoder
package tmxscripter import ( "github.com/kurrik/tmxgo" ) type ScriptableMap struct { *tmxgo.Map } func NewScriptableMap(m *tmxgo.Map) *ScriptableMap { return &ScriptableMap{ Map: m, } } // Returns a layer with the given name if one exists. func (m *ScriptableMap) GetLayer(name string) *ScriptableLayer { if ...
tmxscripter/api.go
0.814348
0.423756
api.go
starcoder
package splunk // nolint: dupl // LogEntryRingBuffer is a ring buffer that supports inserting and reading // chunks of elements in an orderly fashion. It is NOT thread-safe and the // returned batches are not copied, they are a slice against the original // backing array of this logEntry. This means that if the bu...
pkg/core/writer/splunk/log_event_ring.gen.go
0.608129
0.458288
log_event_ring.gen.go
starcoder
package mos65xx import ( "fmt" ) const ( condPass = " \x1b[1;32m✓\x1b[0m " condFail = " \x1b[1;31m✗\x1b[0m " condEqual = "\x1b[1;37m=\x1b[0m" condRange = "\x1b[1;37m∈\x1b[0m" ) // cond is a condition checker for our test harness type cond interface { Cond(Instruction) bool String() string } // conds ...
cond.go
0.553505
0.442877
cond.go
starcoder
package matrix // Matrix : a matrix type Matrix struct { Row, Col int Values []float64 } // ScalAdd : return a matrix by adding scal element wise func ScalAdd(m *Matrix, scal float64) *Matrix { values := make([]float64, m.Col*m.Row) for i := 0; i < m.Row*m.Col; i++ { values[i] = m.Values[i] + scal } return ...
matrix/matrix.go
0.851506
0.803482
matrix.go
starcoder
package forGraphBLASGo import ( "github.com/intel/forGoParallel/pipeline" ) type mxV[Dw, DA, Du any] struct { op Semiring[Dw, DA, Du] A *matrixReference[DA] u *vectorReference[Du] } func newMxV[Dw, DA, Du any]( op Semiring[Dw, DA, Du], A *matrixReference[DA], u *vectorReference[Du], ) computeVectorT[Dw] { ...
functional_Vector_ComputedMxV.go
0.529993
0.551332
functional_Vector_ComputedMxV.go
starcoder
package promql import ( "fmt" "regexp" "time" "github.com/wolffcm/flux/ast" "github.com/influxdata/promql/v2" "github.com/influxdata/promql/v2/pkg/labels" ) var labelMatchOps = map[labels.MatchType]ast.OperatorKind{ labels.MatchEqual: ast.EqualOperator, labels.MatchNotEqual: ast.NotEqualOperator, label...
promql/selector.go
0.625667
0.499084
selector.go
starcoder
package goalgorithms func mergeTopDown(a []int, b []int, i, size int) { l := i lsize := size/2 + size%2 r := i + lsize rsize := size - lsize if lsize > 1 { mergeTopDown(a, b, l, lsize) } if rsize > 1 { mergeTopDown(a, b, r, rsize) } lmax := l + lsize rmax := r + rsize z := 0 for z < size { if l ==...
sort/merge.go
0.565779
0.521837
merge.go
starcoder
package gohorizon import ( "encoding/json" ) // NetworkLabelAssignmentSettings Specification for an individual network label assignment, stipulating the label and how many times it may be assigned to machines with this spec. type NetworkLabelAssignmentSettings struct { // Whether or not this specification is enabl...
model_network_label_assignment_settings.go
0.806434
0.529689
model_network_label_assignment_settings.go
starcoder
Left/Right Pan and Volume Module Takes a single audio buffer stream as input and outputs left and right channels. */ //----------------------------------------------------------------------------- package mix import ( "github.com/deadsy/babi/core" "github.com/deadsy/babi/utils/log" ) //-------------------------...
module/mix/pan.go
0.69035
0.417153
pan.go
starcoder
package sdf // Connector3d stores the information needed to connector to another part type Connector3d struct { Position V3 Vector V3 Angle float64 } // Transform3DConnector applies a transformation matrix to an SDF3 and a connector. // func Transform3DConnector(sdf SDF3, connectors map[string]Connector3d, ma...
sdf/connectors.go
0.646906
0.442637
connectors.go
starcoder
package gonighttime import ( "math" "time" "github.com/kelvins/sunrisesunset" ) type Place struct { Lat float64 Lon float64 Time time.Time } type Route struct { Departure Place Arrival Place } func deg2rad(degrees float64) float64 { return degrees * math.Pi / 180 } func hsin(theta float64) float64 { ...
nighttime.go
0.861974
0.606324
nighttime.go
starcoder
package spec import ( "testing" "time" "github.com/256dpi/gomqtt/client" "github.com/256dpi/gomqtt/packet" "github.com/stretchr/testify/assert" ) // AuthenticationTest tests the broker for valid and invalid authentication. func AuthenticationTest(t *testing.T, config *Config) { deniedClient := client.New() d...
spec/advanced.go
0.672547
0.458773
advanced.go
starcoder
package plots import ( "math" "reflect" "sort" ) // A series of data to be used in a 2D graph. Implements the plotinum XYer // interface. type Series struct { xs, ys []float64 } func MakeSeries(xs, ys []float64) Series { s := Series{xs, ys} return s } func (s *Series) X(i int) float64 { return s.xs[i] } fun...
plots/series.go
0.745306
0.558929
series.go
starcoder
package utils import ( "strings" "time" ) type p struct { find string format string reg string } /* Formats: M - month (1) MM - month (01) MMM - month (Jan) MMMM - month (January) D - day (2) DD - day (02) DDD - day (Mon) DDDD - day (Monday) T - Time (T, 2006-01-02T15:04:05) YY ...
agent/core/utils/fmt_date.go
0.513668
0.401072
fmt_date.go
starcoder
package common import ( "math" ) // returns shortest distances from the given source node to all vertices in the graph func (graph *Graph) ShortestDistancesFromSource(src *Node) map[int]float64 { result := graph.ShortestPath(src, ShortestPathParams{}) return result.Distances } type ShortestPathParams struct { //...
common/graph_algo.go
0.778481
0.545951
graph_algo.go
starcoder
package plenc import "fmt" // WireType represents a protobuf wire type. It's really all about how you can // skip over fields in encoded data that aren't recognised because the field no // longer exists in the struct. type WireType int8 const ( // WTVarInt signals a variable-length encoded integer. Signed integers ...
wire.go
0.58676
0.545407
wire.go
starcoder
package query const ( // EqualsOperator takes two operands and tests if they are equal EqualsOperator eqOperator = "eq" // NotEqualsOperator takes two operands and tests if they are not equal NotEqualsOperator neOperator = "ne" // GreaterThanOperator takes two operands and tests if the left is greater than the ri...
pkg/query/operators.go
0.854263
0.894605
operators.go
starcoder
Coding Exercise #1 There is an error in the following Go Program. Even though the goroutine is correctly launched, it doesnt print any message. package main import ( "fmt" ) func sayHello(n string) { fmt.Printf("Hello, %s!\n", n) } func main() { go sa...
more_code/coding_tasks/concurrency/gorutines_waitgroups_mutexes.go
0.665737
0.58053
gorutines_waitgroups_mutexes.go
starcoder
package common type Tileset struct { parent *Map FirstGID int // the global id (across all tilesets) for the first tile in this set Name string OffsetX int OffsetY int TileWidth int TileHeight int Spacing int Margin int terrain []*Terrain properties map[string]*Property tiles []*Tile } fu...
common/tileset.go
0.681727
0.416322
tileset.go
starcoder
package main import ( "fmt" "strings" "github.com/go-gl/gl/v4.2-core/gl" "github.com/hexaflex/wireworldgpu/math" "github.com/pkg/errors" ) // Shader defines a compiled shader program. type Shader uint32 // Release cleans up the shader. func (s Shader) Release() { gl.DeleteShader(uint32(s)) } // SetUniformMat...
shader.go
0.712132
0.445409
shader.go
starcoder
package gfx import ( "math/rand" "runtime" "time" ) const ( defaultTargetFrameRate = 60 ) var ( width float64 height float64 scaleX float64 scaleY float64 fps int isFixed bool targetFrameRate int targetFrameTime float64 ) // Application defines the interface that must be implemente...
pkg/gfx/gfx.go
0.826327
0.425367
gfx.go
starcoder
package numint // GaussLegendre returns a GaussLegendre rule of specified degree. // The rules are based off of hard-coded constants, and are implemented up to n=12. func GaussLegendre(degree int) *GaussLegendreRule { if degree > len(weightValues) || degree < 1 { return &GaussLegendreRule{} } weights := weightV...
numint/gauss_legendre.go
0.834879
0.599602
gauss_legendre.go
starcoder
package geom import ( "fmt" "math" "github.com/peterstace/simplefeatures/rtree" ) // line represents a line segment between two XY locations. It's an invariant // that a and b are distinct XY values. Do not create a line that has the same // a and b value. type line struct { a, b XY } // uncheckedEnvelope direc...
geom/line.go
0.77907
0.502625
line.go
starcoder
package jsoncs import ( "bytes" ) // Valid reports whether the JSON input is in canonical form. // Invalid JSON input is reported as false. func Valid(b []byte) bool { b, ok := validValue(b) return ok && len(b) == 0 } // validValue reports whether the next JSON value is in its canonical form. // It consume the l...
jsoncs/valid.go
0.725454
0.422624
valid.go
starcoder
// Package changepoint implements algorithms for changepoint detection. package changepoint import "math" // Calculates the cost of the (tau1; tau2] segment. // Remember that tau are one-based indexes. type costFunc func(tau1 int, tau2 int) float64 func pelt(data []float64, minSegment int, cost costFunc, penalty fl...
changepoint.go
0.84124
0.77949
changepoint.go
starcoder
package graph import "fmt" type Node interface { ID() int Edges() []Edge Degree() int Neighbors(EdgeFilter) []Node Hops(EdgeFilter) []*Hop add(Edge) drop(Edge) dropAll() index() int setIndex(int) setID(int) } var _ Node = (*node)(nil) // NodeFilter is a function type used for assessment of nodes during...
node.go
0.694303
0.443359
node.go
starcoder
// Package grafestes contains the consonant vowel names and timing information for the sound sequences used for the // research reported in "Listening Through Voices: Infant Statistical Word Segmentation Across Multiple Speakers", // <NAME> & Lew-Williams, 2015. // The sounds are spoken consonant-vowels that were spli...
speech/grafestes/grafestes.go
0.688783
0.473596
grafestes.go
starcoder
package hangul // Check Given rune is Lead consonant func IsLead(r rune) bool { if LEAD_G <= r && r <= LEAD_H { return true } return false } // Check Given rune is Medial vowel func IsMedial(r rune) bool { if MEDIAL_A <= r && r <= MEDIAL_I { return true } return false } // Check Given rune is Tail consona...
jamo.go
0.613584
0.477311
jamo.go
starcoder
package rewrite import ( "github.com/jonlawlor/matrixexp" ) // AnyExp represents any matrix expression. It is intended for use with the // Template rewriter. It implements matrix algebra but if it is ever used for // calculations it will cause a runtime panic. // Note that this is an int so that it actually takes...
rewrite/expmatch.go
0.893733
0.549761
expmatch.go
starcoder
// SparseMax implementation based on https://github.com/gokceneraslan/SparseMax.torch package fn import ( "github.com/nlpodyssey/spago/pkg/mat" "github.com/nlpodyssey/spago/pkg/mat/f64utils" "math" "sort" ) type SparseMax struct { x Operand y mat.Matrix // initialized during the forward pass, required by the b...
pkg/ml/ag/fn/sparsemax.go
0.754734
0.486758
sparsemax.go
starcoder
package discovery import "fmt" type Switch struct { // A list of MQTT topics subscribed to receive availability (online/offline) updates. Must not be used together with `availability_topic` // Default: <no value> Availability []Availability `json:"availability,omitempty"` // When `availability` is configured, t...
switch.go
0.834272
0.417034
switch.go
starcoder
package types import "sync" type TSafeUints interface { // Reset the slice. Reset() // Contains say if "s" contains "values". Contains(...uint) bool // ContainsOneOf says if "s" contains one of the "values". ContainsOneOf(...uint) bool // Copy create a new copy of the slice. Copy() TSafeUints // Diff ret...
syncuints.go
0.709321
0.484807
syncuints.go
starcoder
package fonet import ( "bytes" "encoding/json" "errors" "io" "log" "math/rand" "time" ) func init() { rand.Seed(time.Now().UnixNano()) } var ( // ErrNotEnoughLayers is returned when trying to create a new network with too few layers. ErrNotEnoughLayers = errors.New("too few layers, minimum of 3 required") ...
network.go
0.61115
0.458652
network.go
starcoder
package table import ( "reflect" "github.com/onsi/ginkgo" ) /* TableEntry represents an entry in a table test. You generally use the `Entry` constructor. */ type TableEntry struct { Description string Parameters []interface{} Pending bool Focused bool } func (t TableEntry) generateIt(itBody reflect....
extensions/table/table_entry.go
0.672547
0.433622
table_entry.go
starcoder
package main import ( "bytes" "encoding/json" "math" "strings" "github.com/maruel/subcommands" ) var cmdEditDistance = &subcommands.Command{ UsageLine: `edit-distance [options]`, ShortDesc: `Computes the edit distance of two strings.`, LongDesc: `Computes the edit distance of two strings using insertion, de...
dm/tools/jobsim_client/edit_distance.go
0.733833
0.437643
edit_distance.go
starcoder
package golf // LoadMap loads the sprite sheet into memory func (e *Engine) LoadMap(mapData [0x4800]byte) { for i, b := range mapData { e.RAM[mapBase-i] = b } } // Map draws the map on the screen starting from tile // mx, my with a size of mw and mh. The map is draw // at screen coordinate dx, dy func (e *Engine)...
golf/golfMap.go
0.726717
0.553807
golfMap.go
starcoder
package observability import ( "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" ) // Pool metrics: // 1. Connections taken // 2. Connections closed // 3. Connections usetime -- how long is a connection used until it is closed, discarded or returned // 4. Connections reused // 4. Connec...
internal/observability/observability.go
0.524395
0.531878
observability.go
starcoder
package tdigest import ( "math" "sort" ) var ( nan = math.NaN() positiveInfinity = math.Inf(1) negativeInfinity = math.Inf(-1) sentinelCentroid = Centroid{Mean: positiveInfinity, Weight: 0.0} ) type centroidsByMeanAsc []Centroid func (c centroidsByMeanAsc) Len() int { return len(c) } f...
src/aggregator/aggregation/quantile/tdigest/tdigest.go
0.631481
0.468851
tdigest.go
starcoder
package gt import ( "database/sql/driver" "encoding/json" "strconv" ) /* Shortcut: parses successfully or panics. Should be used only in root scope. When error handling is relevant, use `.Parse`. */ func ParseNullInt(src string) (val NullInt) { try(val.Parse(src)) return } /* Variant of `int64` where zero value...
gt_null_int.go
0.735167
0.636042
gt_null_int.go
starcoder
package day_08 const input = ` rect 1x1 rotate row y=0 by 10 rect 1x1 rotate row y=0 by 10 rect 1x1 rotate row y=0 by 5 rect 1x1 rotate row y=0 by 3 rect 2x1 rotate row y=0 by 4 rect 1x1 rotate row y=0 by 3 rect 1x1 rotate row y=0 by 2 rect 1x1 rotate row y=0 by 3 rect 2x1 rotate row y=0 by 2 rect 1x1 rotate row y=0 b...
adventofcode_2016/day_08/input.go
0.692226
0.78535
input.go
starcoder
package container import ( "github.com/nwillc/genfuncs" ) // Heap implements Queue. var _ Queue[int] = (*Heap[int])(nil) // Heap implements an ordered heap of any type which can be min heap or max heap depending on the compare provided. // Heap implements Queue. type Heap[T any] struct { slice GSlice[T] compare...
container/heap.go
0.799364
0.491517
heap.go
starcoder
package chargingstrategy import ( "math" "github.com/Telenav/osrm-backend/integration/util" ) type simpleChargeStrategy struct { maxEnergyLevel float64 sixtyPercentOFMaxEnergy float64 eightyPercentOfMaxEnergy float64 costFrom60PercentTo80Percent float64 costFrom60PercentTo100Percent...
integration/service/oasis/graph/chargingstrategy/simple_charge_strategy.go
0.722037
0.565119
simple_charge_strategy.go
starcoder
package key import ( "bytes" "encoding/base64" "encoding/binary" "errors" "math" "time" "github.com/genjidb/genji/document" ) const base64encoder = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" var base64Encoding = base64.NewEncoding(base64encoder).WithPadding(base64.NoPadding) const ar...
key/encoding.go
0.689201
0.424651
encoding.go
starcoder