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 pure
import (
"context"
"fmt"
"time"
"github.com/benthosdev/benthos/v4/internal/bundle"
"github.com/benthosdev/benthos/v4/internal/component/input"
"github.com/benthosdev/benthos/v4/internal/component/input/processors"
"github.com/benthosdev/benthos/v4/internal/docs"
"github.com/benthosdev/benthos/v4/... | internal/impl/pure/input_resource.go | 0.538741 | 0.444927 | input_resource.go | starcoder |
package advent
var _ Problem = &sonorSweep{}
type sonorSweep struct {
dailyProblem
}
func NewSonorSweep() Problem {
return &sonorSweep{
dailyProblem{day: 1},
}
}
func (s *sonorSweep) Solve() interface{} {
input := IntsFromStrings(s.GetInputLines())
var results []int
results = append(results, s.countDepthInc... | internal/advent/day1.go | 0.733261 | 0.473779 | day1.go | starcoder |
package influxql
import (
"fmt"
)
var Language = &ParseTree{}
type ParseTree struct {
Handlers map[Token]func(*Parser) (Statement, error)
Tokens map[Token]*ParseTree
Keys []string
}
// With passes the current parse tree to a function to allow nested functions.
func (t *ParseTree) With(fn func(*ParseTree))... | services/influxql/parse_tree.go | 0.664105 | 0.423995 | parse_tree.go | starcoder |
package iso20022
// Cash movements from or to a fund as a result of investment funds transactions, eg, subscriptions or redemptions.
type FundCashForecast7 struct {
// Unique technical identifier for an instance of a fund cash forecast within a fund cash forecast report as assigned by the issuer of the report.
Iden... | FundCashForecast7.go | 0.862988 | 0.42173 | FundCashForecast7.go | starcoder |
package lexicon
import (
"fmt"
"strings"
"github.com/pkg/errors"
)
// _Trie is a ordinary implementation of trie
type _Trie struct {
hasSuffix bool
suffix []byte
hasValue bool
value int32
children map[byte]*_Trie
}
// newTrie creates a new instance of trie-node
func newTrie() *_Trie {
return new(_T... | trie.go | 0.657098 | 0.470007 | trie.go | starcoder |
package utils
import (
"errors"
"math"
"strconv"
"strings"
"github.com/microsoft/go-cidr-manager/ipv4cidr/consts"
)
// GetNetmask takes the mask number as input and creates the netmask from it
// @input mask uint8: The mask for the CIDR range
// @returns uint32: The integer representation of the netmask
func G... | ipv4cidr/utils/utils.go | 0.817684 | 0.466238 | utils.go | starcoder |
package models
import (
"strconv"
t "time"
)
const (
csvColumnRow = 2 // 1 Header row + 1 Data row (2)
csvColumnCount = 15 // 12 Months of the year + Closed, Accepted and Rejected (15)
)
// StatisticsReport holds statistical data formed from Transaction data.
type StatisticsReport struct {
ClosedTransactions... | models/statistics_report.go | 0.756447 | 0.489992 | statistics_report.go | starcoder |
package path
import (
"sort"
"github.com/xlucas/heap"
)
// Graph represents an arranged set of vertexes.
type Graph struct {
remaining *heap.Heap
vertexMap map[string]*Vertex
}
// NewGraph creates a graph from a collection of vertexes.
func NewGraph(vertexes []*Vertex) *Graph {
return &Graph{
vertexMap: prep... | graph.go | 0.865253 | 0.560794 | graph.go | starcoder |
package stdlib
import (
"fmt"
"reflect"
)
var math = []mapEntry{
// functions and operators
entry("+", Add,
"Returns sum of all number arguments",
"Usage: (+ num1 num2 ...)",
),
entry("-", Sub,
"Returns result of subtracting all the right-most args from first arg.",
),
entry("*", Mul,
"Returns result ... | stdlib/math.go | 0.704262 | 0.461563 | math.go | starcoder |
package wal
// Copyright 2015 MediaMath <http://www.mediamath.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
import (
"fmt"
"time"
"unsafe"
)
// Entry contains the data extracted from insert/update/delete/commit records
type Entr... | pg/wal/entry.go | 0.561215 | 0.41052 | entry.go | starcoder |
package effects
import (
"image"
"runtime"
)
// CTOpts options to pass to the Cartoon effect
type CTOpts struct {
// BlurKernelSize is the gaussian blur kernel size. You might need to blur
// the original input image to reduce the amount of noise you get in the edge
// detection phase. Set to 0 to skip blur, oth... | pkg/effects/cartoon.go | 0.73077 | 0.503418 | cartoon.go | starcoder |
package setop
import (
"bytes"
"fmt"
)
type Skipper interface {
// skip returns a value matching the min and inclusive criteria.
// If the last yielded value matches the criteria the same value will be returned again.
Skip(min []byte, inc bool) (result *SetOpResult, err error)
}
func createSkippersAndWeigh... | setop/operations.go | 0.744656 | 0.456228 | operations.go | starcoder |
package server
import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// TrafficFlowType defines allowed direction of the traffic in the rule
type TrafficFlowType int
const (
// TrafficFlowBidirect allows traffic to both direction
TrafficFlowBidirect TrafficFlowType = iota
)
// Rule of ACL fo... | management/server/rule.go | 0.574992 | 0.401248 | rule.go | starcoder |
package main
import (
"fmt"
"strconv"
"github.com/budavariam/advent_of_code/2018/utils"
)
func main() {
data := utils.LoadInput("11_2")
x, y, size, _ := GetLargestPowerLevelOfAnySize(data[0], 300, 300)
fmt.Printf("%d,%d,%d\n", x, y, size)
}
// GetLargestPowerLevelOfAnySize returns the largest power level in t... | 2018/11_2/solution.go | 0.690246 | 0.448909 | solution.go | starcoder |
package rtree
import (
"math"
"sort"
)
type Feature interface {
Mbr() Mbr
Equals(f Feature) bool
}
type Rtree struct {
dim int
fan int
halfFan int
root *node
size int32
height int8
}
func NewRtree(dim int, fan int, features ...Feature) *Rtree {
t := &Rtree{
dim: dim,
fan: fan,
... | rtree.go | 0.587943 | 0.464476 | rtree.go | starcoder |
package channels
// BatchingChannel implements the Channel interface, with the change that instead of producing individual elements
// on Out(), it batches together the entire internal buffer each time. Trying to construct an unbuffered batching channel
// will panic, that configuration is not supported (and provides ... | vendor/github.com/eapache/channels/batching_channel.go | 0.826432 | 0.54056 | batching_channel.go | starcoder |
// Package cpu provides an emulator for the unnamed time travel control computer/wearable from AoC 2018.
package cpu
import (
"fmt"
)
// Op represents one of the device's 16 opcodes.
type Op int
const (
// AddR (add register), rC = rA + rB.
AddR Op = iota
// AddI (add immediate), rC = rA + #B.
AddI
// MulR (m... | 2018/cpu/cpu.go | 0.587233 | 0.413536 | cpu.go | starcoder |
package wiki
import (
"sort"
"strings"
"time"
)
// Sortable is the interface that allows quiki to sort wiki resources.
type Sortable interface {
SortInfo() SortInfo
}
// SortInfo is the data returned from Sortable items for sorting wiki resources.
type SortInfo struct {
Title string
Author string
Cre... | wiki/sort.go | 0.630799 | 0.438004 | sort.go | starcoder |
package cmdapm
const (
apmCreateLong = `Creates an APM deployment, limitting the creation scope to APM resources.
There are a few ways to create an APM deployment, sane default values are provided, making
the command work out of the box even when no parameters are set. When version is not specified,
the matching ela... | cmd/deployment/apm/create_help.go | 0.700792 | 0.453867 | create_help.go | starcoder |
package script
import (
"go/ast"
"go/token"
"reflect"
)
// compiles a binary expression x 'op' y
func (w *World) compileBinaryExpr(n *ast.BinaryExpr) Expr {
switch n.Op {
default:
panic(err(n.Pos(), "not allowed:", n.Op))
case token.ADD:
return &add{w.newBinExpr(n)}
case token.SUB:
return &sub{w.newBinEx... | script/binaryexpr.go | 0.599485 | 0.461623 | binaryexpr.go | starcoder |
package strings
import (
"fmt"
"math"
)
// Challenge:
// Implement atoi which converts a string to an integer.
// The function first discards as many whitespace characters as necessary until the first non-whitespace character is found.
// Then, starting from this character, takes an optional initial plus or minus ... | easy/strings/atoi.go | 0.628179 | 0.555616 | atoi.go | starcoder |
package util
import (
"github.com/ElvertMora/quasar-fire-app/controllers/request"
"math"
)
var Satellites = []string{"Kenobi", "Skywalker", "Sato"}
func GetMapDistances(request *request.SatellitesRequest) map[string]float64 {
mapSatellites := map[string]float64{}
for _, satellite := range request.Satellites {
... | util/util.go | 0.618435 | 0.501282 | util.go | starcoder |
package gocudnn
/*
#include <cudnn.h>
*/
import "C"
import (
"runtime"
"unsafe"
"github.com/dereklstinson/cutil"
)
//SpatialTransformerD holdes the spatial descriptor
type SpatialTransformerD struct {
descriptor C.cudnnSpatialTransformerDescriptor_t
dims C.int
gogc bool
}
//GridGeneratorForward Th... | cudnnSpatial.go | 0.717111 | 0.421195 | cudnnSpatial.go | starcoder |
package cp
import (
"math"
"fmt"
)
type BB struct {
L, B, R, T float64
}
func (bb BB) String() string {
return fmt.Sprintf("%v %v %v %v", bb.L, bb.T, bb.R, bb.B)
}
func NewBBForExtents(c Vector, hw, hh float64) BB {
return BB{
L: c.X - hw,
B: c.Y - hh,
R: c.X + hw,
T: c.Y + hh,
}
}
func NewBBForCircl... | bb.go | 0.810366 | 0.538801 | bb.go | starcoder |
package region
import (
"context"
"math"
"github.com/ironarachne/world/pkg/geometry"
"github.com/ironarachne/world/pkg/random"
)
// Region is a geographic area.
type Region struct {
Description string `json:"description"`
Altitude int `json:"altitude"` // -99-99, 0 is sea l... | pkg/geography/region/region.go | 0.792183 | 0.491029 | region.go | starcoder |
package fetch
import (
"strconv"
flatbuffers "github.com/google/flatbuffers/go"
)
type Kind int8
const (
KindUNKNOWN Kind = 0
KindNUMERIC Kind = 1
KindHIST Kind = 2
KindHIST_CUMULATIVE Kind = 3
KindTEXT Kind = 4
)
var EnumNamesKind = map[Kind]string{
KindUNKNOWN: ... | vendor/github.com/circonus-labs/gosnowth/fb/fetch/circonus_df4_generated.go | 0.673406 | 0.476701 | circonus_df4_generated.go | starcoder |
package types
import (
"math"
"reflect"
"strings"
"github.com/lyraproj/issue/issue"
"github.com/lyraproj/pcore/px"
"github.com/lyraproj/semver/semver"
)
const tagName = "puppet"
type reflector struct {
c px.Context
}
var pValueType = reflect.TypeOf((*px.Value)(nil)).Elem()
func NewReflector(c px.Context) p... | types/reflector.go | 0.540681 | 0.432962 | reflector.go | starcoder |
// Package summarybar provides renderers for summary bar.
package summarybar
import (
"bytes"
"errors"
"fmt"
"io"
"math"
"sort"
"strings"
"github.com/aws/copilot-cli/internal/pkg/term/progress"
)
var errTotalIsZero = errors.New("the data sums up to zero")
// summaryBarComponent returns a summary bar given ... | internal/pkg/term/progress/summarybar/summarybar.go | 0.83056 | 0.455138 | summarybar.go | starcoder |
package net
import (
"encoding/csv"
"log"
"os"
"strings"
slices "github.com/fabricioism/go-text-classification/utils/slice"
str "github.com/fabricioism/go-text-classification/utils/str"
)
type data struct {
words []string
classes []string
ignore []string
}
// This function takes a file
// and read file ... | net/preprocessing/main.go | 0.643665 | 0.416322 | main.go | starcoder |
package token
import (
"github.com/zimmski/container/list/linkedlist"
)
// Walk traverses a token graph beginning from the given token and calls for every newly visited token the given function.
// A depth-first algorithm is used to traverse the graph. If the given walk function returns an error, the whole walk proc... | token/walk.go | 0.776623 | 0.402686 | walk.go | starcoder |
package gluamapper
import (
"errors"
"fmt"
"reflect"
"strings"
assert "github.com/arl/assertgo"
"github.com/yuin/gopher-lua"
)
var (
OutputValueIsNilError = errors.New("output value is nil")
)
// Mapper maps a Lua table to a Go struct pointer.
type Mapper struct {
// A struct tag name for Lua table keys.
T... | mapper.go | 0.66061 | 0.441312 | mapper.go | starcoder |
package internal
import (
"math"
"reflect"
"time"
"github.com/lyraproj/dgo/dgo"
)
type (
timeType int
exactTimeType struct {
exactType
value *timeVal
}
timeVal time.Time
)
// DefaultTimeType is the unconstrainted Time type
const DefaultTimeType = timeType(0)
var reflectTimeType = reflect.TypeOf(time.... | internal/time.go | 0.762866 | 0.460713 | time.go | starcoder |
package ksql
import (
"errors"
"io"
"strconv"
)
// LexerResult represents a token lexed result
type LexerResult struct {
token Token
end int
}
// Token represents a lexed token with value
type Token struct {
kind TokenKind
value any
}
// TokenKind is the type of token lexed.
type TokenKind uint8
const (
... | lexer.go | 0.522689 | 0.483039 | lexer.go | starcoder |
package bintb
import (
"fmt"
"io"
"regexp"
"strconv"
"time"
"github.com/moisespsena-go/aorm/types"
)
var (
reDTime = regexp.MustCompile(`^(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)$`)
reDTimeZ = regexp.MustCompile(`^(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+) ([+\-]\d+):(\d+)$`)
)
func (TimeZero) Zero() interface{} {
va... | ctDateTime.go | 0.652463 | 0.439447 | ctDateTime.go | starcoder |
package dtables
import (
"io"
"sort"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/dolt/go/libraries/doltcore/diff"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/env/actions"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
)
/... | go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go | 0.641984 | 0.440409 | unscoped_diff_table.go | starcoder |
package image
import (
"image"
"image/draw"
)
// And returns the result of ANDing img1 with img2, offset by offs (intersection). The images are converted to
// image.Gray if not already so. For a pair of pixels, p1 & p2 returns min(p1, p2).
func And(img1, img2 image.Image, offs image.Point) *image.Gray {
r := img1... | image/logical.go | 0.909335 | 0.569912 | logical.go | starcoder |
package cp
import (
"fmt"
"math"
)
const (
INFINITY = math.MaxFloat64
MAGIC_EPSILON = 1e-5
RadianConst = math.Pi / 180
DegreeConst = 180 / math.Pi
POOLED_BUFFER_SIZE = 1024
)
type CollisionBeginFunc func(arb *Arbiter, space *Space, userData interface{}) bool
type CollisionPreSolveFunc func(arb *Arbiter... | everything.go | 0.688783 | 0.522872 | everything.go | starcoder |
package main
import (
"fmt"
"strconv"
"github.com/fancxxy/algorithm/list/singlylinkedlist"
)
/*
f1(x) = 5x^2 + 4x^1 + 2x^0
f2(x) = 5x^1 + 5x^0
f1(x) + f2(x) = 5x^2 + 9x^1 +7x^0
f1(x) * f2(x) = 25x^3 + 45x^2 + 30x^1 + 10x^0
*/
type polynomial struct {
Coefficient int
Exponent int
}
func (p *polynomial) St... | examples/list/polynomial/main.go | 0.551815 | 0.485661 | main.go | starcoder |
package quadtree
import (
vec "github.com/etic4/vecmath"
rl "github.com/gen2brain/raylib-go/raylib"
)
//Centered ...
type Centered interface {
Center() vec.Vec2
Width() float64
Height() float64
Intersect(Centered) bool
}
//Quadtree ...
type Quadtree struct {
points []Centered
maxPoints int
divided bool... | quadtree.go | 0.586286 | 0.45423 | quadtree.go | starcoder |
package charter
import (
"fmt"
"strconv"
gochart "github.com/regorov/go-chart"
"github.com/regorov/go-chart/drawing"
)
type LabelGetterFunc func(c *Curve) string
// LabelFunc describes function parameters
type LabelFunc func(c *Curve, r gochart.Renderer, width, height int)
// LabelMaxMin puts max and min value... | service/charter/labels.go | 0.596903 | 0.461441 | labels.go | starcoder |
package iso20022
// Amount of money associated with a service.
type Fee2 struct {
// Type of fee (charge/commission).
Type *ChargeType5Choice `xml:"Tp"`
// Method used to calculate the fee (charge/commission).
Basis *ChargeBasis2Choice `xml:"Bsis,omitempty"`
// Standard fee (charge/commission) amount as specif... | Fee2.go | 0.811676 | 0.478224 | Fee2.go | starcoder |
// Package ui provides methods to draw a user interface onto the
// the screen and manage resizing.
package ui
const (
scaledWidth, scaledHeight = 854, 480
)
var (
// DrawMode is the scaling mode used.
DrawMode = Scaled
// Scale controls the scaling manually when DrawModel is Unscaled
Scale = 1.0
drawables []... | ui/ui.go | 0.762336 | 0.45532 | ui.go | starcoder |
package lshensemble
import "errors"
var (
errDomainSizeOrder = errors.New("Domain records must be sorted in ascending order of size")
)
func bootstrapOptimalPartitions(domains <-chan *DomainRecord, numPart int) ([]Partition, int) {
sizes, counts := computeSizeDistribution(domains)
partitions := optimalPartitions(... | bootstrap.go | 0.682256 | 0.45175 | bootstrap.go | starcoder |
package lmath
import (
"fmt"
"math"
)
// Vec2 represents a 2D vector or point.
type Vec2 struct {
X, Y float64
}
// String returns an string representation of this vector.
func (a Vec2) String() string {
return fmt.Sprintf("Vec2(X=%f, Y=%f)", a.X, a.Y)
}
// AlmostEquals tells if a == b using the specified epsi... | lmath/vec2.go | 0.939755 | 0.770551 | vec2.go | starcoder |
package flare
// GetAnimationEnd returns the AnimationEnd field if it's non-nil, zero value otherwise.
func (a *Animation) GetAnimationEnd() float64 {
if a == nil || a.AnimationEnd == nil {
return 0.0
}
return *a.AnimationEnd
}
// GetAnimationStart returns the AnimationStart field if it's non-nil, zero value ot... | flare/flare-accessors.go | 0.890416 | 0.606615 | flare-accessors.go | starcoder |
package parse
import (
"fmt"
"reflect"
)
type SemanticError struct {
node Node
msg string
}
func (s *SemanticError) Error() string {
return fmt.Sprintf("Semantic error on `%v`: %v", s.node, s.msg)
}
func NewSemanticError(node Node, msg string) error {
return &SemanticError{node, msg}
}
type TranslationUnit ... | parse/analyze.go | 0.6137 | 0.42662 | analyze.go | starcoder |
package mki3d
/* data structures for textured triangles */
//Vector2dType is 2D vector in MKI3D - used for UV texture coordinates.
type Vector2dType [2]float32
//TriangleUVType is a sequence of UV coordinates of endpoints of a textured triangle.
type TriangleUVType [3]Vector2dType
// TexturionDefType is a Texturion... | mki3d/texture.go | 0.82478 | 0.674816 | texture.go | starcoder |
package kmeans
import (
"bytes"
"encoding/json"
"fmt"
"math"
"math/rand"
"strings"
"time"
)
// EuclideanDistance:
// sqrt((p1 - q1)^2 + (p2 - q2)^2 + (p3 - q3)^2 + ...(pn - qn)^2)
func TransformedEuclideanDistance(t Transformer, p, q Vector) (float64, error) {
pLen, qLen := p.Len(), q.Len()
if pLen != qLen {... | kmeans.go | 0.721841 | 0.476884 | kmeans.go | starcoder |
package rect
import (
"fmt"
"math"
disc "github.com/briannoyama/bvh/discreet"
)
const DIMENSIONS int = 2
type Orthotope struct {
Point [DIMENSIONS]int32
Delta [DIMENSIONS]int32
}
var ACCURACY uint = 13
func (o *Orthotope) Overlaps(orth *Orthotope) bool {
intersects := true
for index, p0 := range orth.Point... | rect/orthotope.go | 0.716417 | 0.44897 | orthotope.go | starcoder |
package gl
import (
"unsafe"
"github.com/thinkofdeath/gl/v3.2-core/gl"
)
// TextureTarget is a target were a texture can be bound to.
type TextureTarget uint32
// Valid texture targets.
const (
Texture2D TextureTarget = gl.TEXTURE_2D
Texture2DMultisample TextureTarget = gl.TEXTURE_2D_MULTISAMPLE
Te... | render/gl/texture.go | 0.687525 | 0.471467 | texture.go | starcoder |
package ratingutil
import (
"fmt"
"sort"
"time"
"github.com/mashiike/rating"
"github.com/pkg/errors"
)
//ApplyStrategy is an alias for a function.
//This function shows how to reflect in a multiplayer game when reflecting the result of Match in Rating.
type ApplyStrategy func(map[Element]rating.Rating, map[Elem... | ratingutil/match.go | 0.762336 | 0.468851 | match.go | starcoder |
package mark
import (
"bufio"
"io"
"os"
)
type parseState struct {
*Document
line string
index, lineNum int
start, startName, startUri int
endDefName int
canDefine bool
opened, referencing, defining bool
code, multiCode ... | parser.go | 0.569853 | 0.441974 | parser.go | starcoder |
package reflect
import (
"go/ast"
)
// Funcs is a type that represents a list of functions.
type Funcs []Func
// Len returns number of functions in the list.
func (fs Funcs) Len() int { return len(fs) }
// Swap changes positions of functions with requested indexes.
func (fs Funcs) Swap(i, j int) { fs[i], fs[j] = f... | internal/reflect/func.go | 0.661704 | 0.402715 | func.go | starcoder |
package calendar
import (
"time"
)
// A CachedCalendar wraps and caches a Calendar
type CachedCalendar struct {
cal Calendar
cacheRed map[time.Time]string // red day description
cacheNotable map[time.Time]string // notable day description
cacheFlag map[time.Time]bool // flag flying day
}
// Cr... | vendor/github.com/xyproto/calendar/cachedcalendar.go | 0.605566 | 0.411525 | cachedcalendar.go | starcoder |
package goterator
func (iter *Iterator) iter(f PredicateFunc) {
skipWhileIsOver := false
ElementLoop:
for {
ok := iter.generator.Next()
if !ok {
return
}
element := iter.generator.Value()
for _, m := range iter.mappers {
switch mapper := m.(type) {
case mapFunc:
element = mapper(element)
ca... | consumer.go | 0.760295 | 0.433562 | consumer.go | starcoder |
package doc
import (
"regexp"
"sort"
"strconv"
"strings"
)
// PropertyListToRaw converts a list of PropertyEntry to the raw original
// document object.
func PropertyListToRaw(properties PropertyEntryList) interface{} {
sort.Sort(properties)
var rawObject interface{}
for _, property := range properties {
_... | pkg/doc/unmarshall.go | 0.658088 | 0.436742 | unmarshall.go | starcoder |
package exp
import "strings"
// OperatorGreaterThan represents an "greater than" comparison, when used in Predicates and Criteria
const OperatorGreaterThan = ">"
// OperatorGreaterOrEqual represents an "greater or equal" comparison, when used in Predicates and Criteria
const OperatorGreaterOrEqual = ">="
// Operato... | operators.go | 0.752286 | 0.590809 | operators.go | starcoder |
package main
/*
Input layer, Hidden Layer, Output layer
Each layer has activations a[0] = X, a[2] = {a1[2]
a2[2]
a3[2]
a4[2]}
Activations are the outputs of each layer l
z[l] = w[l] * x[l] + b
a[l] = activate(z[l])
If there are L layers than out layer y = a[L]
*/
import (
"fmt"... | main.go | 0.522933 | 0.420778 | main.go | starcoder |
package main
import (
"adventofcodego/utils/characters"
"adventofcodego/utils/inputs"
"adventofcodego/utils/utils"
"fmt"
"strings"
)
var DAY int = 13
type dotmatrix struct {
dots []point
width int64
height int64
}
type point struct {
x int64
y int64
}
func parseInput(input string) (matrix dotmatrix, ... | day13/day13.go | 0.544317 | 0.411229 | day13.go | starcoder |
package stats
import "sort"
type StaticCollector struct {
counters map[string]Int64VectorGetter
gauges map[string]Int64VectorGetter
histograms map[string]HistogramVectorGetter
}
func NewStaticCollector() *StaticCollector {
return &StaticCollector{
counters: make(map[string]Int64VectorGetter),
gauges:... | vendor/github.com/upfluence/stats/static_collector.go | 0.644561 | 0.469034 | static_collector.go | starcoder |
package config
// UnitType type
type UnitType string
func (t UnitType) String() string {
return string(t)
}
// UnitType enums
const (
// Misc
UnitTypeNone UnitType = "none"
UnitTypeString UnitType = "string"
UnitTypeShort UnitType = "short"
UnitTypePercent0100 Un... | pkg/hyperdash/config/enum.go | 0.57523 | 0.446857 | enum.go | starcoder |
package shape
import (
"fmt"
"io"
"math"
"github.com/gregoryv/go-design/xy"
)
func NewArrow(x1, y1, x2, y2 int) *Arrow {
return &Arrow{
Start: xy.Position{x1, y1},
End: xy.Position{x2, y2},
Head: NewTriangle(x2, y2, "arrow-head"),
class: "arrow",
}
}
type Arrow struct {
Start xy.Position
End xy... | shape/arrow.go | 0.711531 | 0.415432 | arrow.go | starcoder |
package gomcts
import (
"math"
"math/rand"
)
type node struct {
parent *node
// A fully expanded node will have chldren length equal to the initial
// length of unexpandedMoves, and the latter will be empty
children []*node
// The game move which created this node
move Move
// The game state associated with ... | node.go | 0.68056 | 0.430506 | node.go | starcoder |
package intsets
const bitsPerWord = 64
// Dense is an intsets representation, optimised for 64-bits
type Dense struct {
words []uint64
}
// Copy sets s to the value of x
func (s *Dense) Copy(x *Dense) {
sz := len(x.words)
s.ensure(sz)
s.words = s.words[:sz]
copy(s.words, x.words)
}
// AppendTo appends the entr... | internal/intsets/dense.go | 0.771499 | 0.404331 | dense.go | starcoder |
package dfl
import (
"fmt"
"strings"
"github.com/pkg/errors"
)
// Pipe is a BinaryOperator which represents the "|" pipe operation of left and right values.
type Pipe struct {
*BinaryOperator
}
func (p Pipe) Last() Node {
switch right := p.Right.(type) {
case Pipe:
return right.Last()
}
return p
}
func ... | pkg/dfl/Pipe.go | 0.772445 | 0.404125 | Pipe.go | starcoder |
package edwards25519
type NielsPoint struct {
YPlusX, YMinusX, XY2D FieldElement
}
// Precomputed scalar multiplication table
type ScalarMultTable [32][8]NielsPoint
// Set p to zero, the neutral element. Return p.
func (p *NielsPoint) SetZero() *NielsPoint {
p.YMinusX.SetOne()
p.YPlusX.SetOne()
p.XY2D.SetZero()... | vendor/github.com/bwesterb/go-ristretto/edwards25519/table.go | 0.82828 | 0.567098 | table.go | starcoder |
package copy
import (
"errors"
"fmt"
"reflect"
"unsafe"
"github.com/golang/groupcache/lru"
"github.com/modern-go/reflect2"
)
type Copier = *copier
type copier struct {
cacheSize int
typeCache *lru.Cache
fieldParser FieldParseFunc
}
func NewCopier(opts ...Option) *copier {
c := &copier{
typeCache: ... | copier.go | 0.514888 | 0.433682 | copier.go | starcoder |
package main
import (
"fmt"
"path/filepath"
"github.com/derWhity/AdventOfCode/lib/input"
)
const (
floor = '.'
empty = 'L'
occupied = '#'
offGrid = 0
)
type grid map[int]map[int]rune
func (g grid) print() {
for x := 0; x < len(g); x++ {
for y := 0; y < len(g[x]); y++ {
fmt.Printf("%s", string(g... | 2020/day_11/star_02/main.go | 0.528533 | 0.460592 | main.go | starcoder |
package opcodes
import (
"bytes"
"crypto/sha1"
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"fmt"
"math"
"github.com/syahrul12345/secp256k1"
"golang.org/x/crypto/ripemd160"
)
//GetOPCODELIST returns a mapping representing the OPCODELIST
func GetOPCODELIST() map[int]interface{} {
OPCODELIST := map[int]i... | opcodes/opcodes.go | 0.575111 | 0.439146 | opcodes.go | starcoder |
package diff
import (
"errors"
"fmt"
)
// AbsoluteDateDifference computes the absolute difference in days between the two dates (x, y: unparsed as strings).
// Both x, y are expected to be of the following format: YYYY-MM-DD. The start and end day should not be counted and
// only the absolute difference in dates i... | diff/date.go | 0.817829 | 0.71307 | date.go | starcoder |
package value
import (
"math/big"
)
func asin(c Context, v Value) Value {
if u, ok := v.(Complex); ok {
if !isZero(u.imag) || !inArcRealDomain(u.real) {
return complexAsin(c, u)
}
v = u.real
} else if !inArcRealDomain(v) {
return complexAsin(c, newComplex(v, zero))
}
return evalFloatFunc(c, v, floatA... | value/asin.go | 0.742328 | 0.559531 | asin.go | starcoder |
package core
import (
"sync"
)
//Node is a Branch within the BinarySearchTree.
type Node struct {
value int
left, right *Node
}
// BinarySearchTree (BST) are a particular type of container: data structures that store integers.
type BinarySearchTree struct {
lock sync.RWMutex
Root *Node //Root of the tree... | vendor/github.com/vastness-io/queues/pkg/core/binary_search_tree.go | 0.7865 | 0.429968 | binary_search_tree.go | starcoder |
// Package syntheticattention provides an implementation of the Synthetic Attention described in:
// "SYNTHESIZER: Rethinking Self-Attention in Transformer Models" by Tay et al., 2020.
// (https://arxiv.org/pdf/2005.00743.pdf)
package syntheticattention
import (
"encoding/gob"
mat "github.com/nlpodyssey/spago/pkg/m... | pkg/ml/nn/attention/syntheticattention/syntheticattention.go | 0.868423 | 0.409811 | syntheticattention.go | starcoder |
package hurricane
import (
"fmt"
"godin/utilities"
"math"
"time"
)
type TrackPointSource string
const (
Unknown TrackPointSource = "unknown"
Best TrackPointSource = "BEST"
Forecasted TrackPointSource = "OFCL"
)
type TrackPoint struct {
Timestamp time.Time `json:"timestamp"`
TrackSequence float6... | hurricane/hurricane_event.go | 0.803906 | 0.509764 | hurricane_event.go | starcoder |
package date
import (
"sort"
)
// Range represents range between two dates.
type Range struct {
Start Date `json:"start"`
End Date `json:"end"`
}
// IsValid reports if r is valid range.
func (r Range) IsValid() bool {
return r.Start.IsValid() && r.End.IsValid()
}
// Empty returns true if Start equal End.
func... | range.go | 0.890425 | 0.448426 | range.go | starcoder |
package geojson
import "github.com/tidwall/geojson/geometry"
// Rect ...
type Rect struct {
base geometry.Rect
}
// NewRect ...
func NewRect(rect geometry.Rect) *Rect {
return &Rect{base: rect}
}
// ForEach ...
func (g *Rect) ForEach(iter func(geom Object) bool) bool {
return iter(g)
}
// Empty ...
func (g *Rec... | vendor/github.com/tidwall/geojson/rect.go | 0.866062 | 0.5888 | rect.go | starcoder |
package main
import "math"
const EARTH_RADIUS float64 = 6370.856 //km 地球半径 平均值,千米
//地球半径
const EARTH_R float64 = 6378245.0
func HaverSin(theta float64) float64 {
v := math.Sin(theta / 2)
return v * v
}
func Distance(lat1, lon1, lat2, lon2 float64) float64 {
//用haversine公式计算球面两点间的距离。
//经纬度转换成弧度
lat1 = ConvertDe... | gps.go | 0.657978 | 0.643525 | gps.go | starcoder |
package types
// taken from https://www.enterpriseready.io/features/audit-log/
/*
When an event is logged it should have details that provide enough information about the event to provide the necessary context of who, what, when and where etc. Specifically, the follow fields are critical to an audit log:
Actor - The ... | types/audit-log.go | 0.589126 | 0.466663 | audit-log.go | starcoder |
package opeth
import (
"math/rand"
"io/ioutil"
"strings"
"github.com/Krognol/dgofw"
)
type Opeth struct {
lines []string
g *Generator
}
func NewOpethPlugin() *Opeth {
b, err := ioutil.ReadFile("./opeth_record.txt")
if err != nil {
return nil
}
plugin := &Opeth{lines: strings.Split(string(b), "\n"),... | plugins/opeth/opeth.go | 0.690142 | 0.506897 | opeth.go | starcoder |
package types
import (
"fmt"
"math"
"strconv"
"strings"
"github.com/juju/errors"
"github.com/pingcap/tidb/sessionctx/variable"
)
// Range is the interface of the three type of range.
type Range interface {
fmt.Stringer
Convert2IntRange() IntColumnRange
Convert2ColumnRange() *ColumnRange
Convert2IndexRange... | util/types/range.go | 0.630685 | 0.404802 | range.go | starcoder |
package creational
import (
"bytes"
"encoding/gob"
)
/*
Summary:
Prototype pattern is used to create copies of objects.
Self clone: Actual objects have the responsiblity to make their own clone.
The object to be cloned exposes Clone() methods.
DeepCopy:
DeepCopy() is used in Golang to copy objects with actual dat... | creational/prototype.go | 0.723993 | 0.409693 | prototype.go | starcoder |
package edwards25519
import (
"crypto/cipher"
"encoding/hex"
"errors"
"io"
"go.dedis.ch/kyber/v3"
"go.dedis.ch/kyber/v3/group/internal/marshalling"
)
var marshalPointID = [8]byte{'e', 'd', '.', 'p', 'o', 'i', 'n', 't'}
type point struct {
ge extendedGroupElement
varTime bool
curve *Curve
}
func (P ... | vendor/go.dedis.ch/kyber/v3/group/edwards25519/point.go | 0.784732 | 0.400691 | point.go | starcoder |
package cryptoapis
import (
"encoding/json"
)
// GetBlockDetailsByBlockHeightRIBSL Litecoin
type GetBlockDetailsByBlockHeightRIBSL struct {
// Represents a mathematical value of how hard it is to find a valid hash for this block.
Difficulty string `json:"difficulty"`
// Represents a random value that can be adju... | model_get_block_details_by_block_height_ribsl.go | 0.835148 | 0.432483 | model_get_block_details_by_block_height_ribsl.go | starcoder |
package eif
import "math"
const (
numberOfTreesDefault = 10
)
func cFactor(n float64) float64 {
return 2.0*(math.Log(n-1)+0.5772156649) - (2.0 * (n - 1.) / (n * 1.0))
}
// Forest is a group of trees
type Forest struct {
trees []*Node
c float64
}
// Score calculates the anomaloussnes score (between 0.0 and ... | forest.go | 0.841988 | 0.434521 | forest.go | starcoder |
package model
type moveStruct struct {
from int
to int
}
func (m *moveStruct) From() int {
return m.from
}
func (m *moveStruct) To() int {
return m.to
}
func (m *moveStruct) FromXY() (x int, y int) {
return IndexToXY(m.from)
}
func (m *moveStruct) ToXY() (x int, y int) {
return IndexToXY(m.to)
}
// IsVali... | Move.go | 0.503662 | 0.407923 | Move.go | starcoder |
package indicators
import (
"container/list"
"errors"
"github.com/thetruetrade/gotrade"
)
// A Simple Moving Average Indicator (Sma), no storage, for use in other indicators
type SmaWithoutStorage struct {
*baseIndicatorWithFloatBounds
// private variables
periodTotal float64
periodHistory *list.List
perio... | indicators/sma.go | 0.696165 | 0.413773 | sma.go | starcoder |
package trie
import (
"bytes"
"fmt"
"github.com/lunfardo314/verkle/kzg"
"go.dedis.ch/kyber/v3"
"golang.org/x/crypto/blake2b"
"golang.org/x/xerrors"
)
// State represents kv store plus trie
type State struct {
ts *kzg.TrustedSetup
store KVStore
values KVStore
trie... | trie/trie.go | 0.598312 | 0.437463 | trie.go | starcoder |
package wavefront_plugin
import (
"fmt"
"sort"
"strings"
"github.com/hashicorp/terraform/helper/schema"
"github.com/spaceapegames/go-wavefront"
)
// Terraform Resource Declaration
func resourceDashboard() *schema.Resource {
source := &schema.Schema{
Type: schema.TypeList,
Required: true,
Descr... | wavefront/resource_dashboard.go | 0.569254 | 0.450722 | resource_dashboard.go | starcoder |
Offers functions to work with Hyper-Complex numbers modulo P.
*/
package hypercomplex
import "math/big"
import "bytes"
import "fmt"
import "io"
import "errors"
/*
Represents a Hyper-Complex number.
The number is represented as an array of integers (*big.Int), where the length
is a power of two. If a MultiComp contain... | hyper.go | 0.606848 | 0.527682 | hyper.go | starcoder |
package paunch
import (
"math"
)
type physicsPoint struct {
x, y float64
}
type force struct {
magnitude physicsPoint
active bool
}
// Physics is an object meant to make the Movement of multiple related Movers,
// such as a Renderable and a Collision, easier. It also allows for easy
// management of multiple... | physics.go | 0.804098 | 0.714454 | physics.go | starcoder |
package ecdsa
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/sha256"
"fmt"
"math/big"
)
// p256Order returns the curve order for the secp256r1 curve
// NOTE: this is specific to the secp256r1/P256 curve,
// and not taken from the domain params for the key itself
// (which would be a more generi... | crypto/keys/internal/ecdsa/privkey.go | 0.853913 | 0.434521 | privkey.go | starcoder |
package stool
type ViewExplainer struct {
ViewIndexer ViewIndexer
}
type VariableCollection struct {
Variables map[string]int
}
type ParentCollection struct {
Parents map[string]ViewNode
}
type ChildrenCollection struct {
Children map[string]ViewNode
}
func (this *ViewExplainer) CollectParentsFrom(viewName str... | stool/variable_collector.go | 0.593374 | 0.453746 | variable_collector.go | starcoder |
package config
/**
* Configuration for compression policy label resource.
*/
type Cmppolicylabel struct {
/**
* Name of the HTTP compression policy label. Must begin with a letter, number, or the underscore character (_). Additional characters allowed, after the first character, are the hyphen (-), period (.) pound... | resource/config/cmppolicylabel.go | 0.769254 | 0.406685 | cmppolicylabel.go | starcoder |
package chipmunk
import (
"fmt"
goz "github.com/20tab/gozmo"
"github.com/vova616/chipmunk"
"github.com/vova616/chipmunk/vect"
)
var space *chipmunk.Space
var Gravity goz.Vector2 = goz.Vector2{0, -9.8}
func checkSpace() {
if space == nil {
space = chipmunk.NewSpace()
space.Gravity = vect.Vect{vect.Float(Gr... | chipmunk/chipmunk.go | 0.575946 | 0.429968 | chipmunk.go | starcoder |
package merkle
import (
"bytes"
"encoding/base64"
"encoding/hex"
"fmt"
log "github.com/golang/glog"
)
// RootHashMismatchError indicates a unexpected root hash value.
type RootHashMismatchError struct {
ExpectedHash []byte
ActualHash []byte
}
func (r RootHashMismatchError) Error() string {
return fmt.Spr... | merkle/compact_merkle_tree.go | 0.735452 | 0.541469 | compact_merkle_tree.go | starcoder |
package geom
import "math"
type geom0 struct {
layout Layout
stride int
flatCoords []float64
srid int
}
type geom1 struct {
geom0
}
type geom2 struct {
geom1
ends []int
}
type geom3 struct {
geom1
endss [][]int
}
type CoordConvert func(x, y float64) (float64, float64)
// Bounds returns the... | flat.go | 0.849893 | 0.42185 | flat.go | starcoder |
package config
/**
* Configuration for SNMP mib resource.
*/
type Snmpmib struct {
/**
* Name of the administrator for this Citrix ADC. Along with the name, you can include information on how to contact this person, such as a phone number or an email address. Can consist of 1 to 127 characters that include uppercas... | resource/config/snmpmib.go | 0.658966 | 0.422981 | snmpmib.go | starcoder |
// Package audio interacts with audio operation.
package audio
import (
"context"
"fmt"
"math"
"regexp"
"strconv"
"time"
"chromiumos/tast/errors"
"chromiumos/tast/local/testexec"
"chromiumos/tast/testing"
)
// TestRawData is used to specify parameters of the audio test data, which should be raw, signed, an... | src/chromiumos/tast/local/audio/util.go | 0.72662 | 0.442335 | util.go | starcoder |
package copycat
import (
"reflect"
)
// DeepCopy recursively copies data from src to dst.
func DeepCopy(dst interface{}, src interface{}) error {
args := deepCopyArgs{
d: reflect.ValueOf(dst),
s: reflect.ValueOf(src),
visited: &map[visitedAddr]reflect.Value{},
}
return deepCopy(&args)
}
func de... | deepcopy.go | 0.525856 | 0.404507 | deepcopy.go | starcoder |
package points
import (
"fmt"
"math"
"github.com/mukhinaks/fops/generic"
)
type Location struct {
X float64
Y float64
}
func EuclidianDistance(location1 generic.Point, location2 generic.Point) float64 {
switch v := location1.(type) {
case Location:
loc1 := location1.(Location)
loc2 := location2.(Location... | points/distanceFunctions.go | 0.783285 | 0.485905 | distanceFunctions.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.