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 neuralnetwork
import (
m64 "math"
"gonum.org/v1/gonum/blas/blas32"
"gonum.org/v1/gonum/blas/blas64"
m32 "github.com/chewxy/math32"
)
type floatXX = float32
// M32 has funcs for float32 math
var M32 = struct {
Ceil func(float32) float32
Sqrt func(float32) float32
Pow func(float32, ... | neural_network/mathCompat.go | 0.691185 | 0.622258 | mathCompat.go | starcoder |
package main
import (
"fmt"
)
const (
Vertical = 0x01
Horizontal = 0x02
DiagonalRight = 0x04
DiagonalLeft = 0x08
)
func mulSequence(sequence []int) (res uint64) {
res = 1
for _, i := range sequence {
res *= uint64(i)
}
return
}
func indexToCoords(i int, width int)... | 11-largest-product-in-a-grid/main.go | 0.816736 | 0.513059 | main.go | starcoder |
package tree
import (
"github.com/algorithms-examples/queue"
"github.com/algorithms-examples/stack"
)
//Visitor interface to visit nodes while traversing the tree.
type Visitor interface {
visit(Value interface{})
}
// TraverseRecursivelyNLR is a pre-order traverse.
// Access the data part of the current node.
//... | tree/traverser.go | 0.682362 | 0.513485 | traverser.go | starcoder |
package c4
import (
"bytes"
"crypto/sha512"
"io"
"math/bits"
"strings"
)
// `Tree` implements an ID tree as used for calculating IDs of non-contiguous
// sets of data. A C4 ID Tree is a type of merkle tree except that the list
// of IDs is sorted. According to the standard this is done to insure that
// two iden... | tree.go | 0.755817 | 0.439447 | tree.go | starcoder |
package logic
import (
"math"
"math/rand"
)
// Representations for infinity for minimax algorithm.
const (
NegativeInfinity int64 = math.MinInt64
PositiveInfinity int64 = math.MaxInt64
)
// Move returns the best move based on the current boardstate board.
func (b Board) Move(n *Node) (xpos int, ypos int) {
var ... | src/logic/ai.go | 0.725357 | 0.463444 | ai.go | starcoder |
package gfx
import (
"image"
"image/color"
"image/draw"
"math"
)
// Triangle is an array of three vertexes
type Triangle [3]Vertex
// NewTriangle creates a new triangle.
func NewTriangle(i int, td *TrianglesData) Triangle {
var t Triangle
t[0].Position = td.Position(i)
t[1].Position = td.Position(i + 1)
t[2... | vendor/github.com/peterhellberg/gfx/triangle.go | 0.842248 | 0.614741 | triangle.go | starcoder |
package wavesplatform
import (
"bytes"
"crypto/rand"
"crypto/sha256"
"crypto/sha512"
"encoding/base64"
"hash"
"strings"
"github.com/agl/ed25519"
"github.com/agl/ed25519/edwards25519"
"github.com/mr-tron/base58"
"github.com/tyler-smith/go-bip39"
"golang.org/x/crypto/blake2b"
"golang.org/x/crypto/sha3"
)
... | crypto.go | 0.766381 | 0.458349 | crypto.go | starcoder |
package storage
import (
"context"
"io"
)
type Storage interface {
// CreateObjectExclusively atomically creates an object named name with metadata metadata and data r if no object named name exists.
// Returns a non-nil error e such that ErrorIsCode(e, PreconditionFailed) is true if an object named name already ... | go/internal/pkg/service/storage/storage.go | 0.61659 | 0.427158 | storage.go | starcoder |
package main
import (
rl "github.com/gen2brain/raylib-go/raylib"
"math"
"strings"
)
type hexagon struct {
x, y float32
letter rune
selected bool
}
func (h hexagon) points(r float32) []rl.Vector2 {
res := make([]rl.Vector2, 7)
for i := 0; i < 7; i++ {
fi := float64(i)
... | lang/Go/honeycombs.go | 0.607663 | 0.441492 | honeycombs.go | starcoder |
package condition
import (
"fmt"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/types"
)
//------------------------------------------------------------------------------
func init() {
Constructors[TypeResource] = TypeSpec{
constructor: NewResour... | lib/processor/condition/resource.go | 0.714728 | 0.679983 | resource.go | starcoder |
package influxdb
import (
"io"
"time"
)
// Cursor is a cursor that reads and decodes a ResultSet.
type Cursor interface {
// NextSet will return the next ResultSet. This invalidates the previous
// ResultSet returned by this Cursor and discards any remaining data to be
// read (including any remaining partial re... | cursor.go | 0.646683 | 0.401365 | cursor.go | starcoder |
package gonfig
import (
"errors"
"fmt"
"reflect"
)
// setValueByString sets the value by parsing the string.
func setValueByString(v reflect.Value, s string) error {
if isSlice(v) {
if err := parseSlice(v, s); err != nil {
return fmt.Errorf("failed to parse slice value: %v", err)
}
} else {
if err := p... | values.go | 0.737253 | 0.455199 | values.go | starcoder |
package integration
import (
"errors"
"testing"
"github.com/CyCoreSystems/ari"
)
func TestEndpointList(t *testing.T, s Server) {
runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
h1 := ari.NewEndpointKey("h1", "1")
h2 := ari.NewEndpointKey("h1", "2")
m.Endpoint.On("List", (*ari.Key)(nil)).... | internal/integration/endpoint.go | 0.548915 | 0.405743 | endpoint.go | starcoder |
package plot
// TickLabels implements drawing tick labels.
type TickLabels struct {
X *TickLabelsX
Y *TickLabelsY
}
// NewTickLabels creates a new tick labelling element.
func NewTickLabels() *TickLabels {
return &TickLabels{
X: NewTickLabelsX(),
Y: NewTickLabelsY(),
}
}
// Draw draws tick labels to canvas u... | ticklabels.go | 0.901219 | 0.507324 | ticklabels.go | starcoder |
package objects
import "fmt"
// Compare - This function will compare two objects to make sure they are the
// same and will return a boolean, an integer that tracks the number of
// problems found, and a slice of strings that contain the detailed results,
// whether good or bad.
func Compare(o, obj2 *CommonObjectPro... | objects/compare.go | 0.743447 | 0.477554 | compare.go | starcoder |
package util
import (
"github.com/ayntgl/discordgo"
"github.com/rivo/tview"
)
// GetTreeNodeByReference walks the root `*TreeNode` of the given `*TreeView` *treeView* and returns the TreeNode whose reference is equal to the given reference *r*. If the `*TreeNode` is not found, `nil` is returned instead.
func GetTre... | util/ui.go | 0.821008 | 0.505188 | ui.go | starcoder |
package yologo
import (
"fmt"
"hash"
"hash/fnv"
"github.com/chewxy/hm"
"github.com/chewxy/math32"
"github.com/pkg/errors"
"gorgonia.org/gorgonia"
"gorgonia.org/tensor"
)
type yoloOp struct {
anchors []float32
masks []int
ignoreTresh float32
dimensions int
numClasses int
trainMode bool
g... | yolo_op.go | 0.602179 | 0.439747 | yolo_op.go | starcoder |
package world
import (
"context"
"github.com/ironarachne/world/pkg/geography/region"
"github.com/ironarachne/world/pkg/geometry"
"math"
"github.com/ojrac/opensimplex-go"
"github.com/ironarachne/world/pkg/random"
)
// Tile is a world tile
type Tile struct {
Altitude int
Temperature int
Humidity int
I... | pkg/world/tiles.go | 0.710528 | 0.501343 | tiles.go | starcoder |
package mos65c02
// Lda implements the LDA (load A) instruction, which saves the EffVal
// into the A register.
func Lda(c *CPU) {
c.ApplyNZ(c.EffVal)
c.A = c.EffVal
}
// Ldx implements the LDX (load X) instruction, which saves EffVal into
// X.
func Ldx(c *CPU) {
c.ApplyNZ(c.EffVal)
c.X = c.EffVal
}
// Ldy impl... | pkg/mos65c02/i_loadstor.go | 0.685002 | 0.445288 | i_loadstor.go | starcoder |
package projection
import (
"errors"
"math"
"github.com/tomchavakis/turf-go/geojson/geometry"
meta "github.com/tomchavakis/turf-go/meta/coordEach"
)
const a = 6378137.0
// ToMercator converts a WGS84 GeoJSON object into Mercator (EPSG:900913) projection
func ToMercator(geojson interface{}) (interface{}, error) ... | projection/projection.go | 0.819785 | 0.477981 | projection.go | starcoder |
package GoSDK
import ()
// Filter is the atomic structure inside a query it contains
// A field a value and an operator
type Filter struct {
Field string
Value interface{}
Operator string
}
//Ordering dictates the order the query values are returned in. True is Ascending, False is Descending
type Ordering s... | query.go | 0.683314 | 0.502686 | query.go | starcoder |
package eval
import (
"github.com/kocircuit/kocircuit/lang/circuit/model"
"github.com/kocircuit/kocircuit/lang/go/kit/tree"
)
type Figure interface{}
type Empty struct{}
func (e Empty) String() string { return tree.Sprint(e) }
func (e Empty) Link(span *model.Span, name string, monadic bool) (Shape, Effect, erro... | lang/circuit/eval/figure.go | 0.830491 | 0.411111 | figure.go | starcoder |
package layers
import (
"fmt"
"math"
"strings"
)
type Polynomial struct {
layer
learner
Degree int
input []float64
terms [][]float64
}
func (l *Polynomial) Estimate(input []float64) []float64 {
copy(l.input, input)
for j := range l.terms {
var p float64
for k := range l.terms[j] {
l.terms[j][k] = ... | pkg/layers/polynomial.go | 0.57523 | 0.434821 | polynomial.go | starcoder |
package ipcalc
import (
"net"
"strconv"
"strings"
)
// CopyIP returns a copy of a net.IP address.
func CopyIP(ip net.IP) net.IP {
return append(net.IP(nil), ip...)
}
// IP returns an IP address of the correct byte length.
func IP(ip net.IP) net.IP {
if x := ip.To4(); x != nil {
return CopyIP(x)
}
return Cop... | ipcalc.go | 0.867682 | 0.413063 | ipcalc.go | starcoder |
package vmath
import (
"fmt"
"math"
"github.com/maja42/vmath/math32"
)
// Quat represents a Quaternion.
type Quat struct {
W float32
X, Y, Z float32
}
func (q Quat) String() string {
return fmt.Sprintf("Quat[%f, %f x %f x %f]", q.W, q.X, q.Y, q.Z)
}
// IdentQuat returns the identity quaternion.
func Id... | quat.go | 0.952596 | 0.602997 | quat.go | starcoder |
package etw
import (
"bytes"
"encoding/binary"
)
// inType indicates the type of data contained in the ETW event.
type inType byte
// Various inType definitions for TraceLogging. These must match the definitions
// found in TraceLoggingProvider.h in the Windows SDK.
const (
inTypeNull inType = iota
inTypeUnicode... | vendor/github.com/Microsoft/go-winio/pkg/etw/eventmetadata.go | 0.512937 | 0.404684 | eventmetadata.go | starcoder |
// Package sentropy provides functions for computing entropy and delentropy
// of SippImages, as well as rendering these as images.
package sentropy
import (
"image"
"math"
)
import (
. "github.com/Causticity/sipp/shist"
. "github.com/Causticity/sipp/simage"
)
// SippEntropy is a structure that holds a referenc... | sentropy/sentropy.go | 0.77806 | 0.67708 | sentropy.go | starcoder |
PCB Standoffs, Mounting Pillars
*/
//-----------------------------------------------------------------------------
package obj
import "github.com/deadsy/sdfx/sdf"
//-----------------------------------------------------------------------------
// StandoffParms defines the parameters for a board standoff pillar.
ty... | obj/standoff.go | 0.781581 | 0.404684 | standoff.go | starcoder |
package parsers
import (
"errors"
"regexp"
"strconv"
"strings"
)
var (
// matches the row of the players table
// e.g. ` "NOTREADY ^5:^7 0^5:^7 rdner 25000 30 20 1 ^3^7\n"`
playerEntryRowRE = regexp.MustCompile(`^\s+"(.*)\s+:\s+(\d+):\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+... | pkg/parsers/players.go | 0.587825 | 0.44734 | players.go | starcoder |
package op
import (
"fmt"
"github.com/gonum/floats"
)
// The Mul operator.
type Mul struct {
Left, Right Operator
}
// Eval multiplies aligned values.
func (mul Mul) Eval(X [][]float64) []float64 {
x := mul.Left.Eval(X)
floats.Mul(x, mul.Right.Eval(X))
return x
}
// Arity of Mul is 2.
func (mul Mul) Arity() ... | op/mul.go | 0.778481 | 0.485051 | mul.go | starcoder |
package main
import (
"fmt"
"sort"
"sync"
"time"
"log"
)
// Triplet is a slice containing three (3) integers whose sum equals zero (0).
type Triplet [3]int
// ThreeSum returns a slice of Triplets given a set of real numbers.
func ThreeSum(nums ...int) []Triplet {
// Calculate and log the to... | 323-3sum/main.go | 0.761804 | 0.488893 | main.go | starcoder |
package crypto
// Copyright 2010 The Go Authors. All rights reserved.
// Copyright 2011 ThePiachu. All rights reserved.
// Copyright 2020 LXY1226. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package bitelliptic implements several Kobl... | protocol/crypto/secp192k1.go | 0.803906 | 0.4953 | secp192k1.go | starcoder |
package plandef
import (
"sort"
"strings"
)
// A VarSet is a set of variables. It's represented as an ordered slice of
// uniquely-named variables.
type VarSet []*Variable
// NewVarSet creates a new VarSet from the given variables. The key to 'in'
// should be the variable's Name.
func NewVarSet(in map[string]*Va... | src/github.com/ebay/akutan/query/planner/plandef/varset.go | 0.705075 | 0.435361 | varset.go | starcoder |
package govector
import (
"errors"
"math/rand"
"time"
)
// kmeans is a simple k-means clusterer that determines centroids with the Train function,
// and then classifies additional observations with the Nearest function.
// Nodes represents a collection of vectors to cluster
type Nodes []Vector
var randSeed = ti... | kmeans.go | 0.775987 | 0.718582 | kmeans.go | starcoder |
package basic
import "strings"
// TakeWhilePtrTest is template
func TakeWhilePtrTest() string {
return `
func TestTakeWhile<FTYPE>Ptr(t *testing.T) {
// Test : Take the numbers as long as condition match
var v2 <TYPE> = 2
var v4 <TYPE> = 4
var v5 <TYPE> = 5
var v7 <TYPE> = 7
var v40 <TYPE> = 40
expectedNewLi... | internal/template/basic/takewhileptrtest.go | 0.53777 | 0.433682 | takewhileptrtest.go | starcoder |
package draw
import (
"image"
)
func doellipse(cmd byte, dst *Image, c image.Point, xr, yr, thick int, src *Image, sp image.Point, alpha uint32, phi int, op Op) {
setdrawop(dst.Display, op)
a := dst.Display.bufimage(1 + 4 + 4 + 2*4 + 4 + 4 + 4 + 2*4 + 2*4)
a[0] = cmd
bplong(a[1:], dst.id)
bplong(a[5:], src.id)
... | vendor/9fans.net/go/draw/ellipse.go | 0.654453 | 0.608449 | ellipse.go | starcoder |
package imageutil
import (
"image"
"image/color"
"image/draw"
"strings"
)
const (
AlignTop = "top"
AlignCenter = "center"
AlignBottom = "bottom"
AlignLeft = "left"
AlignRight = "right"
)
// Crop takes an image and crops it to the specified rectangle.
func Crop(src image.Image, retain image.Rectangle) ... | image/imageutil/crop.go | 0.82478 | 0.421552 | crop.go | starcoder |
package cloudformation
import (
"encoding/base64"
"strings"
)
// Ref creates a CloudFormation Reference to another resource in the template
func Ref(logicalName string) string {
return encode(`{ "Ref": "` + logicalName + `" }`)
}
// GetAtt returns the value of an attribute from a resource in the template.
func Ge... | vendor/github.com/awslabs/goformation/cloudformation/intrinsics.go | 0.906018 | 0.540196 | intrinsics.go | starcoder |
package pt
import (
"math"
"math/rand"
)
type Vector struct {
X, Y, Z float64
}
func V(x, y, z float64) Vector {
return Vector{x, y, z}
}
func RandomUnitVector(rnd *rand.Rand) Vector {
for {
var x, y, z float64
if rnd == nil {
x = rand.Float64()*2 - 1
y = rand.Float64()*2 - 1
z = rand.Float64()*2 ... | pt/vector.go | 0.824179 | 0.773002 | vector.go | starcoder |
package performance
import (
"fmt"
"math"
"time"
vegeta "github.com/tsenart/vegeta/lib"
)
// steadyUpPacer is a Pacer that describes attack request rates that increases in the beginning then becomes steady.
// Max | ,----------------
// | /
// | /
// | /
// | /
// Min -+-----... | test/performance/pacers.go | 0.766119 | 0.446495 | pacers.go | starcoder |
package geometry
import (
"math"
"github.com/gonum/matrix/mat64"
)
// Box3 describes a box in 3d by min and max vector
type Box3 struct {
Min *mat64.Vector
Max *mat64.Vector
}
func NewBox3(min, max *mat64.Vector) Box3 {
b3 := Box3{}
if min == nil {
b3.Max = mat64.NewVector(3, []float64{
math.Inf(-1),
... | Box3.go | 0.827863 | 0.763814 | Box3.go | starcoder |
package sqlutil
import (
"fmt"
"strconv"
"strings"
)
const (
sqlConditionIn = "IN"
sqlConditionNotIn = "NOT IN"
)
// BuildInClauseString prepares a SQL IN clause with the given list of string values.
func (c *SQLUtil) BuildInClauseString(field string, values []string) string {
return c.composeInClause(sqlCo... | pkg/sqlutil/sqlinclause.go | 0.69451 | 0.423756 | sqlinclause.go | starcoder |
package main
// Import packages
import ("image"; "image/color"; "image/draw";
"os"
"log")
// Declare a new structure
type Canvas struct {
image.RGBA
}
func NewCanvas(r image.Rectangle) *Canvas {
canvas := new(Canvas)
canvas.RGBA = *image.NewRGBA(r)
return canvas
}
func (c Canvas) Clone() *Canvas {
clone :... | canvas.go | 0.685318 | 0.427636 | canvas.go | starcoder |
package memo
import (
"container/list"
)
// ExprIter enumerates all the equivalent expressions in the Group according to
// the expression pattern.
type ExprIter struct {
// Group and Element solely identify a Group expression.
*Group
*list.Element
// matched indicates whether the current Group expression boun... | planner/memo/expr_iterator.go | 0.662141 | 0.476032 | expr_iterator.go | starcoder |
package debug
import (
"image"
"image/color"
"image/draw"
"github.com/alevinval/fingerprints/internal/types"
)
var (
red = color.RGBA{255, 0, 0, 255}
green = color.RGBA{25, 215, 0, 255}
cyan = color.RGBA{20, 200, 200, 255}
blue = color.RGBA{0, 0, 255, 255}
)
// DrawFeatures draws the original image with... | internal/debug/visualize.go | 0.697403 | 0.55447 | visualize.go | starcoder |
package aerospike
import (
"fmt"
ParticleType "github.com/aerospike/aerospike-client-go/internal/particle_type"
)
// Filter specifies a query filter definition.
type Filter struct {
name string
idxType IndexCollectionType
valueParticleType int
begin Value
end ... | vendor/github.com/aerospike/aerospike-client-go/filter.go | 0.773687 | 0.417746 | filter.go | starcoder |
package runtime
import (
"time"
"github.com/m3db/m3/src/dbnode/ratelimit"
"github.com/m3db/m3/src/dbnode/topology"
xclose "github.com/m3db/m3/src/x/close"
)
// Options is a set of runtime options.
type Options interface {
// Validate will validate the runtime options are valid.
Validate() error
// SetPersis... | vendor/github.com/m3db/m3/src/dbnode/runtime/types.go | 0.674372 | 0.466481 | types.go | starcoder |
package commands
import "github.com/leanovate/gopter"
// SystemUnderTest resembles the system under test, which may be any kind
// of stateful unit of code
type SystemUnderTest interface{}
// State resembles the state the system under test is expected to be in
type State interface{}
// Result resembles the result o... | vendor/github.com/leanovate/gopter/commands/command.go | 0.658637 | 0.467636 | command.go | starcoder |
package date
import (
"errors"
"time"
)
const (
rfc1123JSON = `"` + time.RFC1123 + `"`
rfc1123 = time.RFC1123
)
// TimeRFC1123 defines a type similar to time.Time but assumes a layout of RFC1123 date-time (i.e.,
// Mon, 02 Jan 2006 15:04:05 MST).
type TimeRFC1123 struct {
time.Time
}
// UnmarshalJSON recon... | vendor/github.com/Azure/go-autorest/autorest/date/timerfc1123.go | 0.826327 | 0.466967 | timerfc1123.go | starcoder |
package image
import (
"image/color"
)
// YCbCrSubsampleRatio is the chroma subsample ratio used in a YCbCr image.
type YCbCrSubsampleRatio int
const (
YCbCrSubsampleRatio444 YCbCrSubsampleRatio = iota
YCbCrSubsampleRatio422
YCbCrSubsampleRatio420
YCbCrSubsampleRatio440
YCbCrSubsampleRatio411
YCbCrSubsampleR... | src/image/ycbcr.go | 0.786295 | 0.415136 | ycbcr.go | starcoder |
// Copyright ©2015 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cblas64
import "gonum.org/v1/gonum/blas"
// GeneralCols represents a matrix using the conventional column-major storage scheme.
type GeneralCols ... | blas/cblas64/conv.go | 0.844473 | 0.400808 | conv.go | starcoder |
package flowbits
import (
"unsafe"
)
// PutFloat32Big writes the given float32 to the bitstream in Big Endian format.
func (me *Bitstream) PutFloat32Big(value float32) error {
fp := *(*uint32)(unsafe.Pointer(&value))
return me.PutBitsUnsignedBig(uint64(fp), 32)
}
// PutFloat32Little writes the given float32 to th... | float.go | 0.748536 | 0.413892 | float.go | starcoder |
package main
import (
"encoding/json"
"fmt"
"sort"
"strconv"
"time"
"github.com/google/gapid/core/app/benchmark"
)
// Sample is a time.Duration with more readable JSON serialization.
type Sample time.Duration
// Multisample represents a collection of AnnotatedSamples gathered through
// multiple runs of a
ty... | cmd/perf/samples.go | 0.756987 | 0.420243 | samples.go | starcoder |
package segmenttree
import (
"github.com/TheAlgorithms/Go/math/max"
"github.com/TheAlgorithms/Go/math/min"
)
const emptyLazyNode = -1
//SegmentTree with original Array and the Segment Tree Array
type SegmentTree struct {
Array []int
SegmentTree []int
LazyTree []int
}
//Propagate lazy tree node values... | structure/segmenttree/segmenttree.go | 0.723114 | 0.647756 | segmenttree.go | starcoder |
package processor
import (
"fmt"
"strconv"
"time"
"github.com/Jeffail/benthos/v3/internal/bloblang/field"
"github.com/Jeffail/benthos/v3/internal/docs"
bredis "github.com/Jeffail/benthos/v3/internal/impl/redis"
"github.com/Jeffail/benthos/v3/internal/interop"
"github.com/Jeffail/benthos/v3/lib/log"
"github.c... | lib/processor/redis.go | 0.768038 | 0.644141 | redis.go | starcoder |
package scomplex
import (
"image"
"math"
)
import (
. "github.com/Causticity/sipp/simage"
)
// A ComplexImage is an image where each pixel is a Go complex128.
type ComplexImage struct {
// The "pixel" data.
Pix []complex128
// The rectangle defining the bounds of the image.
Rect image.Rectangle
// The maxim... | scomplex/complex_image.go | 0.741206 | 0.460592 | complex_image.go | starcoder |
package bqsort
import (
"math"
"reflect"
)
// Interface implementations can be sorted by the routines in this package.
// The methods refer to elements of the underlying collection by integer index.
type Interface interface {
// Len is the number of elements in the collection.
Len() int
// Key returns sort-key ... | bqsort.go | 0.732592 | 0.420778 | bqsort.go | starcoder |
package datadog
import (
"encoding/json"
"time"
)
// GetCreator returns the Creator field if non-nil, zero value otherwise.
func (a *Alert) GetCreator() int {
if a == nil || a.Creator == nil {
return 0
}
return *a.Creator
}
// GetCreatorOk returns a tuple with the Creator field if it's non-nil, zero value oth... | vendor/github.com/zorkian/go-datadog-api/datadog-accessors.go | 0.801159 | 0.49762 | datadog-accessors.go | starcoder |
package asyncjobs
import (
"context"
"fmt"
"math/rand"
"sort"
"time"
)
// RetryPolicy defines a period that failed jobs will be retried against
type RetryPolicy struct {
// Intervals is a range of time periods backoff will be based off
Intervals []time.Duration
// Jitter is a factor applied to the specific i... | retrypolicy.go | 0.728748 | 0.476336 | retrypolicy.go | starcoder |
package image
import (
"image"
"image/color"
lib_color "github.com/mchapman87501/go_mars_2020_img_utils/lib/image/color"
)
type CIELab struct {
// Pix, Stride, Rect
Pix []float64
Stride int
Rect image.Rectangle
}
func (p *CIELab) ColorModel() color.Model { return lib_color.CIELabModel }
func (p *CIELab... | lib/image/cie_lab.go | 0.695958 | 0.577763 | cie_lab.go | starcoder |
package optimga
import (
"fmt"
"math"
"math/rand"
)
const nbChildrenRate = 7
type RealES struct {
genotypeCommon
genes []float64
steps []float64 // Sigma standard deviations
rangeGene float64
tglobal float64
tlocal float64
sizeGenotype int // needed for tcglobal and tlocal comp... | genreals.go | 0.594669 | 0.551634 | genreals.go | starcoder |
package querier
import (
"sort"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/tsdb/chunkenc"
"github.com/cortexproject/cortex/pkg/cortexpb"
)
// timeSeriesSeriesSet is a wrapper around a cortexpb.TimeSeries slice to implement to Ser... | pkg/querier/timeseries_series_set.go | 0.876205 | 0.495239 | timeseries_series_set.go | starcoder |
package lib
import (
"fmt"
"time"
"github.com/asukakenji/151a48667a3852a43a2028024ffc102e/common"
"github.com/asukakenji/151a48667a3852a43a2028024ffc102e/constant"
"github.com/asukakenji/151a48667a3852a43a2028024ffc102e/matrix"
"github.com/golang/glog"
"googlemaps.github.io/maps"
)
/*
LocationsToGoogleMapsLoc... | cmd/backtier/lib/helper.go | 0.7237 | 0.505981 | helper.go | starcoder |
package iso20022
// Net position of a segregated holding, in a single security, within the overall position held in a securities account. A securities balance is calculated from the sum of securities' receipts minus the sum of securities' deliveries.
type AggregateBalanceInformation2 struct {
// Total quantity of fi... | AggregateBalanceInformation2.go | 0.867934 | 0.551332 | AggregateBalanceInformation2.go | starcoder |
package layers
import (
"fmt"
"gitlab.com/akita/mgpusim/driver"
"gitlab.com/akita/mgpusim/insts"
"gitlab.com/akita/mgpusim/kernels"
)
// TensorOperator can perform operations on tensors.
type TensorOperator struct {
driver *driver.Driver
context *driver.Context
gemmKernel *insts.HsaCo
transposeK... | benchmarks/dnn/layers/tensoroperator.go | 0.682468 | 0.47457 | tensoroperator.go | starcoder |
package hzgorm
import (
"fmt"
"github.com/jinzhu/gorm"
"reflect"
"strings"
"unicode"
)
type hzGormUtils struct {
}
func (hzutils *hzGormUtils) stringBetween(value string, start string, end string) string {
posFirst := strings.Index(value, start)
if posFirst == -1 {
return ""
}
posLast := strings.Index(val... | utils.go | 0.507324 | 0.403156 | utils.go | starcoder |
package px
import (
"math"
"github.com/giorgiga/sstats"
)
type PixelSet struct {
pixels []Pixel
rgbStats [3]sstats.Summary
}
func MakePixelSet(pixels []Pixel) PixelSet {
rgbStats := [3]sstats.Summary{ sstats.MakeSummary(), sstats.MakeSummary(), sstats.MakeSummary() }
for _,rgb := range pixels {
rgbStats[0].M... | px/pixelset.go | 0.714927 | 0.445349 | pixelset.go | starcoder |
package element
// MulNoCarry see https://hackmd.io/@gnark/modular_multiplication for more info on the algorithm
const MulNoCarry = `
{{ define "mul_nocarry" }}
var t [{{.all.NbWords}}]uint64
var c [3]uint64
{{- range $j := .all.NbWordsIndexesFull}}
{
// round {{$j}}
v := {{$.V1}}[{{$j}}]
{{- if eq $j 0}}
c[1], c... | field/internal/templates/element/mul_nocarry.go | 0.50952 | 0.514888 | mul_nocarry.go | starcoder |
package day3
import (
"math"
"strconv"
"strings"
)
type path struct {
direction string
length int
}
// Point reflects a position within the wire coordindate system
type Point struct {
x int16
y int16
}
// CrossingPoint reflect the coordinate where 2 wires cross. Steps holds the steps for both wires to rea... | day3-crossed-wires/day3/day3.go | 0.820073 | 0.764892 | day3.go | starcoder |
package search
import (
"log"
"github.com/chippydip/go-sc2ai/api"
"github.com/chippydip/go-sc2ai/botutil"
"github.com/chippydip/go-sc2ai/enums/ability"
"github.com/chippydip/go-sc2ai/enums/unit"
)
var sizeCache = map[api.UnitTypeID]api.Size2DI{}
// UnitPlacementSize estimates building footprints based on unit ... | search/placement.go | 0.561936 | 0.408454 | placement.go | starcoder |
// +build linux
package v4l
import "io"
// A Buffer holds the raw image data of a frame captured from a Device. It
// implements io.Reader, io.ByteReader, io.ReaderAt, and io.Seeker. A call to
// Capture, Close, or TurnOff on the corresponding Device may cause the contents
// of the buffer to go away.
type Buffer s... | vendor/github.com/korandiz/v4l/buffer.go | 0.657098 | 0.500183 | buffer.go | starcoder |
package hbook
import "sort"
// indices for the 2D-binning overflows
const (
bngNW int = 1 + iota
bngN
bngNE
bngE
bngSE
bngS
bngSW
bngW
)
type binning2D struct {
bins []Bin2D
dist dist2D
outflows [8]dist2D
xrange Range
yrange Range
nx int
ny int
xedges []Bin1D
yedges []Bi... | hbook/binning2d.go | 0.612657 | 0.540196 | binning2d.go | starcoder |
package datadog
import (
"encoding/json"
"time"
)
// UsageIngestedSpansHour Ingested spans usage for a given organization for a given hour.
type UsageIngestedSpansHour struct {
// The hour for the usage.
Hour *time.Time `json:"hour,omitempty"`
// Contains the total number of bytes ingested during a given hour.
... | api/v1/datadog/model_usage_ingested_spans_hour.go | 0.693473 | 0.479991 | model_usage_ingested_spans_hour.go | starcoder |
package input
import (
"github.com/Jeffail/benthos/v3/lib/input/reader"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message/batch"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/benthos/v3/lib/util/kafka/sasl"
"github.com/... | lib/input/kafka.go | 0.711431 | 0.773002 | kafka.go | starcoder |
package executor
import (
"fmt"
"github.com/lovelly/gleam/sql/context"
"github.com/lovelly/gleam/sql/infoschema"
"github.com/lovelly/gleam/sql/model"
"github.com/lovelly/gleam/sql/plan"
)
// executorBuilder builds an Executor from a Plan.
// The InfoSchema must not change during execution.
type executorBuilder ... | sql/executor/builder.go | 0.562417 | 0.427935 | builder.go | starcoder |
package types
import (
"fmt"
"github.com/src-d/go-mysql-server/sql"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/proto/query"
dtypes "github.com/liquidata-inc/dolt/go/store/types"
)
type ValueToSql func(dtypes.Value) (interface{}, error)
type SqlToValue func(interface{}) (dtypes.Value, error)
type ... | go/libraries/doltcore/sqle/types/types.go | 0.567218 | 0.434521 | types.go | starcoder |
package forge
import (
"errors"
"fmt"
)
// List struct used for holding data neede for Reference data type
type List struct {
values []Value
}
// NewList will create and initialize a new List value
func NewList() *List {
return &List{
values: make([]Value, 0),
}
}
// GetType will simply return back LIST
func... | vendor/github.com/brettlangdon/forge/list.go | 0.697918 | 0.468 | list.go | starcoder |
package graphics2d
// Constant width path tracer. Traces a path at a normal distance of width from the path.
// Join types - round, bevel [default], miter
// TraceProc defines the width and join types of the trace. The gap between two adjacent
// steps must be greater than MinGap for the join function to be called.
t... | traceproc.go | 0.756358 | 0.636763 | traceproc.go | starcoder |
package numeric
import (
"sort"
)
// UintSlice attaches the methods of Interface to []uint, sorting a increasing order.
type UintSlice []uint
func (p UintSlice) Len() int { return len(p) }
func (p UintSlice) Less(i, j int) bool { return p[i] < p[j] }
func (p UintSlice) Swap(i, j int) { p[i], p[j] = ... | numeric/sort.go | 0.622 | 0.522872 | sort.go | starcoder |
package math32
// Curve constructs an array of Vector3
type Curve struct {
points []Vector3
length float32
}
func (c *Curve) GetPoints() []Vector3 {
return c.points
}
func (c *Curve) GetLength() float32 {
return c.length
}
func (c *Curve) SetLength() {
points := c.points
l := float32(0.0)
for i := 1; i < le... | math32/curves.go | 0.899058 | 0.561395 | curves.go | starcoder |
package bitarray
// CopyBitsFromBytes reads nBits bits from b at the offset bOff, and write them
// into the buffer at the offset off.
func (buf *Buffer) CopyBitsFromBytes(off int, b []byte, bOff, nBits int) {
switch {
case off < 0:
panicf("CopyBitsFromBytes: negative off %d.", off)
case buf.nBits < off+nBits:
... | buffer_copy.go | 0.722918 | 0.462716 | buffer_copy.go | starcoder |
package utils
import (
"math"
. "github.com/gmlewis/go-gcode/gcode"
)
const (
defaultFlatness = 1e-4
defaultMinL = 0.1 // mm
)
// VBezierOptions represents options for VBezier3.
type VBezierOptions struct {
Flatness float64
MinL float64
}
// Vectorize cubic Bezier curves by recursive subdivision
// u... | utils/vbezier.go | 0.806319 | 0.484014 | vbezier.go | starcoder |
package document
import (
"errors"
)
// ErrStreamClosed is used to indicate that a stream must be closed.
var ErrStreamClosed = errors.New("stream closed")
// An Iterator can iterate over documents.
type Iterator interface {
// Iterate goes through all the documents and calls the given function by passing each one... | document/iterator.go | 0.768038 | 0.406715 | iterator.go | starcoder |
package compress
import "sort"
type rotation struct {
int
s []uint8
}
type Rotations []rotation
func (r Rotations) Len() int {
return len(r)
}
func less(a, b rotation) bool {
la, lb, ia, ib := len(a.s), len(b.s), a.int, b.int
for {
if x, y := a.s[ia], b.s[ib]; x != y {
return x < y
... | _vendor/src/github.com/pointlander/compress/burrows_wheeler.go | 0.636805 | 0.460046 | burrows_wheeler.go | starcoder |
package model
import (
"database/sql"
"errors"
)
/*
| Table Name | Column Name | Position | Matches | Qty |
| ------------------------------------- | --------------------------------- | -------- | -------------------------------------... | model/domains.go | 0.577257 | 0.409516 | domains.go | starcoder |
package algorithms
import (
"github.com/bionoren/mazes/grid"
"math/rand"
)
// AldousBroderWilsons runs AldousBroder until either the grid is half visited or it has run for size*4 iterations. Then it runs Wilson's algorithm until the grid is fully visited
func AldousBroderWilsons(g grid.Grid) {
// Aldous-broder
si... | algorithms/aldousBroderWilsons.go | 0.562898 | 0.452596 | aldousBroderWilsons.go | starcoder |
package asdu
// about information object 应用服务数据单元 - 信息对象
// InfoObjAddr is the information object address.
// See companion standard 101, subclass 7.2.5.
// The width is controlled by Params.InfoObjAddrSize.
// <0>: 无关的信息对象地址
// - width 1: <1..255>
// - width 2: <1..65535>
// - width 3: <1..16777215>
type InfoObjAdd... | asdu/information.go | 0.534127 | 0.418875 | information.go | starcoder |
package figmatypes
// VectorOrFrameOffset contains the fields from Vector and FrameOffset.
type VectorOrFrameOffset struct {
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
NodeID string `json:"node_id,omitempty"`
NodeOffset *Vector `json:"node_offset,omitempty"`
}
// Types
/... | figmatypes/figma.go | 0.913279 | 0.421611 | figma.go | starcoder |
package axtest
import (
"github.com/golang/protobuf/proto"
"github.com/jmalloc/ax"
"github.com/jmalloc/ax/endpoint"
)
// ContainsMessage returns true if v contains a message equal to m.
func ContainsMessage(v []proto.Message, m proto.Message) bool {
for _, x := range v {
if proto.Equal(x, m) {
return true
... | axtest/compare.go | 0.826432 | 0.4881 | compare.go | starcoder |
package day10
import (
"errors"
"fmt"
"strings"
)
type point struct {
x int
y int
}
// Map is a map of asteroids on a two-dimensional grid.
type Map struct {
asteroids []*Asteroid
grid map[point]*Asteroid
}
var (
errEmptyMap = errors.New("the map string is empty")
)
// LoadFromString reads a map from ... | day10/map.go | 0.779406 | 0.418043 | map.go | starcoder |
package movingcounter
import (
"time"
)
type Clock interface {
Now() time.Time
}
type defaultClock struct{}
func (defaultClock) Now() time.Time {
return time.Now()
}
type Value interface {
Add(a Value) Value
Sub(a Value) Value
Min(a Value) Value
Max(a Value) Value
}
type Int64Value int64
func (v Int64Value... | movingcounter/counter.go | 0.533641 | 0.440289 | counter.go | starcoder |
package nifi
import (
"encoding/json"
)
// DimensionsDTO struct for DimensionsDTO
type DimensionsDTO struct {
// The width of the label in pixels when at a 1:1 scale.
Width *float64 `json:"width,omitempty"`
// The height of the label in pixels when at a 1:1 scale.
Height *float64 `json:"height,omitempty"`
}
//... | model_dimensions_dto.go | 0.807347 | 0.598957 | model_dimensions_dto.go | starcoder |
package sigma
// NodeSimpleAnd is a list of matchers connected with logical conjunction
type NodeSimpleAnd []Branch
// Match implements Matcher
func (n NodeSimpleAnd) Match(e Event) (bool, bool) {
for _, b := range n {
match, applicable := b.Match(e)
if !match || !applicable {
return match, applicable
}
}
... | pkg/sigma/v2/nodes.go | 0.760028 | 0.430147 | nodes.go | starcoder |
package status
import "strings"
import "strconv"
import sisimoji "sisimai/string"
/*
http://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.xhtml
-------------------------------------------------------------------------------------------------
[Class Sub-Codes]
2.X.Y Success
4.X.Y ... | sisimai/smtp/status/lib.go | 0.513425 | 0.560373 | lib.go | starcoder |
package hsvimage
import (
"github.com/spakin/hsvimage/hsvcolor"
"image"
"image/color"
)
// NHSVA is an in-memory image whose At method returns hsvcolor.NHSVA values.
type NHSVA struct {
// Pix holds the image's pixels, in H, S, V, A order. The pixel at
// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.... | image.go | 0.778439 | 0.496338 | image.go | starcoder |
package main
import (
"fmt"
"math"
"github.com/rolfschmidt/advent-of-code-2021/helper"
)
func main() {
fmt.Println("Part 1", Part1())
fmt.Println("Part 2", Part2())
}
func Part1() int {
return Run(false)
}
func Part2() int {
return Run(true)
}
type Point struct {
value int
x int... | day11/main.go | 0.603231 | 0.420362 | main.go | starcoder |
package gql
import (
"context"
"fmt"
"reflect"
"strings"
"github.com/rigglo/gql/pkg/language/ast"
)
/*
Schema is a graphql schema, a root for the mutations, queries and subscriptions.
A GraphQL service’s collective type system capabilities are referred to as that
service’s “schema”. A schema is defined in term... | schema.go | 0.695131 | 0.414247 | schema.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTCurveGeometryCircle115 struct for BTCurveGeometryCircle115
type BTCurveGeometryCircle115 struct {
BTCurveGeometry114
BtType *string `json:"btType,omitempty"`
Clockwise *bool `json:"clockwise,omitempty"`
Radius *float64 `json:"radius,omitempty"`
Xcenter *float64 `j... | onshape/model_bt_curve_geometry_circle_115.go | 0.897785 | 0.406744 | model_bt_curve_geometry_circle_115.go | starcoder |
package graph
import (
"github.com/stackrox/rox/pkg/dackbox/sortedkeys"
)
// Modification represents a readable change to a Graph.
type Modification interface {
RGraph
FromModified([]byte) bool
ToModified([]byte) bool
Apply(graph applyableGraph)
}
// NewModifiedGraph returns a new instance of a ModifiedGraph.... | pkg/dackbox/graph/modified.go | 0.805211 | 0.556038 | modified.go | starcoder |
package util
// VectorMap is a simple trie-based map from a float slice to arbitrary type values
type VectorMap interface {
Get([]int) (interface{}, bool)
Put([]int, interface{})
Remove([]int) (interface{}, bool)
Keys() [][]int
Size() int
}
// NewVectorMap creates a new vector map.
func NewVectorMap() VectorMap ... | util/vectormap.go | 0.810629 | 0.438424 | vectormap.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.