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 prime
import (
"fmt"
"math/big"
)
// An elliptic curve of the form y^2 = x^3 + a*x + b.
type Curve struct {
f *Field // over which the curve is defined
a,b *Element // coefficients
}
// A point with nil x,y coordinates is considered a point at infinity.
type Point struct {
c *Curve // associate... | src/godot/ecdsa/prime/curve.go | 0.805058 | 0.500366 | curve.go | starcoder |
package slippy
import (
"errors"
"fmt"
"github.com/go-spatial/geom"
)
// MaxZoom is the lowest zoom (furthest in)
const MaxZoom = 22
// NewTile returns a Tile of Z,X,Y passed in
func NewTile(z, x, y uint) *Tile {
return &Tile{
Z: z,
X: x,
Y: y,
}
}
// Tile describes a slippy tile.
type Tile struct {
//... | slippy/tile.go | 0.65379 | 0.40028 | tile.go | starcoder |
package main
import (
"image/color"
"math"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/Jacalz/linalg/matrix"
)
// LineDrawer draws lines from a matrix of position vectors.
type LineDrawer struct {
widget.BaseWidget
lines []fyne.CanvasObject
matr... | lines.go | 0.675229 | 0.439627 | lines.go | starcoder |
package godmt
import (
"fmt"
"go/ast"
"go/token"
"reflect"
)
// BasicTypeLiteralParser will try to extract the type of a basic literal type,
// whether const or var.
func BasicTypeLiteralParser(d *ast.Ident, item *ast.BasicLit) ScannedType {
itemType := fmt.Sprintf("%T", item.Value)
if item.Kind == token.INT {... | pkg/godmt/ParserUtils.go | 0.589716 | 0.424889 | ParserUtils.go | starcoder |
package bytesurl
import (
"bytes"
"sort"
)
// Values maps a string key to a list of values.
// It is typically used for query parameters and form values.
// Unlike in the http.Header map, the keys in a Values map
// are case-sensitive.
type Values map[string][][]byte
// Get gets the first value associated with the... | values.go | 0.726717 | 0.484075 | values.go | starcoder |
package data
import (
"fmt"
)
// vector represents a Field's collection of Elements.
type vector interface {
Set(idx int, i interface{})
Append(i interface{})
Extend(i int)
At(i int) interface{}
Len() int
Type() FieldType
PointerAt(i int) interface{}
CopyAt(i int) interface{}
ConcreteAt(i int) (val interfac... | data/vector.go | 0.600305 | 0.595522 | vector.go | starcoder |
package gofsm
import (
"fmt"
"strings"
"time"
)
// TransitionRecord represents an info on a single FSM transtion.
type TransitionRecord struct {
When time.Time
From string
To string
Note string
}
// New initialize a new FSM.
func NewFSM() *FSM {
retur... | fsm.go | 0.730578 | 0.406214 | fsm.go | starcoder |
// package collection is Golang Common methods of slice and array
// Including general operations such as slice and array de duplication, delete, and empty set
// For sorting and adding elements of slices and arrays, please use the official sort package related methods
package collection
import (
"errors"
"fmt"
"r... | collection/collection.go | 0.674158 | 0.517693 | collection.go | starcoder |
package main
import (
. "github.com/9d77v/leetcode/pkg/algorithm/binarytree"
)
/*
题目: 二叉树的最近公共祖先
给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。
百度百科中最近公共祖先的定义为:“对于有根树 T 的两个节点 p、q,最近公共祖先表示为一个节点 x,满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个节点也可以是它自己的祖先)。”
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree
著作... | internal/leetcode/236.lowest-common-ancestor-of-a-binary-tree/main.go | 0.525125 | 0.453383 | main.go | starcoder |
// Counter (CTR) mode with support for continuation.
// CTR converts a block cipher into a stream cipher by
// repeatedly encrypting an incrementing counter and
// xoring the resulting stream of data with the input.
// See NIST SP 800-38A, pp 13-15
package cryptoutils
import (
"bytes"
"crypto/cipher"
"encoding/... | betterctr.go | 0.681833 | 0.432063 | betterctr.go | starcoder |
Lookup Table Based Math Functions
Faster than standard math package functions, but less accurate.
*/
//-----------------------------------------------------------------------------
package core
import "math"
//-----------------------------------------------------------------------------
func init() {
cosLUTInit... | core/lut.go | 0.852322 | 0.520923 | lut.go | starcoder |
package julia
import (
"image"
"image/color"
"sync"
)
func DrawJulia(src image.Image, rgba *image.RGBA, zoom float64, center complex128, iterations float64) {
w, h := float64(rgba.Bounds().Size().X), float64(rgba.Bounds().Size().Y)
ratio := w / h
fillMapper(src)
wg := new(sync.WaitGroup)
wg.Add(int(w))
f... | fractal/julia/julia.go | 0.789071 | 0.487551 | julia.go | starcoder |
package finnhub
import (
"encoding/json"
)
// RecommendationTrend struct for RecommendationTrend
type RecommendationTrend struct {
// Company symbol.
Symbol *string `json:"symbol,omitempty"`
// Number of recommendations that fall into the Buy category
Buy *int64 `json:"buy,omitempty"`
// Number of recommendati... | model_recommendation_trend.go | 0.785802 | 0.523725 | model_recommendation_trend.go | starcoder |
package arts
import (
"math"
"math/rand"
"github.com/andrewwatson/generativeart"
"github.com/andrewwatson/generativeart/common"
"github.com/fogleman/gg"
)
type colorCircle struct {
circleNum int
}
func NewColorCircle(circleNum int) *colorCircle {
return &colorCircle{
circleNum: circleNum,
}
}
// Generati... | arts/colorcircle.go | 0.651244 | 0.49884 | colorcircle.go | starcoder |
package continuous
import (
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Johnson SN Distribution (Normal)
// https://reference.wolfram.com/language/ref/JohnsonDistribution.html
type JohnsonSN struct {
gamma, delta, location, scale float64 // γ, δ, location μ, and scale σ
src... | dist/continuous/johnson_sn.go | 0.827061 | 0.435962 | johnson_sn.go | starcoder |
package indexer
import (
"bytes"
"context"
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"
"image/color"
"math"
"net/http"
"sort"
"strings"
"time"
svg "github.com/ajstarks/svgo"
"github.com/mikeydub/go-gallery/service/persist"
)
/**
* The drawing instructions for the nine different symbols are ... | indexer/metadatas.go | 0.755276 | 0.459015 | metadatas.go | starcoder |
package numgo
import (
"fmt"
"math"
"runtime"
"sort"
)
// Equals performs boolean '==' element-wise comparison
func (a *Array64) Equals(b *Array64) (r *Arrayb) {
r = a.compValid(b, "Equals()")
if r != nil {
return r
}
r = a.comp(b, func(i, j float64) bool {
return i == j || math.IsNaN(i) && math.IsNaN(j)... | boolOps.go | 0.563498 | 0.435421 | boolOps.go | starcoder |
package mound
import (
colorful "github.com/lucasb-eyer/go-colorful"
log "github.com/sirupsen/logrus"
)
// Direction determines the next location of the turmite
type Direction int
// [N]orth [E]ast [S]outh [W]est
// Clockwise movement starting at N (noon)
const (
North Direction = iota
East
South
West
)
// Tu... | mound/turmite.go | 0.737158 | 0.479504 | turmite.go | starcoder |
package ast
/*
* GroupingSet -
* representation of CUBE, ROLLUP and GROUPING SETS clauses
*
* In a Query with grouping sets, the groupClause contains a flat list of
* SortGroupClause nodes for each distinct expression used. The actual
* structure of the GROUP BY clause is given by the groupingSets tree.
*
*... | pkg/ast/grouping_set_kind.go | 0.730097 | 0.4184 | grouping_set_kind.go | starcoder |
package minecraftColor
import (
"image/color"
)
// Convert hex color to RGBA color.
func toRGBA(i int) color.RGBA {
return color.RGBA{
R: uint8(i / 0x10000),
G: uint8(i / 0x100),
B: uint8(i),
A: 0xFF,
}
}
var (
BlackRGBA = toRGBA(0)
// https://minecraft-el.gamepedia.com/Biome/ID
Biome = [256]color... | pkg/minecraftColor/biome.go | 0.511229 | 0.685457 | biome.go | starcoder |
package scp03
import (
"fmt"
"github.com/llkennedy/globalplatform/goimpl/nist/sp800108"
)
// KDF is a wrapper around SP800-108's KBKDF with SCP03-specified parameters
type KDF struct{}
// DataDerivationConstant is a data derivation constant for KDF functions
type DataDerivationConstant byte
const (
// DDCCardCr... | goimpl/scp03/kdf.go | 0.604516 | 0.410047 | kdf.go | starcoder |
package lucene42
import (
"github.com/jtejido/golucene/core/codec/compressing"
)
// lucene42/Lucene42TermVectorsFormat.java
/*
Lucene 4.2 term vectors format.
Very similarly to Lucene41StoredFieldsFormat, this format is based on
compressed chunks of data, with document-level granularity so that a
document can neve... | core/codec/lucene42/termVectors.go | 0.649245 | 0.586878 | termVectors.go | starcoder |
package main
import (
"image"
"image/color"
"image/gif"
"log"
"math"
"os"
"github.com/unixpickle/model3d/model2d"
"github.com/unixpickle/essentials"
"github.com/unixpickle/model3d/model3d"
"github.com/unixpickle/model3d/render3d"
)
const (
FrameSkip = 4
ImageSize = 200
)
func main() {
mesh := CreateMe... | examples/renderings/deformation/main.go | 0.524882 | 0.430806 | main.go | starcoder |
package state
import (
"context"
"time"
)
// State represents the state of the current state machine.
type State interface {
Do(ctx context.Context) (States, error)
}
// OnFailure is invoked when a permanent failure occurs during processing.
type OnFailure interface {
Fail(ctx context.Context, err error) States
... | state/state.go | 0.800848 | 0.519704 | state.go | starcoder |
package weather
// K returns the temperature in kelvin.
func (t Temperature) K() int {
return int(t)
}
// TemperatureFromK creates a kelvin temperature value.
func TemperatureFromK(k float64) Temperature {
return Temperature(k)
}
// C returns the temperature in degrees celcius.
func (t Temperature) C() int {
ret... | modules/weather/units.go | 0.91816 | 0.646739 | units.go | starcoder |
package urlstruct
import (
"database/sql"
"encoding"
"fmt"
"reflect"
"strconv"
"time"
)
var (
textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
timeType = reflect.TypeOf((*time.Time)(nil)).Elem()
durationType = reflect.TypeOf((*time.Duration)(nil)).Elem()
nullBo... | scan.go | 0.537527 | 0.420421 | scan.go | starcoder |
package day11
import (
"errors"
"fmt"
"io"
)
type IntGrid struct {
data [][]int
width int
height int
}
type Point struct {
X int
Y int
}
func (p Point) Plus(offset *Point) *Point {
return &Point{X: p.X + offset.X, Y: p.Y + offset.Y}
}
func NewPoint(x int, y int) *Point {
return &Point{x, y}
}
func New... | day11/grid.go | 0.552298 | 0.417331 | grid.go | starcoder |
package treap
// node represents node of a treap.
type node[T any] struct {
priority int
value T
left *node[T]
right *node[T]
size int
}
// contains returns true if given node contains given value,
// false otherwise.
func (n *node[T]) contains(value T, comp func(T, T) int) bool {
if n == nil {
... | treap/node.go | 0.831964 | 0.57344 | node.go | starcoder |
package aws
import (
"context"
"strconv"
"strings"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin/transform"
)
func tableAwsVpcFlowLogEventListKeyCol... | aws/table_aws_vpc_flow_log_event.go | 0.660391 | 0.441372 | table_aws_vpc_flow_log_event.go | starcoder |
package conversion
import (
"math"
)
// KphToMps - converts kilometres per hour to meters per second
func KphToMps(kph int) float64 {
return float64(kph) / 3.6
}
// KphToKts - converts kilometres per hour to knots
func KphToKts(kph int) float64 {
return float64(kph) / 1.852
}
// KtsToMps - converts knots to mete... | conversion/conversion.go | 0.81593 | 0.534612 | conversion.go | starcoder |
package heap
type Value interface{}
type Cmp func(a, b Value) bool
type Heap interface {
InitWithCmp(cmp Cmp)
Push(x Value)
Pop() Value
Peek() Value
Len() int
IndexOf(x Value) int
Fix(i int)
Remove(i int) Value
Update(i int, value Value)
}
func New() Heap {
return NewWithCap(0)
}
func NewWithCap(cap int... | heap/heap.go | 0.761272 | 0.439026 | heap.go | starcoder |
package git
// BoolCache caches a boolean variable.
// The zero value is an empty cache.
type BoolCache struct {
initialized bool
value bool
}
// Set allows collaborators to signal when the current branch has changed.
func (sc *BoolCache) Set(newValue bool) {
sc.initialized = true
sc.value = newValue
}
// ... | src/git/cache.go | 0.832815 | 0.467696 | cache.go | starcoder |
package trie
import "strings"
type node struct {
content rune
wordMarker bool
children []*node
}
func (n *node) findChild(r rune) *node {
for _, e := range n.children {
if e.content == r {
return e
}
}
return nil
}
// Trie represents a trie also called prefix tree.
// The zero value for Trie is an... | trie.go | 0.757615 | 0.452113 | trie.go | starcoder |
package rollsum
import (
"encoding/binary"
)
const FULL_BYTES_16 = (1 << 16) - 1
// Rollsum32Base decouples the rollsum algorithm from the implementation of
// hash.Hash and the storage the rolling checksum window
// this allows us to write different versions of the storage for the distinctly different
// use-cases... | rollsum/rollsum_32_base.go | 0.718693 | 0.470311 | rollsum_32_base.go | starcoder |
package graph
import (
"sort"
)
type BasicTypeNodeSlice []*BasicTypeNode
func (nm BasicTypeNodeSlice) GetIds() (ids []NodeId) {
for _, n := range nm {
ids = append(ids, n.Id())
}
return
}
func (ns BasicTypeNodeSlice) Sort() (BasicTypeNodeSlice) {
sort.Slice(ns, func(i, j int) bool {
return ns[i].Namex < n... | asg/pkg/v0/asg/graph/NodeSlice_.go | 0.579876 | 0.553083 | NodeSlice_.go | starcoder |
package humanize
import (
"fmt"
"math"
"strings"
"time"
gohumanize "github.com/dustin/go-humanize"
)
func Timestamp(ts time.Time) string {
return fmt.Sprintf("%s (%s)", ts.Format("Mon Jan 02 15:04:05 -0700"), gohumanize.Time(ts))
}
var relativeMagnitudes = []gohumanize.RelTimeMagnitude{
{D: time.Second, Form... | humanize/humanize.go | 0.725065 | 0.471588 | humanize.go | starcoder |
package refconv
import (
"fmt"
"math"
"math/cmplx"
"reflect"
"strconv"
"time"
"github.com/cstockton/go-conv/internal/refutil"
)
var (
emptyTime = time.Time{}
typeOfTime = reflect.TypeOf(emptyTime)
typeOfDuration = reflect.TypeOf(time.Duration(0))
)
func (c Conv) convStrToDuration(v string) (time.... | vendor/github.com/cstockton/go-conv/internal/refconv/time.go | 0.704058 | 0.401336 | time.go | starcoder |
package primitives
import (
"git.maze.io/go/math32"
"github.com/go-gl/mathgl/mgl32"
)
// DRAW WITH: gl.DrawElements(gl.TRIANGLES, xSegments*ySegments*6, gl.UNSIGNED_INT, unsafe.Pointer(nil))
func Sphere(ySegments, xSegments int) (vertices, normals, tCoords []float32, indices []uint32) {
for y := 0; y <= ySegments... | primitives/geometry.go | 0.53048 | 0.671356 | geometry.go | starcoder |
package main
import (
"fmt"
"github.com/theatlasroom/advent-of-code/go/2019/intcode"
"github.com/theatlasroom/advent-of-code/go/2019/utils"
)
/**
--- Day 2: 1202 Program Alarm ---
On the way to your gravity assist around the Moon, your ship computer beeps angrily about a "1202 program alarm". On the radio, an Elf... | go/2019/2019_2.go | 0.53437 | 0.683637 | 2019_2.go | starcoder |
package pak
import "fmt"
type Bin struct {
W, H float64
Boxes []*Box
FreeRectangles []*FreeSpaceBox
Heuristic *Base
}
func NewBin(w float64, h float64, s *Base) *Bin {
if s == nil {
s = &Base{&BestAreaFit{}}
}
return &Bin{w, h, nil, []*FreeSpaceBox{{W: w, H: h}}, s}
}
func (b *Bin)... | bin.go | 0.593727 | 0.459804 | bin.go | starcoder |
package gozxing
type Binarizer interface {
GetLuminanceSource() LuminanceSource
/**
* Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
* cached data. Callers should assume this method is expensive and call it as seldom as possible.
* This method is intended for decod... | binarizr.go | 0.887339 | 0.640003 | binarizr.go | starcoder |
package algorithm
import (
"math"
)
// ALVNode alv tree node
type ALVNode struct {
Data int32
LNode *ALVNode
RNode *ALVNode
Height int16
}
// PreorderTraversal preorder traver
func PreorderTraversal(root *ALVNode) []int32 {
var list []int32
if root.LNode != nil {
list = append(list, PreorderTraversal(ro... | algorithm/alvtree.go | 0.517571 | 0.463869 | alvtree.go | starcoder |
package iso20022
// Choice between types of payment instrument, ie, cheque, credit transfer, direct debit, investment account or payment card.
type PaymentInstrument12Choice struct {
// Electronic money product that provides the cardholder with a portable and specialised computer device, which typically contains a m... | PaymentInstrument12Choice.go | 0.639511 | 0.468851 | PaymentInstrument12Choice.go | starcoder |
package shortestpath
import (
"context"
"math"
"github.com/PacktPublishing/Hands-On-Software-Engineering-with-Golang/Chapter08/bspgraph"
"github.com/PacktPublishing/Hands-On-Software-Engineering-with-Golang/Chapter08/bspgraph/message"
"golang.org/x/xerrors"
)
// Calculator implements a shortest path calculator ... | Chapter08/shortestpath/path.go | 0.814201 | 0.417628 | path.go | starcoder |
package swea
import (
"strconv"
"time"
)
// Language is the container for a language ID
type Language string
const (
// English is the english language ID
English = Language("en")
// Swedish is the swedish language ID
Swedish = Language("sv")
)
// SearchGroupSeries represents searchable group series
type Sea... | swea/types.go | 0.54819 | 0.452717 | types.go | starcoder |
package curves
import (
"github.com/wieku/danser-go/framework/math/vector"
)
type BSpline struct {
points []vector.Vector2f
timing []float32
subPoints []vector.Vector2f
path []*Bezier
ApproxLength float32
}
func NewBSpline(points1 []vector.Vector2f, timing []int64) *BSpline {
pointsLen... | framework/math/curves/bspline.go | 0.675336 | 0.535888 | bspline.go | starcoder |
package math
import (
"errors"
"fmt"
"math"
"math/rand"
"sync"
"github.com/antongulenko/golib"
"github.com/bitflow-stream/go-bitflow/bitflow"
"github.com/bitflow-stream/go-bitflow/script/reg"
log "github.com/sirupsen/logrus"
)
func RegisterSphere(b reg.ProcessorRegistry) {
create := func(p *bitflow.SampleP... | steps/math/sphere.go | 0.738763 | 0.460774 | sphere.go | starcoder |
package gft
import (
"image"
"image/draw"
"github.com/infastin/gul/gm32"
"github.com/infastin/gul/tools"
"github.com/srwiley/rasterx"
)
type cropRectangleFilter struct {
startX, startY float32
width, height float32
mergeCount uint
}
func (f *cropRectangleFilter) Bounds(src image.Rectangle) image.Rectan... | gft/crop.go | 0.822368 | 0.533641 | crop.go | starcoder |
package machine
import (
"fmt"
"github.com/pseidemann/turingmachine/machine/tape"
)
// A Movement describes in which direction the machine's head will move.
type Movement int
// All possible movements of the machine's head.
const (
MoveNone Movement = iota
MoveLeft
MoveRight
)
// Machine is a Turing machine.
... | machine/machine.go | 0.686895 | 0.45847 | machine.go | starcoder |
package assert
import (
"errors"
"fmt"
"strings"
"testing"
"github.com/kode4food/ale/data"
"github.com/stretchr/testify/assert"
)
type (
// Any is the friendly name for a generic interface
Any interface{}
// Wrapper wraps the testify assertions module in order to perform
// checking and conversion that is... | internal/assert/wrapper.go | 0.704973 | 0.606877 | wrapper.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"regexp"
"strconv"
"strings"
)
/**
--- Day 4: Passport Processing ---
You arrive at the airport only to realize that you grabbed your North Pole Credentials instead of your passport. While these documents are extremely similar, North Pole Credentials aren't i... | day04.go | 0.526099 | 0.41745 | day04.go | starcoder |
package textrank
import (
"math"
"strings"
)
// minWordSentence is the minimum number of words a sentence can have to become
// a node in the graph.
const minWordSentence = 5
// RankSentences ranks the sentences in the given text based on the TextRank
// algorithm and returned a list of the ranked sentences in des... | backend/textrank/sentence.go | 0.661923 | 0.445831 | sentence.go | starcoder |
package arrays
// StringIndexOf returns the index of the given element in the given slice.
// -1 is returned if the element is not in the slice.
func StringIndexOf(slice []string, element string) int {
for i, e := range slice {
if e == element {
return i
}
}
return -1
}
// RuneIndexOf returns the index of ... | arrays/indexof.go | 0.870046 | 0.590602 | indexof.go | starcoder |
package main
import (
"errors"
"fmt"
"math"
"os"
"time"
)
const (
RSI_PERIODS = 14
)
type StockPrice struct {
open, close, high, low float64
}
type StockInstance struct {
periodTime time.Time
periodType string //This can ... | stocktools/stockutils.go | 0.575469 | 0.40489 | stockutils.go | starcoder |
package bsegtree
import (
"math"
"sort"
)
type node struct {
from uint64
to uint64
left, right *node
overlap []Interval
}
func (n *node) CompareTo(other Interval) int {
if other.From > n.to || other.To < n.from {
return DISJOINT
}
if other.From <= n.from && other.To >= n.to {
return SUBSET
}
re... | helper.go | 0.750553 | 0.423696 | helper.go | starcoder |
package pkg
// Package is a go package
type Package struct {
Qualifier string
Name string
BaseURL string
TypeDecls []TypeDecl
Iters []Iter
Clients []Client
}
// Type is type literal or qualified identifier. It may be used inline, or
// as part of a type declaration.
type Type interface {
Equal(Type) ... | pkg/pkg.go | 0.728265 | 0.402187 | pkg.go | starcoder |
package ckks
import (
"fmt"
"math"
"sort"
)
// PrecisionStats is a struct storing statistic about the precision of a CKKS plaintext
type PrecisionStats struct {
MaxDelta Stats
MinDelta Stats
MaxPrecision Stats
MinPrecision Stats
MeanDelta Stats
MeanPrecision Stats
MedianDelta ... | ckks/precision.go | 0.660282 | 0.584271 | precision.go | starcoder |
// This is an example of using type hierarchies with a OOP pattern.
// This is not something we want to do in Go. Go does not have the concept of sub-typing.
// All types are their own and the concepts of base and derived types do not exist in Go.
// This pattern does not provide a good design principle in a Go progra... | go/design/grouping_types_1.go | 0.634656 | 0.419172 | grouping_types_1.go | starcoder |
package openapi
import (
"encoding/json"
)
// QueryCollectionRequest A request to perform a search using a pipeline.
type QueryCollectionRequest struct {
Pipeline *QueryCollectionRequestPipeline `json:"pipeline,omitempty"`
// The initial values for the variables the pipeline operates on and transforms throughout ... | internal/openapi/model_query_collection_request.go | 0.870515 | 0.703651 | model_query_collection_request.go | starcoder |
package processor
import (
"fmt"
"sort"
"sync"
"time"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message/tracing"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/gabs/v2"
)... | lib/processor/workflow.go | 0.813275 | 0.793506 | workflow.go | starcoder |
package rtc
import "log"
// M4 is a 4x4 matrix.
type M4 [4]Tuple
// Get returns a value within the matrix.
func (m M4) Get(row, col int) float64 {
return m[row][col]
}
// Equal tests if two matrices are equal.
func (m M4) Equal(other M4) bool {
return m[0].Equal(other[0]) &&
m[1].Equal(other[1]) &&
m[2].Equal... | rtc/matrix.go | 0.901057 | 0.75611 | matrix.go | starcoder |
package cluster
import (
"errors"
"fmt"
"math"
)
var (
weightVector *DenseVector
)
// HammingDistance is a basic dissimilarity function for the kmodes algorithm.
func HammingDistance(a, b *DenseVector) (float64, error) {
if a.Len() != b.Len() {
return -1, errors.New("hamming distance: vectors lengths do not m... | cluster/distances.go | 0.823825 | 0.578448 | distances.go | starcoder |
package cost
import (
"sort"
)
var isPlanned = true
// Plan is the cost difference between two State instances. It is not tied to any specific cloud provider or IaC tool.
// Instead, it is a representation of the differences between two snapshots of cloud resources, with their associated
// costs. The Plan instance... | cost/plan.go | 0.747984 | 0.454714 | plan.go | starcoder |
package main
import (
"fmt"
"math/rand"
"os"
"strconv"
"strings"
"time"
lib "github.com/cncf/devstatscode"
yaml "gopkg.in/yaml.v2"
)
// metrics contain list of metrics to evaluate
type metrics struct {
Metrics []metric `yaml:"metrics"`
}
// metric contain each metric data
// some metrics can be allowed to ... | cmd/gha2db_sync/gha2db_sync.go | 0.57678 | 0.453927 | gha2db_sync.go | starcoder |
package stripe
import "encoding/json"
// CreditNoteReason is the reason why a given credit note was created.
type CreditNoteReason string
// List of values that CreditNoteReason can take.
const (
CreditNoteReasonDuplicate CreditNoteReason = "duplicate"
CreditNoteReasonFraudulent CreditNoteRe... | creditnote.go | 0.686685 | 0.443118 | creditnote.go | starcoder |
package peertest
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"go.uber.org/yarpc/api/peer"
)
// TransportDeps are passed through all the TransportActions in order to pass certain
// state in between Actions
type TransportDeps struct {
PeerIdentifiers map[string]peer.Identifier
Subscribers ... | api/peer/peertest/transportaction.go | 0.629433 | 0.433142 | transportaction.go | starcoder |
package image
import (
"strconv"
)
// A Point is an X, Y coordinate pair. The axes increase right and down.
type Point struct {
X, Y int
}
// String returns a string representation of p like "(3,4)".
func (p Point) String() string {
return "(" + strconv.Itoa(p.X) + "," + strconv.Itoa(p.Y) + ")"
}
// Add returns... | src/pkg/image/geom.go | 0.921645 | 0.625352 | geom.go | starcoder |
package model
import (
"math/rand"
"time"
"github.com/hculpan/go-sdl-lib/component"
)
type GameBoard [][]byte
type GameOfLife struct {
component.BaseGame
BoardWidth int
BoardHeight int
Cycle int
activeBoard *GameBoard
targetBoard *GameBoard
livingRatio float32
}
var Game *GameOfLife
func NewGameOfL... | app/model/gameoflife.go | 0.571049 | 0.443721 | gameoflife.go | starcoder |
package expression
import (
"time"
)
// ValueType represents the type of a value in an expression
type ValueType int
const (
// ValueTypeUnspecified is an unspecified type
ValueTypeUnspecified ValueType = iota
// ValueTypeString is a string
ValueTypeString
// ValueTypeSignedInt8 is a signed 8-bit integer
V... | pkg/expression/token.go | 0.661814 | 0.515315 | token.go | starcoder |
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/bouncer"
)
// Bouncer is the model entity for the Bouncer schema.
type Bouncer struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// CreatedAt holds the value of... | pkg/database/ent/bouncer.go | 0.629661 | 0.403214 | bouncer.go | starcoder |
package main
import (
"fmt"
"math"
"sync"
)
type Frame struct {
Ids []uint16 `json:"ids"`
Positions []float64 `json:"positions"`
}
type Vector3 struct {
X float64
Y float64
Z float64
}
type Point struct {
Acceleration *Vector3
Id uint16
Mass float64
Position *Vector3
Veloci... | simulator.go | 0.573678 | 0.608856 | simulator.go | starcoder |
// Package event provides support for event based telemetry.
package event
import (
"fmt"
"time"
)
type eventType uint8
const (
invalidType = eventType(iota)
LogType // an event that should be recorded in a log
StartSpanType // the start of a span of time
EndSpanType // the end of a span of time
La... | vendor/golang.org/x/tools/internal/telemetry/event/event.go | 0.601828 | 0.456349 | event.go | starcoder |
package plotter
import (
"errors"
"image/color"
"math"
"github.com/gonum/plot"
"github.com/gonum/plot/vg"
"github.com/gonum/plot/vg/draw"
)
// Bubbles implements the Plotter interface, drawing
// a bubble plot of x, y, z triples where the z value
// determines the radius of the bubble.
type Bubbles struct {
... | Godeps/_workspace/src/github.com/gonum/plot/plotter/bubbles.go | 0.894675 | 0.580798 | bubbles.go | starcoder |
package trace
import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/go-gl/mathgl/mgl64"
"math"
)
// TraverseBlocks performs a ray trace between the start and end coordinates.
// A function 'f' is passed which is called for each voxel, if f returns false, the function will return.
// TraverseBlocks pa... | server/block/cube/trace/trace.go | 0.806396 | 0.574066 | trace.go | starcoder |
package rusnum
import (
"math"
)
var (
tenthNumberCase = [3]string{"десятая", "десятых", "десятых"}
hundredthNumberCase = [3]string{"сотая", "сотых", "сотых"}
thousandthNumberCase = [3]string{"тысячная", "тысячных", "тысячных"}
tenthousandthNumberCase = [3]string{"десятитысячная", ... | fracInWords.go | 0.500977 | 0.529203 | fracInWords.go | starcoder |
package foundation
// #include "index_set.h"
import "C"
import (
"unsafe"
"github.com/hsiafan/cocoa/objc"
)
type IndexSet interface {
objc.Object
ContainsIndex(value uint) bool
ContainsIndexes(indexSet IndexSet) bool
ContainsIndexesInRange(_range Range) bool
IntersectsIndexesInRange(_range Range) bool
CountO... | foundation/index_set.go | 0.608943 | 0.490907 | index_set.go | starcoder |
package ring
import "github.com/gholt/holdme"
// BuilderNode is a node within a builder; a node represents a single
// assignment target of replicas of partitions, such as a single disk in a
// distributed storage system.
type BuilderNode struct {
builder *Builder
index int
info string
}
// Info returns the ... | buildernode.go | 0.847416 | 0.414247 | buildernode.go | starcoder |
package mat
import (
"math"
)
var black = NewColor(0, 0, 0)
var white = NewColor(1, 1, 1)
type Pattern interface {
PatternAt(point Tuple4) Tuple4
SetPatternTransform(transform Mat4x4)
GetTransform() Mat4x4
GetInverse() Mat4x4
}
func NewStripePattern(colorA Tuple4, colorB Tuple4) *StripePattern {
m1 := New4x4(... | internal/pkg/mat/pattern.go | 0.740737 | 0.540136 | pattern.go | starcoder |
package komblobulate
import (
"errors"
"fmt"
"io"
)
const (
ResistType_None = byte(0)
ResistType_Rs = byte(1)
CipherType_None = byte(0)
CipherType_Aead = byte(1)
)
// Given three things that might equal each other, finds the
// value that occurs at least twice according to the equality
// function, or nil ... | komblobulate.go | 0.627951 | 0.413063 | komblobulate.go | starcoder |
package value
import (
"strings"
)
type valueType int
const (
intType valueType = iota
charType
bigIntType
bigRatType
bigFloatType
vectorType
matrixType
numType
)
var typeName = [...]string{"int", "char", "big int", "rational", "float", "vector", "matrix"}
func (t valueType) String() string {
return typ... | vendor/robpike.io/ivy/value/eval.go | 0.593256 | 0.628122 | eval.go | starcoder |
package imgdiff
import (
"image"
"image/color"
"math"
"sync"
)
var (
// white values of XYZ colorspace
whiteX, whiteY, whiteZ float64
)
const (
// LAB colorspace
epsilon = 216.0 / 24389.0
kappa = 24389.0 / 27.0
)
func init() {
whiteX, whiteY, whiteZ = xyz(color.RGBA{0xff, 0xff, 0xff, 0xff}, 1)
}
type ... | perceptual.go | 0.635109 | 0.414366 | perceptual.go | starcoder |
package ungraph
import "fmt"
type EdgeInfo int // EdgeInfo, e.g. weight
type VertexType interface{} // VertexType, e.g. 1, 2, 3 or A, B, C
type Edge struct {
isVisited bool // mark that whether the current edge is visited
uIdx, vIdx int // the index of two vertices of the current ... | structure/graph/ungraph/graph.go | 0.54359 | 0.590366 | graph.go | starcoder |
package raft
import (
"errors"
"github.com/relab/raft/commonpb"
)
// Keys for indexing term and who was voted for.
const (
KeyTerm uint64 = iota
KeyVotedFor
KeyFirstIndex
KeyNextIndex
KeySnapshot
)
// Storage provides an interface for storing and retrieving Raft state.
type Storage interface {
Set(key uint6... | vendor/github.com/relab/raft/storage.go | 0.539226 | 0.420897 | storage.go | starcoder |
package geo
import (
"math"
"strings"
)
// decodePolylinePoints decodes encoded Polyline according to the polyline algorithm: https://developers.google.com/maps/documentation/utilities/polylinealgorithm
func decodePolylinePoints(encoded string, precision int) []float64 {
idx := 0
latitude := float64(0)
longitud... | pkg/geo/polyline.go | 0.840848 | 0.468669 | polyline.go | starcoder |
package model
import (
"fmt"
local "github.com/networkservicemesh/networkservicemesh/controlplane/api/local/connection"
"github.com/networkservicemesh/networkservicemesh/controlplane/api/nsm/connection"
remote "github.com/networkservicemesh/networkservicemesh/controlplane/api/remote/connection"
)
// DataplaneSta... | controlplane/pkg/model/dataplane.go | 0.699768 | 0.501709 | dataplane.go | starcoder |
package iplib
import (
"net"
"strings"
)
// Net describes an iplib.Net object, the enumerated functions are those that
// are required for comparison, sorting, generic initialization and for
// ancillary functions such as those found in the iid and iana submodules
type Net interface {
Contains(ip net.IP) bool
Con... | net.go | 0.638723 | 0.407451 | net.go | starcoder |
package flow
import (
"github.com/Shnifer/magellan/graph"
. "github.com/Shnifer/magellan/v2"
)
type updDrawPointer interface {
update(dt float64)
drawPoint(p Point, Q *graph.DrawQueue)
}
type Point struct {
lifeTime float64
maxTime float64
pos V2
updDraw updDrawPointer
attr map[string]float64
}
... | graph/flow/flow.go | 0.614394 | 0.407982 | flow.go | starcoder |
package kubernetes
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
)
func statefulSetSpecFields(isUpdatable bool) map[string]*schema.Schema {
s := map[string]*schema.Schema{
"pod_management_policy": {
Type: schema.TypeString,
Description: "C... | vendor/github.com/terraform-providers/terraform-provider-kubernetes/kubernetes/schema_stateful_set_spec.go | 0.610453 | 0.449755 | schema_stateful_set_spec.go | starcoder |
package unit
// Mass represents a SI unit of mass (in grams, G)
type Mass Unit
// ...
const (
// SI
Yoctogram = Gram * 1e-24
Zeptogram = Gram * 1e-21
Attogram = Gram * 1e-18
Femtogram = Gram * 1e-15
Picogram = Gram * 1e-12
Nanogram = Gram * 1e-9
Microgram = Gram * 1e-6
M... | mass.go | 0.849971 | 0.555676 | mass.go | starcoder |
package filter
import (
"fmt"
"strconv"
"sync/atomic"
"time"
"github.com/AdRoll/baker"
log "github.com/sirupsen/logrus"
)
const (
formatTimeHelp = `
This filter formats and converts date/time strings from one format to another.
It requires the source and destination field names along with 2 format strings, t... | filter/format_time.go | 0.676513 | 0.472014 | format_time.go | starcoder |
package fields
import (
"errors"
"fmt"
"github.com/robertkrimen/otto"
)
// Functions decodes, converts and validates payload using JavaScript functions
type Functions struct {
// Decoder is a JavaScript function that accepts the payload as byte array and
// returns an object containing the decoded values
Deco... | core/adapters/fields/functions.go | 0.845273 | 0.534552 | functions.go | starcoder |
package debug
// LogBuildDetails is no-op production alternative for the same function in present in debug build.
func LogBuildDetails() {}
// StartInjectionServer is no-op production alternative for the same function in present in debug build.
func StartInjectionServer() {}
// IsCSPCDeleteCollectionErrorInjected is... | pkg/debug/release.go | 0.62395 | 0.494507 | release.go | starcoder |
package internal
import (
"encoding/binary"
)
// Buffer is a variable-sized buffer of bytes with Read and Write methods.
// The zero value for Buffer is an empty buffer ready to use.
type Buffer interface {
ReadableBytes() uint32
WritableBytes() uint32
// Capacity returns the capacity of the buffer's underlyin... | pulsar/internal/buffer.go | 0.73782 | 0.535888 | buffer.go | starcoder |
package linemath
import (
"errors"
"fmt"
"math"
)
type Vector3 struct {
X float32
Y float32
Z float32
}
// CreateVector3 创建一个新的矢量
func CreateVector3(x, y, z float32) Vector3 {
return Vector3{
x,
y,
z,
}
}
// Vector3_Zero 返回零值
func Vector3_Zero() Vector3 {
return Vector3{
0,
0,
0,
}
}
// Vecto... | base/linemath/vector3.go | 0.652352 | 0.612252 | vector3.go | starcoder |
// Package padding provides functions for padding blocks of plain text in the
// context of block cipher mode of encryption like ECB or CBC.
package padding
import (
"bytes"
"errors"
)
// Padding interface defines functions Pad and Unpad implemented for PKCS #5 and
// PKCS #7 types of padding.
type Padding interfa... | padding/padding.go | 0.800185 | 0.639412 | padding.go | starcoder |
package app
import (
"fmt"
"regexp"
"sort"
"strings"
"github.com/spf13/cobra"
)
type e2eModeOptions struct {
name string
desc string
focus, skip string
parallel bool
}
const (
// E2eModeQuick runs a single E2E test and the systemd log tests.
E2eModeQuick string = "quick"
// E2eModeNonD... | cmd/sonobuoy/app/modes.go | 0.557845 | 0.469155 | modes.go | starcoder |
package exprxfunc
import (
"strings"
)
var iterator int
func Compose(expression string) string {
prefixExpression := infixToPrefix(expression)
expressionTree := prepareExpressionTree(prefixExpression)
var expressionSlice []string
expressionSlice = prepareExpression(expressionTree, expressionSlice)
return prepa... | compose.go | 0.524882 | 0.455622 | compose.go | starcoder |
package nnops
import (
G "gorgonia.org/gorgonia"
"gorgonia.org/tensor"
)
func Conv2d(im, filter *G.Node, kernelShape tensor.Shape, pad, stride, dilation []int) (retVal *G.Node, err error) {
var op *convolution
if op, err = makeConvolutionOp(im, filter, kernelShape, pad, stride, dilation); err != nil {
return n... | ops/nn/api_cuda.go | 0.777933 | 0.520618 | api_cuda.go | starcoder |
package physics
import (
"github.com/doxxan/glitch/math/vector"
"math"
)
type AABB struct {
Min, Max vector.Vec2
}
func AABBvsAABB(m *Manifold) bool {
a := m.b1
b := m.b2
normal := vector.Sub2(b.Position, a.Position)
abox := a.Box
bbox := b.Box
aXExtent := (abox.Max.X - abox.Min.X) / 2.0
bXExtent := (bb... | physics/physics.go | 0.869424 | 0.583025 | physics.go | starcoder |
package algo
import (
"sort"
)
type Sortable []int
func (s Sortable) Partition(left, right int) int {
// rightmost element
pivot_index := right
// pivot value
pivot := s[pivot_index]
// move right index to left
right -= 1
for {
// move left index to right as long
// as its value is less than the piv... | quicksort.go | 0.735831 | 0.480052 | quicksort.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.