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"
"image"
"image/color"
"github.com/split-cube-studios/ardent"
"github.com/split-cube-studios/ardent/engine"
)
const (
paddleWidth, paddleHeight, paddleOffset, velocity = 10, 50, 10, 4.0
)
var (
xv, yv, w, h = velocity, velocity, 600, 400
)
var (
game engine.Game
ball engin... | examples/pong/main.go | 0.626124 | 0.434581 | main.go | starcoder |
package validator
import (
"github.com/end-r/guardian/typing"
"github.com/end-r/guardian/ast"
)
func (v *Validator) validateStatement(node ast.Node) {
switch n := node.(type) {
case *ast.AssignmentStatementNode:
v.validateAssignment(n)
break
case *ast.ForStatementNode:
v.validateForStatement(n)
break
c... | validator/statements.go | 0.566978 | 0.415966 | statements.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// DomainDnsRecord
type DomainDnsRecord struct {
Entity
// If false, this record must be configured by the customer at the DNS host for Microsoft Online S... | models/domain_dns_record.go | 0.829216 | 0.436982 | domain_dns_record.go | starcoder |
package util
import (
"math"
)
// CalcPointsForArc takes an arc angle (less than or equal to Pi), and calculates the
// points for a Bezier cubic to describe it on a circle centered
// on (0,0) with radius 1. Mid-point of the curve is (1,0)
// Error increases for values > Pi/2
func CalcPointsForArc(theta float64) []... | util/curves.go | 0.842863 | 0.676473 | curves.go | starcoder |
package plaid
import (
"encoding/json"
)
// BankInitiatedReturnRisk The object contains a risk score and a risk tier that evaluate the transaction return risk because an account is overdrawn or because an ineligible account is used. Common return codes in this category include: \"R01\", \"R02\", \"R03\", \"R04\", \... | plaid/model_bank_initiated_return_risk.go | 0.765769 | 0.540863 | model_bank_initiated_return_risk.go | starcoder |
package ecmath
import (
"crypto/subtle"
"encoding/binary"
"encoding/hex"
"i10r.io/crypto/ed25519/internal/edwards25519"
)
// Scalar is a 256-bit little-endian scalar.
type Scalar [32]byte
var (
// Zero is the number 0.
Zero Scalar
// One is the number 1.
One = Scalar{1}
Cofactor = Scalar{8}
// NegOne i... | crypto/ed25519/ecmath/scalar.go | 0.709422 | 0.472623 | scalar.go | starcoder |
package cmd
import (
"fmt"
"os"
"github.com/jaredbancroft/aoc2020/pkg/helpers"
"github.com/spf13/cobra"
)
// day9Cmd represents the day9 command
var day9Cmd = &cobra.Command{
Use: "day9",
Short: "Advent of Code 2020 - Day9: Encoding Error",
Long: `
Advent of Code 2020
--- Day 9: Encoding Error ---
With... | cmd/day9.go | 0.624294 | 0.521898 | day9.go | starcoder |
package geo
import (
"bufio"
"bytes"
"fmt"
"io"
)
type Grid struct {
Data []byte
Width int
Height int
}
func NewGrid(width, height int) *Grid {
return &Grid{
Data: make([]byte, width*height),
Width: width,
Height: height,
}
}
func ReadGrid(r io.Reader) (*Grid, error) {
grid := &Grid{}
buf := ... | go/internal/geo/grid.go | 0.748076 | 0.478407 | grid.go | starcoder |
package indicators
import (
"errors"
"github.com/jaybutera/gotrade"
)
// An Exponential Moving Average Indicator (Ema), no storage, for use in other indicators
type EmaWithoutStorage struct {
*baseIndicatorWithFloatBounds
// private variables
periodTotal float64
periodCounter int
multiplier float64
prev... | indicators/ema.go | 0.760295 | 0.469399 | ema.go | starcoder |
package throttler
import (
"fmt"
"time"
)
// intervalHistory stores a value per interval over time.
// For example, thread_trottler.go stores the number of requests per 1 second
// interval in an intervalHistory instance.
// This data is used by the MaxReplicationLagModule to determine the historic
// average value... | go/vt/throttler/interval_history.go | 0.693369 | 0.545286 | interval_history.go | starcoder |
package vo2solve
import (
"math"
"math/cmplx"
)
import (
"github.com/tflovorn/cmatrix"
vec "github.com/tflovorn/scExplorer/vector"
)
// Calculate 4x4 electronic Hamiltonian.
// k is in the Cartesian basis, with each component scaled by the corresponding
// lattice constant; i.e. k = (a kx, a ky, c kz) and a kx, a... | vo2solve/elHamiltonian.go | 0.684159 | 0.508605 | elHamiltonian.go | starcoder |
package activation
import (
"github.com/TrizlyBear/PWS/math"
)
// Maximum pooling layer
type MaxPooling struct {
max [][][]struct{
y int
x int
}
}
func (e *MaxPooling) Forward(in [][][]float64) [][][]float64{
(*e).max = [][][]struct{
y int
x int
}{}
out := [][][]float64{}
for l,_ := range in {
lout... | sequential/activation/pooling.go | 0.648911 | 0.444083 | pooling.go | starcoder |
package unityai
const MAX_OUTPUT_VERTICES = 32
const PLANE_FLAG byte = 0x80
const PLANE_INDEX_MASK = PLANE_FLAG - 1
func DegenerateTriangle(tri Polygon) bool {
Assert(len(tri) == 3)
ab := tri[1].Sub(tri[0])
ac := tri[2].Sub(tri[0])
n := Cross(ab, ac)
areaSq := SqrMagnitude(n)
return areaSq == 0
}
func IsSafeC... | dynamic_mesh.cpp.go | 0.696681 | 0.559832 | dynamic_mesh.cpp.go | starcoder |
package jsonapisdk
import (
"github.com/kucjac/jsonapi"
"net/http"
)
type Endpoint struct {
// Type is the endpoint type
Type EndpointType
// PrecheckPairs are the pairs of jsonapi.Scope and jsonapi.Filter
// The scope deines the model from where the preset values should be taken
// The second defines the fil... | endpoint.go | 0.535584 | 0.40645 | endpoint.go | starcoder |
package convert
// SliceOfString converts the value into a slice of strings.
// It works with interface{}, []interface{}, []string, and string values.
// If the passed value cannot be converted, then an empty slice is returned.
func SliceOfString(value interface{}) []string {
switch value := value.(type) {
case st... | slice.go | 0.80479 | 0.613208 | slice.go | starcoder |
package twofive
import "github.com/francoispqt/gojay"
// Source describes the nature and behavior of the entity that is the source of the bid request
// upstream from the exchange. The primary purpose of this object is to define post-auction or upstream
// decisioning when the exchange itself does not control the fin... | go/request/rtb_twofive/source.go | 0.715921 | 0.438665 | source.go | starcoder |
package main
import (
"fmt"
//"github.com/hajimehoshi/ebiten/ebitenutil"
)
// MMU - Memory management unit. Exposes a read/write interface to some internal memory
type MMU struct {
internalRAM []uint8
cart *Cartridge
statMode uint8
}
// Returns an 8-bit value at the given address
func (mmu *MMU) ... | src/mmu.go | 0.654674 | 0.4133 | mmu.go | starcoder |
package advent
import "github.com/davidparks11/advent2021/internal/coordinate"
var _ Problem = &smokeBasin{}
type smokeBasin struct {
dailyProblem
}
func NewSmokeBasin() Problem {
return &smokeBasin{
dailyProblem{
day: 9,
},
}
}
func (s *smokeBasin) Solve() interface{} {
input := asciiNumGridToIntArray(... | internal/advent/day9.go | 0.729231 | 0.589716 | day9.go | starcoder |
package config
import (
"errors"
"io/ioutil"
"github.com/hashicorp/hcl"
"github.com/hashicorp/hcl/hcl/ast"
)
// ParseAssertionsSchema takes a target configuration and translates it into in-memory structures.
func ParseAssertionsSchema(data []byte) (*AssertionSpec, error) {
astRoot, err := hcl.ParseBytes(data)
... | src/machassert/config/assertions_parser.go | 0.532425 | 0.406067 | assertions_parser.go | starcoder |
package json
import "sort"
// Contains returns true if a contains b. This implements the @>, <@ operators.
// See the Postgres docs for the expected semantics of Contains.
// https://www.postgresql.org/docs/10/static/datatype-json.html#JSON-CONTAINMENT
// The naive approach to doing array containment would be to do ... | pkg/util/json/contains.go | 0.655336 | 0.61757 | contains.go | starcoder |
package goapi
import . `github.com/yak-labs/chirp-lang`
import (
bytes `bytes`
fmt `fmt`
reflect `reflect`
strconv `strconv`
strings `strings`
)
func init() {
Roots[`/bytes/Compare`] = FuncRoot{ Func: reflect.ValueOf(bytes.Compare) }
Roots[`/bytes/Contains`] = FuncRoot{ Func: reflect.ValueOf(bytes.Contains) }
... | goapi/tiny/wrap.go | 0.531453 | 0.617887 | wrap.go | starcoder |
// Package errors provides error types and function
package errors
var (
// ErrCreateProperty represents a function to generate an error that the property creation failed.
ErrCreateProperty = func(err error) error {
return Wrap(err, "failed to create property")
}
// ErrIndexNotFound represents an error that th... | internal/errors/ngt.go | 0.744192 | 0.45944 | ngt.go | starcoder |
package elements
import "github.com/fileformats/graphics/jt/model"
// Geometric Transform Attribute Element contains a 4x4 homogeneous transformation matrix that positions the associated
// LSG node’s coordinate system relative to its parent LSG node.
// JT format LSG traversal semantics state that geometric transfor... | jt/segments/elements/GeometricTransformAttribute.go | 0.710729 | 0.662339 | GeometricTransformAttribute.go | starcoder |
package matchers
import (
"reflect"
"testing"
)
type Expectation struct {
t *testing.T
actual interface{}
}
func (e *Expectation) ToEqual(expected interface{}) {
e.verifyExpectedNotNil(expected)
if !reflect.DeepEqual(e.actual, expected) {
e.t.Fatalf("Expected\n\t%v\nto equal\n\t%v\n", e.actual, expect... | internal/matchers/expectation.go | 0.581303 | 0.670949 | expectation.go | starcoder |
package solar
import (
"math"
"time"
c "github.com/rtovey/astro-lib/common"
o "github.com/rtovey/astro-lib/orbit"
)
const (
solarYearDurationDays = 365.242191
solarEclipticLongitudeAtEpoch = 279.403303
solarEclipticLongitudeOfPerigee = 282.768422
solarOrbitEccentricity = 0.016713
)
type... | solar/solarPosition.go | 0.804214 | 0.490053 | solarPosition.go | starcoder |
package cgp
import (
"math"
"math/rand"
"sync"
"time"
)
// A CGPFunction is a function that is usable in a Genetic Program. It takes
// zero or more parameters and outputs a single result. For example
// a CGPFunction could implement binary AND or floating point multiplication.
type CGPFunction func([]float64) fl... | cgp.go | 0.701713 | 0.642741 | cgp.go | starcoder |
package kernel
import (
"fmt"
"math"
)
const almostzero = .000001
type _NearestNeighbor struct{}
func (_NearestNeighbor) Do(x float64) float64 {
if -.5 < x && x <= .5 {
return 1
}
return 0
}
func (_NearestNeighbor) Rad() int {
return 0
}
func (_NearestNeighbor) String() string {
return "NearestNeighbor"
}
... | tools/kernel/inplements.go | 0.712632 | 0.468183 | inplements.go | starcoder |
package main
func main() {
}
type DataCollection struct {
data []byte
}
func NewDataCollection(data []byte) *DataCollection {
dc := new(DataCollection)
dc.data = data
return dc
}
// ValueAt returns the Nth item.
func (c *DataCollection) ValueAt(n int) bool {
byteIndex := n / 8
bitIndex := (uint)(n % 8)
mask... | cmd/prng-test/main.go | 0.68721 | 0.412589 | main.go | starcoder |
package plot
// Elements defines a list of elements.
type Elements []Element
// Add appends an element to the list.
func (els *Elements) Add(el Element) { *els = append(*els, el) }
// AddGroup appends elements as a single group to the list.
func (els *Elements) AddGroup(adds ...Element) { els.Add(Elements(adds)) }
... | elements.go | 0.906896 | 0.61757 | elements.go | starcoder |
package toms
import (
"github.com/dreading/gospecfunc/machine"
"github.com/dreading/gospecfunc/utils"
"math"
)
// SYNCH1 calculates the synchrotron radiation function
// x ∫ 0 to infinity { K(5/3)(t) } dt
// where K(5/3) is a modified Bessel function of order 5/3.
// The code uses Chebyshev expansions with the ... | integrals/internal/toms/synchrotron.go | 0.568775 | 0.429071 | synchrotron.go | starcoder |
package storetestcases
import (
"context"
"io/ioutil"
"log"
"sync/atomic"
"testing"
"github.com/stratumn/go-chainscript"
"github.com/stratumn/go-chainscript/chainscripttest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// TestGetSegment tests what happens when you get a segm... | store/storetestcases/getsegment.go | 0.51879 | 0.547162 | getsegment.go | starcoder |
package schnorr
import (
"math/big"
"github.com/emmyzkp/crypto/common"
)
// BlindedTrans represents a blinded transcript.
type BlindedTrans struct {
A *big.Int
B *big.Int
Hash *big.Int
ZAlpha *big.Int
}
func NewBlindedTrans(a, b, hash, zAlpha *big.Int) *BlindedTrans {
return &BlindedTrans{
A: ... | schnorr/dlog_equality_bt.go | 0.714329 | 0.455622 | dlog_equality_bt.go | starcoder |
package tag
import (
"fmt"
"github.com/square/metrics/api"
"github.com/square/metrics/function"
)
// dropTagSeries returns a copy of the timeseries where the given `dropTag` has been removed from its TagSet.
func dropTagSeries(series api.Timeseries, dropTag string) api.Timeseries {
tagSet := series.TagSet.Clone... | function/builtin/tag/tag.go | 0.837021 | 0.40439 | tag.go | starcoder |
package klog
import (
"cloud.google.com/go/civil"
"errors"
"fmt"
"regexp"
"strconv"
gotime "time"
)
// Time represents a wall clock time. It can be shifted to the adjacent dates.
type Time interface {
Hour() int
Minute() int
// MidnightOffset returns the duration since (positive) or until (negative) midnigh... | src/time.go | 0.70202 | 0.428174 | time.go | starcoder |
package steganography
import (
"bytes"
"errors"
"image/color"
"github.com/stegoer/server/pkg/util"
)
// ChannelType represents a pixel color channel.
type ChannelType byte
// PixelData represents data of one particular pixel of an image.
type PixelData struct {
Width int
Height int
Channels []ChannelTyp... | pkg/steganography/pixels.go | 0.868827 | 0.412471 | pixels.go | starcoder |
package local
import (
"github.com/ready-steady/adapt/algorithm"
"github.com/ready-steady/adapt/algorithm/internal"
"github.com/ready-steady/adapt/basis"
"github.com/ready-steady/adapt/grid"
)
// Algorithm is the interpolation algorithm.
type Algorithm struct {
ni uint
no uint
grid Grid
basis Basis
}
// Ba... | algorithm/local/main.go | 0.734691 | 0.405213 | main.go | starcoder |
Implements a basic perceptron neural network - Earliest network model proposed
by Rosenblatt in late 1950s.
*/
package algo
import (
"math"
"math/rand"
"time"
)
var EPSILON float64 = 0.00000001
//Soure :
//https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
func FloatEquals... | src/go/src/github.com/redsofa/perceptron/algo/algo.go | 0.716913 | 0.618982 | algo.go | starcoder |
package iota_mnemonic
import (
"fmt"
"github.com/iotaledger/giota"
"github.com/tyler-smith/go-bip39"
)
// Generates IOTA seed trits from a 64 bytes seed
// The algorithm was adapted from
// https://github.com/iota-trezor/trezor-mcu/blob/25292640b560a644ebf88d0dae848e8928e68127/firmware/iota.c#L70
// Absorb 4 time... | iota_mnemonic/iota_mnemonic.go | 0.720172 | 0.422028 | iota_mnemonic.go | starcoder |
package godash
import (
"math"
)
// Creates an array of elements splits into groups the length of size. If array
// can't be split evenly, the final chunk will be the remaining elements.
//go:generate make generate FILE=chunk FUNC=chunk TYPE=int,int8,int16,int32,int64,uint,uint8,uint16,uint32,uint64,string,float32,... | chunk.go | 0.532668 | 0.596316 | chunk.go | starcoder |
package list
// ToArray transforms a list into an array of values.
// It only handles non-cyclic lists. If a cycle is detected, it will panic.
func ToArray(l *Node) []int {
result := make([]int, 0)
seenNodes := make(map[*Node]bool)
for cursor := l; cursor != nil; cursor = cursor.Next {
if ok := seenNodes[cursor];... | data_structures/list/utils.go | 0.803675 | 0.458409 | utils.go | starcoder |
package collect
import (
"fmt"
)
type SliceCollection[T ~[]E, E any] struct {
z T
}
func UseSlice[T ~[]E, E any](items T) *SliceCollection[T, E] {
return &SliceCollection[T, E]{items}
}
func (s *SliceCollection[T, E]) All() T {
return s.z
}
func (s *SliceCollection[T, E]) New(items T) *SliceCollection[T, E] {
... | slice.go | 0.65368 | 0.505188 | slice.go | starcoder |
package lstm
import (
"github.com/gorgonia/parser"
G "gorgonia.org/gorgonia"
"gorgonia.org/tensor"
)
// Model holds the tensor of the model
type Model struct {
wi []float32
ui []float32
biasI []float32
wf []float32
uf []float32
biasF []float32
wo []float32
uo []float32
biasO []float32
... | model.go | 0.691602 | 0.608827 | model.go | starcoder |
package fsm // https://venilnoronha.io/a-simple-state-machine-framework-in-go
import (
"context"
"errors"
"sync"
)
// StateType represents an extensible state type in the state machine.
type StateType string
// EventType represents an extensible event type in the state machine.
type EventType string
// Action re... | fsm/fsm.go | 0.695752 | 0.668759 | fsm.go | starcoder |
package stats
import (
"fmt"
"math"
"github.com/jamestunnell/go-dsp/util/floatslice"
)
// CrossCorrelation determines the normalized cross-correlation of a feature with an image.
// Normalization is from -1 to +1, where +1 is high correlation, -1 is high
// correlation (of inverse), and 0 is no correlation.
// Fo... | stats/crosscorrelation.go | 0.773345 | 0.58951 | crosscorrelation.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_kde
#include <capi/kde.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type KdeOptionalParam struct {
AbsError float64
Algorithm string
Bandwidth float64
InitialSampleSize int
InputModel *kdeModel
... | kde.go | 0.76454 | 0.528716 | kde.go | starcoder |
package retry
import (
"math"
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
// BackoffStrategy is function that calculates for how long should delay be before
// sending next request.
type BackoffStrategy func(n int) time.Duration
// ConstantBackoff returns backoff that returns always sa... | middlewares/retry/backoff.go | 0.868172 | 0.460107 | backoff.go | starcoder |
package modules
import (
"fmt"
)
const (
// SixWordsPositionTopLeft is a SixWordsPosition of type TopLeft.
SixWordsPositionTopLeft SixWordsPosition = iota
// SixWordsPositionMiddleLeft is a SixWordsPosition of type MiddleLeft.
SixWordsPositionMiddleLeft
// SixWordsPositionBottomLeft is a SixWordsPosition of ty... | modules/six_words_enum.go | 0.615781 | 0.432303 | six_words_enum.go | starcoder |
package posev
import (
"github.com/mitsuse/matrix-go"
"github.com/mitsuse/matrix-go/dense"
//~ "log"
"math"
"math/rand"
)
// matrix.Matrix.Scalar() mutates the matrix, it is not always handy
func ScalarMult(m matrix.Matrix, s float64) matrix.Matrix {
r := dense.Zeros(m.Shape())
c := m.All()
for c.HasNext() {... | posev.go | 0.702326 | 0.496582 | posev.go | starcoder |
Package date provides time.Time derivatives that conform to the Swagger.io (https://swagger.io/)
defined date formats: Date and DateTime. Both types may, in most cases, be used in lieu of
time.Time types. And both convert to time.Time through a ToTime method.
*/
package date
import (
"fmt"
"time"
)
const (
fullD... | vendor/github.com/Azure/go-autorest/autorest/date/date.go | 0.868297 | 0.580471 | date.go | starcoder |
package evaluator
import (
"bytes"
"fmt"
"github.com/radlinskii/interpreter/ast"
"github.com/radlinskii/interpreter/object"
)
var (
// TRUE is a single object that all the appeareances of boolean nodes with value "true" will point to.
TRUE = &object.Boolean{Value: true}
// FALSE is a single object that all th... | evaluator/evaluator.go | 0.62498 | 0.463323 | evaluator.go | starcoder |
package generaltree
import (
"fmt"
"math"
"github.com/MehdiEidi/gods/queue/linkedqueue"
"github.com/MehdiEidi/gods/stack/linkedstack"
)
type GeneralTree[T any] struct {
Root *Node[T]
Size int
}
// New constructs and returns an empty general tree.
func New[T any]() *GeneralTree[T] {
return &GeneralTree[T]{}
}... | tree/generaltree/general_tree.go | 0.810516 | 0.557123 | general_tree.go | starcoder |
package fn
// Special math functions.
import (
"math"
)
const π = float64(math.Pi)
const ln2 = math.Ln2
const lnSqrt2π = 0.918938533204672741780329736406 // log(sqrt(2*pi))
const min64 = math.SmallestNonzeroFloat64 // DBL_MIN
const eps64 = 1.1102230246251565e-16 // DBL_EPSILON
const maxEx... | go/src/code.google.com/p/go-fn/fn/fn.go | 0.638835 | 0.488283 | fn.go | starcoder |
package main
const PB_FIELD_NOT_REPEATED = -1
type Protobuf Handle
func (Protobuf) ReadInt(field string, index int) int
func (Protobuf) ReadInt64(field string, value *[2]int, index int)
func (Protobuf) ReadFloat(field string, index int) float
func (Protobuf) ReadBool(field string, index int) bool
func (Protobuf) Rea... | sourcemod/protobuf.go | 0.855157 | 0.65972 | protobuf.go | starcoder |
package api
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderProcessPage() string {
figs := A{
"FigMkProc": RenderFigurePngSvg("Process elements execute OS processes on behalf of the user.", "mkproc", "600px"),
}
return RenderHtml("Using processes", Render(processBody, figs))
}
const... | gocircuit.org/api/process.go | 0.729809 | 0.476762 | process.go | starcoder |
package eedid
import (
"bytes"
"encoding/binary"
"fmt"
)
type DisplayID struct {
Version byte
VariableDataBlockLength byte
DisplayPrimaryUsecase DisplayPrimaryUsecase
NumberOfExtensions byte
DataBlocks []byte
DetailedTimingDataBlock DetailedTimingDataBlock
}
type DisplayP... | pkg/eedid/DisplayID.go | 0.567937 | 0.400398 | DisplayID.go | starcoder |
package mathg
import "math"
type Vec2 struct {
X float64
Y float64
}
func (v *Vec2) IsZero() bool {
return math.Abs(v.X) < epsilon && math.Abs(v.Y) < epsilon
}
func (v *Vec2) IsEqual(v2 *Vec2) bool {
return math.Abs(v.X-v2.X) < epsilon && math.Abs(v.Y-v2.Y) < epsilon
}
func (v *Vec2) Zero() {
v.X = 0.0
v.Y =... | vec2.go | 0.91686 | 0.480966 | vec2.go | starcoder |
package goprometheus
import (
metricCollector "github.com/afex/hystrix-go/hystrix/metric_collector"
"github.com/gin-gonic/gin"
p "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
)
type ... | go-prometheus.go | 0.689619 | 0.442275 | go-prometheus.go | starcoder |
package dei
import (
"math"
"math/rand"
"sort"
)
type BRA struct {
alpha, beta, betastart, betastep float64 // Parameters of the algorithm
maxiter int // Maximum number of iterations
solution Solution
value, delay int
}
// Constructor
func BiasedRandomised (alpha, betastart, betastep float64, maxite... | dei/bra.go | 0.615088 | 0.443299 | bra.go | starcoder |
package circuits
import (
"fmt"
"math/big"
"github.com/consensys/gnark-crypto/ecc"
"github.com/consensys/gnark/backend/hint"
"github.com/consensys/gnark/frontend"
)
type hintCircuit struct {
A, B frontend.Variable
}
func (circuit *hintCircuit) Define(api frontend.API) error {
res, err := api.NewHint(mulBy7, ... | internal/backend/circuits/hint.go | 0.661923 | 0.404919 | hint.go | starcoder |
package blocks
import (
"fmt"
"strings"
v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
yamlv3 "gopkg.in/yaml.v3"
"github.com/authzed/spicedb/pkg/commonerrors"
"github.com/authzed/spicedb/pkg/tuple"
)
// Assertions represents assertions defined in the validation file.
type Assertions struct {
// Asse... | pkg/validationfile/blocks/assertions.go | 0.694821 | 0.531209 | assertions.go | starcoder |
package renderer
import (
"github.com/abieberbach/goplanemp"
"github.com/abieberbach/goplane/xplm/dataAccess"
"github.com/abieberbach/goplane/extra"
)
type dataType int
const (
gear_ratio dataType = 0
flap_ratio dataType = 1
spoiler_ratio dataType = 2
speedbreak_ratio dataType = 3
slat_ratio dataType = 4
wi... | renderer/dataAccess.go | 0.555435 | 0.429071 | dataAccess.go | starcoder |
package analyze
import (
"fmt"
"github.com/calebcase/sla/uow"
"github.com/gonum/stat"
"github.com/stripe/veneur/tdigest"
)
type Circular struct {
Current int
Data []float64
}
func NewCircular(size int) *Circular {
circular := Circular{
Data: make([]float64, size),
}
return &circular
}
func (c *Circ... | analyze/record.go | 0.717507 | 0.493592 | record.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTMParameterQuantity147 struct for BTMParameterQuantity147
type BTMParameterQuantity147 struct {
BTMParameter1
BtType *string `json:"btType,omitempty"`
Expression *string `json:"expression,omitempty"`
IsInteger *bool `json:"isInteger,omitempty"`
Units *string `json:... | onshape/model_btm_parameter_quantity_147.go | 0.749821 | 0.415966 | model_btm_parameter_quantity_147.go | starcoder |
package sales
// Decimal defines model for Decimal.
type Decimal string
// Error defines model for Error.
type Error struct {
// An error code that identifies the type of error that occured.
Code string `json:"code"`
// Additional details that can help the caller understand or fix the issue.
Details *string `js... | sales/types.gen.go | 0.869687 | 0.489992 | types.gen.go | starcoder |
package allure
// Label is the implementation of the label.
// A label is an entity used by Allure to make metrics and grouping of tests.
type Label struct {
Name string `json:"name"` // Label's name
Value string `json:"value"` // Label's value
}
// NewLabel - builds and returns a new allure.Label. The label key ... | pkg/allure/label.go | 0.807726 | 0.529446 | label.go | starcoder |
package coordconv
import (
"errors"
"math"
"github.com/golang/geo/s1"
"github.com/golang/geo/s2"
)
// PolarStereographic provides conversions between geodetic (latitude and
// longitude) coordinates and Polar Stereographic (easting and northing)
// coordinates.
type PolarStereographic struct {
semiMajorAxis ... | polarstereographic.go | 0.687 | 0.674466 | polarstereographic.go | starcoder |
package main
import (
//"log"
)
type QuadTreeNode struct {
//Parent *QuadTreeNode
//SideLength int
Leaf *Paper
Q0, Q1, Q2, Q3 *QuadTreeNode
}
type QuadTree struct {
MinX, MinY, MaxX, MaxY, MaxR int
Root *QuadTreeNode
}
func QuadTreeInsertPape... | tiles/quadtree.go | 0.644784 | 0.48249 | quadtree.go | starcoder |
package layers
import (
"log"
"math"
"math/rand"
"gitlab.com/akita/dnn/layers"
"gitlab.com/akita/dnn/tensor"
"gitlab.com/akita/mgpusim/driver"
)
// FullyConnectedLayer represents a fully-connected layer.
type FullyConnectedLayer struct {
InputSize, OutputSize int
GPUDriver *driver.Driver
GPUCtx ... | benchmarks/dnn/layers/fullyconnected.go | 0.720368 | 0.487246 | fullyconnected.go | starcoder |
package secio
import (
"unsafe"
mol "github.com/driftluo/tentacle-go/secio/mol"
)
// intoBytes convert to molecule bytes
func intoBytes(b []byte) mol.Bytes {
tmp := intoByteslice(b)
return mol.NewBytesBuilder().Set(tmp).Build()
}
// intoString convert to molecule string
func intoString(s string) mol.String {
b... | secio/handshake_struct.go | 0.592077 | 0.423398 | handshake_struct.go | starcoder |
package mdp
// Model is the model parameters of Markov Descision Processes of your problem.
type Model struct {
StateOf map[int]*State
states []State
actions []Action
transitions []Transition
}
// NumStates returns a number of states in MDP.
func (m *Model) NumStates() int {
return len(m.states)
}
// NumActions... | mdp/model.go | 0.859443 | 0.581541 | model.go | starcoder |
package mocks
import (
"github.com/sasalatart/batcoms/domain/wikiactors"
)
// WikiFaction returns a faction instance of wikiactors.Actor that may be used for testing purposes
func WikiFaction() wikiactors.Actor {
return wikiactors.Actor{
Kind: wikiactors.FactionKind,
ID: 21418258,
URL: ... | mocks/wikiactors.go | 0.526099 | 0.559832 | wikiactors.go | starcoder |
package kata
import "sort"
// Converts number into digits.
// Weight of digit i is i**10.
func number2digits(n int64) []int8 {
d := make([]int8, 0, 20)
if n < 0 {
panic("negative number")
}
for n > 0 {
d = append(d, int8(n%10))
n /= 10
}
return d
}
// Converts digits into number value.
func digits2number... | 5_kyu/Find_the_smallest.go | 0.616243 | 0.497009 | Find_the_smallest.go | starcoder |
package ilm
import (
"strconv"
)
const (
// rule ID field column width in table output
idColumnWidth int = 16
// rule prefix field column width in table output
prefixColumnWidth int = 16
// StatusColumnWidth column width in table output
statusColumnWidth int = 12
// ExpiryColumnWidth column width in table out... | cmd/ilm/tabular_info.go | 0.599251 | 0.412234 | tabular_info.go | starcoder |
package pathreflect
import (
"fmt"
"reflect"
"strconv"
"strings"
spew "github.com/davecgh/go-spew/spew"
)
const (
PathSep = "/"
)
var (
zeroValue = reflect.Value{}
)
type Path []string
func Parse(pathString string) Path {
parts := strings.Split(pathString, PathSep)
finalParts := []string{}
// Remove emp... | src/github.com/getlantern/pathreflect/pathreflect.go | 0.629091 | 0.407658 | pathreflect.go | starcoder |
package test_literal
func assert(want int, act int, code string)
func println(format ...string)
func main() {
assert(97, 'a', "'a'")
assert(10, '\n', "'\\n'")
assert(511, 0o777, "0o777")
assert(0, 0x0, "0x0")
assert(10, 0xa, "0xa")
assert(10, 0xA, "0xA")
assert(48879, 0xbeef, "0xbeef")
assert(48879, 0xBEEF, ... | testdata/esc/literal.go | 0.558688 | 0.621943 | literal.go | starcoder |
package dckks
import (
"math/big"
"encoding/binary"
"github.com/tuneinsight/lattigo/v3/ckks"
"github.com/tuneinsight/lattigo/v3/drlwe"
"github.com/tuneinsight/lattigo/v3/ring"
"github.com/tuneinsight/lattigo/v3/rlwe"
"github.com/tuneinsight/lattigo/v3/utils"
)
// MaskedTransformProtocol is a struct storing t... | dckks/transform.go | 0.664758 | 0.416381 | transform.go | starcoder |
package dns
import (
"encoding/json"
)
// DataMatrixResult Time series containing a range of data points over time for each time series
type DataMatrixResult struct {
// The data points' labels
Metric *map[string]string `json:"metric,omitempty"`
// Time series data point values
Values *[]DataValue `json:"values,... | pkg/dns/model_data_matrix_result.go | 0.804828 | 0.540499 | model_data_matrix_result.go | starcoder |
package pure
import (
"context"
"strconv"
"time"
"github.com/benthosdev/benthos/v4/internal/bundle"
"github.com/benthosdev/benthos/v4/internal/component/processor"
"github.com/benthosdev/benthos/v4/internal/docs"
"github.com/benthosdev/benthos/v4/internal/log"
"github.com/benthosdev/benthos/v4/internal/messag... | internal/impl/pure/processor_try.go | 0.633977 | 0.634175 | processor_try.go | starcoder |
package writer
import "github.com/benpate/activitystream/vocabulary"
// Accept
func Accept(actor Object, object Object) Object {
return NewObject().
Type(vocabulary.ActivityTypeAccept).
Actor(actor).
Object(object)
}
// Add
func Add(actor Object, object Object, target Object) Object {
return NewObject().
T... | writer/activities.go | 0.517327 | 0.450359 | activities.go | starcoder |
package p514
import (
"math"
)
/**
In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring", and use the dial to spell a specific keyword in order to open the door.
Given a string ring, which represents the code engraved on the outer ring and an... | algorithms/p514/514.go | 0.606382 | 0.690435 | 514.go | starcoder |
package deploy
const (
NotificationTmpl = `{{ define "rancher.title" }}
{{ if eq (index .Alerts 0).Labels.alert_type "event"}}
{{ (index .Alerts 0).Labels.event_type}} event of {{(index .Alerts 0).Labels.resource_kind}} occurred
{{ else if eq (index .Alerts 0).Labels.alert_type "nodeHealthy"}}
The kubelet on the nod... | pkg/controllers/user/alert/deploy/notification_template.go | 0.512205 | 0.524577 | notification_template.go | starcoder |
package naq
import "github.com/ContextLogic/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/y"},
Time: cldr.CalendarDateFormat{Full: "h:mm:ss a zzzz", Long: "h:mm:ss a z", Medium: "... | resources/locales/naq/calendar.go | 0.50708 | 0.451931 | calendar.go | starcoder |
package goutil
import (
"reflect"
"unsafe"
)
// AddrInt returns a pointer int representing the address of i.
func AddrInt(i int) *int {
return &i
}
// InitAndGetString if strPtr is empty string, initialize it with def,
// and return the final value.
func InitAndGetString(strPtr *string, def string) string {
if s... | vendor/github.com/henrylee2cn/goutil/other.go | 0.648578 | 0.452234 | other.go | starcoder |
package datastream
//The ExtendedDataRange interface - this is the object that is returned from different caches/stores - it represents
//a range of data values stored in a certain way, and Next() gets the next datapoint in the range.
type ExtendedDataRange interface {
Index() int64 //Returns t... | src/connectordb/datastream/datarange.go | 0.812012 | 0.743936 | datarange.go | starcoder |
package main
import (
"errors"
"fmt"
)
type GraphType string
const (
DIRECTED GraphType = "DIRECTED"
UNDIRECTED GraphType = "UNDIRECTED"
)
type Graph interface {
Init()
AddEdge(vertexOne, vertexTwo int) error
AddEdgeWithWeight(vertexOne, vertexTwo, weight int) error
RemoveEdge(vertexOne, vertexTwo int) er... | Graphs/graphs_adjacency_matrix.go | 0.642096 | 0.551695 | graphs_adjacency_matrix.go | starcoder |
package texture
import (
"github.com/g3n/engine/geometry"
"github.com/g3n/engine/graphic"
"github.com/g3n/engine/light"
"github.com/g3n/engine/material"
"github.com/g3n/engine/math32"
"github.com/g3n/engine/texture"
"github.com/g3n/engine/util/helper"
"github.com/g3n/g3nd/app"
"time"
)
func init() {
app.Dem... | demos/texture/plane.go | 0.617743 | 0.402157 | plane.go | starcoder |
package packet
import (
"github.com/go-gl/mathgl/mgl32"
"github.com/google/uuid"
"github.com/LiteLDev/BEProtocolGolang/minecraft/protocol"
)
// AddPlayer is sent by the server to the client to make a player entity show up client-side. It is one of the
// few entities that cannot be sent using the AddActor packet.
... | minecraft/protocol/packet/add_player.go | 0.532911 | 0.448547 | add_player.go | starcoder |
package main
import (
"github.com/MattSwanson/raylib-go/physics"
"github.com/MattSwanson/raylib-go/raylib"
)
func main() {
screenWidth := int32(800)
screenHeight := int32(450)
rl.SetConfigFlags(rl.FlagMsaa4xHint)
rl.InitWindow(screenWidth, screenHeight, "Physac [raylib] - physics demo")
// Physac logo drawin... | examples/physics/physac/demo/main.go | 0.593609 | 0.40754 | main.go | starcoder |
The original Space-Saving algorithm:
https://icmi.cs.ucsb.edu/research/tech_reports/reports/2005-23.pdf
The Filtered Space-Saving enhancement:
http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf
This implementation follows the algorithm of the FSS paper, but not the
suggested implementation. Specifi... | vendor/github.com/dgryski/go-topk/topk.go | 0.802942 | 0.540863 | topk.go | starcoder |
package bun
import (
"net/url"
"strings"
)
var defaultCommand = "g"
// Commands is a map from the list of available commands to the function that will handle the redirect
var Commands = map[string]Command{
"bad": Command{
Name: "Blockchain address",
Key: "bad",
redirectFunc: simpleAppend("... | default.go | 0.501953 | 0.418459 | default.go | starcoder |
package main
import (
. "gorgonia.org/gorgonia"
"gorgonia.org/tensor"
)
var of = tensor.Float32
type FC struct {
W *Node
Act func(x *Node) (*Node, error)
}
func (l *FC) fwd(x *Node) (*Node, error) {
xw := Must(Mul(x, l.W))
if l.Act == nil {
return xw, nil
}
return l.Act(xw)
}
type NN struct {
g *ExprG... | Chapter07/dqn_maze_solver/nn.go | 0.603815 | 0.419707 | nn.go | starcoder |
package networkpolicy
import (
"fmt"
"math"
"sort"
"k8s.io/klog"
"github.com/vmware-tanzu/antrea/pkg/agent/types"
)
const (
PriorityBottomCNP = uint16(100)
PriorityTopCNP = uint16(65000)
InitialPriorityOffset = uint16(640)
InitialPriorityZones = 100
)
// InitialOFPriorityGetter is a function ... | pkg/agent/controller/networkpolicy/priority.go | 0.633297 | 0.420421 | priority.go | starcoder |
package greatspacerace
import "github.com/TSavo/chipmunk/vect"
type Segment struct {
Point1, Point2 vect.Vect
}
type Track struct {
Id, Name string
Laps, MaxTicks int
Segments []Segment
Goal Segment
StartingAngle vect.Float
Checkpoints []Segment
}
func (S1 *Segment) Intersects(S2 *S... | track.go | 0.584508 | 0.503601 | track.go | starcoder |
package CloudForest
import (
"math"
)
/*
AdaCostTarget wraps a numerical feature as a target for us in Cost Sensitive Adaptive Boosting (AdaC2.M1)
"Boosting for Learning Multiple Classes with Imbalanced Class Distribution"
<NAME>, <NAME> and <NAME>
See equations in slides here:
http://people.ee.duke.edu/~lcarin/Mi... | adacosttarget.go | 0.761361 | 0.440409 | adacosttarget.go | starcoder |
package value
import (
"github.com/JosephNaberhaus/go-delta-sync/agnostic/blocks/types"
)
// Refers to a literal null/nil/empty value
type Null struct {
isValueType
isMethodIndependent
}
func NewNull() Null {
return Null{}
}
// Refers to a literal string value
type String struct {
isValueType
isMethodIndepend... | agnostic/blocks/value/literal.go | 0.817283 | 0.477371 | literal.go | starcoder |
package iso20022
// Transfer from one investment fund/fund class to another investment fund or investment fund class by the investor. A switch is composed of one or several subscription legs, and one or several redemption legs.
type SwitchOrder3 struct {
// Unique and unambiguous identifier for a group of individual... | SwitchOrder3.go | 0.826362 | 0.44071 | SwitchOrder3.go | starcoder |
package gift
import (
"image"
"image/color"
"image/draw"
)
type pixel struct {
R, G, B, A float32
}
type imageType int
const (
itGeneric imageType = iota
itNRGBA
itNRGBA64
itRGBA
itRGBA64
itYCbCr
itGray
itGray16
itPaletted
)
type pixelGetter struct {
imgType imageType
imgBounds image.Rectangle... | libraries/gift/pixels.go | 0.543833 | 0.508788 | pixels.go | starcoder |
package xof
import (
"io"
"strconv"
"golang.org/x/crypto/blake2b"
"golang.org/x/crypto/blake2s"
"golang.org/x/crypto/sha3"
)
// XOF defines the interface to hash functions that support arbitrary-length output.
type XOF interface {
// Write absorbs more data into the hash's state. It panics if called
// after ... | xof/xof.go | 0.678647 | 0.427337 | xof.go | starcoder |
package datastructure
import (
"errors"
"fmt"
"github.com/duke-git/lancet/v2/datastructure"
)
// SinglyLink is a linked list. Whose node has a Value generics and Next pointer points to a next node of the link.
type SinglyLink[T any] struct {
Head *datastructure.LinkNode[T]
length int
}
// NewSinglyLink retur... | datastructure/link/singlylink.go | 0.588416 | 0.422981 | singlylink.go | starcoder |
package redis_rate
import "github.com/go-redis/redis/v8"
// Copyright (c) 2017 <NAME>
// https://github.com/rwz/redis-gcra/blob/master/vendor/perform_gcra_ratelimit.lua
var allowN = redis.NewScript(`
-- this script has side-effects, so it requires replicate commands mode
redis.replicate_commands()
local rate_limit_k... | lua.go | 0.760651 | 0.455562 | lua.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.