code stringlengths 114 1.05M | path stringlengths 3 312 | quality_prob float64 0.5 0.99 | learning_prob float64 0.2 1 | filename stringlengths 3 168 | kind stringclasses 1
value |
|---|---|---|---|---|---|
package main
import (
"fmt"
"math"
"math/rand"
"time"
)
// number of points to search for closest pair
const n = 1e6
// size of bounding box for points.
// x and y will be random with uniform distribution in the range [0,scale).
const scale = 100.
// point struct
type xy struct {
x, y float64 // coordinates
k... | tasks/Closest-pair-problem/closest-pair-problem-2.go | 0.614163 | 0.572962 | closest-pair-problem-2.go | starcoder |
package pixelpusher
import (
"encoding/binary"
"image/color"
"github.com/xyproto/pf"
)
// Pixel draws a pixel to the pixel buffer
func Pixel(pixels []uint32, x, y int32, c color.RGBA, pitch int32) {
pixels[y*pitch+x] = binary.BigEndian.Uint32([]uint8{c.A, c.R, c.G, c.B})
}
// PixelRGB draws an opaque pixel to t... | pixel.go | 0.802594 | 0.550607 | pixel.go | starcoder |
// Package cputemp implements an i3bar module that shows the CPU temperature.
package cputemp
import (
"fmt"
"math"
"strconv"
"strings"
"time"
"github.com/spf13/afero"
"github.com/soumya92/barista/bar"
"github.com/soumya92/barista/base"
"github.com/soumya92/barista/outputs"
)
// Temperature represents the... | modules/cputemp/cputemp.go | 0.753013 | 0.417865 | cputemp.go | starcoder |
package filter
import (
"math"
)
// DoubleFilter matches against double values.
type DoubleFilter interface {
// Match returns true if the given value is considered a match.
Match(v float64) bool
}
const (
// doubleEps is used to determine whether two floating point numbers are considered equal.
doubleEps = 1e-... | filter/double_filter.go | 0.865181 | 0.663737 | double_filter.go | starcoder |
package datadog
import (
"encoding/json"
"time"
)
// UsageAuditLogsHour Audit logs usage for a given organization for a given hour.
type UsageAuditLogsHour struct {
// The hour for the usage.
Hour *time.Time `json:"hour,omitempty"`
// The total number of audit logs lines indexed during a given hour.
LinesIndex... | api/v1/datadog/model_usage_audit_logs_hour.go | 0.73307 | 0.414721 | model_usage_audit_logs_hour.go | starcoder |
package suggest
import (
"github.com/suggest-go/suggest/pkg/index"
"github.com/suggest-go/suggest/pkg/merger"
)
// Candidate is an item of Collector
type Candidate struct {
// Key is a position (docId) in posting list
Key index.Position
// Score is a float64 number that represents a score of a document
Score fl... | pkg/suggest/collector.go | 0.762336 | 0.415907 | collector.go | starcoder |
package binrpc
import (
"bytes"
"encoding/binary"
"fmt"
"io"
"log"
"math/rand"
)
/*
Kamailio's binrpc protocol consists of a variable-byte header
with an attached payload.
HEADER:
| 4 bits | 4 bits | 4 bits | 2b | 2b | variable | variable |
| BinRpcMagic | BinRpcVersion | Flags | LL | CL ... | binrpc/binrpc.go | 0.598782 | 0.424949 | binrpc.go | starcoder |
package ring
// NumberTheoreticTransformer is an interface to provide
// flexibility on what type of NTT is used by the struct Ring.
type NumberTheoreticTransformer interface {
Forward(r *Ring, p1, p2 *Poly)
ForwardLvl(r *Ring, level int, p1, p2 *Poly)
ForwardLazy(r *Ring, p1, p2 *Poly)
ForwardLazyLvl(r *Ring, lev... | ring/ring_ntt_interface.go | 0.798698 | 0.475484 | ring_ntt_interface.go | starcoder |
package main
import (
"math"
. "github.com/jakecoffman/cp"
"github.com/jakecoffman/cp/examples"
)
var dollyBody *Body
// Constraint used as a servo motor to move the dolly back and forth.
var dollyServo *PivotJoint
// Constraint used as a winch motor to lift the load.
var winchServo *SlideJoint
// Temporary jo... | examples/crane/crane.go | 0.637821 | 0.484136 | crane.go | starcoder |
package css
import (
"strings"
"golang.org/x/net/html"
)
// Represents a callback function that will be invoked when the default
// matching machinery couldn't match the given SimpleSelector and HTML node.
// If the callback function returns true it means that the node matches.
type SimpleSelectorMatchFunc func(S... | css/selector_matching.go | 0.701815 | 0.443781 | selector_matching.go | starcoder |
package aipreflect
import "google.golang.org/protobuf/reflect/protoreflect"
// MethodType is an AIP method type.
type MethodType int
//go:generate stringer -type MethodType -trimprefix MethodType
const (
// MethodTypeNone represents no method type.
MethodTypeNone MethodType = iota
// MethodTypeGet is the method... | reflect/aipreflect/methodtype.go | 0.645902 | 0.472562 | methodtype.go | starcoder |
package math3d
import "math"
// Matrix struct holds a 4x4 matrix
type Matrix struct {
X Vector
Y Vector
Z Vector
W Vector
}
// ToArray converts the matrix to its array representation
func (m Matrix) ToArray() []float64 {
ret := append(m.X.ToArray(), m.Y.ToArray()...)
ret = append(ret, m.Z.ToArray()...)
return... | math3d/matrix.go | 0.910743 | 0.752126 | matrix.go | starcoder |
package builder
import "encoding/json"
// A metric contains measurements or data points. Each data point has a time
// stamp of when the measurement occurred and a value that is either a long or
// double and optionally contains tags. Tags are labels that can be added to
// better identify the metric. For example, i... | vendor/github.com/ArthurHlt/go-kairosdb/builder/metric.go | 0.896518 | 0.591723 | metric.go | starcoder |
package genfuncs
import (
"fmt"
"golang.org/x/exp/constraints"
)
var (
// Orderings
LessThan = -1
EqualTo = 0
GreaterThan = 1
// Predicates
IsBlank = OrderedEqualTo("")
IsNotBlank = Not(IsBlank)
F32IsZero = OrderedEqualTo(float32(0.0))
F64IsZero = OrderedEqualTo(0.0)
IIsZero = OrderedEqual... | dry.go | 0.778186 | 0.673819 | dry.go | starcoder |
package main
import (
. "github.com/9d77v/leetcode/pkg/algorithm/math"
. "github.com/9d77v/leetcode/pkg/algorithm/unionfind"
)
/*
题目:岛屿的最大面积
给定一个包含了一些 0 和 1 的非空二维数组 grid 。
一个 岛屿 是由一些相邻的 1 (代表土地) 构成的组合,这里的「相邻」要求两个 1 必须在水平或者竖直方向上相邻。你可以假设 grid 的四个边缘都被 0(代表水)包围着。
找到给定的二维数组中最大的岛屿面积。(如果没有岛屿,则返回面积为 0 。)
注意: 给定的矩阵grid ... | internal/leetcode/695.max-area-of-island/main.go | 0.536313 | 0.434881 | main.go | starcoder |
package gost
import (
"errors"
"net"
)
var (
// ErrEmptyChain is an error that implies the chain is empty.
ErrEmptyChain = errors.New("empty chain")
)
// Chain is a proxy chain that holds a list of proxy nodes.
type Chain struct {
nodes []Node
}
// NewChain creates a proxy chain with proxy nodes nodes.
func Ne... | chain.go | 0.643441 | 0.419767 | chain.go | starcoder |
package dmr
// Data Type information element definitions, DMR Air Interface (AI) protocol, Table 6.1
const (
PrivacyIndicator uint8 = iota // Privacy Indicator information in a standalone burst
VoiceLC // Indicates the beginning of voice transmission, carries addressin... | packet.go | 0.611846 | 0.54056 | packet.go | starcoder |
package geo
import (
"math"
"github.com/golang/geo/s1"
"github.com/golang/geo/s2"
)
const (
// According to Wikipedia, the Earth's radius is about 6,371km
EARTH_RADIUS = 6371
)
// Geometry is a geometric shape that can be used to
// verify whether Geo point is contained in there or not.
type Geometry interface... | geo/geometry.go | 0.885693 | 0.62641 | geometry.go | starcoder |
package filter
import (
"gonum.org/v1/gonum/mat"
)
// Filter is a dynamical system filter.
type Filter interface {
// Predict returns a prediction of which will be
// next internal state
Predict(x, u mat.Vector) (Estimate, error)
// Update returns estimated system state based on external measurement ym.
Update(... | filter.go | 0.568536 | 0.587115 | filter.go | starcoder |
package math
import "math"
type Vector3 struct {
X float64
Y float64
Z float64
}
func (v *Vector3) Set( x, y, z float64) *Vector3{
v.X = x
v.Y = y
v.Z = z
return v
}
func (v *Vector3) SetScalar( scalar float64 ) *Vector3 {
v.X = scalar
v.Y = scalar
v.Z = scalar
return v
}
func (v *Vector3) SetX( x flo... | math/vector3.go | 0.703244 | 0.725065 | vector3.go | starcoder |
package model
import (
"fmt"
"strings"
"time"
"k8s.io/heapster/store/daystore"
"k8s.io/heapster/store/statstore"
)
// latestTimestamp returns its largest time.Time argument
func latestTimestamp(first time.Time, second time.Time) time.Time {
if first.After(second) {
return first
}
return second
}
// newIn... | vendor/k8s.io/heapster/model/util.go | 0.784195 | 0.416322 | util.go | starcoder |
package timing
import (
"github.com/knieriem/can"
)
const (
tq = 1
minPhSeg2 = 2 * tq
maxPhSeg2 = 8 * tq
maxPhSeg1 = 8 * tq
maxTSeg1 = maxProp + maxPhSeg1
maxProp = 8 * tq
syncSeg = 1 * tq
)
// Calculate a CANopen bit timing for a given oscillator frequency
// and the desired bitrate.
func CanOpe... | timing/calc.go | 0.623033 | 0.426979 | calc.go | starcoder |
package download_tracker
import (
"container/list"
"time"
"github.com/patrickmn/go-cache"
"github.com/turt2live/matrix-media-repo/util"
)
/*
* The download tracker works by keeping a limited number of buckets for each media record
* in an expiring cache. The number of buckets is the equal to the number of minu... | src/github.com/turt2live/matrix-media-repo/util/download_tracker/tracker.go | 0.658966 | 0.415373 | tracker.go | starcoder |
package v1alpha1
import (
"strings"
"golang.org/x/xerrors"
)
// Node represents a Task in a pipeline.
type Node struct {
// Task represent the PipelineTask in Pipeline
Task PipelineTask
// Prev represent all the Previous task Nodes for the current Task
Prev []*Node
// Next represent all the Next task Nodes fo... | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1/dag.go | 0.610802 | 0.40031 | dag.go | starcoder |
package example
// Adapted from: tour.golang.org
import (
"fmt"
)
func printSlice(action string, s []int) {
// len() is the number of elements in the slice while cap() is the max size of the underlying array
fmt.Printf("len=%d cap=%d %v - %s\n", len(s), cap(s), s, action)
}
func ranges() {
// Dropping the eleme... | chase/internal/pkg/example/arrays_slices.go | 0.656218 | 0.644952 | arrays_slices.go | starcoder |
package clocks
import (
"bytes"
"image/color"
"log"
"math"
"time"
"github.com/fogleman/gg"
"github.com/golang/freetype/truetype"
"golang.org/x/image/bmp"
"golang.org/x/image/font/gofont/goregular"
)
var (
colorTicks color.Color = color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0xFF}
colorArHo... | service/pac/clocks/analog.go | 0.614047 | 0.403773 | analog.go | starcoder |
package reflect
import "unsafe"
// Len returns v's length.
func (v MapValue) Len() int {
return maplen(v.pointer())
}
// MapIndex returns the value associated with key in the map v.
// It returns the zero Value if key is not found in the map or if v represents a nil map.
// As in Go, the key's value must be assigna... | reflect_map_value.go | 0.734881 | 0.459501 | reflect_map_value.go | starcoder |
package main
import (
"github.com/gen2brain/raylib-go/physics"
"github.com/gen2brain/raylib-go/raylib"
)
const (
velocity = 0.5
)
func main() {
screenWidth := float32(800)
screenHeight := float32(450)
raylib.SetConfigFlags(raylib.FlagMsaa4xHint)
raylib.InitWindow(int32(screenWidth), int32(screenHeight), "Phy... | examples/physics/physac/shatter/main.go | 0.629661 | 0.403537 | main.go | starcoder |
package darts
import (
"fmt"
"github.com/sbinet/npyio/npz"
"gonum.org/v1/gonum/mat"
"math"
)
type actFunc func(i, j int, v float64) float64
//DenseNet is a dense net
type DenseNet struct {
w mat.Matrix
b mat.Vector
active actFunc
}
//Sigmoid a active function
func Sigmoid(r, c int, z float64) float... | src/darts/netmodel.go | 0.594434 | 0.422207 | netmodel.go | starcoder |
package sort
// BubbleSort sorts slice by using bubble sort.
func BubbleSort(a []int) {
n := len(a)
if n <= 1 {
return
}
var flag bool
for i := 0; i < n; i++ {
flag = false
for j := 0; j < n-i-1; j++ {
if a[j] > a[j+1] {
a[j], a[j+1] = a[j+1], a[j]
flag = true
}
}
if !flag {
break
... | sort/sort.go | 0.615897 | 0.438785 | sort.go | starcoder |
package elliptic
import "math/big"
// CurveParams contains the parameters of an elliptic curve and also provides
// a generic, non-constant time implementation of Curve.
type CurveParams struct {
P *big.Int // the order of the underlying field
N *big.Int // the order of the base point
B *big.Int... | src/crypto/elliptic/params.go | 0.903959 | 0.727516 | params.go | starcoder |
package heartbeat
import (
"time"
"github.com/garyburd/redigo/redis"
)
// Heartbeater serves as a factory-type, in essence, to create both Hearts and
// Detectors. It maintains information about the ID used to heartbeat with, the
// Location in which to store ticks, the interval at which to update that
// location... | heartbeat/heartbeater.go | 0.639286 | 0.512083 | heartbeater.go | starcoder |
package smd
import (
"math"
"github.com/gonum/matrix/mat64"
)
const (
// EarthRotationRate is the average Earth rotation rate in radians per second.
EarthRotationRate = 7.292115900231276e-5
// EarthRotationRate2 is another value (project of StatOD).
EarthRotationRate2 = 7.29211585275553e-5
)
// Rot313Vec conv... | rotation.go | 0.845369 | 0.726741 | rotation.go | starcoder |
package view
import (
"github.com/viant/sqlx/io"
"github.com/viant/xunsafe"
"reflect"
"sync"
"unsafe"
)
//Visitor represents visitor function
type Visitor func(value interface{}) error
//Collector collects and build result from view fetched from Database
//If View or any of the View.With MatchStrategy support P... | view/collector.go | 0.569613 | 0.45423 | collector.go | starcoder |
// Package counterpair is an example using go-frp modeled after the Elm example found at:
// https://github.com/evancz/elm-architecture-tutorial/blob/master/examples/inception/CounterPair.elm
package counterpair
import (
"github.com/gmlewis/go-frp/v2/examples/inception/counter"
h "github.com/gmlewis/go-frp/v2/html"... | examples/inception/counterpair/counterpair.go | 0.821331 | 0.44553 | counterpair.go | starcoder |
package planar
import (
"log"
"math/big"
"github.com/go-spatial/geom"
)
const (
// Experimental testing produced this result.
// For finding the intersect we need higher precision.
// Then geom.PrecisionLevelBigFloat
PrecisionLevelBigFloat = 110
)
func AreLinesColinear(l1, l2 geom.Line) bool {
x1, y1 := l1... | planar/line_intersect.go | 0.68784 | 0.610889 | line_intersect.go | starcoder |
package syntax
import (
"regexp/syntax"
"unicode"
)
type charNodeMatcher interface {
Match(rune, syntax.Flags) bool
}
type reverseMatcher struct {
M charNodeMatcher
}
func (m reverseMatcher) Match(r rune, flags syntax.Flags) bool {
return !m.M.Match(r, flags)
}
type unicodeMatcher struct {
R *unicode.RangeTa... | syntax/matcher.go | 0.707607 | 0.450843 | matcher.go | starcoder |
package orm
import (
"bytes"
"context"
"github.com/goradd/goradd/web/examples/gen/goradd/model"
"github.com/goradd/goradd/web/examples/gen/goradd/model/node"
)
func (ctrl *ManyManyPanel) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error) {
buf.WriteString(`
<h1>Many-to-Many Relationships</h1>
<p... | web/examples/tutorial/orm/8-manymany.tpl.go | 0.575827 | 0.436022 | 8-manymany.tpl.go | starcoder |
package engine
import "math"
// Entity is a basic game entity.
type Entity interface {
Tick()
SetCollider(*Collider)
Position() Vec2
AddImage(...Image)
Images() []Image
Class() string
Dispose()
IsDisposed() bool
}
// CoreEntity is a default Entity implementation.
type CoreEntity struct {
Vec2
prevPos ... | engine/entity.go | 0.823612 | 0.438665 | entity.go | starcoder |
package main
import (
"bayesiannetwork"
"bufio"
"encoding/csv"
"fmt"
"io"
"math"
"math/rand"
"os"
"strconv"
)
func loadData(fname string) [][]float64 {
// Load a TXT file.
f, _ := os.Open(fname)
// Create a new reader.
r := csv.NewReader(bufio.NewReader(f))
data := make([][]float64, 0)
for {
recor... | example.go | 0.671794 | 0.410402 | example.go | starcoder |
package registration
import (
"context"
"testing"
"github.com/ory/kratos/ui/node"
"github.com/ory/x/assertx"
"github.com/bxcodec/faker/v3"
"github.com/gofrs/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/ory/kratos/x"
)
type FlowPersister interface {
UpdateR... | selfservice/flow/registration/persistence.go | 0.598077 | 0.593109 | persistence.go | starcoder |
package diff
import (
"github.com/liquidata-inc/dolt/go/libraries/doltcore/schema"
)
type SchemaChangeType int
const (
// SchDiffNone is the SchemaChangeType for two columns with the same tag that are identical
SchDiffNone SchemaChangeType = iota
// SchDiffAdded is the SchemaChangeType when a column is in the n... | go/libraries/doltcore/diff/schema_diff.go | 0.562898 | 0.593668 | schema_diff.go | starcoder |
package fuzzydice
import (
"errors"
"fmt"
"reflect"
"sort"
"strings"
)
// FuzzyDice describes a FuzzyDice instance with loaded objects. A single FuzzyDice instance can contain structures of
// varying types, as long as they share common fields for searching.
type FuzzyDice struct {
objects []object
}
// Load w... | fuzzydice.go | 0.784319 | 0.504639 | fuzzydice.go | starcoder |
package frenyard
// Constants
// SizeUnlimited is equal to the maximum value an int32 can have, represents an infinite value. Note that 0x80000000 is reserved; -0x7FFFFFFF is considered the definitive 'negative unlimited' value for simplicity's sake.
const SizeUnlimited int32 = 0x7FFFFFFF
// Vec2iUnlimited returns a... | frenyard/coreMaths.go | 0.900677 | 0.563738 | coreMaths.go | starcoder |
package el
import (
g "github.com/maragudk/gomponents"
)
// Address returns an element with name "address" and the given children.
func Address(children ...g.Node) g.NodeFunc {
return g.El("address", children...)
}
// Article returns an element with name "article" and the given children.
func Article(children ...g... | el/section.go | 0.86267 | 0.449816 | section.go | starcoder |
package main
import (
"math"
"github.com/ByteArena/box2d"
"github.com/wdevore/Ranger-Go-IGE/api"
"github.com/wdevore/Ranger-Go-IGE/extras/particles"
"github.com/wdevore/Ranger-Go-IGE/extras/shapes"
)
// Lava particle
type triPhysicsComponent struct {
particles.Particle
physicsComponent
categoryBits uint16 /... | examples/complex/physics/complex/c4_lava/tri_physics_component.go | 0.744285 | 0.480296 | tri_physics_component.go | starcoder |
package main
import (
"image/color"
"math"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/text"
"github.com/hajimehoshi/ebiten/vector"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
// Draws a block color polygon.
func drawPolygon(screen *ebiten.Image, clr color.Color, coordinates... | shared.go | 0.727298 | 0.459864 | shared.go | starcoder |
package day5
import (
"adventofcode/utils"
"fmt"
"strconv"
"strings"
)
func orderedPath(a int, b int) (int, int) {
if a < b {
return a, b
} else {
return b, a
}
}
func ParseWindMatrix(winds []string, parseDiagonal bool) [][]uint8 {
matrixDim := 1000
matrix := make([][]uint8, matrixDim)
for i := range m... | day5/day5.go | 0.680454 | 0.446857 | day5.go | starcoder |
package parser
import (
"os"
"github.com/goccy/go-graphviz/cgraph"
)
type Parser struct {
Data string
Index int
File *os.File
Graph *Graph
}
func (p *Parser) Block() {
block := p.Graph.AddNode("block")
if p.Data[p.Index] != LBRACE {
panic("Left brace '{' expected")
}
p.apply("")
lbrace := p.Graph.Ad... | rd_parser/parser/parser.go | 0.512937 | 0.48499 | parser.go | starcoder |
package ridge
import (
"github.com/gonum/matrix"
"github.com/gonum/matrix/mat64"
"fmt"
"math"
)
const BasicallyZero = 1.0e-15
func fmtMat(mat mat64.Matrix) fmt.Formatter {
return mat64.Formatted(mat, mat64.Excerpt(2), mat64.Squeeze())
}
type RidgeRegression struct {
X *mat64.Dense
XSVD *m... | vendor/github.com/berkmancenter/ridge/ridge.go | 0.799677 | 0.621139 | ridge.go | starcoder |
package flownetwork
import (
"bufio"
"fmt"
"io"
"github.com/wangyoucao577/algorithms_practice/graph"
)
// EdgeFlowUnit represent unit of capacity/flow of one edge
type EdgeFlowUnit int
// CapacityStorage represent capacities/residualCapacities on a flow network
type CapacityStorage map[graph.EdgeID]EdgeFlowUnit... | flownetwork/flownetwork.go | 0.806624 | 0.560553 | flownetwork.go | starcoder |
package losses
import (
"github.com/nlpodyssey/spago/ag"
"github.com/nlpodyssey/spago/mat"
)
// MAE measures the mean absolute error (a.k.a. L1 Loss) between each element in the input x and target y.
func MAE(x ag.Node, y ag.Node, reduceMean bool) ag.Node {
loss := ag.Abs(ag.Sub(x, y))
if reduceMean {
return a... | losses/losses.go | 0.909802 | 0.703575 | losses.go | starcoder |
package solver
import (
"fmt"
"github.com/erikbryant/magnets/board"
"github.com/erikbryant/magnets/common"
"github.com/erikbryant/magnets/magnets"
)
// justOne iterates through all empty cells. For any that have just one
// possibility left in the cbs, it sets that frame.
func (cbs CBS) justOne(game magnets.Game)... | solver/solver.go | 0.647687 | 0.406921 | solver.go | starcoder |
package rgb16
// Conversion of different RGB colorspaces with their native illuminators (reference whites) to CIE XYZ scaled to [0, 1e9] and back.
// RGB values MUST BE LINEAR and in the nominal range [0, 2^16].
// XYZ values are usually in [0, 1e9] but may be slightly outside this interval.
// To get quick and dir... | i16/rgb16/rgb.go | 0.717111 | 0.533276 | rgb.go | starcoder |
package bsc
import (
"github.com/jesand/stats"
"github.com/jesand/stats/channel"
"github.com/jesand/stats/dist"
"github.com/jesand/stats/factor"
"github.com/jesand/stats/variable"
"math/rand"
)
// Create a new binary symmetric channel with the specified noise rate.
func NewBSC(noiseRate float64) *BSC {
if nois... | channel/bsc/bsc.go | 0.794624 | 0.566258 | bsc.go | starcoder |
package ump
import (
"math"
)
type grid struct {
cellSize float32
rows map[int]map[int]*cell
}
func newGrid(cellSize int) *grid {
return &grid{
cellSize: float32(cellSize),
rows: make(map[int]map[int]*cell),
}
}
func (g *grid) update(body *Body) {
for _, c := range body.cells {
c.leave(body)
}
... | grid.go | 0.642993 | 0.405684 | grid.go | starcoder |
package fit
import (
"math"
)
func ConstantError1D(
x, y []float64, p0 []Parameter, f Func1D,
) (p, err []float64, cov [][]float64) {
pdf := ConstantError1DPDF(x, y, f)
sampler := NewSampler()
sampler.Run(pdf, p0, Steps(20000))
chains := sampler.Chains()
return chainStats(chains)
}
func Error1D(
x, y, yerr ... | fit.go | 0.540924 | 0.403655 | fit.go | starcoder |
package main
import (
"math"
"github.com/lucasb-eyer/go-colorful"
)
const (
colorPointRed = 0
colorPointGreen = 1
colorPointBlue = 2
)
// XY is a colour represented using the CIE colour space.
type XY struct {
X float64
Y float64
}
// colourPointsForModel returns the XY bounds for the specified lightbulb... | services/domotics/bridge/cmd/deconzd/color.go | 0.824638 | 0.497131 | color.go | starcoder |
package bitree
import (
"errors"
)
type BiTreeNode struct {
data interface{}
left *BiTreeNode
right *BiTreeNode
}
type BiTree struct {
size int
root *BiTreeNode
compare func(a, b interface{}) int
}
func NewBiTree() *BiTree {
return &BiTree{
size: 0,
root: nil,
}
}
var ErrByLogical = errors.New(... | golang/t_bitree/bitree/bitree.go | 0.590543 | 0.453746 | bitree.go | starcoder |
// Package washout provides washout filters
// to approximately display the sensation of vehicle motions.
package washout
import (
"math"
"github.com/shoarai/washout/internal/integral"
)
// A Washout is a washout filter.
type Washout struct {
TranslationScale, RotationScale float64
translationHighPassFilters *... | washout.go | 0.840684 | 0.595051 | washout.go | starcoder |
package values
import (
"encoding/csv"
"github.com/iancoleman/strcase"
"reflect"
"strings"
)
// NewImmutable creates a new immutable Values object
func NewImmutable(values map[string]interface{}) *ImmutableValues {
return &ImmutableValues{
values: values,
}
}
// New creates a new Values object
func New(valu... | pkg/helm/values/values.go | 0.680772 | 0.507202 | values.go | starcoder |
package mat
import (
"fmt"
"strings"
)
// Mat4 represents 4x4 matrix stored by (column * 4 + row) index.
// (Column is stored first to optimize memory access when transforming vector.)
type Mat4 [16]float32
func (m Mat4) Floats() [16]float32 {
return m
}
func (m Mat4) Mul(a Mat4) Mat4 {
var out Mat4
for i := 0... | mat/mat4.go | 0.561095 | 0.546738 | mat4.go | starcoder |
package payouts
// AdditionalData3DSecure struct for AdditionalData3DSecure
type AdditionalData3DSecure struct {
// This parameter indicates that you are able to process 3D Secure 2 transactions natively on your payment page. Send this field when you are using `/payments` endpoint with any of our [native 3D Secure 2 ... | src/payouts/model_additional_data3_d_secure.go | 0.826151 | 0.550909 | model_additional_data3_d_secure.go | starcoder |
package imageblk
import (
"fmt"
"math"
"strconv"
"sync"
"github.com/janelia-flyem/dvid/dvid"
"github.com/janelia-flyem/dvid/server"
"github.com/janelia-flyem/dvid/storage"
)
// ArbSlice is a 2d rectangle that can be positioned arbitrarily in 3D.
type ArbSlice struct {
topLeft dvid.Vector3d
topRight dvi... | datatype/imageblk/arb_image.go | 0.676834 | 0.494507 | arb_image.go | starcoder |
package bild
import (
"fmt"
"image"
"math"
)
// ConvolutionMatrix interface.
// At returns the matrix value at position x, y.
// Normalized returns a new matrix with normalized values.
// SideLength returns the matrix side length.
type ConvolutionMatrix interface {
At(x, y int) float64
Normalized() ConvolutionMa... | convolution.go | 0.895791 | 0.62498 | convolution.go | starcoder |
// Package frames describes the Frame interface.
// A set of standard frames are also defined in this package. These are: Fixed, Window, Wild and WildMin.
package frames
import (
"errors"
"strconv"
"github.com/sniperkit/xfilter/internal/bytematcher/patterns"
"github.com/sniperkit/xfilter/internal/persist"
)
// ... | internal/bytematcher/frames/frames.go | 0.836721 | 0.561696 | frames.go | starcoder |
package kclosestnumbers
import (
"container/heap"
"sort"
)
/*
Given a sorted number array and two integers ‘K’ and ‘X’, find ‘K’ closest numbers to ‘X’ in the array.
Return the numbers in the sorted order. ‘X’ is not necessarily present in the array.
Input: [5, 6, 7, 8, 9], K = 3, X = 7
Output: [6, 7, 8]
Input: [... | Pattern13 - Top K Elements/K_Closest_Numbers/solution.go | 0.829008 | 0.586641 | solution.go | starcoder |
package alteryx_formulas
import (
"math"
"math/rand"
"sort"
"strconv"
)
func (calc *calculator) addNumbers() {
add := func(left interface{}, right interface{}) interface{} {
return left.(float64) + right.(float64)
}
calc.ifNonNullLeftRight(add)
}
func (calc *calculator) subtractNumbers() {
subtract := func... | calculator_numbers.go | 0.620622 | 0.412767 | calculator_numbers.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPExpressionOperator244 struct for BTPExpressionOperator244
type BTPExpressionOperator244 struct {
BTPExpression9
BtType *string `json:"btType,omitempty"`
ForExport *bool `json:"forExport,omitempty"`
GlobalNamespace *bool `json:"globalNamespace,omitempty"`
ImportMi... | onshape/model_btp_expression_operator_244.go | 0.717804 | 0.456228 | model_btp_expression_operator_244.go | starcoder |
package camt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document02600105 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.026.001.05 Document"`
Message *UnableToApplyV05 `xml:"UblToApply"`
}
func (d *Document02600105) AddMessage() *UnableTo... | iso20022/camt/UnableToApplyV05.go | 0.722037 | 0.472623 | UnableToApplyV05.go | starcoder |
package core
import (
"context"
"github.com/jhump/golang-x-tools/internal/event/keys"
"github.com/jhump/golang-x-tools/internal/event/label"
)
// Log1 takes a message and one label delivers a log event to the exporter.
// It is a customized version of Print that is faster and does no allocation.
func Log1(ctx co... | internal/event/core/fast.go | 0.656768 | 0.423577 | fast.go | starcoder |
package ring
import (
"context"
"sort"
"time"
)
// ReplicationSet describes the ingesters to talk to for a given key, and how
// many errors to tolerate.
type ReplicationSet struct {
Ingesters []InstanceDesc
// Maximum number of tolerated failing instances. Max errors and max unavailable zones are
// mutually ... | vendor/github.com/cortexproject/cortex/pkg/ring/replication_set.go | 0.635109 | 0.40486 | replication_set.go | starcoder |
package trie
import (
"fmt"
"sort"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/util"
)
type trieNode struct {
trieKey *trieKey
value []byte
childrenCryptoHashes map[int][]byte
valueUpdated bool
childrenCryptoHashesUpdated map[int]bool
m... | core/ledger/statemgmt/trie/trie_node.go | 0.606032 | 0.430806 | trie_node.go | starcoder |
package labCode
/*
NetworkResponse create response messages for network.
All of the RPC are sent using these message functions. The functions will create a Response
object with the data it has to send. Then the MessageHandler function will send and retreive the response
from the other contact.
*/
// Will create a sim... | labCode/networkResponse.go | 0.733165 | 0.433921 | networkResponse.go | starcoder |
package condition
import (
"fmt"
"github.com/Jeffail/benthos/v3/internal/bloblang/mapping"
"github.com/Jeffail/benthos/v3/internal/bloblang/parser"
"github.com/Jeffail/benthos/v3/internal/bloblang/query"
"github.com/Jeffail/benthos/v3/internal/interop"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffai... | lib/condition/bloblang.go | 0.766075 | 0.672338 | bloblang.go | starcoder |
package command
import (
"strings"
"awesome-dragon.science/go/goGoGameBot/internal/interfaces"
)
// Data represents all the data available for a command call
type Data struct {
FromTerminal bool
Args []string
OriginalArgs string
Source string
Target string
Manager *Manager
util ... | internal/command/data.go | 0.716219 | 0.408159 | data.go | starcoder |
package iso20022
// Specifies corporate action dates.
type CorporateActionDate2 struct {
// Date on which positions are struck at the end of the day to note which parties will receive the relevant amount of entitlement, due to be distributed on payment date.
RecordDate *DateFormat4Choice `xml:"RcrdDt,omitempty"`
... | CorporateActionDate2.go | 0.791459 | 0.594669 | CorporateActionDate2.go | starcoder |
package app
// Window is the interface that describes a window.
type Window interface {
Navigator
Closer
// Position returns the window position.
Position() (x, y float64)
// Move moves the window to the position (x, y).
Move(x, y float64)
// Center moves the window to the center of the screen.
Center()
/... | window.go | 0.817574 | 0.41941 | window.go | starcoder |
package draw
import (
"image"
)
// String draws the string in the specified font, placing the upper left corner at p.
// It draws the text using src, with sp aligned to pt, using operation SoverD onto dst.
func (dst *Image) String(pt image.Point, src *Image, sp image.Point, f *Font, s string) image.Point {
dst.Disp... | vendor/9fans.net/go/draw/string.go | 0.833663 | 0.638723 | string.go | starcoder |
package evaluator
func (e *Evaluator) snapStartOfSecond() {
e.current = BeginningOfSecond(e.current)
}
func (e *Evaluator) snapStartOfMinute() {
e.current = BeginningOfMinute(e.current)
}
func (e *Evaluator) snapStartOfHour() {
e.current = BeginningOfHour(e.current)
}
func (e *Evaluator) snapStartOfDay() {
e.cu... | evaluator/evaluator_dates.go | 0.624408 | 0.592873 | evaluator_dates.go | starcoder |
package carbon
import (
"bytes"
"strconv"
"strings"
)
// ToTimestamp outputs a timestamp with second(will be removed from v2.0, only keep Timestamp).
// 输出秒级时间戳(将在v2.0版本移除,只保留 Timestamp)
func (c Carbon) ToTimestamp() int64 {
if c.IsInvalid() {
return 0
}
return c.Timestamp()
}
// ToTimestampWithSecond output... | outputer.go | 0.535827 | 0.434161 | outputer.go | starcoder |
// download contains a library for downloading data from logs.
package download
import (
"fmt"
"time"
backoff "github.com/cenkalti/backoff/v4"
"github.com/golang/glog"
)
// BatchFetch should be implemented to provide a mechanism to fetch a range of leaves.
// Enough leaves should be fetched to fully fill `leave... | clone/internal/download/batch.go | 0.563258 | 0.434761 | batch.go | starcoder |
package entity
import (
"errors"
"fmt"
"regexp"
"strconv"
// "agenda/loghelper"
)
// Date : class with y, m, d, h and m
type Date struct {
Year, Month, Day, Hour, Minute int
}
func (mDate Date) init(tYear, tMonth, tDay, tHour, tMinute int) {
mDate.Year = tYear
mDate.Month = tMonth
mDate.Day = tDay
mDate.Ho... | entity/date.go | 0.570571 | 0.511168 | date.go | starcoder |
package miscmodule
import (
"math/rand"
"sort"
"strconv"
"strings"
bot "../sweetiebot"
"github.com/erikmcclure/discordgo"
)
const maxShowDice int64 = 250
type showrollCommand struct {
}
func (c *showrollCommand) Info() *bot.CommandInfo {
return &bot.CommandInfo{
Name: "ShowRoll",
Usage: ... | miscmodule/ShowRollCommand.go | 0.595728 | 0.498535 | ShowRollCommand.go | starcoder |
package cron
import "time"
// Now returns a new timestamp.
func Now() time.Time {
return time.Now().UTC()
}
// Since returns the duration since another timestamp.
func Since(t time.Time) time.Duration {
return Now().Sub(t)
}
// Min returns the minimum of two times.
func Min(t1, t2 time.Time) time.Time {
if t1.Is... | cron/util.go | 0.837753 | 0.557725 | util.go | starcoder |
package captcha
import (
"image"
"image/color"
"image/draw"
"math"
"github.com/golang/freetype"
"github.com/golang/freetype/truetype"
)
// Image 图片
type Image struct {
*image.RGBA
}
// NewImage 创建一个新的图片
func NewImage(w, h int) *Image {
img := &Image{image.NewRGBA(image.Rect(0, 0, w, h))}
return img
}
func... | vendor/github.com/afocus/captcha/draw.go | 0.52829 | 0.425367 | draw.go | starcoder |
package sudoku
import (
"math"
"math/rand"
)
//ProbabilityDistribution represents a distribution of probabilities over
//indexes.
type ProbabilityDistribution []float64
//Normalized returns true if the distribution is normalized: that is, the
//distribution sums to 1.0
func (d ProbabilityDistribution) normalized()... | probability_distribution.go | 0.745584 | 0.604399 | probability_distribution.go | starcoder |
package iso20022
// Provides information related to the collateral position, that is, the identification of the exposed party, the total exposure amount and the total collateral amount held by the taker. It also contains the valuation dates and the requested settlement date of collateral if there is a shortage of coll... | Summary1.go | 0.813609 | 0.542742 | Summary1.go | starcoder |
package goslice
import "golang.org/x/exp/constraints"
// SumSlice returns the sum of all the elements in the given slice.
// No attempt is made to detect overflow.
func SumSlice[T constraints.Ordered](elems []T) T {
var sum T
for _, elem := range elems {
sum += elem
}
return sum
}
// ProdSlice returns the prod... | alg.go | 0.837819 | 0.549278 | alg.go | starcoder |
package ach
import (
"strings"
"unicode/utf8"
)
// ADVFileControl record contains entry counts, dollar totals and hash
// totals accumulated from each batchADV control record in the file.
type ADVFileControl struct {
// ID is a client defined string used as a reference to this record.
ID string `json:"id"`
// R... | advFileControl.go | 0.618435 | 0.483831 | advFileControl.go | starcoder |
package eml
// A Solution describes an event sourced system
// It will contain bounded contexts and meta information about what environment to deploy it to.
// It can also contain references to other bounded contexts from the 'PlayStore' (Context Store? Microservice Store?
type Solution struct {
EmlVersion string ... | pkg/eml/eml_specification.go | 0.760473 | 0.426799 | eml_specification.go | starcoder |
package spy
import (
"reflect"
)
type Matcher interface {
//Match matches provided value against conditions and returns true or false
// this method should not panic
Match(actual interface{}) bool
}
type stringMatcher struct {
value string
}
func (m stringMatcher) Match(a interface{}) bool {
v, ok := a.(strin... | matchers.go | 0.855911 | 0.410047 | matchers.go | starcoder |
package chessboard
type PieceInterface interface {
Movements() []PieceMovement
Symbol() string
}
// Piece is a generic piece
type Piece struct {
Board *Board
XPos int
YPos int
PieceInterface
}
func (p *Piece) GetIndex() (BoardIndex, error) {
return p.Board.CoordinatesToIndex(Coordinates{p.XPos, p.YPos})
}
... | piece.go | 0.818229 | 0.425904 | piece.go | starcoder |
package main
import (
"bufio"
"log"
"math"
"os"
"sort"
)
const (
Empty = '.'
Asteroid = '#'
)
func angle(x, y, xi, yi int) float64 {
dx, dy := xi-x, yi-y
deg := (math.Atan2(float64(dy), float64(dx)) * 180) / math.Pi
if deg < 0 {
deg += 360
}
// munge to match coordinate system of grid
deg += 90
... | 2019/10/main.go | 0.68784 | 0.461684 | main.go | starcoder |
package curve
import "github.com/oasisprotocol/curve25519-voi/internal/field"
const (
// CompressedPointSize is the size of a compressed point in bytes.
CompressedPointSize = 32
// MontgomeryPointSize is the size of the u-coordinate of a point on
// the Montgomery form in bytes.
MontgomeryPointSize = 32
// R... | curve/constants.go | 0.549399 | 0.54583 | constants.go | starcoder |
package main
import astar "github.com/beefsack/go-astar"
type tile struct {
x int
y int
visual rune
area area
creature *creature
}
func newTile(x, y int, a area) *tile {
return &tile{
x: x,
y: y,
visual: ' ',
area: a,
}
}
func (t *tile) getNeighbour(direction int) *til... | day15b/tile.go | 0.60288 | 0.498169 | tile.go | starcoder |
package sandbox
import (
"encoding/json"
)
// SandboxInsertBeamStatsRequestBeamStatsMap struct for SandboxInsertBeamStatsRequestBeamStatsMap
type SandboxInsertBeamStatsRequestBeamStatsMap struct {
InHttp *SandboxBeamCounts `json:"inHttp,omitempty"`
InMqtt *SandboxBeamCounts `json:"inMqtt,omitempty"`
InTcp *Sandb... | openapi/sandbox/model_sandbox_insert_beam_stats_request_beam_stats_map.go | 0.696371 | 0.58261 | model_sandbox_insert_beam_stats_request_beam_stats_map.go | starcoder |
package main
import (
"github.com/ByteArena/box2d"
"github.com/wdevore/Ranger-Go-IGE/api"
"github.com/wdevore/Ranger-Go-IGE/engine/rendering/color"
"github.com/wdevore/Ranger-Go-IGE/extras/shapes"
)
type fencePhysicsComponent struct {
physicsComponent
bottomLineNode api.INode
rightLineNode api.INode
topLine... | examples/complex/physics/complex/c2_zones/fence_physics_component.go | 0.681409 | 0.463991 | fence_physics_component.go | starcoder |
package integration
import (
"errors"
"testing"
"time"
"github.com/devhossamali/ari"
"github.com/devhossamali/ari/rid"
tmock "github.com/stretchr/testify/mock"
)
var _ = tmock.Anything
var nonEmpty = tmock.MatchedBy(func(s string) bool { return s != "" })
func TestChannelData(t *testing.T, s Server) {
key :... | internal/integration/channel.go | 0.553505 | 0.466481 | channel.go | starcoder |
package solidserver
import (
"encoding/json"
"fmt"
"github.com/hashicorp/terraform/helper/schema"
"log"
"net/url"
"regexp"
"strconv"
"strings"
)
func dataSourcednsview() *schema.Resource {
return &schema.Resource{
Read: dataSourcednsviewRead,
Schema: map[string]*schema.Schema{
"name": {
Type: ... | solidserver/data_source_dns_view.go | 0.529263 | 0.410579 | data_source_dns_view.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.