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 types
import (
"io"
"github.com/lyraproj/puppet-evaluator/eval"
"github.com/lyraproj/puppet-evaluator/utils"
"reflect"
)
type PatternType struct {
regexps []*RegexpType
}
var Pattern_Type eval.ObjectType
func init() {
Pattern_Type = newObjectType(`Pcore::PatternType`,
`Pcore::ScalarDataType {
attr... | types/patterntype.go | 0.646237 | 0.466906 | patterntype.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// UserTrainingStatusInfo
type UserTrainingStatusInfo struct {
// Stores addition... | models/user_training_status_info.go | 0.564098 | 0.444565 | user_training_status_info.go | starcoder |
package transpilers
import (
"fmt"
"cloud.google.com/go/bigquery"
"github.com/beneath-hq/beneath/pkg/schemalang"
)
// ToBigQuery transpiles an Avro schema to a BigQuery schema
func ToBigQuery(s schemalang.Schema, doc bool) bigquery.Schema {
t := &toBigQuery{
Doc: doc,
Refs: make(map[string]*bigquery.FieldS... | pkg/schemalang/transpilers/bigquery_to.go | 0.630116 | 0.460895 | bigquery_to.go | starcoder |
package core
//PolyLine - Aka Polygonal chain, linestring,
type PolyLine []Line
// GeomType - Describes geometry type
func (PolyLine) GeomType() string {
return "polyline"
}
// Creates a Polyline from a slice of Points
func createPolylineFromPoints(points []Point) PolyLine {
var p PolyLine
for i, pt := range poin... | core/Polyline.go | 0.845241 | 0.461138 | Polyline.go | starcoder |
package graphs
import (
"math"
// u "github.com/mayukh42/goals/utils"
)
type Point struct {
X int
Y int
Z int
}
func NewPoint(x, y int) *Point {
return &Point{
X: x,
Y: y,
}
}
func (p *Point) CompareX(p_ *Point) int {
// -1, 0, 1
if p_.X < p.X {
return -1
} else if p_.X > p.X {
return 1
}
return... | graphs/grid.go | 0.672332 | 0.509032 | grid.go | starcoder |
package model
// Common basic data structures: PdfRectangle, PdfDate, etc.
// These kinds of data structures can be copied, do not need a unique copy of each object.
import (
"errors"
"fmt"
"regexp"
"strconv"
. "github.com/unidoc/unidoc/pdf/core"
)
// Definition of a rectangle.
type PdfRectangle struct {
Llx ... | vendor/github.com/unidoc/unidoc/pdf/model/structures.go | 0.695131 | 0.562477 | structures.go | starcoder |
package main
import (
"flag"
"fmt"
"os"
"github.com/kr/pretty"
"invasion"
)
func main() {
flag.Usage = func() {
fmt.Println(`Map Visualizer
Reads in pre-defined map data and displays it on screen
`)
flag.PrintDefaults()
}
mapFile := flag.String("map", "", "m... | util/map_visualizer.go | 0.544801 | 0.426381 | map_visualizer.go | starcoder |
// go build
// ./example2
// Sample program to visualize the impact of dimensionality reduction.
package main
import (
"encoding/csv"
"image/color"
"log"
"os"
"strconv"
"github.com/gonum/floats"
"github.com/gonum/matrix/mat64"
"github.com/gonum/plot"
"github.com/gonum/plot/plotter"
"github.com/gonum/plot/... | topics/data_science/dimensionality_reduction/example2/example2.go | 0.634204 | 0.418697 | example2.go | starcoder |
package indicators
// DX = ( (+DI)-(-DI) ) / ( (+DI) + (-DI) )
import (
"errors"
"github.com/thetruetrade/gotrade"
"math"
)
// An Directional Movement Index Indicator (Dx), no storage, for use in other indicators
type DxWithoutStorage struct {
*baseIndicatorWithFloatBounds
// private variables
minusDI ... | indicators/dx.go | 0.649023 | 0.473414 | dx.go | starcoder |
package maputils
// Keys - takes a map with keys K and values V, returns a slice of type K of the map's keys.
// Note: Go maps do not preserve insertion order.
func Keys[K comparable, V any](mapInstance map[K]V) []K {
keys := make([]K, len(mapInstance))
i := 0
for k := range mapInstance {
keys[i] = k
i++
}
... | maputils/maputils.go | 0.873053 | 0.534127 | maputils.go | starcoder |
package vespyr
import (
"fmt"
"math/rand"
"github.com/MaxHalford/gago"
"github.com/sirupsen/logrus"
)
// EMACrossoverStrategy is a strategy for that buys and sells based on
// EMA crossovers.
type EMACrossoverStrategy struct {
ShortPeriod uint `yaml:"short_period"`
LongPeriod uint `yaml:"long_period... | pkg/vespyr/ema_crossover_strategy.go | 0.792665 | 0.404331 | ema_crossover_strategy.go | starcoder |
package suffix_automata
type Dawg struct {
qW int32
lastTransition int32
states []State
slinks []int32
transitions []Transition
}
func NewDawg(len int) *Dawg {
states := make([]State, 1, 2*len-1)
states[0].len = 0
states[0].lastTransition = -1
slinks := make([]int32, 1, 2*len-1)
slinks[0... | dodo/suffix_automata/dawg.go | 0.622574 | 0.439266 | dawg.go | starcoder |
package main
import (
"fmt"
"math"
"sort"
"strings"
"time"
"github.com/sanderploegsma/advent-of-code/2019/utils"
)
func main() {
input, _ := utils.ReadFile("input.txt")
asteroids := ParseInput(input)
start := time.Now()
p, num := PartOne(asteroids)
fmt.Printf("[PART ONE] position (%d, %d) can detect %d a... | 2019/go/10/main.go | 0.802013 | 0.489686 | main.go | starcoder |
package f32
import "fmt"
// An Affine is a 3x3 matrix of float32 values for which the bottom row is
// implicitly always equal to [0 0 1].
// Elements are indexed first by row then column, i.e. m[row][column].
type Affine [2]Vec3
func (m Affine) String() string {
return fmt.Sprintf(`Affine[% 0.3f, % 0.3f, % 0.3f,
... | vendor/github.com/fyne-io/mobile/exp/f32/affine.go | 0.73077 | 0.54353 | affine.go | starcoder |
package bls12381
import (
"errors"
"math"
"math/big"
)
// PointG1 is type for point in G1.
// PointG1 is both used for Affine and Jacobian point representation.
// If z is equal to one the point is considered as in affine form.
type PointG1 [3]fe
func (p *PointG1) Set(p2 *PointG1) *PointG1 {
p[0].set(&p2[0])
p... | plugin/dapp/evm/executor/vm/common/crypto/bls12381/g1.go | 0.797399 | 0.535159 | g1.go | starcoder |
package randxdr
import (
"math"
"regexp"
"strings"
goxdr "github.com/xdrpp/goxdr/xdr"
)
// Selector is function used to match fields of a goxdr.XdrType
type Selector func(string, goxdr.XdrType) bool
// Setter is a function used to set field values for a goxdr.XdrType
type Setter func(*randMarshaller, string, go... | randxdr/presets.go | 0.604983 | 0.727951 | presets.go | starcoder |
package decoder
import (
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"reflect"
)
func NewLayerDecoder(decodingLayers ...gopacket.DecodingLayer) *LayerDecoder {
ld := &LayerDecoder{
DecodingLayerMap: make(map[gopacket.LayerType]gopacket.DecodingLayer),
}
for _, dl := range decodingLayers ... | engine/decoder/decoder.go | 0.735547 | 0.421611 | decoder.go | starcoder |
package shamir
// Package secret implements Shamir secret sharing over finite fields and secret sharing over the integers for integers.
// In addition, facilities are offered to perform computations on shares of secrets.
import (
"crypto/rand"
"errors"
"math/big"
)
var (
ErrorNoShares = errors.New("Em... | secretsharing.go | 0.832169 | 0.491212 | secretsharing.go | starcoder |
package day19
import (
"math/rand"
"aoc/internal/geo3d"
)
type Scanner struct {
Position geo3d.Pos
Beacons []geo3d.Pos
rotations []*Scanner
}
func NewScanner(position geo3d.Pos, beacons ...geo3d.Pos) *Scanner {
v := &Scanner{
Position: position,
Beacons: make([]geo3d.Pos, 0, 32),
}
v.Add(beacons...)
... | go/2021/day19/day19.go | 0.604282 | 0.499146 | day19.go | starcoder |
package com
import (
"errors"
"math"
"reflect"
)
// PowInt is int type of math.Pow function.
func PowInt(x int, y int) int {
if y <= 0 {
return 1
} else {
if y%2 == 0 {
sqrt := PowInt(x, y/2)
return sqrt * sqrt
} else {
return PowInt(x, y-1) * x
}
}
}
// Round return float64 to the nearest w... | math.go | 0.673299 | 0.468547 | math.go | starcoder |
package binary_search
import (
"fmt"
)
type IBST interface {
Insert(data int)
Delete(data int)
Find(data int) (currNode *node, parentNode *node)
}
type ITraverser interface {
Size()
InorderDFS()
PreorderDFS()
PostorderDFS()
BFS()
}
type node struct {
data int
left *node
right *node
}
type bst struct {
... | datastructures/trees/binary-search/binary-search-tree.go | 0.672762 | 0.519156 | binary-search-tree.go | starcoder |
package runtime
import "reflect"
func Add(left interface{}, right interface{}) interface{} {
switch typedLeft := left.(type) {
case int:
switch typedRight := right.(type) {
case int:
return int(typedLeft) + typedRight
case float64:
return float64(typedLeft) + typedRight
default:
panic("can not add ... | docstore/runtime/arithmetic.go | 0.713931 | 0.518059 | arithmetic.go | starcoder |
package vm
import (
"fmt"
"strings"
"github.com/dbaumgarten/yodk/pkg/number"
)
// VariableFromString tries to create a variable of the correct type from the given string.
// If the string is enclosed in quotes, the string between the quotes is used as string-value for the variable.
// Else, it tries to parse the ... | pkg/vm/variable.go | 0.701611 | 0.432003 | variable.go | starcoder |
package ondatra
import (
opb "github.com/openconfig/ondatra/proto"
)
// ISIS is a representation of a IS-IS config on the ATE.
type ISIS struct {
pb *opb.ISISConfig
}
// IPReachabilityConfig is the IS-IS config for a simulated network pool.
type IPReachabilityConfig struct {
pb *opb.IPReachability
}
// ISReacha... | isis.go | 0.720762 | 0.572902 | isis.go | starcoder |
package venom
import (
"reflect"
"strconv"
"strings"
"time"
"github.com/mitchellh/mapstructure"
)
func stringToTimeDurationHookFunc() mapstructure.DecodeHookFunc {
return func(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if... | decode_hooks.go | 0.552298 | 0.408867 | decode_hooks.go | starcoder |
package set
import (
"github.com/pingcap/tidb/util/hack"
)
// StringSetWithMemoryUsage is a string set with memory usage.
type StringSetWithMemoryUsage struct {
StringSet
bInMap int64
}
// NewStringSetWithMemoryUsage builds a string set.
func NewStringSetWithMemoryUsage(ss ...string) (setWithMemoryUsage StringSe... | util/set/set_with_memory_usage.go | 0.571049 | 0.452778 | set_with_memory_usage.go | starcoder |
package radixtree
import (
"fmt"
"strings"
)
type node struct {
value interface{} // value of the node or nil if there is no value
next []*node // array of pointers to the next node
}
const R = 256 // extended ASCII
// Creates a new node structure, initializing the next array
func createNode() *node {
n :... | radixtree.go | 0.750278 | 0.472257 | radixtree.go | starcoder |
package csv
import (
"context"
"encoding/csv"
"fmt"
"io"
"os"
"strconv"
"github.com/pbanos/botanic/feature"
"github.com/pbanos/botanic/set"
)
/*
Writer is an interface for a set to which samples
can be written to.
*/
type Writer interface {
// Write will attempt to write the given number
// of samples and ... | set/csv/csv.go | 0.573917 | 0.515254 | csv.go | starcoder |
package buffer
import (
"bytes"
"unicode"
"unicode/utf8"
"github.com/satran/e/utils"
)
type RangeFunc func(from Cursor, to Cursor)
// A Cursor represents a position within a buffer.
type Cursor struct {
Line *Line
LineNum int
Boffset int
}
type Range struct {
Start Cursor
End Cursor
}
// Before repo... | buffer/cursor.go | 0.751192 | 0.42054 | cursor.go | starcoder |
package streams
import "io"
// ByteMapper remaps all intercepted bytes based on the passed ByteMapperFunc. It should be safe
// to use either a statefull or idempotent function in this. However you should avoid reuse of a
// stateful ByteMapperFunc as correct behavior is difficult and error prone to implement.
type B... | byte_mapper.go | 0.678647 | 0.404213 | byte_mapper.go | starcoder |
package geometry
import (
"encoding/binary"
"math"
)
// IndexKind is the kind of index to use in the options.
type IndexKind byte
// IndexKind types
const (
None IndexKind = 0
QuadTree IndexKind = 1
)
func (kind IndexKind) String() string {
switch kind {
default:
return "Unknown"
case None:
return "... | series.go | 0.830697 | 0.589953 | series.go | starcoder |
package tuple
// T0 holds a tuple of 0 values.
type T0 = struct{}
// There is no 1-tuple - a 1-tuple is represented by the type itself.
// T2 holds a tuple of 2 values.
type T2[A0, A1 any] struct {
A0 A0
A1 A1
}
// T returns all the tuple's values.
func (t T2[A0, A1]) T() (A0, A1) {
return t.A0, t.A1
}
// MkT2 ... | tuple/tuple-gen.go | 0.757705 | 0.723053 | tuple-gen.go | starcoder |
package sdp
/*Author - <NAME>
RFC 4566 - https://tools.ietf.org/html/rfc4566#section-5.9
Timing ("t=")
t=<start-time> <stop-time>
The "t=" lines specify the start and stop times for a session.
Multiple "t=" lines MAY be used if a session is active at multiple
irregularly spaced times; each additiona... | sdp/sdpTime.go | 0.685634 | 0.524212 | sdpTime.go | starcoder |
package blockchain
import (
"github.com/mohanarpit/yolochain/models"
"crypto/sha256"
"encoding/hex"
"time"
"math/rand"
"log"
"github.com/davecgh/go-spew/spew"
"github.com/mohanarpit/yolochain/blockchainGrpc"
)
func CalculateStringHash(s string) string {
h := sha256.New()
h.Write([]byte(s))
hashed := h.Sum(... | blockchain/utils.go | 0.608594 | 0.419291 | utils.go | starcoder |
package graph
import (
"github.com/basp1/pocket/intlist"
)
const NIL = -1
type Graph struct {
VertexCount int
EdgeCount int
Free int
From []int
Next []int
To []int
Vertices []interface{}
Edges []interface{}
intlist *intlist.Intlist
}
func New() *Graph {
self := &Graph{}
self.VertexCoun... | graph/graph.go | 0.575349 | 0.410727 | graph.go | starcoder |
package modules
import (
"regexp"
"strings"
"github.com/bbuck/dragon-mud/scripting/lua"
)
var regexpCache = make(map[string]*regexp.Regexp)
// Sutil contains several features that Lua string handling lacks, things like
// joining and regex matching and splitting and trimming and various other
// things.
// spl... | scripting/modules/sutil.go | 0.549157 | 0.497376 | sutil.go | starcoder |
package merkletree
import (
"bytes"
"crypto"
)
// isPlausible checks that the given path starts with a leaf and ends with root.
func (p Path) isPlausible() (ok bool) {
test := true
if len(p) < 2 {
return false
}
// Leaf element (first in path).
test = test && p[0].IsLeaf // Must be a leaf.
test = test... | merkletree/verify.go | 0.595257 | 0.552298 | verify.go | starcoder |
package un
import (
"reflect"
"sync"
)
func init() {
MakeEach(&Each)
MakeEach(&EachInt)
// MakeEach(&EachString)
MakeEach(&EachStringInt)
MakeEachP(&EachP)
}
// Each func(func(A, B), []A)
// Applies the given iterator function to each element of a collection (slice or map).
// If the collection is a Slice, th... | each.go | 0.680879 | 0.439326 | each.go | starcoder |
package netpbm
import (
"bufio"
"errors"
"fmt"
"image"
"image/color"
"io"
"strings"
"github.com/spakin/netpbm/npcolor"
)
// GrayM is an in-memory image whose At method returns npcolor.GrayM values.
type GrayM struct {
// Pix holds the image's pixels as gray values. The pixel at (x, y)
// starts at Pix[(y-... | pgm.go | 0.899298 | 0.604107 | pgm.go | starcoder |
package main
import (
"fmt"
"strconv"
"os"
"math"
"math/cmplx"
"image"
"image/png"
"image/color"
)
// inMandelSet returns the number of iteration it takes to test for divergence // at any given point (x,y) on the complex plane. If we can show that If we reach max_iterations without p... | go-fractal-yourself.go | 0.663451 | 0.422445 | go-fractal-yourself.go | starcoder |
package go_solve_kit
import (
"sort"
"strconv"
)
type Int int
type IntArray []Int
func (i Int) ValueOf() int {
return int(i)
}
func (i Int) ToString() String {
return String(strconv.Itoa(i.ValueOf()))
}
func (array IntArray) Length() Int {
return Int(len(array))
}
func (array IntArray) Map(lambda func(v Int... | Int.go | 0.567697 | 0.425247 | Int.go | starcoder |
package iso20022
// Payment instrument between a debtor and a creditor, which flows through one or more financial institutions or systems.
type CreditTransfer8 struct {
// Information supplied to enable the matching of an entry with the items that the transfer is intended to settle, such as commercial invoices in an... | CreditTransfer8.go | 0.634204 | 0.572364 | CreditTransfer8.go | starcoder |
package convjson
import (
"encoding/json"
"fmt"
"reflect"
"regexp"
"strconv"
"strings"
"github.com/pkg/errors"
)
// Value describes a value
type Value struct {
typ ValueType
val reflect.Value
}
// ValueType describes value type
type ValueType int8
// all available value type
const (
TypeNil = Val... | convjson/convjson.go | 0.660063 | 0.427755 | convjson.go | starcoder |
package pi
import (
"fmt" // Used for error formatting
"math/rand" // Used for random number generation in Monte Carlo method
"runtime" // Used to get information on available CPUs
"time" // Used for seeding the random number generation
)
func MonteCarloPi(randomPoints int) float64 {
rnd := rand.Ne... | math/pi/montecarlopi.go | 0.727395 | 0.413418 | montecarlopi.go | starcoder |
package export
import "github.com/prometheus/client_golang/prometheus"
// CoordinationExporter contains all the Prometheus metrics that are possible to gather from the Jetty service
type CoordinationExporter struct {
TierTotalCapacity *prometheus.GaugeVec `description:"Total capacity in bytes available in ... | pkg/export/coordination.go | 0.811601 | 0.531878 | coordination.go | starcoder |
package fastimage
// Type represents the type of the image detected, or `Unknown`.
type Type uint64
const (
// Unknown represents an unknown image type
Unknown Type = iota
// BMP represendts a BMP image
BMP
// BPM represendts a BPM image
BPM
// GIF represendts a GIF image
GIF
// JPEG represendts a JPEG image... | fastimage.go | 0.720663 | 0.549218 | fastimage.go | starcoder |
package gollection
// Returns true if the target is included in the iterator.
func Contains[T comparable](target T, it Iterator[T]) bool {
for v, ok := it.Next().Get(); ok; v, ok = it.Next().Get() {
if v == target {
return true
}
}
return false
}
// Returns the sum of all the elements in the iterator.
func ... | terminal.go | 0.796174 | 0.561095 | terminal.go | starcoder |
package geometry
import (
"math"
"github.com/gonum/matrix/mat64"
)
type CatmullRome3 struct {
pc PointCloud
}
func NewCatmullRome3(pc PointCloud) *CatmullRome3 {
cr := &CatmullRome3{pc}
return cr
}
func (cr *CatmullRome3) GetPoint(t float64) *mat64.Vector {
point := mat64.NewVector(3, []float64{0, 0, 0})
/... | curve3.go | 0.531209 | 0.657387 | curve3.go | starcoder |
// Just for playing around a bit and testing stuff.
package main
import (
"bufio"
"flag"
"fmt"
"os"
"time"
br "github.com/FabianWe/boolrecognition"
"github.com/FabianWe/boolrecognition/lpb"
)
// iterativeAverage computes iteratively the average of a series of values.
// Implemented as described here: http://... | cmd/benchmarklpb/benchmarklpb.go | 0.509276 | 0.445952 | benchmarklpb.go | starcoder |
package pass
import (
"fmt"
"github.com/mmcloughlin/addchain/acc/ir"
"github.com/mmcloughlin/addchain/internal/errutil"
)
// Interface for a processing pass.
type Interface interface {
Execute(*ir.Program) error
}
// Func adapts a function to the pass Interface.
type Func func(*ir.Program) error
// Execute cal... | vendor/github.com/mmcloughlin/addchain/acc/pass/pass.go | 0.739611 | 0.413004 | pass.go | starcoder |
package units
import (
"errors"
"fmt"
"strconv"
"strings"
"github.com/JojiiOfficial/gaw"
)
// Datasize represents a unit of data size (in bits, bit)
type Datasize float32
// ...
const (
// base 10 (SI prefixes)
Bit Datasize = 1e0
Byte = Bit * 8
Kilobyte = Byte * 1e3
Megabyte = Byte * 1e6
Gigabyte = ... | models/units/Datasize.go | 0.724286 | 0.523481 | Datasize.go | starcoder |
package document
import (
"baliance.com/gooxml"
"baliance.com/gooxml/color"
"baliance.com/gooxml/measurement"
"baliance.com/gooxml/schema/soo/wml"
)
// TableBorders allows manipulation of borders on a table.
type TableBorders struct {
x *wml.CT_TblBorders
}
// X returns the inner wml.CT_TblBorders
func (b Tabl... | document/tableborders.go | 0.811937 | 0.424591 | tableborders.go | starcoder |
package multiless
type (
// A helper for long chains of "less-than" comparisons, where later comparisons are only
// required if earlier ones haven't resolved the comparison.
Computation struct {
ok bool
less bool
}
)
func New() Computation {
return Computation{}
}
func (me Computation) EagerSameLess(same... | vendor/github.com/anacrolix/multiless/multiless.go | 0.669637 | 0.432663 | multiless.go | starcoder |
package binary_search_tree
import "fmt"
/*
root,
left,
right,
Insert, recursive add
Delete,
Find,
Rotation
Depth
Traversal, Depth-first search, Pre-order(NLR)
Traversal, Depth-first search, In-order(LNR)
Traversal, Depth-first Post-order (LRN)
Traversal, Breadth-first search
inorder successor, is the largest thing... | algorithms/data-structures/tree/binary_search_tree/binary_search_tree.go | 0.63341 | 0.442637 | binary_search_tree.go | starcoder |
package ec2
import (
"math/big"
s256 "github.com/fsn-dev/dcrm-walletService/crypto/secp256k1"
"github.com/fsn-dev/dcrm-walletService/crypto/sha3"
"github.com/fsn-dev/dcrm-walletService/internal/common/math/random"
)
type ZkUProof struct {
E *big.Int
S *big.Int
}
type ZkABProof struct {
Alpha []*big.Int
Beta... | mpcdsa/crypto/ec2/schnorrZK.go | 0.614625 | 0.46393 | schnorrZK.go | starcoder |
package model
import "github.com/markcheno/go-talib"
// 単純移動平均
type SMA struct {
period int
values []float64
}
func NewSMA(inReal []float64, period int) *SMA {
if period <= 0 || len(inReal) <= period {
return nil
}
values := talib.Sma(inReal, period)
if values == nil {
return nil
}
return &SMA{
perio... | trader/domain/model/indicator.go | 0.583559 | 0.485112 | indicator.go | starcoder |
package gtreap
type Treap struct {
compare Compare
root *node
}
// Compare returns an integer comparing the two items
// lexicographically. The result will be 0 if a==b, -1 if a < b, and
// +1 if a > b.
type Compare func(a, b interface{}) int
// Item can be anything.
type Item interface{}
type node struct {
i... | vendor/github.com/blevesearch/gtreap/treap.go | 0.777849 | 0.443721 | treap.go | starcoder |
package drawing
import (
"image/color"
"math"
"time"
)
// Clear ... Clears the entire surface.
func (s *Surface) Clear(c color.RGBA) {
defer s.trackDuration("Clear", time.Now())
s.Background = c
s.FillRect(s.Bounds, s.Background)
}
// GetPoint ... Gets a point from the surface.
func (s *Surface) GetPoint(x, y... | primitives.go | 0.85226 | 0.67551 | primitives.go | starcoder |
package paletted
import (
"image"
)
func DrawOver(dst *image.Paletted, r image.Rectangle, src *image.Paletted, sp image.Point) {
for y := 0; y < r.Dy(); y++ {
for x := 0; x < r.Dx(); x++ {
sx := src.Rect.Min.X + sp.X + x
sy := src.Rect.Min.Y + sp.Y + y
dx := dst.Rect.Min.X + r.Min.X + x
dy := dst.Rec... | paletted/mod.go | 0.58676 | 0.55911 | mod.go | starcoder |
package tuner
// tuner.go is a texel tuning implementation for Blunder.
import (
"blunder/engine"
"bufio"
"fmt"
"math"
"os"
"strings"
)
const (
DataFile = "/home/algerbrex/quiet-labeled.epd"
NumCores = 4
NumWeights = 774
Draw float64 = 0.5
WhiteWin float64 = 1.0
BlackWin float64 = 0.... | tuner/tuner.go | 0.663233 | 0.465509 | tuner.go | starcoder |
package expect
import (
"fmt"
"reflect"
"regexp"
"strings"
)
type To struct {
Be *Be
Have *Have
Else *Else
And *To
t T
actual interface{}
assert bool
}
func newTo(t T, actual interface{}, assert bool) *To {
to := &To{
t: t,
actual: actual,
assert: assert,
}
to.Else = newElse(... | to.go | 0.603348 | 0.579876 | to.go | starcoder |
package tilecover
import (
"log"
"math"
"github.com/paulmach/orb"
"github.com/paulmach/orb/maptile"
)
// LineString creates a tile cover for the line string.
func LineString(ls orb.LineString, z maptile.Zoom) maptile.Set {
set := make(maptile.Set)
line(set, ls, z, nil)
return set
}
// LineStringCount creates... | maptile/tilecover/line_string.go | 0.597138 | 0.473962 | line_string.go | starcoder |
package structex
import (
"fmt"
"reflect"
"strconv"
"strings"
)
type endian int
const (
little endian = 0
big endian = 1
undefined endian = 2
)
type bitfield struct {
nbits uint64
reserved bool
}
const (
none = iota
sizeOf
countOf
)
type layout struct {
format int
name string
rela... | tags.go | 0.541166 | 0.403684 | tags.go | starcoder |
package trie
import (
"errors"
"github.com/FilipNikolovski/go-datastructs-and-algorithms/ds/stacks/arraystack"
)
// Trie is a trie of runes. Each trie node has an 'end' bool flag, which
// indicates whether the node represents the end character of a word.
type Trie struct {
children map[rune]*Trie
end bool
... | ds/trees/trie/trie.go | 0.739234 | 0.497803 | trie.go | starcoder |
package spdx
import (
"encoding/json"
"fmt"
"strings"
)
type Supplier struct {
// can be "NOASSERTION"
Supplier string
// SupplierType can be one of "Person", "Organization", or empty if Supplier is "NOASSERTION"
SupplierType string
}
// UnmarshalJSON takes a supplier in the typical one-line format and parse... | spdx/package.go | 0.680454 | 0.474996 | package.go | starcoder |
package data
import (
"math"
"github.com/farshidtz/senml/v2"
"github.com/linksmart/historical-datastore/registry"
)
func Same_name_same_types(count int, series registry.TimeSeries, decremental bool) senml.Pack {
value := 22.1
stringValue := "Machine Room"
boolValue := false
dataValue := "aGkgCg"
timeinit := ... | vendor/github.com/linksmart/historical-datastore/data/senmlfaker.go | 0.511961 | 0.427815 | senmlfaker.go | starcoder |
package cryptoapis
import (
"encoding/json"
)
// AddressCoinsTransactionConfirmedEachConfirmationDataItem Defines an `item` as one result.
type AddressCoinsTransactionConfirmedEachConfirmationDataItem struct {
// Represents the specific blockchain protocol name, e.g. Ethereum, Bitcoin, etc.
Blockchain string `jso... | model_address_coins_transaction_confirmed_each_confirmation_data_item.go | 0.823612 | 0.449513 | model_address_coins_transaction_confirmed_each_confirmation_data_item.go | starcoder |
package pvoc
import(
"fmt"
"math"
)
type SlidingBuffer struct {
Data []float64
lastValidSample int
hasReceivedData bool
}
func NewSlidingBuffer(length int) (buffer *SlidingBuffer) {
buffer = &SlidingBuffer{
Data: make([]float64, length, length),
lastValidSample: -1,
hasReceivedData: false,
... | pvoc/buffers.go | 0.693577 | 0.410225 | buffers.go | starcoder |
package compilerutil
import (
"hash/fnv"
hamt "github.com/raviqqe/hamt.go"
)
// ImmutableMap defines an immutable map struct, where Set-ing a new key returns a new ImmutableMap.
type ImmutableMap interface {
// Get returns the value found at the given key, if any.
Get(key string) (interface{}, bool)
// Set re... | compilerutil/immutablemap.go | 0.828072 | 0.608943 | immutablemap.go | starcoder |
package gfx
import (
"github.com/go-gl/gl/v2.1/gl"
)
// FilterMode represents the interpolation mode for texture rendering.
type FilterMode int
const (
// NearestFilter scales images with nearest neighbor interpolation.
NearestFilter FilterMode = iota
// LinearFilter scales image with linear interpolation.
Line... | gfx/texture.go | 0.72027 | 0.452173 | texture.go | starcoder |
package axon
import (
"fmt"
"reflect"
"unsafe"
)
// SynapseVarStart is the byte offset of fields in the Synapse structure
// where the float32 named variables start.
// Note: all non-float32 infrastructure variables must be at the start!
const SynapseVarStart = 4
// axon.Synapse holds state for the synaptic conn... | axon/synapse.go | 0.706494 | 0.622861 | synapse.go | starcoder |
package linear
import (
"time"
)
// Units for Distance values. Always multiply with a unit when setting the initial value like you would for
// time.Time. This prevents you from having to worry about the internal storage format.
const (
Nanometer Distance = 1e-6
Micrometer Distance = 1e-3
Millimeter Dista... | linear/distance_generated.go | 0.927855 | 0.766556 | distance_generated.go | starcoder |
package solver
import (
"fmt"
"sync"
digest "github.com/opencontainers/go-digest"
)
// EdgeIndex is a synchronous map for detecting edge collisions.
type EdgeIndex struct {
mu sync.Mutex
items map[indexedDigest]map[indexedDigest]map[*edge]struct{}
backRefs map[*edge]map[indexedDigest]map[indexedDigest]stru... | vendor/github.com/moby/buildkit/solver-next/index.go | 0.614741 | 0.414247 | index.go | starcoder |
package keras2go
import "math"
/**
* Just your basic 1d matrix multipication.
* computes C = A*B
* assumes A,B,C are all 1d arrays of matrices stored in row major order.
*
* :param C: output Array.
* :param A: input Array 1.
* :param B: input Array 2.
* :param outrows: number of rows of C and A.
* :param outcols: num... | helper_functions.go | 0.693265 | 0.719114 | helper_functions.go | starcoder |
package transform
import (
"math"
)
const (
xPi = math.Pi * 3000.0 / 180.0
a = 6378245.0
ee = 0.00669342162296594323
mc = 20037508.34
threshold = 0.000001
)
func inChina(lon, lat float64) bool {
return !(lon > 72.004 && lon < 137.8347 && lat > 0.8293 && lat < 55.8271)
}
// BD09toGCJ02 百度坐标系->火星坐标系
func ... | transform.go | 0.50952 | 0.548069 | transform.go | starcoder |
package render3d
import "github.com/unixpickle/model3d/model3d"
// Translate moves the object by an additive offset.
func Translate(obj Object, offset model3d.Coord3D) Object {
return &translatedObject{
Object: obj,
Offset: offset,
}
}
type translatedObject struct {
Object Object
Offset model3d.Coord3D
}
fu... | render3d/transform.go | 0.867204 | 0.492737 | transform.go | starcoder |
package xz
/* from linux/lib/xz/xz_lzma2.h ***************************************/
/* Range coder constants */
const (
rcShiftBits = 8
rcTopBits = 24
rcTopValue = 1 << rcTopBits
rcBitModelTotalBits = 11
rcBitModelTotal = 1 << rcBitModelTotalBits
rcMoveBits = 5
)
/*
* M... | Godeps/_workspace/src/xi2.org/x/xz/dec_lzma2.go | 0.5794 | 0.404331 | dec_lzma2.go | starcoder |
package beerjson
import "encoding/json"
import "fmt"
// ID: https://raw.githubusercontent.com/beerjson/beerjson/master/json/recipe.json
// The efficiencyType stores each efficiency component.
type EfficiencyType struct {
// The percentage of sugar from the grain yield that is extracted and converted during the mash... | recipe.go | 0.664976 | 0.40295 | recipe.go | starcoder |
package coordinate
import (
"math"
)
const (
xPi = 3.14159265358979324 * 3000.0 / 180.0
// pi
pi = 3.1415926535897932384626
// 长半轴
a = 6378245.0
// 扁率
ee = 0.00669342162296594323
)
func transformLatitude(longitude, latitude float64) float64 {
ret := -100.0 + 2.0 * longitude + 3.0 ... | coordinate.go | 0.771585 | 0.565119 | coordinate.go | starcoder |
package seq
import (
"fmt"
"github.com/callpraths/gorobdd/internal/node"
)
type leafOp func(a node.Leaf, b node.Leaf) node.Leaf
// GraphEqual determines if the BDDs rooted at the given nodes have identical
// graph structures. For this purpose, Leaf nodes with the same value are considered
// equal.
func GraphEqua... | internal/seq/binary.go | 0.784897 | 0.555194 | binary.go | starcoder |
package draw2dAnimation
import (
"code.google.com/p/draw2d/draw2d"
)
const (
TopMargin int = iota
BottomMargin
LeftMargin
RightMargin
)
type TextWithFrame struct {
*ComposedFigure
Margins []float64
}
// Constructor accepting initialized base class and creating text with rectangular frame and equal margins fo... | draw2dAnimation/textWithFrame.go | 0.812347 | 0.434461 | textWithFrame.go | starcoder |
package errors
import (
"errors"
"fmt"
"github.com/pandulaDW/go-frames/base"
)
// CustomError will return a custom error based on the message provided
func CustomError(msg string) error {
return errors.New(msg)
}
// CustomWithStandardError will return a custom error massage combined with a standard error message... | errors/errors.go | 0.77193 | 0.469216 | errors.go | starcoder |
package wasm
import (
"context"
"errors"
"fmt"
"reflect"
"github.com/tetratelabs/wazero/api"
)
// FunctionKind identifies the type of function that can be called.
type FunctionKind byte
const (
// FunctionKindWasm is not a Go function: it is implemented in Wasm.
FunctionKindWasm FunctionKind = iota
// Funct... | vendor/github.com/tetratelabs/wazero/internal/wasm/gofunc.go | 0.550124 | 0.437042 | gofunc.go | starcoder |
package main
import (
"fmt"
"math"
"strconv"
"strings"
)
/**
--- Day 12: Rain Risk ---
Your ferry made decent progress toward the island, but the storm came in faster than anyone expected. The ferry needs to take evasive actions!
Unfortunately, the ship's navigation computer seems to be malfunctioning; rather t... | day12.go | 0.699357 | 0.664989 | day12.go | starcoder |
package limage
import (
"image"
"image/color"
"vimagination.zapto.org/limage/lcolor"
)
// GrayAlpha is an image of GrayAlpha pixels
type GrayAlpha struct {
Pix []lcolor.GrayAlpha
Stride int
Rect image.Rectangle
}
// NewGrayAlpha create a new GrayAlpha image with the given bounds
func NewGrayAlpha(r image... | grayalpha.go | 0.863622 | 0.536677 | grayalpha.go | starcoder |
package reads
import (
"github.com/influxdata/influxdb/storage/reads/datatypes"
"github.com/influxdata/influxdb/tsdb/cursors"
)
func (w *ResponseWriter) getFloatPointsFrame() *datatypes.ReadResponse_Frame_FloatPoints {
var res *datatypes.ReadResponse_Frame_FloatPoints
if len(w.buffer.Float) > 0 {
i := len(w.bu... | storage/reads/response_writer.gen.go | 0.593256 | 0.455986 | response_writer.gen.go | starcoder |
package memstorage
import (
"sync"
"time"
)
// supposed to be slow
func nanoNow() uint64 {
return uint64(time.Now().UnixNano())
}
// tick returns the total number of times the interval has occurred between start and current
func tick(start, current uint64, interval time.Duration) uint64 {
return (current - start... | pkg/memstorage/bucket.go | 0.68215 | 0.410284 | bucket.go | starcoder |
package keeper
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/gravity-devs/liquidity/x/liquidity/types"
)
// RegisterInvariants registers all liquidity invariants.
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
ir.RegisterRoute(types.ModuleName, "escrow-amount",
LiquidityPo... | x/liquidity/keeper/invariants.go | 0.718594 | 0.437403 | invariants.go | starcoder |
package tokens
import "fmt"
// Claims represents token claims.
type Claims map[string]interface{}
func (c Claims) getFloat64Claim(claim string) (float64, bool) {
if value, ok := c[claim]; ok {
switch tvalue := value.(type) {
case float32:
return float64(tvalue), true
case uint:
return float64(tvalue), t... | tokens/shared.go | 0.658637 | 0.523055 | shared.go | starcoder |
package jp
// X creates an empty Expr.
func X() Expr {
return Expr{}
}
// A creates an Expr with a At (@) fragment.
func A() Expr {
return Expr{At('@')}
}
// B creates an Expr with a Bracket fragment.
func B() Expr {
return Expr{Bracket(' ')}
}
// C creates an Expr with a Child fragment.
func C(key string) Expr... | jp/build.go | 0.829699 | 0.467453 | build.go | starcoder |
package options
// UpdateOptions represents all possible options to the UpdateOne() and UpdateMany() functions.
type UpdateOptions struct {
ArrayFilters *ArrayFilters // A set of filters specifying to which array elements an update should apply
BypassDocumentValidation *bool // If true, allows t... | vendor/go.mongodb.org/mongo-driver/mongo/options/updateoptions.go | 0.816991 | 0.403214 | updateoptions.go | starcoder |
package msgraph
// RatingUnitedStatesMoviesType undocumented
type RatingUnitedStatesMoviesType string
const (
// RatingUnitedStatesMoviesTypeVAllAllowed undocumented
RatingUnitedStatesMoviesTypeVAllAllowed RatingUnitedStatesMoviesType = "AllAllowed"
// RatingUnitedStatesMoviesTypeVAllBlocked undocumented
RatingU... | v1.0/RatingUnitedStatesMoviesTypeEnum.go | 0.601359 | 0.478894 | RatingUnitedStatesMoviesTypeEnum.go | starcoder |
package otlptest
import (
"context"
"fmt"
"testing"
"time"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel/exporters/otlp"
commonpb "go.opentelemetry.io/otel/exporters/otlp/internal/opentelemetry-proto-gen/common/v1"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/metric"
"go.ope... | exporters/otlp/internal/otlptest/otlptest.go | 0.577138 | 0.432962 | otlptest.go | starcoder |
// Useful test functions for validating (mostly) string outputs match
// what is expected.
package assert
import (
"bytes"
"github.com/danos/mgmterror"
"github.com/danos/utils/exec"
"io"
"os"
"strings"
"testing"
)
func init() {
exec.NewExecError = func(path []string, err string) error {
return mgmterror.N... | testutils/assert/assert.go | 0.655336 | 0.548976 | assert.go | starcoder |
package output
import (
"errors"
"fmt"
"github.com/Jeffail/benthos/v3/lib/broker"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message/batch"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/benthos/v3/lib/x/docs"
)
//----... | lib/output/broker.go | 0.751283 | 0.647325 | broker.go | starcoder |
// Package epochs implements time-based feeds using epochs as index
// and provide sequential as well as concurrent lookup algorithms
package epochs
import (
"encoding/binary"
"fmt"
"github.com/penguintop/penguin/pkg/crypto"
"github.com/penguintop/penguin/pkg/feeds"
)
const (
maxLevel = 32
)
var _ feeds.Index... | pkg/feeds/epochs/epoch.go | 0.891321 | 0.402774 | epoch.go | starcoder |
package conf
// Float32Var defines a float32 flag and environment variable with specified name, default value, and usage string.
// The argument p points to a float32 variable in which to store the value of the flag and/or environment variable.
func (c *Configurator) Float32Var(p *float32, name string, value float32, ... | value_float32.go | 0.891457 | 0.78691 | value_float32.go | starcoder |
// Package tkr contains functions for working with Tanzu Kubernetes Release information.
package tkr
import (
"fmt"
"os"
"gopkg.in/yaml.v3"
)
// ImagePackage represents information for an image.
type ImagePackage struct {
ImagePath string `yaml:"imagePath"`
Tag string `yaml:"tag"`
Repository string `y... | cli/cmd/plugin/unmanaged-cluster/tkr/tkr.go | 0.52683 | 0.501831 | tkr.go | starcoder |
package linkedlist
// Node is the node type used within the linked list.
type node[T comparable] struct {
prev *node[T]
next *node[T]
val T
}
// LinkedList is the main linked list type.
type LinkedList[T comparable] struct {
first *node[T]
last *node[T]
count int
}
// New is used to create a new linked list.... | linkedlist/linkedlist.go | 0.763968 | 0.480601 | linkedlist.go | starcoder |
package plaid
import (
"encoding/json"
)
// AssetReportTransaction struct for AssetReportTransaction
type AssetReportTransaction struct {
// Please use the `payment_channel` field, `transaction_type` will be deprecated in the future. `digital:` transactions that took place online. `place:` transactions that were... | plaid/model_asset_report_transaction.go | 0.840292 | 0.453867 | model_asset_report_transaction.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.