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 geom import ( "github.com/water-vapor/euclidea-solver/configs" "github.com/water-vapor/euclidea-solver/pkg/hashset" "math" "math/rand" ) // Segment is uniquely determined by its sorted endpoints type Segment struct { hashset.Serializable point1, point2 *Point } // NewSegment creates a segment from two ...
pkg/geom/segment.go
0.845209
0.461017
segment.go
starcoder
package aabb import ( "reflect" ) type Tree struct { Root *treeNode NodeIndexMap map[AABB]*treeNode } func NewTree() *Tree { return &Tree{ NodeIndexMap: make(map[AABB]*treeNode), } } func (tree *Tree) IsEmpty() bool { return tree.Root == nil } func (tree *Tree) Depth() int { stack := newTreeNodeSt...
resolv/aabb/tree.go
0.698329
0.434581
tree.go
starcoder
package iso20022 // Description of the financial instrument. type FinancialInstrumentAttributes68 struct { // Identifies the financial instrument. SecurityIdentification *SecurityIdentification19 `xml:"SctyId"` // Quantity of entitled intermediate securities based on the balance of underlying securities. Quantit...
data/train/go/cf69142594cacb429dddb669bd9a425dcfd7951eFinancialInstrumentAttributes68.go
0.848282
0.425128
cf69142594cacb429dddb669bd9a425dcfd7951eFinancialInstrumentAttributes68.go
starcoder
package nn import ( "image" "image/png" "io" "math" "gonum.org/v1/gonum/mat" "gonum.org/v1/gonum/stat/distuv" ) func sigmoid(r, c int, x float64) float64 { return 1.0 / (1 + math.Exp(-1*x)) } func sigmoidDx(x float64) float64 { return x * (1 - x) } func sigmoidPrime(m mat.Matrix) mat.Matrix { rows, _ := m...
src/nn/utils.go
0.765681
0.456834
utils.go
starcoder
package square type Location struct { // The Square-issued ID of the location. Id string `json:"id,omitempty"` // The name of the location. This information appears in the dashboard as the nickname. Name string `json:"name,omitempty"` Address *Address `json:"address,omitempty"` // The [IANA Timezone](https://www...
square/model_location.go
0.749637
0.470858
model_location.go
starcoder
// Package measurement export utility functions to manipulate/format performance profile sample values. package measurement import ( "fmt" "strings" "time" "github.com/google/pprof/profile" ) // ScaleProfiles updates the units in a set of profiles to make them // compatible. It scales the profiles to the smalle...
internal/measurement/measurement.go
0.852429
0.624637
measurement.go
starcoder
// Package chunks provides facilities for representing, storing, and fetching content-addressed chunks of Noms data. package chunks import ( "bytes" "github.com/liquidata-inc/dolt/go/store/d" "github.com/liquidata-inc/dolt/go/store/hash" ) // Chunk is a unit of stored data in noms type Chunk struct { r hash....
go/store/chunks/chunk.go
0.787972
0.475118
chunk.go
starcoder
package Problem0385 import ( "strconv" "github.com/aQuaYi/LeetCode-in-Go/kit" ) /** * // This is the interface that allows for creating nested lists. * // You should not implement it, or speculate about its implementation * type NestedInteger struct { * } * * // Return true if this NestedInteger holds a singl...
Algorithms/0385.mini-parser/mini-parser.go
0.704262
0.467757
mini-parser.go
starcoder
package sketchy import ( "fmt" "github.com/tdewolff/canvas" "log" "math" ) // Primitive types // Point is a simple point in 2D space type Point struct { X float64 Y float64 } // Line is two points that form a line type Line struct { P Point Q Point } // Curve A curve is a list of points, may be closed type...
geometry.go
0.795499
0.53206
geometry.go
starcoder
package oddsengine import ( "math" "strconv" "strings" ) // Summary is a type which represents the an averaged results of multiple // conflicts. type Summary struct { // TotalSimulations The number of simulations that have been ran TotalSimulations int `json:"totalSimulations"` // AverageRounds The number of r...
summary.go
0.859472
0.578686
summary.go
starcoder
package model // Legend is the option set for a legend component. // Legend component shows symbol, color and name of different series. You can click legends to toggle displaying series in the chart. // https://echarts.apache.org/en/option.html#legend type Legend struct { // Component ID, not specified by default. If...
model/legend.go
0.870294
0.561575
legend.go
starcoder
package selector import ( "fmt" ipld "github.com/ipfs/fs-repo-migrations/ipfs-10-to-11/_vendor/github.com/ipld/go-ipld-prime" ) // Selector is the programmatic representation of an IPLD Selector Node // and can be applied to traverse a given IPLD DAG type Selector interface { Interests() []ipld.PathSegment ...
ipfs-10-to-11/_vendor/github.com/ipld/go-ipld-prime/traversal/selector/selector.go
0.709422
0.57827
selector.go
starcoder
package cryptoapis import ( "encoding/json" ) // ListUnspentTransactionOutputsByAddressRIBlockchainSpecificVShieldedSpend struct for ListUnspentTransactionOutputsByAddressRIBlockchainSpecificVShieldedSpend type ListUnspentTransactionOutputsByAddressRIBlockchainSpecificVShieldedSpend struct { // Defines a Merkle tr...
model_list_unspent_transaction_outputs_by_address_ri_blockchain_specific_v_shielded_spend.go
0.862207
0.432543
model_list_unspent_transaction_outputs_by_address_ri_blockchain_specific_v_shielded_spend.go
starcoder
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Internally a map holds elements in up to 255 bytes of key+value. // When key or value or both are too large, it uses pointers to key+value // instead. Test...
test/bigmap.go
0.596433
0.504394
bigmap.go
starcoder
package storage import ( "fmt" "github.com/tendermint/iavl" dbm "github.com/tendermint/tm-db" "github.com/xlab/treeprint" ) // RWTree provides an abstraction over IAVL that maintains separate read and write paths. Reads are routed to the most // recently saved version of the tree - which provides immutable acce...
storage/rwtree.go
0.724578
0.466481
rwtree.go
starcoder
package slice import ( "fmt" "math" "math/rand" ) // IndexOfUInt64 gets the index of an uint64 element in an uint64 slice func IndexOfUInt64(x []uint64, y uint64) int { for i, v := range x { if v == y { return i } } return -1 } // ContainsUInt64 checks whether an uint64 element is in an uint64 slice fun...
slice/uint64.go
0.727879
0.589982
uint64.go
starcoder
package trueskill import ( "math" "github.com/bigflood/go-trueskill/gaussian" ) type TrueSkill struct { Mu float64 // mean of ratings Sigma float64 // standard deviation of ratings Beta float64 Tau float64 // dynamic factor DrawProbability float64 } func (ts *True...
trueskill.go
0.80147
0.57332
trueskill.go
starcoder
package lo // T2 creates a tuple from a list of values. func T2[A any, B any](a A, b B) Tuple2[A, B] { return Tuple2[A, B]{A: a, B: b} } // T3 creates a tuple from a list of values. func T3[A any, B any, C any](a A, b B, c C) Tuple3[A, B, C] { return Tuple3[A, B, C]{A: a, B: b, C: c} } // T4 creates a tuple from a...
vendor/github.com/samber/lo/tuples.go
0.869715
0.846514
tuples.go
starcoder
package sections import ( "github.com/edanko/dxf-go/core" ) const absRotationBit = 0x1 const textStringBit = 0x2 const elementShapeBit = 0x4 // LineElement represents a single element in a LineType. type LineElement struct { Length float64 AbsoluteRotation bool IsTextString bool IsShape b...
sections/linetype.go
0.727395
0.514034
linetype.go
starcoder
package seeder import ( "github.com/golang/glog" "reflect" ) func MergeStructFields(dst, src interface{}) { in := reflect.ValueOf(src) out := reflect.ValueOf(dst) if src == nil || dst == nil { return } if in.Kind() == reflect.Ptr { in = in.Elem() } if out.Kind() == reflect.Ptr { out = out.Elem() } i...
openstack-seeder/pkg/seeder/utils.go
0.521471
0.443962
utils.go
starcoder
package client // JobSpec describes how the job execution will look like. type V1JobSpec struct { // Specifies the duration in seconds relative to the startTime that the job may be active before the system tries to terminate it; value must be positive integer ActiveDeadlineSeconds int64 `json:"activeDeadlineSeconds...
vendor/github.com/kubernetes-client/go/kubernetes/client/v1_job_spec.go
0.794505
0.47524
v1_job_spec.go
starcoder
package eaopt import ( "errors" "fmt" "math/rand" ) // A Speciator partitions a population into n smaller subpopulations. Each // subpopulation shares the same random number generator inherited from the // initial population. type Speciator interface { Apply(indis Individuals, rng *rand.Rand, populationIndex int)...
speciation.go
0.663669
0.504089
speciation.go
starcoder
package brotli /* Copyright 2013 Google Inc. All Rights Reserved. Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Computes the bit cost reduction by combining out[idx1] and out[idx2] and if it is below a threshold, stores the pair (idx1, idx2) ...
vendor/github.com/andybalholm/brotli/cluster_command.go
0.605333
0.447098
cluster_command.go
starcoder
package d2 import "fmt" // Rectangler is the interface implemented by objects that can return a // rectangular representation of themselves in 2D space. type Rectangler interface { Rectangle() Rectangle } // A Rectangle is defined by 2 points, Min and Max, represented by 2 Vec2. type Rectangle struct { Min, Max Ve...
f32/d2/rect.go
0.909068
0.668899
rect.go
starcoder
package main import ( "fmt" ) // Limit represents all integers which are greater than this limit can be // written as the sum of two abundant numbers. const Limit = 28123 // GetProperDivisors gets all non-negative divisors of n, not inlcluding itself. func GetProperDivisors(n int) []int { divisors := []int{1} lim...
p023/main.go
0.689096
0.422624
main.go
starcoder
package opt import ( "math" "github.com/cpmech/gosl/fun" "github.com/cpmech/gosl/io" "github.com/cpmech/gosl/la" "github.com/cpmech/gosl/plt" "github.com/cpmech/gosl/utl" ) // History holds history of optmization using directiors; e.g. for Debugging type History struct { // data Ndim int // dimens...
opt/history.go
0.579162
0.492066
history.go
starcoder
package models import ( "fmt" "github.com/ThinkiumGroup/go-common" "github.com/ThinkiumGroup/go-common/trie" ) type ( // The shard chain is used to send to other shards the AccountDelta list processed by this // shard should fall on the other shard. Including block header and the proof ShardDeltaMessage struc...
models/dataevents.go
0.578448
0.592313
dataevents.go
starcoder
package eql import "fmt" func mathAdd(left, right operand) (interface{}, error) { switch v := left.(type) { case int: switch rv := right.(type) { case int: return v + rv, nil case float64: return float64(v) + rv, nil default: return 0, fmt.Errorf( "math: +, incompatible type to add both operan...
x-pack/elastic-agent/pkg/eql/math.go
0.68215
0.54583
math.go
starcoder
package common import ( "encoding/binary" "errors" ) var ErrIrregularData = errors.New("irregular data") type ZeroCopySource struct { s []byte off uint64 // current reading index } // Len returns the number of bytes of the unread portion of the // slice. func (self *ZeroCopySource) Len() uint64 { length := u...
common/zero_copy_source.go
0.741019
0.405625
zero_copy_source.go
starcoder
package pg import ( "bytes" "database/sql/driver" "encoding/hex" "fmt" "strconv" "strings" ) type StringArray struct { Strings []string } // Scan implements the sql.Scanner interface. func (a *StringArray) Scan(src interface{}) error { switch src := src.(type) { case []byte: return a.scanBytes(src) case ...
string_array.go
0.544559
0.415907
string_array.go
starcoder
package network import ( "encoding/json" "fmt" "math" "os" "time" "github.com/gookit/color" "gopkg.in/cheggaaa/pb.v1" ) // Network contains the Layers, Weights, Biases of a neural network then the actual output values // and the learning rate. type Network struct { Layers []Matrix Weights []Matrix Biases ...
network/network.go
0.768993
0.526586
network.go
starcoder
package distance /* This module provides common distance functions for measuring distance between observations. Minkowski Distance is one the most inclusive among one as other distances are only a specific case of Minkowski Distance(Chebyshev Distance is not straightforward, though). when p=1 in MinkowskiDistance, i...
distance/distance.go
0.87079
0.874507
distance.go
starcoder
package linear import ( "time" ) // Units for Acceleration values. Always multiply with a unit when setting the initial value like you would for // time.Time. This prevents you from having to worry about the internal storage format. const ( NanometerPerSecondSquared Acceleration = Acceleration(NanometerPerSecond)...
linear/acceleration_generated.go
0.947039
0.698895
acceleration_generated.go
starcoder
package tree import ( "github.com/lasthyphen/dijetsnetgo1.2/ids" "github.com/lasthyphen/dijetsnetgo1.2/snow/consensus/snowman" ) type Tree interface { // Add places the block in the tree Add(snowman.Block) // Get returns the block that was added to this tree whose parent and ID // match the provided block. If...
vms/proposervm/tree/tree.go
0.610337
0.426441
tree.go
starcoder
package raycaster import ( "github.com/mattkimber/gorender/internal/geometry" "github.com/mattkimber/gorender/internal/manifest" "github.com/mattkimber/gorender/internal/sampler" "github.com/mattkimber/gorender/internal/voxelobject" "sync" ) type RenderInfo []RenderSample type RenderSample struct { Collision ...
internal/raycaster/raycaster.go
0.738575
0.425247
raycaster.go
starcoder
package iso20022 // Specifies prices related to a corporate action option. type CorporateActionPrice19 struct { // Indicates whether the price is an indicative price or a market price. IndicativeOrMarketPrice *IndicativeOrMarketPrice2Choice `xml:"IndctvOrMktPric,omitempty"` // 1. Price at which security will be p...
CorporateActionPrice19.go
0.838283
0.499878
CorporateActionPrice19.go
starcoder
package isometric import ( "image" "image/color" "math" "github.com/weqqr/panorama/game" "github.com/weqqr/panorama/lm" "github.com/weqqr/panorama/mesh" "github.com/weqqr/panorama/raster" "github.com/weqqr/panorama/world" ) const Gamma = 2.2 const BaseResolution = 16 var ( YOffsetCoef = int(math.Round(...
render/isometric/rasterizer.go
0.710226
0.471223
rasterizer.go
starcoder
type LinkedList struct { val int next *LinkedList } /** Initialize your data structure here. */ func Constructor() LinkedList { return LinkedList{} } func (l *LinkedList) GetNode(index int) *LinkedList { node := l for i := 0; i < index; i++ { if node == nil { return nil ...
algorithms/go/linked_list.go
0.813461
0.461259
linked_list.go
starcoder
package structs type PacketHeader struct { M_packetFormat uint16 // 2018 M_packetVersion uint8 // Version of this packet type, all start from 1 M_packetId uint8 // Identifier for the packet type, see below M_sessionUID uint64 // Unique identifier for the session M_sessionTime float32 //...
structs/structs.go
0.512449
0.582313
structs.go
starcoder
package ann import ( "math/rand" ) type Matrix [][]float64 func (m Matrix) Rows() int { return len(m) } func (m Matrix) Cols() int { return len(m[0]) } // Add each each element in `a` to `m` func (m Matrix) Add(a Matrix) Matrix { if m.Rows() != a.Rows() || m.Cols() != a.Cols() { panic("Can't add 2 different ...
ann/matrix.go
0.843219
0.560493
matrix.go
starcoder
package nl import "github.com/MaxSlyugrov/cldr" var calendar = cldr.Calendar{ Formats: cldr.CalendarFormats{ Date: cldr.CalendarDateFormat{Full: "EEEE d MMMM y", Long: "d MMMM y", Medium: "d MMM y", Short: "dd-MM-yy"}, Time: cldr.CalendarDateFormat{Full: "HH:mm:ss zzzz", Long: "HH:mm:ss z", Medium: "HH:m...
resources/locales/nl/calendar.go
0.507568
0.453746
calendar.go
starcoder
package tree import ( "strconv" "strings" ) // Tree is a binary tree type Tree struct { Left *Tree Value int Right *Tree } const terminationSymbol = "#" // NewFromPreOrderSeq creates a new binary tree from a pre-ordered sequence of values. The terminations // are marked with character func NewFromPreOrderedSe...
tree/tree.go
0.714329
0.475118
tree.go
starcoder
package circuit import ( "crypto/aes" "crypto/cipher" "crypto/rand" "fmt" "github.com/markkurossi/mpc/ot" ) var ( verbose = false ) func idxUnary(l0 ot.Label) int { if l0.S() { return 1 } return 0 } func idx(l0, l1 ot.Label) int { var ret int if l0.S() { ret |= 0x2 } if l1.S() { ret |= 0x1 } ...
circuit/garble.go
0.644784
0.407451
garble.go
starcoder
package openflow import ( "fmt" "os/exec" "strings" "github.com/kelda/kelda/counter" "github.com/kelda/kelda/minion/ipdef" "github.com/kelda/kelda/minion/ovsdb" ) /* OpenFlow Psuedocode -- Please, for the love of God, keep this updated. OpenFlow is extremely difficult to reason about -- especially when its bu...
minion/network/openflow/openflow.go
0.5144
0.434161
openflow.go
starcoder
package pyfmt import ( "errors" "fmt" "strconv" "strings" "unicode/utf8" ) type flags struct { fillChar rune align int sign string showRadix bool minWidth string precision string renderVerb string percent bool empty bool } // Render is the renderer used to render dispatched for...
render.go
0.506347
0.418103
render.go
starcoder
package simulation import ( "fmt" "math/rand" "time" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp/helpers" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/simulation" hub "github.com/sentinel-official/hub/types" node "github.com/sentinel-official/hub/x...
x/plan/simulation/msgs.go
0.533641
0.410402
msgs.go
starcoder
package main //Find duplicates by checking if intersecting rect shares >DUPLICATE_AREA_THRESHOLD of area of the smaller of the two rects. //Passed in pointer to Destination slice is reassigned to new slice. //Run time O(n^2). n = number of Destinations func deleteDuplicatesFromDestinationArray(destsArrayPointer *[]Des...
consolidate.go
0.556159
0.436922
consolidate.go
starcoder
package siesta import ( "encoding/binary" ) // Decoder is able to decode a Kafka wire protocol message into actual data. type Decoder interface { // Gets an int8 from this decoder. Returns EOF if end of stream is reached. GetInt8() (int8, error) // Gets an int16 from this decoder. Returns EOF if end of stream is...
Godeps/_workspace/src/github.com/elodina/siesta/decoder.go
0.757346
0.4081
decoder.go
starcoder
package input import ( "github.com/gravestench/bitset" ) // NewInputVector creates a new input vector func NewInputVector() *Vector { v := &Vector{ KeyVector: bitset.NewBitSet(), ModifierVector: bitset.NewBitSet(), MouseButtonVector: bitset.NewBitSet(), } return v.Clear() } // Vector represents...
pkg/systems/input/input_vector.go
0.659295
0.555918
input_vector.go
starcoder
package module_page import ( "fmt" "os" "strings" "github.com/charmbracelet/lipgloss" "github.com/lucasb-eyer/go-colorful" "golang.org/x/term" ) const ( // In real life situations we'd adjust the document to fit the width we've // detected. In the case of this example we're hardcoding the width, and // late...
app/components/modules/module_page/module_page.go
0.550607
0.425068
module_page.go
starcoder
package exp import ( "xelf.org/xelf/ast" "xelf.org/xelf/bfr" "xelf.org/xelf/knd" "xelf.org/xelf/lit" "xelf.org/xelf/typ" ) // Exp is the common interface of all expressions with kind, type and source info. type Exp interface { Kind() knd.Kind Resl() typ.Type Source() ast.Src String() string Print(*bfr.P) er...
exp/exp.go
0.512205
0.410225
exp.go
starcoder
package io import ( "regexp" "strconv" "strings" ) const ( ValueRegex = `(\".+\"|-?\d+(\.\d+)?|-?\d+|(true|false)|(\[.*\]))` listRegex = `\[\s*(((\s*\".+\"\s*,\s*)*(\s*\".+\"\s*))|((\s*\d+\s*,\s*)*(\s*\d+\s*))|((\s*\d+(\.\d+)?\s*,\s*)*(\s*\d+(\.\d+)?\s*))|((\s*(true|false)\s*,\s*)*(\s*(true|false)\s*)...
src/ecs/io/valueParser.go
0.517083
0.408159
valueParser.go
starcoder
package main import ( "fmt" "math/rand" "sync/atomic" "time" ) // En este ejemplo nuestro estado le pertenecerá // a una sola gorutina. Esto garantiza que los // datos jamás se corromperán por el acceso // concurrente. Para poder leer o escribir a ese // estado, otras gorutinas tienen que enviar // m...
examples/gorutinas-con-estado/gorutinas-con-estado.go
0.519521
0.477493
gorutinas-con-estado.go
starcoder
package model /* The model type is the tip of the modelling pyramid and contains a set of subsidiary models - like one to model the skill hiearchy, another to model who holds which skill etc. The type provides methods for CRUD operations like adding a person or allocating a skill to a person. The model implements its ...
model/model.go
0.668772
0.529872
model.go
starcoder
package bvh import ( "container/heap" "fmt" "golang.org/x/exp/constraints" ) type Node[I constraints.Float, B interface { Union(B) B Surface() I }, V any] struct { box B Value V parent *Node[I, B, V] children [2]*Node[I, B, V] isLeaf bool } func (n *Node[I, B, V]) findAnotherChild(not *Node[I, ...
server/internal/bvh/bvh.go
0.513425
0.403156
bvh.go
starcoder
package rmsprop import ( "github.com/nlpodyssey/spago/gd" "github.com/nlpodyssey/spago/mat" "github.com/nlpodyssey/spago/nn" ) var _ gd.MethodConfig = &Config[float32]{} // Config provides configuration settings for an RMSProp optimizer. type Config[T mat.DType] struct { gd.MethodConfig LR T Epsilon T D...
gd/rmsprop/rmsprop.go
0.841435
0.425068
rmsprop.go
starcoder
package medium import ( "math" "unicode" ) // https://leetcode.com/problems/add-two-numbers/description/ // You are given two non-empty linked lists representing two non-negative integers. // The digits are stored in reverse order and each of their nodes contain a single digit. // Add the two numbers and return it ...
algorithms/medium/medium.go
0.808786
0.590632
medium.go
starcoder
package iso20022 // Set of elements used to provide information on the dates related to the underlying individual transaction. type TransactionDates2 struct { // Point in time when the payment order from the initiating party meets the processing conditions of the account servicing agent. This means that the account ...
TransactionDates2.go
0.806891
0.651895
TransactionDates2.go
starcoder
package lib import ( "fmt" "strconv" "strings" "github.com/dunelang/dune" ) func init() { dune.RegisterLib(Convert, ` declare namespace convert { export function toInt(v: string | number | runtime.FunctionInfo): number export function toFloat(v: string | number): number export function toString(v: ...
lib/convert.go
0.615897
0.450359
convert.go
starcoder
package valgo type Int64Validator struct { *validatorContext } func IsInt64(value int64, nameAndTitle ...string) *Int64Validator { return NewValidator().IsInt64(value, nameAndTitle...) } func CheckInt64(value int64, nameAndTitle ...string) *Int64Validator { return NewValidator().CheckInt64(value, nameAndTitle...)...
int64_validator.go
0.721743
0.434461
int64_validator.go
starcoder
package brainfuck import "fmt" type Instruction struct { ptr int tokens []rune tape *Tape level int } func NewInstruction(tokens []rune, tape *Tape) *Instruction { return &Instruction{ptr: -1, tokens: tokens, tape: tape, level: 0} } // Fetch increase moves the pointer to the next tokens. // Returns wheth...
brainfuck/instruction.go
0.602529
0.407599
instruction.go
starcoder
package reporting import ( "fmt" "strconv" "time" ) // HoursWorkedThisWeek returns the total hours documented per day since Sunday // (ie work week starts Monday at 00:01) func HoursWorkedThisWeek(filename, user string) float64 { data := getTrackedData(filename)[user] now := time.Now() return sumThisWeek(data,...
pkg/reporting/simple.go
0.705886
0.413773
simple.go
starcoder
package sampler import ( "fmt" "math/rand" "github.com/pkg/errors" ) // AliasSampler implements the Alias Method to sample from a discrete // probability distribution. Initialized with the Vose Method, the // sampler takes O(n) to initialize and O(1) to sample. type AliasSampler struct { ProbabilityTable []float...
sampler/alias.go
0.846419
0.523481
alias.go
starcoder
package config /** * Configuration for ACL entry resource. */ type Nsacl struct { /** * Name for the extended ACL rule. Must begin with an ASCII alphabetic or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), equals (=), and hyphen (-) ch...
resource/config/nsacl.go
0.803906
0.421373
nsacl.go
starcoder
// This file contains the code snippets included in "The Go image/draw package." package main import ( "image" "image/color" "image/draw" ) func main() { Color() Rect() RectAndScroll() ConvAndCircle() Glyph() } func Color() { c := color.RGBA{255, 0, 255, 255} r := image.Rect(0, 0, 640, 480) dst := image...
doc/progs/image_draw.go
0.657209
0.421254
image_draw.go
starcoder
package h3go import "math" // BBox is geographic bounding box with coordinates defined in radians type BBox struct { north float64 // north latitude south float64 // south latitude east float64 // east longitude west float64 // west longitude } // bboxIsTransmeridian returns whether the given bounding box cro...
bbox.go
0.913409
0.579311
bbox.go
starcoder
package gobls import "bytes" // BufferScanner enumerates newline terminated strings from a provided slice of // bytes faster than bufio.Scanner and gobls.Scanner. This is particular useful // when a program already has the entire buffer in a slice of bytes. This // structure uses newline as the line terminator, but r...
bufferScanner.go
0.839701
0.451568
bufferScanner.go
starcoder
package duration import ( "fmt" "math" "os" "sort" "github.com/kshedden/dstream/dstream" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/plotutil" "gonum.org/v1/plot/vg" ) // SurvfuncRight uses the method of Kaplan and Meier to estimate the // survival distribution based on (possibly) rig...
duration/survfunc.go
0.667906
0.537102
survfunc.go
starcoder
package export import ( "github.com/opendroid/hk/logger" "go.uber.org/zap" "sort" "strconv" ) // BodyMassElement elements in various types of body-mass data type BodyMassElement struct { CreationDate int64 `json:"creation_timestamp_sec"` SourceName string `json:"source"` Unit string `json:"unit,o...
export/bodymass.go
0.594434
0.451145
bodymass.go
starcoder
package haystack import ( "encoding/json" "errors" "fmt" "math" "strconv" "strings" ) // Number wraps a 64-bit floating point number and unit name. type Number struct { val float64 unit string } // NewNumber creates a new Number. For unitless numbers, use an empty string unit: "" func NewNumber(val float64,...
Number.go
0.705684
0.412294
Number.go
starcoder
package handy import ( "math/big" ) func intToBigint(i interface{}) *big.Int { bi := big.NewInt(0) switch x := i.(type) { case int: bi.SetInt64(int64(x)) case int8: bi.SetInt64(int64(x)) case int16: bi.SetInt64(int64(x)) case int32: bi.SetInt64(int64(x)) case int64: bi.SetInt64(x) case uint: bi....
inarray.go
0.503174
0.512327
inarray.go
starcoder
package stats import ( "sync" "time" ) // TimeBucketCounter is a counter that records the approximate number of events over a // recent interval; the length of this interval and the resolution are configurable. Used // to measure the approximate processing rate for the digger. type TimeBucketCounter struct { sync....
pkg/stats/bucket.go
0.681621
0.403508
bucket.go
starcoder
package builtin import ( "errors" "github.com/kode4food/ale/data" ) // Error messages const ( ErrIndexOutOfBounds = "index out of bounds" ErrPutRequiresPair = "put requires a key/value combination or a pair" ) // First returns the first value in the sequence var First = data.Applicative(func(args ...data.Value...
core/internal/builtin/sequences.go
0.776114
0.554229
sequences.go
starcoder
package linq import ( "reflect" "strconv" "time" "github.com/screeningeagledreamlab/go-util" ) // Predicate is a function that returns a boolean for an input. type Predicate func(item interface{}) bool // PredicateOfByte is a function that returns a boolean for an input. type PredicateOfByte func(item byte) boo...
linq/linq.go
0.854308
0.616965
linq.go
starcoder
package botutil import ( "github.com/chippydip/go-sc2ai/api" "github.com/chippydip/go-sc2ai/enums/ability" "github.com/chippydip/go-sc2ai/enums/buff" "github.com/chippydip/go-sc2ai/enums/unit" ) // Unit combines the api Unit with it's UnitTypeData and adds some additional convenience methods. type Unit struct { ...
botutil/unit.go
0.79049
0.433921
unit.go
starcoder
package test import ( "fmt" "strings" ) type test interface { Helper() Error(...interface{}) } // Wrapper around testing.T. type Assertion struct { t test } // Constructs and returns the wrapper. func NewAssertion(t test) *Assertion { if t == nil { panic("nil test") } return &Assertion{t} } func buildMe...
test/assertions.go
0.809012
0.660966
assertions.go
starcoder
package compact import ( "github.com/dnovikoff/tempai-core/tile" ) type Mask uint const ( FullMask = 15 ) func MaskByCount(c int) uint { return FullMask >> uint(4-c) } func NewMask(mask uint, t tile.Tile) Mask { m := Mask(shift(t)) << 4 return m | Mask(mask&15) } func (m Mask) Tile() tile.Tile { return tile...
compact/mask.go
0.582135
0.55429
mask.go
starcoder
package metrics_metadata // The metadata for a single retrieved metric timeseries type MetricTimeSeries struct { // Name of the MTS. Metric names are UTF-8 strings with a maximum length of 256 characters (1024 bytes). Metric string `json:"metric,omitempty"` // Metric type of the MTS for this metadata. The possible ...
metrics_metadata/model_metric_time_series.go
0.861422
0.494812
model_metric_time_series.go
starcoder
package blockchain import ( "math" "github.com/incognitochain/incognito-chain/common" ) // BuildKeccak256MerkleTree creates a merkle tree using Keccak256 hash func. // This merkle tree is used for storing all beacon (and bridge) data to relay them to Ethereum. func BuildKeccak256MerkleTree(data [][]byte) [][]byte ...
blockchain/keccak256_merkle.go
0.688364
0.474205
keccak256_merkle.go
starcoder
package generator // wxyzWing removes candidates. A group consists of one "pivot" cell and 3 "wing" cells. The pivot must be able to see all of the wing cells. The group includes 4 digits, exactly one of which must be "unrestricted". A digit is restricted if every occurrance of the digit in the group can see every oth...
generator/wxyzWing.go
0.667364
0.552962
wxyzWing.go
starcoder
package quantile import ( "bytes" "fmt" "sort" ) // SliceSummary is a GK-summary with a slice backend type SliceSummary struct { Entries []Entry N int } // NewSliceSummary allocates a new GK summary backed by a DLL func NewSliceSummary() *SliceSummary { return &SliceSummary{} } func (s SliceSummary) Str...
quantile/slice_summary.go
0.687945
0.408159
slice_summary.go
starcoder
package assert import ( "bytes" "fmt" "reflect" "runtime" "strings" "testing" ) var ( equals = make(map[reflect.Type]*Matcher) less = make(map[reflect.Type]*Matcher) greater = make(map[reflect.Type]*Matcher) ) type Matcher struct { method reflect.Value verb string } func zeroValueOrReal(v interface...
assert/assert.go
0.633183
0.532729
assert.go
starcoder
package main /* https://leetcode.com/problems/flipping-an-image/, accessed 31 March 2019 Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed. For example, flipping [1, 1, 0...
0832_FlippingAnImage/main.go
0.739234
0.530419
main.go
starcoder
package tile3d func calcPadding(offset, paddingUnit uint32) uint32 { padding := offset % paddingUnit if padding != 0 { padding = paddingUnit - padding } return padding } func paddingBytes(bytes []byte, srcLen int, paddingUnit uint32, paddingCode byte) { padding := calcPadding(uint32(srcLen), paddingUnit) for...
utils.go
0.637482
0.453564
utils.go
starcoder
package operators import ( "context" "github.com/b97tsk/rx" ) // DoAfter mirrors the source, but performs a side effect after each emission. func DoAfter(tap rx.Observer) rx.Operator { return func(source rx.Observable) rx.Observable { return func(ctx context.Context, sink rx.Observer) { source.Subscribe(ctx,...
operators/doAfter.go
0.780997
0.418637
doAfter.go
starcoder
package cspacegen import ( "errors" "fmt" "math/rand" ) // Indexes of coordinates. const ( X = 0 // x coordinate Y = 1 // y coordinate Z = 2 // z coordinate ) // Default vales of parameters. const ( DefaultSize = 10 // size MaxFullness = 9 // maximum of fullness ) const ( insideOffset = 0.33 ) // Point3D...
generator/cspacegen/cspacegen.go
0.745306
0.642292
cspacegen.go
starcoder
package machine_learning //---------------------------------------------------------------------------------------------------------------------- func PrecisionRecallF1(prediction []int, classes []int, num_classes int) (float64, float64, float64){ if len(prediction) != len(classes) { panic("prediction and...
machine_learning/classification_metrics.go
0.663996
0.476823
classification_metrics.go
starcoder
package geom import ( "math" "math/rand" ) type Bounds struct { Min, Max Vec Center Vec Radius float64 MinArray, MaxArray [3]float64 } func NewBounds(min, max Vec) *Bounds { center := min.Plus(max).Scaled(0.5) return &Bounds{ Min: min, Max: max, Center: cen...
pkg/geom/bounds.go
0.769946
0.448849
bounds.go
starcoder
package features import ( "fmt" "strconv" "strings" ) // Feature represents a feature of nats-operator. type Feature string // FeatureMap is a mapping between features of nats-operator and their current status. type FeatureMap map[Feature]bool const ( // ClusterScoped is used to indicate whether nats-operator ...
nats/nats-operator/pkg/features/features.go
0.726717
0.509947
features.go
starcoder
package dsl import ( "bytes" "regexp" "strings" ) // Scanner is a unified structure for scanner components which defines their port signature type Scanner struct { // Set is an IIP that contains valid characters. Supports special characters: \r, \n, \t. // A regular expression character class can be passed like:...
dsl/scanners.go
0.502441
0.410313
scanners.go
starcoder
package BinarySearchTrees import "fmt" type Node struct { left *Node right *Node val int } type BST struct { root *Node } func New() (BST) { return BST{ root: nil, } } func (t *BST) Add(key int) { fmt.Printf("Adding key: %d\n", key) t.root = t._addNode(key, t.root) } func (t BST) _addNode(key int, r...
internal/BinarySearchTrees/BinarySearchTree.go
0.530966
0.415136
BinarySearchTree.go
starcoder
package main import ( "fmt" ) // tag::metaverse[] // Game describes the state of one two-player game. type Game struct { Pos1, Pos2 int Score1, Score2 int } const ( diracSize = 3 winScoreDirac = 21 ) // Metaverse tracks how many universes there are for each game state. type Metaverse map[Game]int // ...
day21/go/razziel89/metaverse.go
0.544801
0.403156
metaverse.go
starcoder
package aoc2020 /* https://adventofcode.com/2020/day/15 --- Day 15: Rambunctious Recitation --- You catch the airport shuttle and try to book a new flight to your vacation island. Due to the storm, all direct flights have been cancelled, but a route is available to get around the storm. You take it. While you wait ...
app/aoc2020/aoc2020_15.go
0.722233
0.826011
aoc2020_15.go
starcoder
package rfm95 // https://www.hoperf.com/data/upload/portal/20190801/RFM96W-V2.0.pdf const ( // FXOSC is the radio's oscillator frequency in Hertz. FXOSC = 32000000 // SPIWriteMode is used to encode register addresses for SPI writes. SPIWriteMode = 1 << 7 ) // FIFO const ( RegFifo = 0x00 // FIFO read/write acce...
rfm95.go
0.547222
0.525734
rfm95.go
starcoder
package randx import ( "errors" "github.com/hsiafan/glow/v2/mathx/intx" "github.com/hsiafan/glow/v2/timex" "math" "math/rand" ) // Rand is a rand with more useful methods type Rand struct { rand.Rand } // New return a new Rand using timestamp as seed func New() *Rand { return NewWithSeed(timex.EpochMills()) }...
mathx/randx/rand.go
0.67822
0.410225
rand.go
starcoder
package assert import ( "fmt" "strings" ) // OnString is the result of calling ThatString on an Assertion. // It provides assertion tests that are specific to strings. type OnString struct { Assertion value string } // ThatString returns an OnString for string based assertions. // The untyped argument is conver...
core/assert/string.go
0.643665
0.434041
string.go
starcoder
package geometry import ( "github.com/dlespiau/dax" "github.com/dlespiau/dax/math" ) type Sphere struct { radius float32 nVSegments, nHSegments int phiStart, phiLength float32 thetaStart, thetaLength float32 } func NewSphere(radius float32, nVSegments, nHSegments int) *Sphere { s := new(...
geometry/sphere.go
0.696681
0.445107
sphere.go
starcoder
package utils import ( "image" ) // ExcessMode specifies how excess space is dealt with for tools that may // produce results with different dimensions to the input image. type ExcessMode int const ( // Ignore any "left over" space. So the resultant Rectangles may be smaller // than the original given. IGNORE Ex...
utils/image.go
0.786582
0.690781
image.go
starcoder
package hoi import ( "fmt" "github.com/mg/i" ) type zip struct { itrs []i.Forward err error atEnd bool } // The Zip iterator will zip together a collection of data streams, stopping // after the shortest data stream is finished. Given e.g. the data streams // [1,2,3], [5,6,7] and [10,11,12,13] Zip will prov...
hoi/zip.go
0.560253
0.405096
zip.go
starcoder
package gameoflife const ( CellStateDead = 0 CellStateNewCell = 1 CellStateAlive = 2 ) type CellState int func (state CellState) isAlive() bool { if state == CellStateNewCell || state == CellStateAlive { return true } return false } type Universe struct { Width, Height int Cells [][]CellState...
game-of-life/universe.go
0.631822
0.548432
universe.go
starcoder