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 redblack
import (
"fmt"
"go.uber.org/zap"
)
type color bool
const (
red color = false
black color = true
)
type node struct {
key string
value string
left *node
right *node
p *node
color color
}
// RedBlack implement Tree interface for RedBlackTree
type RedBlack struct {
root *n... | pkg/tree/redblack/redblack.go | 0.6508 | 0.410402 | redblack.go | starcoder |
package iso20022
// Details of the securities trade.
type SecuritiesTradeDetails37 struct {
// Market in which a trade transaction has been executed.
PlaceOfTrade *MarketIdentification78 `xml:"PlcOfTrad,omitempty"`
// Infrastructure which may be a component of a clearing house and wich facilitates clearing and se... | SecuritiesTradeDetails37.go | 0.830834 | 0.438725 | SecuritiesTradeDetails37.go | starcoder |
// Package verification contains verifiers for clients of the map to confirm
// entries are committed to.
package verification
import (
"bytes"
"crypto"
"fmt"
"github.com/google/trillian/experimental/batchmap"
"github.com/google/trillian/merkle/coniks"
"github.com/google/trillian/merkle/smt"
"github.com/googl... | experimental/batchmap/sumdb/verification/inclusion.go | 0.752195 | 0.556821 | inclusion.go | starcoder |
package day12
import (
"bufio"
"fmt"
"io"
"os"
"strconv"
)
type Coord [2]int
type Direction int
const (
East Direction = iota
South
West
North
Left
Right
Forward
)
type Entry struct {
distance int
direction Direction
}
func Day12() {
input, err := parseInput()
if err != nil {
panic(err)
}
fmt... | day12/day12.go | 0.585812 | 0.434401 | day12.go | starcoder |
package main
// Note: Adjacency list representation of graph was already implemented by me in previous graphs section. Hence I have
// modified few things which converts this adjacency list to adjacency matrix and then the bellman ford algorithm is
// implemented. However you can directly take user inputs and add it i... | algorithms/graphs/bellman_ford/bellman_ford.go | 0.628179 | 0.532547 | bellman_ford.go | starcoder |
package node
import (
"sort"
"github.com/insolar/insolar/insolar"
)
type Accessor struct {
snapshot *Snapshot
refIndex map[insolar.Reference]insolar.NetworkNode
sidIndex map[insolar.ShortNodeID]insolar.NetworkNode
addrIndex map[string]insolar.NetworkNode
// should be removed in future
active []insolar.Ne... | network/node/accessor.go | 0.583559 | 0.427935 | accessor.go | starcoder |
package ccd
import (
"strconv"
"strings"
"time"
"github.com/mattn/go-pkg-xmlx"
)
const (
// Found both these formats in the wild
TimeDecidingIndex = 14
TimeFormat = "20060102150405-0700"
TimeFormat2 = "20060102150405.000-0700"
)
type TimeType string
const (
// represents a single point in tim... | ccd/util.go | 0.679923 | 0.401658 | util.go | starcoder |
Package events implements the audit log interface events.IAuditLog
using filesystem backend.
Audit logs
----------
Audit logs are events associated with user logins, server access
and session log events like session.start.
Example audit log event:
{"addr.local":"192.168.127.12:3022",
"addr.remote":"192.168.127.12:... | lib/events/doc.go | 0.6137 | 0.407569 | doc.go | starcoder |
package rs
import (
"fmt"
)
type poly struct {
field *Field
coefficients []byte // In reverse order.
}
var zero = []byte{0}
var one = []byte{1}
// |coefficients| representing elements of GF(size), arranged from most
// significant (highest-power term) coefficient to least significant.
func makePoly(field... | poly.go | 0.822724 | 0.658857 | poly.go | starcoder |
package twidgets
import (
"fmt"
"github.com/gdamore/tcell"
"gitlab.com/tslocum/cview"
)
const (
arrowUp = "▲"
arrowDown = "▼"
)
// SortType is a direction that can be sorted with
type Sort int
const (
// Sort ascending
SortAsc Sort = iota
// Sort descending
SortDesc
)
// Table extends cview.Table with s... | table.go | 0.624064 | 0.406921 | table.go | starcoder |
package disasm
type OpDoc struct {
Short string
Long string
Formulae string
}
var OpDocs = map[string]OpDoc{
"SOF": {Short: "Scale and offset",
Long: "SOF will multiply the current value in ACC with C and will then " +
"add the constant D to the result.",
Formulae: "C * ACC + D",
},
"AND": {Short:... | disasm/docs.go | 0.510008 | 0.609698 | docs.go | starcoder |
package lfuda
import (
"sync"
"github.com/bparli/lfuda-go/simplelfuda"
)
// Cache is a thread-safe fixed size lfuda cache.
type Cache struct {
lfuda simplelfuda.LFUDACache
lock sync.RWMutex
}
// New creates an lfuda of the given size.
func New(size float64) *Cache {
return newWithEvict(size, "LFUDA", nil)
}
... | lfuda.go | 0.76934 | 0.500793 | lfuda.go | starcoder |
package align
import (
"unicode"
"git.sr.ht/~flobar/lev"
)
// Pos represents the start and end position of an alignment.
type Pos struct {
B, E int // Start end end positions of the alignment slice.
str []rune // Reference string of the alignment.
}
// mkpos creates a new Pos instance with leading and subse... | pkg/apoco/align/align.go | 0.507812 | 0.50708 | align.go | starcoder |
package suite
import (
"testing"
"reflect"
"fmt"
"github.com/kylelemons/godebug/pretty"
)
type AnyType int
type RunTest func(*testing.T, *Test, int)
const (
Any AnyType = 0
)
type Test struct {
Name string
Caller interface{}
Request []interface{}
Response []interface{}
}
type Table s... | suite/suite.go | 0.630116 | 0.433262 | suite.go | starcoder |
package deep
import "math"
// Mode denotes inference mode
type Mode int
const (
// ModeDefault is unspecified mode
ModeDefault Mode = 0
// ModeMultiClass is for one-hot encoded classification, applies softmax output layer
ModeMultiClass Mode = 1
// ModeRegression is regression, applies linear output layer
Mode... | plugins/data/learn/ml-libs-godeep/activation.go | 0.882047 | 0.652823 | activation.go | starcoder |
package golfcart
import (
"github.com/alecthomas/participle/v2"
"github.com/alecthomas/participle/v2/lexer"
"github.com/alecthomas/participle/v2/lexer/stateful"
)
type ExpressionList struct {
Pos lexer.Position
Expressions []*Expression `@@*`
}
type Expression struct {
Pos lexer.Position
Assignment ... | pkg/golfcart/parse.go | 0.562417 | 0.450964 | parse.go | starcoder |
package convexHull
import "sort"
// Point is a struct that holds the X Y cooridinates
// of a specific point in the Ecliden plane or space.
type Point struct {
X, Y int
}
// Points is a slice built up of Point structs.
type Points []Point
func (points Points) Swap(i, j int) {
points[i], points[j] = points[j], poi... | convexHull/convexHull.go | 0.833019 | 0.551211 | convexHull.go | starcoder |
package compact_time
import (
"fmt"
"strings"
gotime "time"
)
type TimeType uint8
const (
TimeTypeDate = TimeType(iota)
TimeTypeTime
TimeTypeTimestamp
)
type TimezoneType uint8
const (
TimezoneTypeUnset = TimezoneType(iota)
TimezoneTypeUTC
TimezoneTypeLocal
TimezoneTypeAreaLocation
TimezoneTypeLatitude... | time.go | 0.797793 | 0.610889 | time.go | starcoder |
package entities
import (
"fmt"
"reflect"
)
// Chunk represents square area. Many Entities are deployed over Chunk.
type Chunk struct {
Base
ChunkPoint
Residence *DelegateResidence
Company *DelegateCompany
RailNode *DelegateRailNode
Parent *Cluster
InRailEdges map[uint]*DelegateRailEdge
OutRailEdges ... | entities/chunk.go | 0.624064 | 0.400984 | chunk.go | starcoder |
package bytequantity
import (
"fmt"
"math"
"regexp"
"strconv"
"strings"
)
const (
/// Examples: 1mb, 1 gb, 1.0tb, 1mib, 2g, 2.001 t
byteQuantityRegex = `^([0-9]+\.?[0-9]{0,3})[ ]?(mi?b?|gi?b?|ti?b?)?$`
mib = "MiB"
gib = "GiB"
tib = "TiB"
gbConvert ... | pkg/bytequantity/bytequantity.go | 0.839471 | 0.42173 | bytequantity.go | starcoder |
package continuous
import (
"fmt"
"math"
)
// Distance calculates the distance between to vectors,
// given the set of indices
func Distance(a, b []float64, indices []int) float64 {
d := 0.0
for _, v := range indices {
d += (a[v] - b[v]) * (a[v] - b[v])
}
return math.Sqrt(d)
}
// Harmonic calculates the harm... | continuous/Functions.go | 0.7413 | 0.474327 | Functions.go | starcoder |
package haversine
import (
"math"
)
const (
EarthRadiusMi = 3958 // radius of the earth in miles.
EarthRadiusKm = 6371 // radius of the earth in kilometers.
EarthRadiusNM = 3440 // radius of the earth in nautical miles
)
// Coord represents a lat/long geographic coordinate, usually in degrees +EN/-WS.
type Coord... | haversine.go | 0.921746 | 0.673739 | haversine.go | starcoder |
package bitfield
import (
"encoding/binary"
"math/bits"
)
var _ = Bitfield(Bitvector256{})
// Bitvector256 is a bitfield with a fixed defined size of 256. There is no length bit
// present in the underlying byte array.
type Bitvector256 []byte
const bitvector256ByteSize = 32
const bitvector256BitSize = bitvector2... | bitvector256.go | 0.789193 | 0.468183 | bitvector256.go | starcoder |
package scaling
import (
"github.com/wieku/danser-go/framework/math/vector"
)
type Scaling int
const (
// The source is not scaled.
None = Scaling(iota)
// Scales the source to fit the target while keeping the same aspect ratio. This may cause the source to be smaller than the
// target in one direction.
Fit
... | framework/math/scaling/scaling.go | 0.786705 | 0.534066 | scaling.go | starcoder |
package parseg
import (
"io"
"github.com/ajiyoshi-vg/parseg/stream"
)
type Parser[T any] interface {
Parse(stream.Stream) (*T, int, error)
TryParser() Parser[T]
IntoFunc() ParserFunc[T]
}
var (
_ Parser[int] = (ParserFunc[int])(nil)
_ Parser[int] = (*ParserFunc[int])(nil)
)
type ParserFunc[T any] func(strea... | parser.go | 0.509764 | 0.433921 | parser.go | starcoder |
package metrics
import (
"bytes"
"fmt"
"sort"
"text/tabwriter"
)
// A ConfusionMatrix stores true positives (TP), true negatives (TN), false
// positives (FP) and false negatives (FN).
type ConfusionMatrix map[float64]map[float64]float64
// NClasses returns the number of classes in a ConfusionMatrix.
func (cm Co... | metrics/confusion_matrix.go | 0.776538 | 0.428831 | confusion_matrix.go | starcoder |
package unit
import (
"fmt"
"strings"
)
// DataSizeUnit defines available units used for specifying expected storage size, expected upload size, and expected download size
var DataSizeUnit = []string{"kb", "mb", "gb", "tb", "kib", "mib", "gib", "tib"}
var DataSizeMultiplier = map[string]uint64{
"kb": 1e3,
"mb"... | common/unit/storage.go | 0.580233 | 0.478955 | storage.go | starcoder |
package assert
import (
"errors"
"testing"
)
// Equal calls t.Fatalf if result != expected.
func Equal[T comparable](t testing.TB, result, expected T) {
t.Helper()
if result != expected {
t.Fatalf("%v != %v", result, expected)
}
}
// EqualSlices calls t.Fatalf if result expected do not contain the same eleme... | assert/assert.go | 0.63273 | 0.691797 | assert.go | starcoder |
package walker
import (
"fmt"
"strings"
"github.com/beefsack/go-astar"
)
// Graph extends a dijkstra's graph based on the schema.
type Graph struct {
schema *Schema
pathers map[Vertex]*pather
}
// NewGraph prepares a graph from a schema.
func NewGraph(s *Schema) *Graph {
var g Graph
g.pathers = make(map[Ve... | graph.go | 0.607197 | 0.429549 | graph.go | starcoder |
package extraction
import (
"image"
"log"
"math"
"github.com/alevinval/fingerprints/src/matrix"
"github.com/alevinval/fingerprints/src/types"
)
// Frame detects the boundaries of the fingerprint and establishes
// a reference point and the angle of such reference point.
func Frame(binarizedSegmented *matrix.M) ... | src/extraction/frame.go | 0.760295 | 0.471953 | frame.go | starcoder |
package main
import (
"fmt"
"math"
)
const threeSixty float64 = 360.0
const oneEighty float64 = 180.0
const radius float64 = 6378137.0
const webMercatorLatLimit float64 = 85.05112877980659
type ErrTile struct {
X int `json:"x"`
Y int `json:"y"`
Z int `json:"z"`
Res string `json:"res"`
}
//Tile ... | tilepack.go | 0.772015 | 0.403861 | tilepack.go | starcoder |
package main
import (
"math"
. "github.com/jakecoffman/cp"
"github.com/jakecoffman/cp/examples"
)
const (
FLUID_DENSITY = 0.00014
FLUID_DRAG = 2.0
)
func kScalarBody(body *Body, point, n Vector) float64 {
rcn := point.Sub(body.Position()).Cross(n)
return 1.0/body.Mass() + rcn*rcn/body.Moment()
}
func wat... | examples/buoyancy/buoyancy.go | 0.758242 | 0.530784 | buoyancy.go | starcoder |
package cryptypes
import "database/sql/driver"
// EncryptedByte supports encrypting Byte data
type EncryptedByte struct {
Field
Raw byte
}
// Scan converts the value from the DB into a usable EncryptedByte value
func (s *EncryptedByte) Scan(value interface{}) error {
return decrypt(value.([]byte), &s.Raw)
}
// V... | cryptypes/type_byte.go | 0.824956 | 0.625867 | type_byte.go | starcoder |
package advent
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
// Parse a line with format 1-2 a: abcde
// Returns the two integers, the single letter and the string
func parsePasswordLine(line string) (first int, second int, target string, password string, err error) {
line = strings.Replace(line, ":"... | cmd/day2.go | 0.645567 | 0.434281 | day2.go | starcoder |
package num
import (
"encoding/binary"
"math"
"github.com/flier/gocombine/pkg/parser"
"github.com/flier/gocombine/pkg/parser/bytes"
"github.com/flier/gocombine/pkg/parser/combinator"
)
// Uint16 reads a uint16 out of the byte stream with the specified endianess.
func Uint16(endian binary.ByteOrder) parser.Func[... | pkg/parser/bytes/num/num.go | 0.785309 | 0.505859 | num.go | starcoder |
package main
import (
"fmt"
"log"
"sort"
"strconv"
)
func strToFloat64(str string) float64 {
f, err := strconv.ParseFloat(str, 64)
if err != nil {
log.Fatal(err)
}
return f
}
func main() {
rows := [][]string{
[]string{"cdomain.com", "3", "-5.02", "aaa", "aaa"},
[]string{"cdomain.com", "2", "133.02", "... | doc/go_sort_algorithm/code/07_sort_by.go | 0.592431 | 0.454048 | 07_sort_by.go | starcoder |
package avalanche
// Vote represents a single vote for a target
type Vote struct {
err uint32 // this is called "error" in abc for some reason
hash Hash
}
// NewVote creates a new Vote for the given hash
func NewVote(err uint32, hash Hash) Vote {
return Vote{err, hash}
}
// GetHash returns the target hash
func (... | vote.go | 0.806853 | 0.47591 | vote.go | starcoder |
package mdr
import (
"fmt"
"math"
"math/rand"
)
var NormalZtable *Table
func init() {
Verbose.Printf("mdr.randgen.go init() entry\n")
defer Verbose.Printf("mdr.randgen.go init() exit\n")
// table contains : z value, area (ie. probability) to left of z value
// upper half of table only, negative values = (1.0... | mdr_randgen.go | 0.545286 | 0.474936 | mdr_randgen.go | starcoder |
package photon
import (
"math"
"math/rand"
"github.com/alan-christopher/bb84/go/bb84/bitmap"
)
// NewSimulatedChannel creates a pair of (Sender, Receiver) structs simulating a
// Quantum channel. It is expected that each call to Send() will be mirrored by
// a call to Receive(). Expect errors if that is not the c... | go/bb84/photon/simulated.go | 0.658527 | 0.500793 | simulated.go | starcoder |
package labels
import (
"fmt"
"sync"
"github.com/janelia-flyem/dvid/dvid"
)
var (
mc mergeCache
labelsMerging dirtyCache
labelsSplitting dirtyCache
)
const (
// MaxAllowedLabel is the largest label that should be allowed by DVID if we want to take
// into account the maximum integer size with... | datatype/common/labels/labels.go | 0.716814 | 0.557905 | labels.go | starcoder |
package suncalc
import (
m "math"
"time"
)
const rad = m.Pi / 180
// time conversions
const (
daySec = 60 * 60 * 24
j1970 = 2440588.0
j2000 = 2451545.0
)
func toJulian(t time.Time) float64 {
return float64(t.Unix()) / daySec - 0.5 + j1970
}
func fromJulian(j float64) time.Time {
return time.Unix(int64((j + ... | vendor/src/github.com/whosonfirst/suncalc-go/suncalc.go | 0.878171 | 0.519278 | suncalc.go | starcoder |
package finder
import (
"context"
"errors"
"math"
"strings"
"sync"
)
// Finder is the type to find the nearest reference
type Finder struct {
referenceMap referenceMapType
reference []string
referenceBucket referenceBucketType
Alg Algorithm
LengthTolerance float64 // A number between 0.... | finder/find.go | 0.760917 | 0.42322 | find.go | starcoder |
package msgraph
// ProvisioningStepType undocumented
type ProvisioningStepType string
const (
// ProvisioningStepTypeVImport undocumented
ProvisioningStepTypeVImport ProvisioningStepType = "Import"
// ProvisioningStepTypeVScoping undocumented
ProvisioningStepTypeVScoping ProvisioningStepType = "Scoping"
// Prov... | beta/ProvisioningStepTypeEnum.go | 0.54577 | 0.435241 | ProvisioningStepTypeEnum.go | starcoder |
package core
import (
"strings"
"github.com/raviqqe/hamt"
)
// DictionaryType represents a dictionary in the language.
type DictionaryType struct {
hamt.Map
}
// Eval evaluates a value into a WHNF.
func (d *DictionaryType) eval() Value {
return d
}
var (
emtpyDictionary = DictionaryType{hamt.NewMap()}
// Em... | src/lib/core/dictionary.go | 0.713831 | 0.513546 | dictionary.go | starcoder |
package main
import (
"container/heap"
"encoding/base64"
"fmt"
"image"
"image/color"
"image/png"
"io"
"golang.org/x/image/draw"
)
type maze struct {
image.Gray
maze []byte
}
func newMaze(src image.Image, width, height int) *maze {
r := image.Rect(0, 0, width, height)
w, h := r.Dx(), r.Dy()
pix := make... | maze.go | 0.564339 | 0.4474 | maze.go | starcoder |
package genetic_algorithm
import (
"fmt"
"math"
"math/rand"
)
// https://hg.python.org/cpython/file/4480506137ed/Lib/statistics.py#l453
func meanFloat64(values []float64) float64 {
if len(values) == 0 {
return 0
}
var sum float64
for _, val := range values {
sum += val
}
return sum / float64(len(values... | helper.go | 0.619701 | 0.524151 | helper.go | starcoder |
package is
import (
"reflect"
"strings"
"testing"
)
type suiteTest struct {
fn func(Is)
name string
}
// Suite runs the given test suite.
// If the suite contains a method named `Setup` it is called before any tests are run.
// Tests must start with `Test` and take `is.IS` as the first arg.
// Finally after a... | suite.go | 0.564699 | 0.42316 | suite.go | starcoder |
package gridmap
import (
"geometry"
"sort"
)
const (
MAP_WIDTH = 7200 // 地图度(x)
MAP_HEIGHT = 7200 // 地图高(y)
MIST_BLOCK_SIZE = 90 // 迷雾块大小
MIST_CELL_SIZE = 15 // 迷雾格子大小
)
// 正方形左下角
func GetSquareBottom(center geometry.Coordinate, width int32) geometry.Coordinate {
var originX = center.X - width... | go/gridmap.go | 0.500488 | 0.446193 | gridmap.go | starcoder |
package routing
import (
"net/http"
)
const (
nodeTypeStatic = iota
nodeTypeDynamic
)
type tree struct {
root *node
}
func (t *tree) insert(chunks []chunk, handler http.HandlerFunc) *node {
root2, leaf2 := createTreeFromChunks(chunks)
leaf2.handler = handler
t.root = combine(t.root, root2)
return leaf2
}
... | tree.go | 0.604516 | 0.525612 | tree.go | starcoder |
package interpreter
import (
"github.com/fract-lang/fract/pkg/arithmetic"
"github.com/fract-lang/fract/pkg/fract"
"github.com/fract-lang/fract/pkg/grammar"
"github.com/fract-lang/fract/pkg/objects"
"github.com/fract-lang/fract/pkg/parser"
"github.com/fract-lang/fract/pkg/vector"
)
func compareValues(operator st... | internal/interpreter/process_condition.go | 0.534127 | 0.466481 | process_condition.go | starcoder |
package nums
import (
"math"
)
const (
minTValue = 0.0
halfTVaue = 0.5
maxTValue = 1.0
)
var (
// MinT is the smallest T parameter
MinT = TParam{minTValue}
// HalfT is the average between min and max T values
HalfT = TParam{halfTVaue}
// MaxT is the biggest T Parameter
MaxT = TParam{maxTValue}
)
/*
A TPar... | nums/tparam.go | 0.746971 | 0.444625 | tparam.go | starcoder |
package dotmatrix
import (
"fmt"
"image"
"image/color"
"image/draw"
"io"
)
// Flushes an image to the io.Writer. E.g. by using braille characters.
type Flusher interface {
Flush(w io.Writer, img image.Image) error
}
// Filter may alter an image in any way, including resizing it.
// It is applied prior to drawi... | image.go | 0.664323 | 0.414958 | image.go | starcoder |
package vision
import (
"image"
"image/draw"
"math"
"github.com/joaowiciuk/vision/kernel"
"github.com/joaowiciuk/matrix"
)
// Canny implements the popular canny edge detector
func Canny(img image.Image, upperThreshold, lowerThreshold uint8, k int, σ float64) (j *image.Gray) {
lowT := float64(lowerThreshold)
... | canny.go | 0.651022 | 0.551332 | canny.go | starcoder |
package model
var RuleCategories = make(map[string]*RuleCategory)
var RuleCategoriesOrdered []*RuleCategory
func init() {
RuleCategories[CategoryExamples] = &RuleCategory{
Id: CategoryExamples,
Name: "Examples",
Description: "Examples help consumers understand how API calls should look. They are really impo... | model/rule_categories.go | 0.531696 | 0.414721 | rule_categories.go | starcoder |
package mqv
import (
"math/big"
"math/bits"
)
// SubtleIntSize returns the size of a SubtleInt that can store at least
// numBits of information.
func SubtleIntSize(numBits int) int {
const wordSize = bits.UintSize / 8
numBytes := ((numBits + 7) >> 3)
numWords := (numBytes + wordSize - 1) / wordSize
return num... | subtle.go | 0.756987 | 0.517693 | subtle.go | starcoder |
package hier
import "strconv"
// Graph is the basic graph
type Graph struct {
Nodes Nodes
// Ranking
ByRank []Nodes
}
// ID is an unique identifier to a Node
type ID int
// Node is the basic information about a node
type Node struct {
ID ID
Virtual bool
In Nodes
Out Nodes
Label string
// Rank info
Ra... | internal/hier/graph.go | 0.791297 | 0.434641 | graph.go | starcoder |
package main
import (
"fmt"
"math"
"testing"
)
type Var string
type literal float64
type unary struct {
op rune
x Expr
}
type binary struct {
op rune
x, y Expr
}
type call struct {
fn string
args []Expr
}
type Env map[Var]float64
type Expr interface {
Eval(env En... | gopl-sample/eval.go | 0.646572 | 0.453201 | eval.go | starcoder |
package xmlParser
import (
"errors"
"fmt"
"reflect"
"regexp"
"strconv"
"strings"
"time"
"github.com/clbanning/mxj"
)
/*
XMLNode is wrapper to mxj map.
It can traverse the xml to get the data.
NOTE:
All attributes will also become a node with key '-attributesName'.
And tags with attributes, their value will... | xmlParser/xml_node.go | 0.66061 | 0.402275 | xml_node.go | starcoder |
package gen
import (
pschema "github.com/pulumi/pulumi/pkg/v3/codegen/schema"
)
// typeOverlays augment the types defined by the kubernetes schema.
var typeOverlays = map[string]pschema.ComplexTypeSpec{
"kubernetes:core/v1:ServiceSpec": {
ObjectTypeSpec: pschema.ObjectTypeSpec{
Properties: map[string]pschema.... | provider/pkg/gen/overlays.go | 0.503418 | 0.405066 | overlays.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTExportTessellatedEdgesEdge1364 struct for BTExportTessellatedEdgesEdge1364
type BTExportTessellatedEdgesEdge1364 struct {
BtType *string `json:"btType,omitempty"`
Id *string `json:"id,omitempty"`
Vertices *[]BTVector3d389 `json:"vertices,omitempty"`
}
// NewBTExpor... | onshape/model_bt_export_tessellated_edges_edge_1364.go | 0.66356 | 0.490236 | model_bt_export_tessellated_edges_edge_1364.go | starcoder |
package auth0fga
import (
"encoding/json"
)
// WriteAssertionsRequestParams struct for WriteAssertionsRequestParams
type WriteAssertionsRequestParams struct {
Assertions []Assertion `json:"assertions"`
}
// NewWriteAssertionsRequestParams instantiates a new WriteAssertionsRequestParams object
// This constructor w... | model_write_assertions_request_params.go | 0.681303 | 0.525856 | model_write_assertions_request_params.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_nbc
#include <capi/nbc.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type NbcOptionalParam struct {
IncrementalVariance bool
InputModel *nbcModel
Labels *mat.Dense
Test *mat.Dense
Training *mat.De... | nbc.go | 0.710025 | 0.472562 | nbc.go | starcoder |
package board
// CoordinateToBitBoard returns BitBoard that is flagged only at the specified coordinates
func CoordinateToBitBoard(x int, y int) BitBoard {
var bb BitBoard = 0x8000000000000000
bb = bb >> x
bb = bb >> (y * 8)
return bb
}
// MakeLegalBoard returns BitBoard with flags only on the squares where the... | board/util.go | 0.829181 | 0.481881 | util.go | starcoder |
package basic
import "strings"
// FilterPtrTest applies the function(1st argument) on each item of the list and returns new list
func FilterPtrTest() string {
return `
func TestFilter<FTYPE>Ptr(t *testing.T) {
var v1 <TYPE> = 1
var v2 <TYPE> = 2
var v3 <TYPE> = 3
var v4 <TYPE> = 4
var v10 <TYPE> = 10
var v20 <... | internal/template/basic/filterptrtest.go | 0.541894 | 0.487307 | filterptrtest.go | starcoder |
package ts
// Create Elementary stream packets containing our stream src
func CreateStreamPackets(streamInfo StreamInfo, samplesInfo []SampleInfo, fragment *FragmentData) {
// For each sample
for _, sample := range samplesInfo {
// Create the elementary stream
elementaryStream := CreateElementaryStreamSrc(strea... | src/ts/CreateStreamPackets.go | 0.603581 | 0.435121 | CreateStreamPackets.go | starcoder |
package cmd
import (
"errors"
"fmt"
"strings"
"github.com/JosephLai241/shift/database"
"github.com/JosephLai241/shift/timesheet"
"github.com/JosephLai241/shift/utils"
"github.com/spf13/cobra"
)
// amendCmd represents the amend command.
var amendCmd = &cobra.Command{
Use: `amend (in|out) "NEW MESSAGE"`,
S... | cmd/amend.go | 0.655667 | 0.419529 | amend.go | starcoder |
package main
const inccidentTemplate = `{
{{.MessageTarget}}
"markdown": "<blockquote class='{{.MessageColor}}'> {{.Emoji}} {{.MessageStatus}} <br/>
<b>Check Name:</b> {{.CheckName}}
{{if (ne .MessageStatus "Resolved") }}
<b>Execution Time:</b> {{.CheckExecutionTime}} <br... | template.go | 0.565539 | 0.435902 | template.go | starcoder |
package rate
import (
"math"
"sync"
"time"
)
const hz float64 = 1.0 / float64(time.Second)
// Estimator is a rate estimator using exponential decay. It is not
// thread-safe.
type Estimator struct {
interval time.Duration
seconds float64
value float64
base float64
time time.Time
running bool
}... | rate/rate.go | 0.845879 | 0.614394 | rate.go | starcoder |
package card
import (
"context"
"github.com/ianeinser/xendit-go"
)
/* Token */
///--- CreateToken creates new token
func CreateToken(data *CreateTokenParams) (*xendit.Token, *xendit.Error) {
return CreateTokenWithContext(context.Background(), data)
}
///--- CreateTokenWithContext creates new token with context
... | card/card.go | 0.685002 | 0.428054 | card.go | starcoder |
package main
// help prints the help message and exits.
import (
"fmt"
"os"
"strings"
)
// help generates the help message.
func help(opts CliOptions) {
if opts.HelpArg == "" {
helpTop()
} else {
// generate the help for a recipe
recipe := loadRecipe(opts.HelpArg)
fmt.Printf("Help for %v - %v\n", recipe... | src/cb/help.go | 0.51879 | 0.41117 | help.go | starcoder |
package binpack2d
// List of different heuristic rules that can be used when deciding where to place a new rectangle.
const (
RULE_BEST_SHORT_SIDE_FIT = iota
RULE_BEST_LONG_SIDE_FIT
RULE_BEST_AREA_FIT
RULE_BOTTOM_LEFT
RULE_CONTACT_POINT
num_rules
)
// The Rectangle structure defines position and size of ... | binpack2d.go | 0.914972 | 0.732687 | binpack2d.go | starcoder |
package connect
import "encoding/json"
type HistogramType string
const (
HistogramOneDay HistogramType = "HistogramOneDay" // Data interval: 5min, Max samples: 288
HistogramTwoHours HistogramType = "HistogramTwoHours" // Data interval: 20sec, Max samples: 360
HistogramOneWeek HistogramType = "HistogramOneWee... | systemHealth.go | 0.693473 | 0.649064 | systemHealth.go | starcoder |
package ecs
// Mask is the format of the bitmask
type Mask uint64
// Mask is the size of Mask in bits
const MaskTotalBits = 64
var nibbleToBitsSet = [16]uint{0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}
// NewMask creates a new bitmask from a list of IDs
// If any ID is bigger or equal MaskTotalBits, it'll not b... | bitmask.go | 0.743727 | 0.528777 | bitmask.go | starcoder |
package twiml
import (
"fmt"
"regexp"
"strings"
)
// Validate aggregates the results of individual validation functions and returns true
// when all validation functions pass
func Validate(vf ...bool) bool {
for _, f := range vf {
if !f {
return false
}
}
return true
}
// OneOf validates that a field is... | validate.go | 0.690246 | 0.423041 | validate.go | starcoder |
package diffence
const (
defaultRulesJSON = `[
{
"part": "filename",
"type": "regex",
"pattern": "\\A.*_rsa\\z",
"caption": "Private SSH key",
"description": null
},
{
"part": "filename",
"type": "regex",
"pattern": "\\A.*_dsa\\z",
"caption": "Private SSH key",
"descripti... | rules.go | 0.565779 | 0.496094 | rules.go | starcoder |
package mvt
import (
"log"
"github.com/go-spatial/geom/cmp"
"github.com/go-spatial/geom/winding"
"github.com/go-spatial/geom"
)
// PrepareGeo converts the geometry's coordinates to tile pixel coordinates. tile should be the
// extent of the tile, in the same projection as geo. pixelExtent is the dimension of t... | vendor/github.com/go-spatial/geom/encoding/mvt/prepare.go | 0.684264 | 0.699819 | prepare.go | starcoder |
package block
import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/entity"
"github.com/df-mc/dragonfly/server/item"
"github.com/df-mc/dragonfly/server/world"
"github.com/df-mc/dragonfly/server/world/particle"
"github.com/go-gl/mathgl/mgl64"
"math/rand"
)
// DoubleFlower is... | server/block/double_flower.go | 0.651909 | 0.438785 | double_flower.go | starcoder |
package cvss3
import "fmt"
type BaseMetrics struct {
AttackVector
AttackComplexity
PrivilegesRequired
UserInteraction
Scope
Confidentiality
Integrity
Availability
}
type AttackVector int
const (
AttackVectorNetwork AttackVector = iota + 1
AttackVectorAdjecent
AttackVectorLocal
AttackVectorPhysical
)
v... | cvss3/base_metrics.go | 0.657098 | 0.47658 | base_metrics.go | starcoder |
package validator
import (
"fmt"
"math/big"
"sort"
"strings"
"github.com/hyperledger/burrow/crypto"
)
var big0 = big.NewInt(0)
// A Validator multiset - can be used to capture the global state of validators or as an accumulator each block
type Set struct {
powers map[crypto.Address]*big.Int
publicKeys ma... | evmcc/vendor/github.com/hyperledger/burrow/acm/validator/set.go | 0.792544 | 0.472197 | set.go | starcoder |
package main
import (
"math"
"math/rand"
. "github.com/hborntraeger/pt/pt"
)
func offset(stdev float64) Vector {
a := rand.Float64() * 2 * math.Pi
r := rand.NormFloat64() * stdev
x := math.Cos(a) * r
y := math.Sin(a) * r
return Vector{x, 0, y}
}
func intersects(scene *Scene, shape Shape) bool {
box := shap... | examples/go.go | 0.604632 | 0.542379 | go.go | starcoder |
package schemax
import "sync"
/*
ObjectClassCollection describes all ObjectClasses-based types:
- *SuperiorObjectClasses
- *AuxiliaryObjectClasses
*/
type ObjectClassCollection interface {
// Get returns the *ObjectClass instance retrieved as a result
// of a term search, based on Name or OID. If no match is foun... | oc.go | 0.770637 | 0.420034 | oc.go | starcoder |
package main
import (
"fmt"
"math"
)
// Describe2Der describes 2D shapes
type Describe2Der interface {
area() float64
perim() float64
}
// Describe3Der describes 3D shapes
type Describe3Der interface {
volume() float64
surface() float64
}
// Circle description
type Circle struct {
radius float64
}
// Rectan... | software/development/languages/go-cheat-sheet/src/function-method-interface-package-example/interface/interfaces.go | 0.853974 | 0.4474 | interfaces.go | starcoder |
Marching Squares Quadtree
Convert an SDF2 boundary to a set of line segments.
Uses quadtree space subdivision.
*/
//-----------------------------------------------------------------------------
package render
import (
"math"
"sync"
"github.com/deadsy/sdfx/sdf"
)
//---------------------------------------------... | render/march2x.go | 0.692954 | 0.558086 | march2x.go | starcoder |
package braille
import (
"image"
"image/color"
"github.com/borkshop/bork/internal/bitmap"
"github.com/borkshop/bork/internal/cops/display"
)
// Margin is the typical margin of skipped bits necessary to make Braille line
// art look straight. Pass as the margin argument to DrawBitmap.
var Margin = image.Point{1, ... | internal/cops/braille/braille.go | 0.736969 | 0.580382 | braille.go | starcoder |
package xstring
import (
"fmt"
"reflect"
"strconv"
"strings"
)
// Version returns package version
func Version() string {
return "0.3.0"
}
// Author returns package author
func Author() string {
return "[<NAME>](https://www.likexian.com/)"
}
// License returns package license
func License() string {
return "... | xstring/xstring.go | 0.742888 | 0.405625 | xstring.go | starcoder |
package specs
import (
"testing"
"github.com/Fs02/grimoire"
"github.com/Fs02/grimoire/c"
"github.com/Fs02/grimoire/errors"
"github.com/stretchr/testify/assert"
)
// Query tests query specifications without join.
func Query(t *testing.T, repo grimoire.Repo) {
// preparte tests data
user := User{Name: "name1", ... | adapter/specs/query.go | 0.562777 | 0.512022 | query.go | starcoder |
package geom
//Polygon is a two-dimensional geometry representing a polygon
type Polygon []LineString
//PolygonZ is a three-dimensional geometry representing a polygon
type PolygonZ []LineStringZ
//PolygonM is a two-dimensional geometry representing a polygon, with an additional value defined on each vertex
type Po... | polygon.go | 0.87724 | 0.736306 | polygon.go | starcoder |
package internal
import (
"math/rand"
"sort"
"github.com/onsi-experimental/ginkgo/v2/types"
)
type GroupedSpecIndices []SpecIndices
type SpecIndices []int
func OrderSpecs(specs Specs, suiteConfig types.SuiteConfig) (GroupedSpecIndices, GroupedSpecIndices) {
/*
Ginkgo has sophisticated suport for randomizing s... | internal/ordering.go | 0.645679 | 0.421016 | ordering.go | starcoder |
package segmentation
import (
"fmt"
"github.com/miguelfrde/image-segmentation/disjointset"
"github.com/miguelfrde/image-segmentation/graph"
"sort"
"time"
)
/**
* Performs the image segmentation using the "Graph Based Segmentation"
* algorithm. It uses sigma to apply a gaussian filter with it to the image
* to... | segmentation/gbs.go | 0.844569 | 0.491639 | gbs.go | starcoder |
package arrow
import (
"reflect"
)
type typeEqualsConfig struct {
metadata bool
}
// TypeEqualOption is a functional option type used for configuring type
// equality checks.
type TypeEqualOption func(*typeEqualsConfig)
// CheckMetadata is an option for TypeEqual that allows checking for metadata
// equality bes... | go/arrow/compare.go | 0.739705 | 0.405272 | compare.go | starcoder |
package strset
import (
"encoding/json"
"sort"
)
// Set represents a set of unique strings.
type Set struct{ items []string }
// New creates a set with a given cap.
func New(size int) *Set {
return &Set{items: make([]string, 0, size)}
}
// Use turns a slice into a set, re-using the underlying slice.
// WARNING: ... | strset.go | 0.808786 | 0.446314 | strset.go | starcoder |
package question
const (
// Label holds the string label denoting the question type in the database.
Label = "question"
// FieldID holds the string denoting the id field in the database.
FieldID = "id" // FieldHash holds the string denoting the hash vertex property in the database.
FieldHash ... | ent/question/question.go | 0.511961 | 0.428592 | question.go | starcoder |
package leaves
import (
"bufio"
"fmt"
"os"
"github.com/FateFaker/leaves/internal/pickle"
"github.com/FateFaker/leaves/transformation"
)
func lgTreeFromSklearnDecisionTreeRegressor(tree pickle.SklearnDecisionTreeRegressor, scale float64, base float64) (lgTree, error) {
t := lgTree{}
// no support for categoric... | skensemble_io.go | 0.640074 | 0.435241 | skensemble_io.go | starcoder |
package value
import (
"math/big"
)
// domain: (−∞, ∞)
// range: [-1, +1]
func sin(c Context, v Value) Value {
return evalFloatFunc(c, v, floatSin)
}
// domain: (−∞, ∞)
// range: [-1, +1]
func cos(c Context, v Value) Value {
return evalFloatFunc(c, v, floatCos)
}
// domain: (−∞, ∞)
// range: (−∞, ∞)
func tan(c ... | value/sin.go | 0.672009 | 0.542197 | sin.go | starcoder |
package hbook
import (
"bytes"
"encoding/gob"
"io"
"math"
"github.com/go-hep/dtypes"
"github.com/go-hep/rio"
)
// H1D is a 1-dim histogram with weighted entries.
type H1D struct {
bins []Bin1D // in-range bins
allbins []Bin1D // in-range bins and under/over-flow bins
axis Axis
entries int64 // ... | h1d.go | 0.766905 | 0.51818 | h1d.go | starcoder |
package handlers
import (
"fmt"
"math"
"strconv"
"strings"
)
const (
earthRadius = 6378137.0
earthCircumference = math.Pi * earthRadius
initialResolution = 2 * earthCircumference / 256
dpi uint8 = 96
)
type tileCoord struct {
z uint8
x, y uint64
}
// tileCoordF... | handlers/tile.go | 0.728941 | 0.477981 | tile.go | starcoder |
package unit
import (
"fmt"
"math"
"github.com/brettbuddin/shaden/dsp"
"github.com/brettbuddin/shaden/graph"
)
// InMode is a mode of processing of an In.
type InMode int
// InModes
const (
Block InMode = iota
Sample
)
const controlPeriod = 64
// In is a unit input
type In struct {
name strin... | unit/in.go | 0.777131 | 0.499207 | in.go | starcoder |
package obj
import (
"github.com/deadsy/sdfx/sdf"
"github.com/ivanpointer/pterosphera/render"
)
// BTU Defines the dimensions of a single BTU (Ball Transfer Unit)
type BTU struct {
// BaseR is the radius of the base of the BTU.
BaseR float64
// BaseH is the height of the base (stem) of the BTU.
BaseH float64
... | go_sdx/obj/btu.go | 0.672117 | 0.415195 | btu.go | starcoder |
package ternary
// Str returns string on true or string on false condition
func Str(cond bool, onTrue string, onFalse string) string {
if cond {
return onTrue
}
return onFalse
}
// StrInt returns string on true or int on false condition
func StrInt(cond bool, onTrue string, onFalse int) interface{} {
if cond {
... | string.go | 0.694717 | 0.403508 | string.go | starcoder |
package query
import (
"github.com/grafana-tools/sdk"
)
// Option represents an option that can be used to configure a query.
type Option func(constant *Query)
// SortOrder represents the ordering method applied to values.
type SortOrder int
const (
// None will preserve the results ordering as returned by the qu... | vendor/github.com/K-Phoen/grabana/variable/query/query.go | 0.81468 | 0.455683 | query.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.