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 aoc2021
import (
"fmt"
"strconv"
"strings"
)
/*
--- Day 11: Dumbo Octopus ---
You enter a large cavern full of rare bioluminescent dumbo octopuses! They seem to not like the Christmas lights on your submarine, so you turn them off for now.
There are 100 octopuses arranged neatly in a 10 by 10 grid. Each o... | app/aoc2021/aoc2021_11.go | 0.637934 | 0.496216 | aoc2021_11.go | starcoder |
package pixelpusher
import (
"encoding/binary"
"image/color"
"sync"
)
// pointInTriangle tries to decide if the given x and y are within the triangle defined by p0, p1 and p2
// area is 1.0 divided on (the area of the triangle, times 2)
func pointInTriangle(x, y int32, p0, p1, p2 *Pos, areaMod float32) bool {
s :... | triangle.go | 0.681515 | 0.640622 | triangle.go | starcoder |
package cmd
import (
"os"
"strings"
"time"
"github.com/ryanberckmans/est/core"
"github.com/spf13/cobra"
)
var scheduleCmd = &cobra.Command{
Use: "schedule",
Short: "Display a predicted, probabilistic schedule for unstarted, estimated tasks",
Long: `Display a predicted, probabilistic schedule for unstarted,... | cmd/schedule.go | 0.590189 | 0.531392 | schedule.go | starcoder |
package tree
// Visitor visits every node in the tree. The visitor-pattern is used to traverse
// the grammar-tree. Every tree-node has an 'Accept' method that lets the visitor
// visit itself and all of its children. In contrast to many visitor-pattern
// implementations, the visitor is not an interface. It has a lot... | pkg/compiler/grammar/tree/visitor.go | 0.658966 | 0.574037 | visitor.go | starcoder |
package model2d
import (
"fmt"
"math"
"github.com/heustis/tsp-solver-go/model"
)
// Edge2D represents the line segment between two points.
type Edge2D struct {
Start *Vertex2D `json:"start"`
End *Vertex2D `json:"end"`
vector *Vertex2D
length float64
}
// DistanceIncrease returns the difference in length ... | model2d/edge2d.go | 0.91837 | 0.777553 | edge2d.go | starcoder |
package Euler2D
import (
"fmt"
"image/color"
"time"
"github.com/notargets/avs/chart2d"
"github.com/notargets/avs/functions"
graphics2D "github.com/notargets/avs/geometry"
utils2 "github.com/notargets/avs/utils"
"github.com/notargets/gocfd/utils"
)
type PlotMeta struct {
Plot bool
Scale ... | model_problems/Euler2D/plot.go | 0.70304 | 0.4575 | plot.go | starcoder |
package model
import (
"fmt"
"reflect"
"strconv"
)
// Model is an utility type to access and manipulate struct informations.
type Model struct {
Fields []Field // field fields (pointers to fields)
ref interface{}
tag string
}
func structType(s interface{}) reflect.Value {
v := reflect.ValueOf(s)
if v.... | model.go | 0.720172 | 0.463809 | model.go | starcoder |
package strmatcher
import (
"math/bits"
"sort"
"strings"
"unsafe"
)
// PrimeRK is the prime base used in Rabin-Karp algorithm.
const PrimeRK = 16777619
// RollingHash calculates the rolling murmurHash of given string based on a provided suffix hash.
func RollingHash(hash uint32, input string) uint32 {
for i := ... | common/strmatcher/matchergroup_mph.go | 0.685318 | 0.455441 | matchergroup_mph.go | starcoder |
package main
import (
"math"
"math/rand"
)
// Distribution provides an interface to model a statistical distribution.
type Distribution interface {
Advance()
Get() float64 // should be idempotent
}
// NormalDistribution models a normal distribution.
type NormalDistribution struct {
Mean float64
StdDev float6... | cmd/bulk_data_gen/distribution.go | 0.925626 | 0.627152 | distribution.go | starcoder |
package data
import (
"math"
"github.com/calummccain/coxeter/vector"
)
const (
eVal53n = 3.0884042547 // math.Pi / math.Atan(P)
pVal53n = 6.0
eVal53nTrunc = 3.0884042547 // math.Pi / math.Atan(P)
pVal53nTrunc = 11.465072284 // math.Pi / math.Atan(math.Sqrt(1.0/(7.0+4.0*Rt2)))
eVal53nRect = 3.0884042547 // m... | data/53n.go | 0.508544 | 0.569553 | 53n.go | starcoder |
package stat
import (
"math"
"sort"
"strings"
"fmt"
"net/url"
)
// Return p percentil of pre-sorted integer data. 0 <= p <= 100.
func PercentilInt(data []int, p int) int {
n := len(data)
if n == 0 {
return 0
}
if n == 1 {
return data[0]
}
pos := float64(p) * float64(n+1) / 100
fpos := math.Floor(pos... | stat/stat.go | 0.544801 | 0.46873 | stat.go | starcoder |
package chart
import "math"
var (
// Draw contains helpers for drawing common objects.
Draw = &draw{}
)
type draw struct{}
// LineSeries draws a line series with a renderer.
func (d draw) LineSeries(r Renderer, canvasBox Box, xrange, yrange Range, style Style, vs ValueProvider) {
if vs.Len() == 0 {
return
}
... | vendor/github.com/nicholasjackson/bench/vendor/github.com/wcharczuk/go-chart/draw.go | 0.728845 | 0.448607 | draw.go | starcoder |
package scalars
import (
"strconv"
"github.com/saturn4er/graphql"
"github.com/saturn4er/graphql/language/ast"
"github.com/saturn4er/graphql/language/kinds"
"github.com/EGT-Ukraine/go2gql/api/multipart_file"
)
var GraphQLInt64Scalar = graphql.NewScalar(graphql.ScalarConfig{
Name: "Int64",
Description: "The `I... | api/scalars/scalars.go | 0.649245 | 0.460532 | scalars.go | starcoder |
package balancedtree
import (
"fmt"
"math"
"github.com/puxin71/DesignPatternInGo/linklist"
"github.com/puxin71/DesignPatternInGo/queue"
)
type Node struct {
Value int
LeftChild *Node
RightChild *Node
}
type binaryTree struct {
root *Node
nodeCount int
height int
}
type BinaryTree interface ... | balancedtree/tree.go | 0.636918 | 0.416085 | tree.go | starcoder |
package types
import "strconv"
// Analysis files, file settings, analysis settings and column mapping.
type Analysis struct {
Columns map[string]string
Data []map[string]string
Settings Settings
}
// CircHeatmap is a circular heatmap plot
type CircHeatmap struct {
Name string `json:"name"`... | pkg/types/settings.go | 0.725649 | 0.468487 | settings.go | starcoder |
package republique
import (
"fmt"
"math"
)
// Waypoint data for each segment of a move order
type Waypoint struct {
X int32
Y int32
X2 int32
Y2 int32
Speed float64
Elapsed float64
Turns int
Going string
Distance float64
Path string
Prep bool
}
// GetValue gets... | proto/map.go | 0.543106 | 0.415314 | map.go | starcoder |
package gcm
import (
"encoding/binary"
)
// gcmFieldElement represents a value in GF(2¹²⁸). In order to reflect the GCM
// standard and make binary.BigEndian suitable for marshaling these values, the
// bits are stored in big endian order. For example:
// the coefficient of x⁰ can be obtained by v.low >> 63.
// ... | internal/gcm/gcm.go | 0.753467 | 0.439086 | gcm.go | starcoder |
package dslengine
import "fmt"
type (
// Definition is the common interface implemented by all definitions.
Definition interface {
// Context is used to build error messages that refer to the definition.
Context() string
}
// DefinitionSet contains DSL definitions that are executed as one unit.
// The slic... | dslengine/definitions.go | 0.726037 | 0.475849 | definitions.go | starcoder |
package bullet3
// #cgo CFLAGS: -I"./bullet3/lib/include/bullet" -I"./bullet3/lib/include/bullet_robotics" -I"./bullet3/lib/include/bullet" -I"./bullet3/lib/include"
// #cgo LDFLAGS: -L./bullet3/lib/lib -lBulletRobotics -lBulletInverseDynamics -lBulletInverseDynamicsUtils -l BulletFileLoader -l BulletWorldImporter -lB... | bullet.go | 0.608129 | 0.420064 | bullet.go | starcoder |
package merger
import (
"fmt"
"reflect"
)
// Merge merges a and b together where b has precedence.
// It is not destructive on their parameters, but these must not be modified while
// merge is in progress.
func Merge(a interface{}, b interface{}) (interface{}, error) {
aKind := reflect.ValueOf(a).Kind()
bKind :=... | merge.go | 0.52902 | 0.458409 | merge.go | starcoder |
package ast
// Yes, a lot of the right end points of the statements are off by one, and
// will also error out because of null exceptions in probably half of the
// cases. I will come back to this later but I seriously cannot be arsed right
// now.
import (
"strings"
"github.com/yjp20/turtle/straw/token"
)
type N... | straw/ast/ast.go | 0.526099 | 0.45944 | ast.go | starcoder |
package main
import "container/heap"
/*
题目:
如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个数的平均值。
例如,
[2,3,4] 的中位数是 3
[2,3] 的中位数是 (2 + 3) / 2 = 2.5
设计一个支持以下两种操作的数据结构:
void addNum(int num) - 从数据流中添加一个整数到数据结构中。
double findMedian() - 返回目前所有元素的中位数。
限制:
最多会对 addNum、findMedian... | internal/lcof/41.shu-ju-liu-zhong-de-zhong-wei-shu/main.go | 0.537041 | 0.403567 | main.go | starcoder |
package ccopy
import (
"errors"
"fmt"
"reflect"
)
const tagCcopy = "ccopy"
// Config represents the config for the customizable deep copy.
// Maps between tag value and functions that receive the tagged data and return the same data type.
type Config map[string]interface{}
// Copy deep copies an object respectin... | ccopy.go | 0.564339 | 0.528473 | ccopy.go | starcoder |
package main
import (
"image"
"image/color"
"log"
"github.com/tajtiattila/blur"
)
func process(current, previous image.Image) image.Image {
img := AbsDiff(blur.Gaussian(previous, 18, blur.ReuseSrc), blur.Gaussian(current, 18, blur.ReuseSrc))
img = blur.Gaussian(img, 12, blur.ReuseSrc)
return Threshold(img, 10... | examples/motion/image.go | 0.648689 | 0.416915 | image.go | starcoder |
package bp3d
import (
"fmt"
"math"
"sort"
)
// Bin represents a container in which items will be put into.
type Bin struct {
Name string
Width float64
Height float64
Depth float64
MaxWeight float64
Items []*Item // Items that packed in this bin
}
type BinSlice []*Bin
func (bs BinSlice) Len... | bp3d.go | 0.775605 | 0.474509 | bp3d.go | starcoder |
package query
import (
"fmt"
"strings"
)
type InsertQuery struct {
table string
ignore bool
columns []string
duplicates []string
values [][]string
placeholder Placeholder
}
func NewInsert(t string) InsertQuery {
return InsertQuery{
table: t,
... | insert.go | 0.511229 | 0.4081 | insert.go | starcoder |
package tpl
func DefaultModels() map[string]Description {
models := make(map[string]Description)
models["basic"] = Description{
Short: "'basic' is default. This model provides data about current project, developer etc",
Long: `Use the basic model if the template you are creating don't has the
need for a single... | src/tpl/defaults.go | 0.747524 | 0.518607 | defaults.go | starcoder |
package state
import (
"github.com/abchain/fabric/core/ledger/statemgmt"
"strings"
)
// CompositeRangeScanIterator - an implementation of interface 'statemgmt.RangeScanIterator'
// This provides a wrapper on top of more than one underlying iterators
type CompositeRangeScanIterator struct {
itrs []*statemgmt... | core/ledger/statemgmt/state/composite_range_scan_iterator.go | 0.538255 | 0.401336 | composite_range_scan_iterator.go | starcoder |
package date
import (
"fmt"
"time"
)
type Date struct {
tm time.Time
}
const timeFmt = "2006-01-02"
func Today() Date {
return FromTime(time.Now())
}
func TodayIn(loc *time.Location) Date {
return FromTime(time.Now().In(loc))
}
func Parse(s string) (Date, error) {
tm, err := time.ParseInLocation(timeFmt, s,... | date.go | 0.666171 | 0.4436 | date.go | starcoder |
package mysql
import (
"time"
"gitlab.jiagouyun.com/cloudcare-tools/datakit/io"
"gitlab.jiagouyun.com/cloudcare-tools/datakit/plugins/inputs"
)
type dbmMetric struct {
Enabled bool `toml:"enabled"`
}
type dbmStateMeasurement struct {
name string
tags map[string]string
fields map[string]interface{}
ts ... | plugins/inputs/mysql/dbm_statements.go | 0.563258 | 0.46478 | dbm_statements.go | starcoder |
package problem023
import "math"
type queue struct {
innerSlice []boardState
}
type queueEmpty struct{}
func (err queueEmpty) Error() string {
return "queue empty"
}
func newQueue(len int, cap int) *queue {
return &queue{innerSlice: make([]boardState, len, cap)}
}
func (q *queue) enqueue(item boardState) {
q.... | problem023/problem023.go | 0.61057 | 0.419113 | problem023.go | starcoder |
package util
import (
"github.com/uncharted-distil/distil-compute/primitive/compute"
)
const (
// Accuracy identifies model metric based on nearness to the original result.
Accuracy = "accuracy"
// F1 identifies model metric based on precision and recall
F1 = "f1"
// F1Micro identifies model metric based on p... | api/util/metrics.go | 0.657318 | 0.490236 | metrics.go | starcoder |
package mat64
import (
"github.com/gonum/blas"
"github.com/gonum/blas/blas64"
)
var (
symDense *SymDense
_ Matrix = symDense
_ Symmetric = symDense
_ RawSymmetricer = symDense
)
const (
ErrUplo = "mat64: blas64.Symmetric not upper"
)
// SymDense is a symmetric matrix that uses Dense storage.
ty... | gocv/Godeps/_workspace/src/github.com/gonum/matrix/mat64/symmetric.go | 0.693473 | 0.44746 | symmetric.go | starcoder |
package graphs
type Graph struct {
nodes map[string]bool // Set of nodes
// Map of neighbours. Key is source node and value another map where key is destination node and value is cost
edges map[string]map[string]int
// Destination map represents nodes which are pointing edges towards key
re... | collections/graphs/graph.go | 0.750827 | 0.633297 | graph.go | starcoder |
package suvec
import (
"log"
)
type Type int
const (
Matrix64 Type = iota
Box
Point3d
ErrorMatrix
)
type ErrorCode int
const (
MatchingDimensions = iota
NotSquareMatrix
NotImplemented
NotAScalarType
)
type Mat struct {
typ Type
rows, cols int
data []float64
}
/** Iehandle Internal error ... | lib/basic.go | 0.676192 | 0.534734 | basic.go | starcoder |
package trail
import (
"fmt"
"strconv"
)
// RFID15 is a 15 decimal implant number based on ISO 11784 & 11785.
// The data is packed in the 48 least significant bits.
type RFID15 uint64
// ParseRFID15 returns the parsed value if, and only if, s is syntactically correct.
func ParseRFID15(s string) RFID15 {
if len(... | id.go | 0.757884 | 0.421909 | id.go | starcoder |
package dorp
import (
"errors"
"fmt"
"io"
"golang.org/x/crypto/nacl/secretbox"
)
// A SetMessage is the Go representation of the JSON message
// sent to set states
type SetMessage struct {
DoorState string
LightState string
}
// A State is a binary condition of the door or lights.
type State byte
//go:gene... | dorp.go | 0.604866 | 0.407569 | dorp.go | starcoder |
package golist
import (
"fmt"
"math/rand"
"sort"
"time"
)
// SliceByte is a slice of type byte.
type SliceByte struct {
data []byte
}
// NewSliceByte returns a pointer to a new SliceByte initialized with the specified elements.
func NewSliceByte(elems ...byte) *SliceByte {
s := new(SliceByte)
s.data = make([... | slice_byte.go | 0.807916 | 0.557002 | slice_byte.go | starcoder |
package main
var (
version = "devel-release"
commit = "unknown-hash"
date = "unknown-date"
)
const (
gomodShort = "A tool to visualise and analyse a Go project's dependency graph."
gomodLong = `A CLI tool for interacting with your Go project's dependency graph on various
levels. See the online documentation... | main_strings.go | 0.799951 | 0.437103 | main_strings.go | starcoder |
package common
// AlgorithmID encodes symmetric algorithm parameters for Soter.
type AlgorithmID uint32
const (
algorithmMask = 0xF0000000
algorithmOffset = 28
kdfMask = 0x0F000000
kdfOffset = 24
paddingMask = 0x000F0000
paddingOffset = 16
keyLengthMask = 0x00000FFF
keyLengthOffset = 0... | themis/spec/common/soter-alg.go | 0.698535 | 0.402921 | soter-alg.go | starcoder |
package response
// Python-related response types
const (
PythonDocumentationType = "python_documentation"
PythonSignaturePatternType = "python_signatures"
PythonSignatureCompletionsType = "python_signature_completions"
PythonCompletionsType = "python_completions"
PythonSuggestionsType ... | kite-go/response/python.go | 0.73173 | 0.422803 | python.go | starcoder |
package symexpr
import (
"fmt"
"math"
)
func (*Time) Eval(t float64, x, c, s []float64) float64 { return t }
func (v *Var) Eval(t float64, x, c, s []float64) float64 { return x[v.P] }
func (cnst *Constant) Eval(t float64, x, c, s []float64) float64 { return c[cnst.P] }
func (cnst *ConstantF) Eval(t float64, x, c... | eval.go | 0.627609 | 0.540439 | eval.go | starcoder |
package point
import (
"fmt"
"github.com/aiseeq/s2l/protocol/api"
"math"
"math/cmplx"
"sort"
)
type Pointer interface {
Point() Point
}
type Point complex128
type Points []Point
type Filter func(pt Point) bool
type Line struct {
A, B Point
}
type Lines []Line
type Circle struct {
Point
R float64
}
func Pt(... | lib/point/point.go | 0.792143 | 0.448426 | point.go | starcoder |
package genmap2d
import (
"image/color"
)
// Various tile IDs.
const (
TileIDGrass byte = iota
TileIDWater
TileIDTree
TileIDSand
TileIDMountain
TileIDSnow
TileIDVillage
TileIDMax
)
// TileFromHeight returns the tile ID for a given height.
func (m *Map) TileFromHeight(h int) byte {
if h <= 0 {
return Tile... | genmap2d/tiles.go | 0.662578 | 0.480662 | tiles.go | starcoder |
package v2d
import (
"github.com/chewxy/math32"
)
// Add adds the two vectors.
func (v Vec) Add(w Vec) Vec {
return Vec{X: v.X + w.X, Y: v.Y + w.Y}
}
// Sub subtracts w from v.
func (v Vec) Sub(w Vec) Vec {
return Vec{X: v.X - w.X, Y: v.Y - w.Y}
}
// Neg returns -v.
func (v Vec) Neg() Vec {
return Vec{X: -v.X, ... | vec.go | 0.925936 | 0.604574 | vec.go | starcoder |
package network
import (
"math"
"github.com/haashi/go-neural/matrix"
)
// Network : a neural network
type Network struct {
inputs int
hiddenLayers int
outputs int
weights []*matrix.Matrix
learningRate float64
biasWeights []*matrix.Matrix
bias float64
}
// CreateNetwork : create a n... | network/network.go | 0.748168 | 0.620737 | network.go | starcoder |
package gorgonia
import (
"fmt"
"github.com/chewxy/gorgonia/tensor"
tf32 "github.com/chewxy/gorgonia/tensor/f32"
tf64 "github.com/chewxy/gorgonia/tensor/f64"
ti "github.com/chewxy/gorgonia/tensor/i"
"github.com/chewxy/gorgonia/tensor/types"
)
// Value represents a value that Gorgonia accepts
type Value interfa... | values.go | 0.668772 | 0.534491 | values.go | starcoder |
package bst
type OrderType string
type BST_Node struct {
Parent *BST_Node
Left *BST_Node
Right *BST_Node
Data int
}
type BST struct {
Root *BST_Node
LeafCount int
}
func NewBST() *BST {
return &BST{
Root: nil,
LeafCount: 0,
}
}
func (bt *BST) Insert(data int) {
if bt.LeafCount == 0 {
... | data-structures/binary-search-trees/bst/bst.go | 0.64579 | 0.474631 | bst.go | starcoder |
package sc
// FFT implements the Fast Fourier Transform.
// The fast fourier transform analyzes the frequency content of a signal,
// which can be useful for audio analysis or for frequency-domain sound processing (phase vocoder).
type FFT struct {
// A buffer to store spectral data. The buffer's size must correspond... | vendor/github.com/scgolang/sc/fft.go | 0.734691 | 0.6597 | fft.go | starcoder |
package beholder
// ConditionsDataSource .
var ConditionsDataSource = rulesDataSource(ConditionEntity,
rule("Conditions",
"Conditions alter a creature's capabilities in a variety of ways and can arise as a result of a spell, a class feature, a monster's attack, or other effect. Most conditions, such as blinded, are... | src/data-conditions.go | 0.563858 | 0.690751 | data-conditions.go | starcoder |
package lamb
import (
mat "github.com/nlpodyssey/spago/pkg/mat32"
"github.com/nlpodyssey/spago/pkg/ml/nn"
"github.com/nlpodyssey/spago/pkg/ml/optimizers/gd"
)
var _ gd.MethodConfig = &Config{}
// Config provides configuration settings for Lamb optimizer.
type Config struct {
gd.MethodConfig
StepSize mat.Float
... | pkg/ml/optimizers/gd/lamb/lamb.go | 0.842604 | 0.414129 | lamb.go | starcoder |
package election
import (
"encoding/json"
"github.com/paulmach/go.geojson"
"github.com/twpayne/go-polyline"
)
// EncodedGeometry correlates to a GeoJSON linear ring geometry, replacing
// coordinates with the encoded representation.
type EncodedGeometry struct {
Type string `json:"type"`
Coordinates ... | go_backend/encoded_polyline.go | 0.859605 | 0.437103 | encoded_polyline.go | starcoder |
package datespec
import (
"time"
)
type DateSpec interface {
OccursOn(*Date) bool
}
// DailyDateSpec takes place every day.
type DailyDateSpec struct{}
// UnionDateSpec takes place on days where any of Specs take place.
type UnionDateSpec struct {
Specs []DateSpec
}
// EveryNthDayDateSpec takes place every Coun... | pkg/datespec/datespec.go | 0.676192 | 0.655322 | datespec.go | starcoder |
package godeck
import (
"fmt"
"math/rand"
"sort"
"time"
)
// Suit is the number associated to the card
type Suit uint8
const (
// Spade is the value of a type of cards
Spade Suit = iota
// Diamond is the value of a type of cards
Diamond
// Club is the value of a type of cards
Club
// Heart is the value of... | card.go | 0.569374 | 0.461259 | card.go | starcoder |
package bulk
import (
"context"
"math/rand"
"time"
)
// Backoff implements exponential backoff.
// The wait time between retries is a random value between 0 and the "retry envelope".
// The envelope starts at Initial and increases by the factor of Multiplier every retry,
// but is capped at Max.
type Backoff struc... | bulk/backoff.go | 0.700588 | 0.410106 | backoff.go | starcoder |
// +build ignore
package main
import (
"log"
"os"
"text/template"
)
func main() {
for _, typ := range []struct{ Type, Name, MathName string }{
{"int32", "Int32", ""},
{"int64", "Int64", ""},
{"uint32", "Uint32", ""},
{"uint64", "Uint64", ""},
{"float32", "Float32", "Float32"},
{"float64", "Float64",... | generate-tests.go | 0.553143 | 0.42483 | generate-tests.go | starcoder |
package ripemd160
import "encoding/binary"
// https://homes.esat.kuleuven.be/~bosselae/ripemd160.html
// https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf
// nonlinear functions at bit level: exor, mux, -, mux, -
func f(j int, x, y, z uint32) uint32 {
// f(j, x, y, z) = x ⊕ y ⊕ z ... | ripemd160/ripemd160.go | 0.532182 | 0.404507 | ripemd160.go | starcoder |
package tools
import (
"fmt"
"reflect"
"strconv"
"strings"
)
type StrConvert func(in string) (out interface{}, err error)
// TypeConvert container
var TypeConvert map[reflect.Kind]StrConvert
func init() {
TypeConvert = make(map[reflect.Kind]StrConvert)
TypeConvert[reflect.Bool] = BoolConvert... | core/tools/type_convert.go | 0.650023 | 0.404507 | type_convert.go | starcoder |
package base
import (
"errors"
"fmt"
"strconv"
"strings"
"time"
)
// NewEmptyGTS return an empty GTS
func NewEmptyGTS() *GTS {
return >S{
ClassName: "",
Labels: Labels{},
Attributes: Attributes{},
LastActivity: 0,
Values: [][]interface{}{},
}
}
// NewGTS return a nammed GTS
func N... | base/gts-helper.go | 0.574753 | 0.509642 | gts-helper.go | starcoder |
package pixelate
import (
"image"
"image/color"
"github.com/Nyarum/img/utils"
)
// Halves the width of the double-width image created by hxl to produce nice
// smooth edges.
func halveWidth(img image.Image) image.Image {
b := img.Bounds()
o := image.NewRGBA(image.Rect(0, 0, b.Dx()/2, b.Dy()))
for y := 0; y < ... | pixelate/hxl.go | 0.773473 | 0.555134 | hxl.go | starcoder |
package tsdmetrics
import "github.com/rcrowley/go-metrics"
type IntegerHistogram interface {
Clear()
Count() int64
Max() int64
Mean() int64
Min() int64
Percentile(float64) int64
Percentiles([]float64) []int64
Sample() metrics.Sample
Snapshot() IntegerHistogram
StdDev() int64
Sum() int64
Update(int64)
Var... | integer_histogram.go | 0.932951 | 0.706209 | integer_histogram.go | starcoder |
package ms
import (
"encoding/binary"
)
const (
BlocketteHeaderSize = 4
Blockette1000Size = 4
Blockette1001Size = 4
)
// BlocketteHeader stores the header of each miniseed blockette.
type BlocketteHeader struct {
BlocketteType uint16
NextBlockette uint16 // Byte of next blockette, 0 if last blockette
}
//... | vendor/github.com/GeoNet/kit/seis/ms/blockette.go | 0.755547 | 0.449574 | blockette.go | starcoder |
package art
import (
"fmt"
"math"
)
func (a *Art) Add(operand ...string) error {
if len(operand) != 2 {
return fmt.Errorf("invalid operands length: %v", operand)
}
x, err := a.Get(operand[0])
if err != nil {
return err
}
y, err := a.Get(operand[1])
if err != nil {
return err
}
if err := a.Set(oper... | arithmetic.go | 0.532668 | 0.411879 | arithmetic.go | starcoder |
package html
import (
"encoding/json"
"reflect"
"strings"
"unicode"
"github.com/murlokswarm/app"
"github.com/pkg/errors"
)
type mapper struct {
completePipeline []string
index int
jsonValue string
}
func newMapper(pipeline []string, jsonValue string) *mapper {
return &mapper{
completeP... | html/map.go | 0.539711 | 0.41182 | map.go | starcoder |
package tools
import (
"math"
"math/rand"
"strconv"
"sync"
"time"
)
// A struct that represents a simulator
// seed for a given type of sensor value
type SimulatorSeed struct {
// A float64 that represents the initial value of the seed
Initial float64
// A float64 that represents the value by which the seed ... | tools/simtools.go | 0.824144 | 0.70202 | simtools.go | starcoder |
package spatial
// Polygon is a data type for storing simple polygons.
type Polygon []Line
func (p Polygon) Project(proj ConvertFunc) {
for ri := range p {
for i := range p[ri] {
p[ri][i] = proj(p[ri][i])
}
}
}
func (p Polygon) Copy() Projectable {
var np Polygon
for _, ring := range p {
np = append(np,... | lib/spatial/polygon.go | 0.681621 | 0.530297 | polygon.go | starcoder |
package cmd
import "tix/logger"
const helpMessage =
`Tix -A command line utility for generating jira, etc tickets from a markdown document.
Usage: tix [OPTIONS] <markdown file>
-d prints out ticket information instead of creating tickets (shorthand)
-dryrun
prints out ticket information instead of creating tickets
-h... | cmd/help.go | 0.633637 | 0.685693 | help.go | starcoder |
package stringslice
// MatchFunc is a function that matches elements in a string slice.
type MatchFunc func(string) bool
// Filter returns a slice containing the elements of slice for which match returns true.
func Filter(slice []string, match MatchFunc) []string {
out := make([]string, 0, len(slice))
for _, s := r... | stringslice/stringslice.go | 0.885322 | 0.450118 | stringslice.go | starcoder |
package bls12381
import (
"fmt"
"github.com/cloudflare/circl/ecc/bls12381/ff"
)
type isogG1Point struct{ x, y, z ff.Fp }
func (p isogG1Point) String() string { return fmt.Sprintf("x: %v\ny: %v\nz: %v", p.x, p.y, p.z) }
// IsOnCurve returns true if g is a valid point on the curve.
func (p *isogG1Point) IsOnCurve(... | ecc/bls12381/g1Isog.go | 0.696268 | 0.47244 | g1Isog.go | starcoder |
package easytime
import (
"time"
)
var (
DateTimeFormat = "2006-01-02 15:04:05"
DateFormat = "2006-01-02"
TimeFormat = "15:04:05"
ShortDateTimeFormat = "20060102150405"
ShortDateFormat = "20060102"
ShortTimeFormat = "150405"
)
// NowString Gets the current time string
func NowS... | time/time.go | 0.800146 | 0.436922 | time.go | starcoder |
package gortex
import "fmt"
// DeltaRNN cell https://arxiv.org/pdf/1703.08864.pdf
type DeltaRNN struct {
Wr *Matrix
Ur *Matrix
Wx *Matrix
Wh *Matrix
Wo *Matrix
Br *Matrix
Bias *Matrix
A *Matrix
B *Matrix
C *Matrix
}
// MakeDeltaRNN create new cell
func MakeDeltaRNN(x_size, h_size, out_... | rnn.delta.rnn.go | 0.681091 | 0.432063 | rnn.delta.rnn.go | starcoder |
package io
import (
"time"
)
type RowsInterface interface {
GetRow(i int) []byte // Position to the i-th record
GetData() []byte // Pointer to the beginning of the data
GetNumRows() int
GetRowLen() int
SetRowLen(int)
}
type RowSeriesInterface interface {
GetMetadataKey() string // The filesystem metadata ... | utils/io/rowseries.go | 0.620966 | 0.510863 | rowseries.go | starcoder |
package radius
func ironRadius(mass float64) float64 {
var radius float64
if mass <= 0.001496 {
radius1 := FractionRadius(mass, 0, 0, 0)
radius2 := PlanetRadiusHelper(mass, 0.001496, 0.09947, 0.002096, 0.1112, 0.002931, 0.1243)
radius = RangeAdjust(mass, radius1, radius2, 0.0, 0.001496)
} else if mass <= 0.00... | stargen/radius/iron-radius.go | 0.506836 | 0.66046 | iron-radius.go | starcoder |
package views
import (
"sync"
"github.com/gdamore/tcell/v2"
)
// TextBar is a Widget that provides a single line of text, but with
// distinct left, center, and right areas. Each of the areas can be styled
// differently, and they align to the left, center, and right respectively.
// This is basically a convenie... | views/textbar.go | 0.666171 | 0.459743 | textbar.go | starcoder |
package vtctld
import (
"fmt"
"sort"
"sync"
"vitess.io/vitess/go/vt/discovery"
"vitess.io/vitess/go/vt/topo/topoproto"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)
const (
// tabletMissing represents a missing/non-existent tablet for any metric.
tabletMissing = -1
// These values represent the thre... | go/vt/vtctld/tablet_stats_cache.go | 0.577376 | 0.473049 | tablet_stats_cache.go | starcoder |
package iso20022
// Account between an investor(s) and a fund manager or a fund. The account can contain holdings in any investment fund or investment fund class managed (or distributed) by the fund manager, within the same fund family.
type InvestmentAccount34 struct {
// Unique and unambiguous identification for t... | InvestmentAccount34.go | 0.792062 | 0.455562 | InvestmentAccount34.go | starcoder |
package ring
import (
"crypto/rand"
"math"
"math/bits"
)
func computeMatrixTernary(p float64) (M [][]uint8) {
var g float64
var x uint64
precision := uint64(56)
M = make([][]uint8, 2)
g = p
g *= math.Exp2(float64(precision))
x = uint64(g)
M[0] = make([]uint8, precision-1)
for j := uint64(0); j < preci... | HE/ring/ternarySampler.go | 0.818664 | 0.400925 | ternarySampler.go | starcoder |
package segmentindex
import (
"bytes"
"encoding/binary"
"fmt"
"math"
"sort"
"github.com/pkg/errors"
)
type Tree struct {
nodes []*Node
}
type Node struct {
Key []byte
Start uint64
End uint64
}
func NewTree(capacity int) Tree {
return Tree{
nodes: make([]*Node, 0, capacity),
}
}
func NewBalanced... | adapters/repos/db/lsmkv/segmentindex/tree.go | 0.71889 | 0.445409 | tree.go | starcoder |
package gocv
import (
"github.com/fwessels/go-cv-simd/sse2"
)
//AbsDifferenceSum gets sum of absolute difference of two gray 8-bit images.
// Both images must have the same width and height.
func AbsDifferenceSum(a, b gocvsimd.View) uint64 {
return gocvsimd.SimdSse2AbsDifferenceSum(a, b)
}
// AbsDifferenceSumMaske... | correlation.go | 0.70477 | 0.78469 | correlation.go | starcoder |
package yamlpath
import (
"fmt"
"regexp"
"gopkg.in/yaml.v3"
)
type filter func(node, root *yaml.Node) bool
func newFilter(n *filterNode) filter {
if n == nil {
return never
}
switch n.lexeme.typ {
case lexemeFilterAt, lexemeRoot:
path := pathFilterScanner(n)
return func(node, root *yaml.Node) bool {
... | pkg/yamlpath/filter.go | 0.609989 | 0.469216 | filter.go | starcoder |
package rlwe
import (
"github.com/tuneinsight/lattigo/v3/ring"
"github.com/tuneinsight/lattigo/v3/utils"
)
// PolyQP represents a polynomial in the ring of polynomial modulo Q*P.
// This type is simply the union type between two ring.Poly, each one
// containing the modulus Q and P coefficients of that polynomial.
... | rlwe/ring_qp.go | 0.772874 | 0.590602 | ring_qp.go | starcoder |
package iso20022
// Completion of a securities settlement instruction, wherein securities are delivered/debited from a securities account and received/credited to the designated securities account.
type Transfer26 struct {
// Unique and unambiguous identifier for a transfer execution, as assigned by a confirming par... | Transfer26.go | 0.791942 | 0.42471 | Transfer26.go | starcoder |
package bulletproof
import (
crand "crypto/rand"
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/coinbase/kryptology/pkg/core/curves"
)
// BatchProve proves that a list of scalars v are in the range n.
// It implements the aggregating logarithmic proofs defined on pg21.
// Instead of taking a sing... | pkg/bulletproof/range_batch_prover.go | 0.776411 | 0.461988 | range_batch_prover.go | starcoder |
// Package dataflow provides data flow analyses that can be performed on a
// previously constructed control flow graph, including a reaching definitions
// analysis and a live variables analysis for local variables.
package dataflow
// This file contains functions common to all data flow analyses, as well as
// one ... | analysis/dataflow/dataflow.go | 0.628749 | 0.522689 | dataflow.go | starcoder |
package mqo
import "math"
type Vector2 struct {
X float32
Y float32
}
type Vector3 struct {
X float32
Y float32
Z float32
}
func (v *Vector3) Len() float32 {
return float32(math.Sqrt(float64(v.X*v.X + v.Y*v.Y + v.Z*v.Z)))
}
func (v *Vector3) Normalize() {
l := v.Len()
if l > 0 {
v.X /= l
v.Y /= l
v.Z... | mqo/mqo.go | 0.625095 | 0.533276 | mqo.go | starcoder |
package main
import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric/protos/peer"
)
// SimpleAsset은 간단한 체인 코드를 구현하여 자산을 관리합니다.
type SimpleAsset struct {
}
// 초기화를 위해 체인 코드 인스턴스화 중에 Init가 호출됩니다.
// 데이터. chaincode 업그레이드는이 기능을 호출하여 재설정합니다.
// 데이터를 이전합니다.
func (t *S... | chaincode.go | 0.507812 | 0.461077 | chaincode.go | starcoder |
package dag
import (
"fmt"
"reflect"
"sort"
"strconv"
)
// the marshal* structs are for serialization of the graph data.
type marshalGraph struct {
// Type is always "Graph", for identification as a top level object in the
// JSON stream.
Type string
// Each marshal structure requires a unique ID so that it ... | terraform/terraform/vendor/github.com/hashicorp/terraform/internal/dag/marshal.go | 0.713631 | 0.419648 | marshal.go | starcoder |
package elastic
// The function_score allows you to modify the score of documents that
// are retrieved by a query. This can be useful if, for example,
// a score function is computationally expensive and it is sufficient
// to compute the score on a filtered set of documents.
// For more details, see
// http://www.e... | vendor/gopkg.in/olivere/elastic.v2/search_queries_fsq.go | 0.871543 | 0.416381 | search_queries_fsq.go | starcoder |
package jwt
import (
"encoding/json"
"fmt"
"reflect"
"time"
"github.com/grafana/grafana/pkg/models"
"gopkg.in/square/go-jose.v2/jwt"
)
func (s *AuthService) initClaimExpectations() error {
if err := json.Unmarshal([]byte(s.Cfg.JWTAuthExpectClaims), &s.expect); err != nil {
return err
}
for key, value := ... | pkg/services/auth/jwt/validation.go | 0.573201 | 0.464537 | validation.go | starcoder |
package volume
import (
"errors"
"github.com/louis030195/protometry/api/vector3"
)
// NewBoxMinMax returns a new box using min max
func NewBoxMinMax(minX, minY, minZ, maxX, maxY, maxZ float64) *Box {
return &Box{
Min: vector3.NewVector3(minX, minY, minZ),
Max: vector3.NewVector3(maxX, maxY, maxZ),
}
}
... | api/volume/box.go | 0.891899 | 0.545709 | box.go | starcoder |
package trade_knife
import (
"github.com/amir-the-h/goex"
"time"
)
// Interval is the timeframe concept and determines duration of each candle.
type Interval string
// Duration Returns actual duration of the interval.
func (i Interval) Duration() time.Duration {
switch i {
case Interval1m:
return time.Minute
... | interval.go | 0.632162 | 0.51013 | interval.go | starcoder |
package resize
import (
"image"
"image/color"
)
// ycc is an in memory YCbCr image. The Y, Cb and Cr samples are held in a
// single slice to increase resizing performance.
type ycc struct {
// Pix holds the image's pixels, in Y, Cb, Cr order. The pixel at
// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.... | ycc.go | 0.770724 | 0.635053 | ycc.go | starcoder |
package bufr
import (
"fmt"
"encoding/json"
)
// LookupFunction is for looking up meanings of code values on code tables
type LookupFunction = func(uint) string
var MISSING_VALUE_OF_NBITS = make(map[int]uint)
func init() {
// Store the missing values for corresponding number of bits for
// quick loo... | bufr/field.go | 0.613468 | 0.40486 | field.go | starcoder |
package edit
import (
"strings"
"github.com/elves/elvish/util"
)
// cell is an indivisible unit on the screen. It is not necessarily 1 column
// wide.
type cell struct {
rune
width byte
style string
}
// pos is the position within a buffer.
type pos struct {
line, col int
}
var invalidPos = pos{-1, -1}
func... | edit/buffer.go | 0.619356 | 0.425486 | buffer.go | starcoder |
package main
type IntPair struct {
First, Second int
}
// O(w.h) time | O(w.h) space
// where W is the width of the matrix and H is the height
func MinimumPassesOfMatrix(matrix [][]int) int {
passes := convertNegatives(matrix)
if !containsNegative(matrix) {
return passes - 1
} else {
return -1
}
}
func cont... | src/graphs/medium/min-passes-matrix/go/iterative.go | 0.744006 | 0.538194 | iterative.go | starcoder |
Package nestedpendingoperations is a modified implementation of
pkg/util/goroutinemap. It implements a data structure for managing go routines
by volume/pod name. It prevents the creation of new go routines if an existing
go routine for the volume already exists. It also allows multiple operations to
execute in paralle... | cluster-autoscaler/vendor/k8s.io/kubernetes/pkg/volume/util/nestedpendingoperations/nestedpendingoperations.go | 0.734786 | 0.448607 | nestedpendingoperations.go | starcoder |
package riak
import (
"errors"
"fmt"
"reflect"
"strings"
"github.com/tpjg/goriakpbc/json"
)
/*
Make structs work like a Document Model, similar to how the Ruby based "ripple"
gem works. This is done by parsing the JSON data and mapping it to the struct's
fields. To enable easy integration with Ruby/ripple proje... | model.go | 0.611614 | 0.434101 | model.go | starcoder |
package ca_ES_VALENCIA
import "github.com/MaxSlyugrov/cldr"
var currencies = []cldr.Currency{
{Currency: "AFA", DisplayName: "afgani afganés (1927–2002)", Symbol: ""},
{Currency: "AFN", DisplayName: "afgani afganés", Symbol: ""},
{Currency: "ALK", DisplayName: "lek albanés (1946–1965)", Symbol: ""},
{Currency: "A... | resources/locales/ca_ES_VALENCIA/currency.go | 0.50415 | 0.408955 | currency.go | starcoder |
package stats
import "math"
// Series is a container for a series of data
type Series []Coordinate
// Coordinate holds the data in a series
type Coordinate struct {
X, Y float64
}
// LinearRegression finds the least squares linear regression on data series
func LinearRegression(s Series) (regressions Series, err e... | tools/vendor/github.com/montanaflynn/stats/regression.go | 0.795142 | 0.785267 | regression.go | starcoder |
package backend
import (
"context"
"github.com/baudtime/baudtime/msg"
"github.com/prometheus/prometheus/pkg/labels"
)
type Backend interface {
Queryable
// StartTime returns the oldest timestamp stored in the storage.
StartTime() (int64, error)
// Appender returns a new appender against the storage.
Append... | backend/interface.go | 0.784938 | 0.412648 | interface.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.