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 input
import (
"errors"
"fmt"
"sync"
"sync/atomic"
"time"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
)
//------------------------------------------------------------------... | lib/input/sequence.go | 0.694821 | 0.687355 | sequence.go | starcoder |
package ctxerr
import (
"strconv"
"strings"
"github.com/maxatome/go-testdeep/internal/util"
)
// Path defines a structure depth path, typically used to mark a
// position during a deep traversal in case of error.
type Path []pathLevel
type pathLevelKind uint8
type pathLevel struct {
Content string
Pointers ... | vendor/github.com/maxatome/go-testdeep/internal/ctxerr/path.go | 0.665302 | 0.40592 | path.go | starcoder |
package geom
import (
"github.com/water-vapor/euclidea-solver/configs"
"github.com/water-vapor/euclidea-solver/pkg/hashset"
"math"
)
// Point is a object containing its two coordinates
type Point struct {
hashset.Serializable
x, y float64
}
// NewPoint creates a point from coordinates
func NewPoint(x, y float64... | pkg/geom/point.go | 0.901316 | 0.461927 | point.go | starcoder |
package common
import (
"time"
)
type Data map[string]interface{}
func (d Data) Get(key string) interface{} { return d[key] }
func (d Data) Set(key string, value interface{}) { d[key] = value }
func (d Data) Clear(key string) { d[key] = nil }
func (d Data) GetBool(key string) bool ... | common/data.go | 0.535341 | 0.576333 | data.go | starcoder |
package igloo
import (
"github.com/hajimehoshi/ebiten/v2"
)
// SpriteOptions determines the starting state of our sprite
type SpriteOptions struct {
Image *ebiten.Image
Transform *Transform
// Value of 0 will use the image width
Width float64
// Value of 0 will use the image height
Height float64
// Defau... | sprite.go | 0.801781 | 0.457985 | sprite.go | starcoder |
package palettor
import (
"image/color"
"sort"
)
// A Palette represents the dominant colors extracted from an image, as a
// mapping from color to the weight of that color's cluster. The weight can be
// used as an approximation for that color's relative dominance in an image.
type Palette struct {
colorWeights m... | palette.go | 0.916321 | 0.526038 | palette.go | starcoder |
package binary
import (
"errors"
"github.com/matrixorigin/matrixone/pkg/container/nulls"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/encoding"
"github.com/matrixorigin/matrixone/pkg/vectorize/extract"
"g... | pkg/sql/plan2/function/builtin/binary/extract.go | 0.566258 | 0.503967 | extract.go | starcoder |
package tada
import (
"time"
)
type valueContainer struct {
slice interface{}
isNull []bool
cache []string
name string
id string
}
type valueContainerAlias struct {
Slice interface{} `json:"slice"`
IsNull []bool `json:"isNull"`
Name string `json:"name"`
ID string `json:"id"`
}... | types.go | 0.590897 | 0.566019 | types.go | starcoder |
package sqlbuilder
// InsertStatement represents a INSERT statement.
type InsertStatement struct {
columns ColumnList
values []literal
into Table
err error
}
// Insert returns new INSERT statement. The table is Table object for into.
func Insert(into Table) *InsertStatement {
if into == nil {
return &Inse... | insert.go | 0.587115 | 0.507446 | insert.go | starcoder |
package util
import (
"fmt"
"math"
"time"
)
const InfDuration = time.Duration(math.MaxInt64)
// DoubleToTime converts an epoch timestamp in seconds to Time.
// Overflow is not considered.
func DoubleToTime(t float64) time.Time {
if t == 0 {
return time.Time{}
}
sec, frac := math.Modf(t)
return time.Unix(int... | util/time.go | 0.743168 | 0.435061 | time.go | starcoder |
package plugin
// State represent the current plugin state. State are immutable
// (to prevent predefined state edition).
type State struct {
code byte // State code
desc string // State name
raw interface{} // Additional and optional content (error or string)
}
// Predefined states.
var (
// State c... | plugin/state.go | 0.70069 | 0.414129 | state.go | starcoder |
package geomfn
import (
"github.com/cockroachdb/cockroach/pkg/geo"
"github.com/cockroachdb/errors"
"github.com/twpayne/go-geom"
)
// Scale returns a modified Geometry whose coordinates are multiplied by the factors.
// If there are missing dimensions in factors, the corresponding dimensions are not scaled.
func S... | pkg/geo/geomfn/scale.go | 0.827306 | 0.460653 | scale.go | starcoder |
package analyzer
import (
"fmt"
"math"
"strings"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/expression"
"github.com/dolthub/go-mysql-server/sql/plan"
)
// orderTables returns an access order for the tables provided, attempting to minimize total query cost
func orderTables... | sql/analyzer/join_search.go | 0.573678 | 0.40987 | join_search.go | starcoder |
package ast
import (
"fmt"
"lo/environment"
"lo/parseerror"
"lo/token"
"reflect"
)
// Interpreter ...
type Interpreter struct {
Environment environment.Environment
}
// NewInterpreter creates a new interpreter
func NewInterpreter() *Interpreter {
env := environment.NewEnvironment()
return &Interpreter{Enviro... | ast/interpreter.go | 0.628407 | 0.433022 | interpreter.go | starcoder |
package srec19
import (
"encoding/binary"
"errors"
"sync"
)
//record stores the data of one line/record of an ihex32 file.
type record struct {
//rwm is used to coordinate multithreaded reading/writing when applying offsets or calculating checksums.
rwm sync.Mutex
//byteCount contains the hex string value that ... | srec19/record.go | 0.584983 | 0.525308 | record.go | starcoder |
package opencv
import (
"bytes"
"fmt"
"image"
"image/jpeg"
"gopkg.in/sensorbee/opencv.v0/bridge"
"gopkg.in/sensorbee/sensorbee.v0/data"
)
var (
imagePath = data.MustCompilePath("image")
)
// TypeImageFormat is an ID of image format type.
type TypeImageFormat int
const (
typeUnknownFormat TypeImageFormat = ... | raw_data.go | 0.628521 | 0.427217 | raw_data.go | starcoder |
package loggregator
import (
"fmt"
"github.com/rcrowley/go-metrics"
"strconv"
"strings"
"time"
)
//go:generate Counterfeiter github.com/rcrowley/go-metrics.Counter
//go:generate Counterfeiter github.com/rcrowley/go-metrics.Gauge
//go:generate Counterfeiter github.com/rcrowley/go-metrics.GaugeFloat64
//go:genera... | converters.go | 0.517571 | 0.400808 | converters.go | starcoder |
package vader
import (
"log"
"math"
"strconv"
"strings"
)
// Normalize the score to be between -1 and 1 using an alpha that
// approximates the max expected value
func Normalize(score float64) float64 {
normalizedScore := score / math.Sqrt((score*score)+float64(Alpha))
if normalizedScore < -1.0 {
return -1.0... | vader/utils.go | 0.786828 | 0.404155 | utils.go | starcoder |
package cryptobin
// Aes
func (this Cryptobin) Aes() Cryptobin {
this.multiple = "Aes"
return this
}
// Des
func (this Cryptobin) Des() Cryptobin {
this.multiple = "Des"
return this
}
// TriDes
func (this Cryptobin) TriDes() Cryptobin {
this.multiple = "TriDes"
return this
}
// Twofish
fu... | pkg/lakego-pkg/go-cryptobin/cryptobin/use.go | 0.624752 | 0.453443 | use.go | starcoder |
package geo
import (
"fmt"
"math"
)
// A Projector is a function that converts the given point to a different space.
type Projector func(p *Point)
// A Projection is a set of projectors to map forward and backwards to the projected space.
type Projection struct {
Project Projector
Inverse Projector
}
const merc... | vendor/github.com/paulmach/go.geo/projections.go | 0.838382 | 0.587766 | projections.go | starcoder |
package imagehash
import (
"errors"
"strconv"
)
// BitArray is an internal struct used by dhash to simplify appending bits to
// a byte array from left to right.
type BitArray struct {
byteArray []byte
max int
mask0 byte
mask1 byte
arrayIdx int
bitIdx uint
}
// NewBitArray is a constructor function... | vendor/github.com/devedge/imagehash/bitarray.go | 0.782247 | 0.475301 | bitarray.go | starcoder |
package cios
import (
"encoding/json"
)
// RecordedDates struct for RecordedDates
type RecordedDates struct {
// データが存在する日付のリスト Ex.[1, 20, 22, 23]
Dates []int64 `json:"dates"`
}
// NewRecordedDates instantiates a new RecordedDates object
// This constructor will assign default values to properties that have it d... | cios/model_recorded_dates.go | 0.565059 | 0.476823 | model_recorded_dates.go | starcoder |
package chunk
import (
"bytes"
"encoding/binary"
"fmt"
"hash/crc32"
)
// Chunk represents one of the many chunks of a png file
type Chunk struct {
id int // chunk index
dataSize []byte // 4 bytes - data field size
tipo []byte // 4 bytes - [a-Z] letters only (chunk type)
Data []byte // $dataSi... | chunk/entry.go | 0.715821 | 0.412826 | entry.go | starcoder |
package osgb
import (
"errors"
"math"
)
var (
// ErrPointOutsidePolygon indicates the position is too far offshore to be transformed.
ErrPointOutsidePolygon = errors.New("point outside polygon")
// ErrPointOutsideTransformation indicates the position is completely outside the grid transformation extent
ErrPoint... | ostn_osgm_gb.go | 0.673192 | 0.429848 | ostn_osgm_gb.go | starcoder |
package dusl
import (
"fmt"
)
// Sparser stands for Superpermissive-Parser.
// The Sparse method converts an ambit into a syntax tree,
// the SparseUndent method converts an entire source into a syntax tree.
type Sparser interface {
Sparse(ambit *Ambit) *Syntax
SparseUndent(src *Source) *Syntax
}
type sparser ... | sparser.go | 0.708112 | 0.407245 | sparser.go | starcoder |
package binarysearchtree
import (
"errors"
)
// Node represents a tree node
// TODO: add support for any type, not just int
type Node struct {
Value int // Value the node stores
left, right *Node // pointers to the left and right children of the key
}
// Insert will add a new node to the tree whose root i... | binarysearchtree/btree.go | 0.535098 | 0.503845 | btree.go | starcoder |
package utils
import (
"fmt"
"time"
)
func StartOfDay(date time.Time) time.Time {
return FloorDate(date)
}
func StartOfToday(tz *time.Location) time.Time {
return StartOfDay(FloorDate(time.Now().In(tz)))
}
func EndOfDay(date time.Time) time.Time {
floored := FloorDate(date)
if floored == date {
date = date.... | utils/date.go | 0.785432 | 0.545225 | date.go | starcoder |
Package parser contains a GraphQL parser. Based on GraphQL spec June 2018.
Lexer for Source Text - @spec 2.1
Lex() is a lexer function to convert a given search query into a list of tokens.
Based on a talk by <NAME>: Lexical Scanning in Go
https://www.youtube.com/watch?v=HxaD_trXwRE
The lexer's output is pushed in... | lang/graphql/parser/const.go | 0.735547 | 0.762866 | const.go | starcoder |
package sorted
import (
bin "encoding/binary"
"reflect"
"sort"
"github.com/kelindar/binary"
)
// IntsCodecAs returns an int slice codec with the specified precision and type.
func IntsCodecAs(sliceType reflect.Type, sizeOfInt int) binary.Codec {
return &intSliceCodec{
sliceType: sliceType,
sizeOfInt: sizeO... | sorted/codecs.go | 0.772359 | 0.441252 | codecs.go | starcoder |
package fp
// ZeroIntP Returns true if num is zero, else false
func ZeroIntP(v int) bool {
if v == 0 {
return true
}
return false
}
// ZeroIntPPtr Returns true if num is zero, else false
func ZeroIntPPtr(v *int) bool {
if *v == 0 {
return true
}
return false
}
// ZeroInt64P Returns true if num is zero, els... | fp/zero.go | 0.773986 | 0.468487 | zero.go | starcoder |
package cal
import "time"
// Holidays in Sweden
// Reference https://sv.wikipedia.org/wiki/Helgdagar_i_Sverige
// Days with the [2] notation, meaning days with reduced working hours
// haven't been added, as this is not regulated by law.
var (
seNyarsdagen = newYear.SetLabel("Nyarsdagen")
seTrettondedagJ... | v2/holiday_defs_se.go | 0.573678 | 0.431464 | holiday_defs_se.go | starcoder |
package ptp
import (
"encoding/json"
"fmt"
"math"
"sort"
)
const (
maxDecimalsFeedrate = 1
maxDecimalsFanSpeed = 0
maxDecimalsTemperature = 1
maxDecimalsLayerHeight = 4
)
type bufferData struct {
Offset int `json:"offset"`
Size int `json:"size"`
}
type legendHeader struct {
... | ptp/legend.go | 0.763572 | 0.467271 | legend.go | starcoder |
package backoff
import (
"math/rand"
"time"
)
/*
ExponentialBackOff is an implementation of BackOff that increases
it's back off period for each retry attempt using a randomization function
that grows exponentially.
Backoff() time is calculated using the following formula:
randomized_interval =
retry_in... | vendor/github.com/azr/backoff/exponential.go | 0.864996 | 0.527195 | exponential.go | starcoder |
package pytest
import (
"context"
"errors"
"fmt"
"strings"
"time"
xpytest_proto "github.com/chainer/xpytest/proto"
)
// Pytest represents one pytest execution.
type Pytest struct {
PythonCmd string
MarkerExpression string
Xdist int
Files []string
Executor func(
conte... | pkg/pytest/pytest.go | 0.558086 | 0.400749 | pytest.go | starcoder |
package nune
import (
"sync"
"github.com/vorduin/slices"
)
// handleZip processes an elementwise operation accordingly.
func handleZip[T Number](lhs, rhs, out []T, f func(T, T) T, nCPU int) {
var wg sync.WaitGroup
for i := 0; i < nCPU; i++ {
min := (i * len(lhs) / nCPU)
max := ((i + 1) * len(lhs)) / nCPU
... | zip.go | 0.602412 | 0.401717 | zip.go | starcoder |
package opt
import (
"encoding/json"
"fmt"
)
// Maybe is a simple implementation of an optional value type.
type Maybe[V any] struct {
defined bool
value V
}
// Some returns a Maybe that has a defined value.
func Some[V any](value V) Maybe[V] {
return Maybe[V]{defined: true, value: value}
}
// None returns a... | framework/opt/maybe.go | 0.664758 | 0.46223 | maybe.go | starcoder |
package orm
import (
"bytes"
"context"
"github.com/goradd/goradd/pkg/orm/op"
"github.com/goradd/goradd/web/examples/gen/goradd/model"
"github.com/goradd/goradd/web/examples/gen/goradd/model/node"
)
func (ctrl *QueryPanel) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error) {
buf.WriteString(`
<h... | web/examples/tutorial/orm/3-query.tpl.go | 0.676192 | 0.533519 | 3-query.tpl.go | starcoder |
package torch
// #include "gotorch.h"
import "C"
import (
"reflect"
"unsafe"
)
// torch::tensor
type Tensor struct {
tensor C.Tensor
device GoDevice
}
type Tensors struct {
tensors []C.Tensor
}
// at::Tensor
type ATensor struct {
atensor C.ATensor
device GoDevice
}
// go slice
type GoTensor struct {
value... | go/tensor.go | 0.581303 | 0.443781 | tensor.go | starcoder |
package absorbingmarkovchain
import (
"github.com/RoaringBitmap/roaring"
)
type dGraph struct {
Nodes *roaring.Bitmap
Edges func(from uint32) (to []uint32)
}
func (gin dGraph) addSelfLoops() (gout dGraph) {
gout.Edges = func(from uint32) (to []uint32) {
to = gin.Edges(from)
if match, p := uint32Exist(to, fro... | graphs.go | 0.533884 | 0.429609 | graphs.go | starcoder |
package mysql
import (
"fmt"
"strings"
sq "github.com/Masterminds/squirrel"
"github.com/eveisesi/skillz"
"xorm.io/builder"
)
type tableConf struct {
table string
columns []string
}
func BuildFilters(s sq.SelectBuilder, operators ...*skillz.Operator) sq.SelectBuilder {
for _, a := range operators {
if !a... | internal/mysql/mysql.go | 0.621771 | 0.461077 | mysql.go | starcoder |
package day17
import (
"bufio"
"fmt"
"io"
"regexp"
"strconv"
"strings"
)
type Point struct {
X, Y int
}
type Velocity struct {
X, Y int
}
type Probe struct {
Position Point
Velocity Velocity
}
type Target struct {
MinX, MaxX int
MinY, MaxY int
}
func (t Target) Hit(p Point) bool {
return (p.X >= t.Mi... | day17/day17.go | 0.640861 | 0.422803 | day17.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// UserExperienceAnalyticsWorkFromAnywhereDevicesSummary the user experience analytics Work From Anywhere metrics devices summary.
type UserExperienceAnalyticsWork... | models/user_experience_analytics_work_from_anywhere_devices_summary.go | 0.655005 | 0.418043 | user_experience_analytics_work_from_anywhere_devices_summary.go | starcoder |
package dotc
import (
"io"
"text/template"
)
// SliceStream implements code generation for streams of slices
type SliceStream Slice
// Pointer simply proxies to Slice, needed because of template limitation
func (s SliceStream) Pointer() bool {
return Slice(s).Pointer()
}
// RawType simply proxies to Slice, need... | x/dotc/slices.go | 0.792665 | 0.425904 | slices.go | starcoder |
package _4_binarytree
import (
"fmt"
)
type TreeNode struct {
val int
left *TreeNode
right *TreeNode
}
type Tree struct {
root *TreeNode
}
func NewTreeNode(val int) *TreeNode {
return &TreeNode{
val: val,
left: nil,
right: nil,
}
}
func NewTree() *Tree {
... | 24_binarytree/searchtree.go | 0.614857 | 0.487185 | searchtree.go | starcoder |
package lookslike
import (
"reflect"
"github.com/elastic/go-lookslike/internal/llreflect"
"github.com/elastic/go-lookslike/llpath"
)
type walkObserverInfo struct {
key llpath.PathComponent
value interface{}
root map[string]interface{}
path llpath.Path
}
// walkObserver functions run once per object in t... | vendor/github.com/elastic/go-lookslike/walk.go | 0.767864 | 0.442757 | walk.go | starcoder |
package three
var _vector1 = Vector3{}
var _vector2 = Vector3{}
var _normalMatrix = Matrix3{}
// NewPlane :
func NewPlane(normal Vector3, constant float64) *Plane {
// normal is assumed to be normalized
return &Plane{normal, constant}
}
// Plane :
type Plane struct {
Normal Vector3
Constant float64
}
// Set ... | server/three/plane.go | 0.850593 | 0.698034 | plane.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"strconv"
"strings"
)
/*
--- Day 2: Password Philosophy ---
Your flight departs in a few days from the coastal airport; the easiest way down to the coast from here is via toboggan.
The shopkeeper at the North Pole Toboggan Rental Shop is having a bad day. "Something's wron... | 2020/day-02/main.go | 0.630116 | 0.623835 | main.go | starcoder |
package advent2017
func ManhattanDistanceTo(cellNumber int) int {
point := toCartesianCoordinate(cellNumber)
return point.manhattanDistanceFromOrigin()
}
type Point struct {
x, y int
}
func (p Point) manhattanDistanceFromOrigin() int {
if p.x < 0 {
p.x = -p.x
}
if p.y < 0 {
p.y = -p.y
}
return p.x + p.... | advent2017/manhattan_distance.go | 0.812644 | 0.529203 | manhattan_distance.go | starcoder |
package msgraph
// RatingGermanyMoviesType undocumented
type RatingGermanyMoviesType string
const (
// RatingGermanyMoviesTypeVAllAllowed undocumented
RatingGermanyMoviesTypeVAllAllowed RatingGermanyMoviesType = "AllAllowed"
// RatingGermanyMoviesTypeVAllBlocked undocumented
RatingGermanyMoviesTypeVAllBlocked Ra... | v1.0/RatingGermanyMoviesTypeEnum.go | 0.589007 | 0.545528 | RatingGermanyMoviesTypeEnum.go | starcoder |
package main
import (
"fmt"
"image"
"io"
)
type Canvas struct {
Width int
Height int
Pix []Color
}
func NewCanvas(width, height int) Canvas {
canvas := Canvas{
width,
height,
make([]Color, width*height, width*height),
}
return canvas
}
func xyFloatToInt(fx, fy float64, w, h int) (x, y int, ok b... | canvas.go | 0.643105 | 0.482368 | canvas.go | starcoder |
package specifics
import "math"
// EmptyStrSlice returns an empty string slice
func EmptyStrSlice() []string {
return make([]string, 0)
}
// StrSliceContains checks if the string slice
// contains the given string
func StrSliceContains(slice []string, s string) bool {
for _, str := range slice {
if str == s {
... | strslices.go | 0.719285 | 0.410815 | strslices.go | starcoder |
package graph
import (
"encoding/json"
"fmt"
"log"
"strconv"
)
const (
//MaxVertices -- Defines the Max number of node/vertices a graph can have
MaxVertices = 1000
)
//Data -- Used to decode map input data from json
type Data struct {
TotalNodes int `json:"total_nodes"`
Directed bool ... | data_structures/graph/graph2.go | 0.590425 | 0.412471 | graph2.go | starcoder |
package algorithm
import (
"fmt"
"reflect"
"github.com/parallaxsecond/parsec-client-go/interface/operations/psaalgorithm"
)
type AeadFactory interface {
Aead(algType AeadAlgorithmType) *Algorithm
AeadShortenedTag(algType AeadAlgorithmType, tagLength uint32) *Algorithm
}
type aeadFactory struct{}
func NewAead... | parsec/algorithm/aead.go | 0.636127 | 0.448849 | aead.go | starcoder |
// Package code contains the bytecode instructions for the mtail virtual machine.
package code
type Opcode int
const (
Bad Opcode = iota // Invalid instruction, indicates a bug in the generator.
Stop // Stop the program, ending processing of this input.
Match // Match... | internal/vm/code/opcodes.go | 0.701713 | 0.431225 | opcodes.go | starcoder |
package main
// RuneGrid contains the rendered text UI
type RuneGrid struct {
width int
height int
cells [][]rune
}
// New constructs a RuneGrid with the given width and height
func NewRuneGrid(width, height int) RuneGrid {
grid := RuneGrid{
width: width,
height: height,
cells: make([][]rune, height),
... | runegrid.go | 0.64646 | 0.542924 | runegrid.go | starcoder |
package stdlib
import (
"fmt"
"github.com/d5/tengo"
"github.com/d5/tengo/objects"
)
// FuncAR transform a function of 'func()' signature
// into CallableFunc type.
func FuncAR(fn func()) objects.CallableFunc {
return func(args ...objects.Object) (ret objects.Object, err error) {
if len(args) != 0 {
return n... | vendor/github.com/d5/tengo/stdlib/func_typedefs.go | 0.662469 | 0.427994 | func_typedefs.go | starcoder |
package main
import (
rl "github.com/gen2brain/raylib-go/raylib"
"math"
)
type RectWorld struct {
width int32
height int32
stateIdx int32
states [2][]bool
}
func NewRectWorld(width, height int32) *RectWorld {
var states [2][]bool
for i := 0; i < len(states); i++ {
states[i] = make([]bool, width*heig... | rectworld.go | 0.624064 | 0.473414 | rectworld.go | starcoder |
package search
/*
What? Interview coaching from Googlers!
negativespace-22
Dropbox Interview – Design Hit Counter
It starts with a simple question – if you are building a website, how do you count the number of visitors for the past 1 minute?
“Design hit counter” problem has recently been asked by many companies incl... | search/hit_counter.go | 0.52074 | 0.87251 | hit_counter.go | starcoder |
package util
import (
"fmt"
"io"
)
// Graph models a dense directed graph of string-labeled nodes.
type Graph struct {
verts map[string]int
vertNames []string
edges [][]bool
w [][]int
}
// Len returns the number of vertices in the graph.
func (g *Graph) Len() int {
return len(g.edges)
}
// V... | util/graph.go | 0.822082 | 0.623807 | graph.go | starcoder |
package govaluate
import (
"errors"
"fmt"
)
const isoDateFormat string = "2006-01-02T15:04:05.999999999Z0700"
const shortCircuitHolder int = -1
var DUMMY_PARAMETERS = MapParameters(map[string]interface{}{})
/*
EvaluableExpression represents a set of ExpressionTokens which, taken together,
are an expression that... | EvaluableExpression.go | 0.723114 | 0.542863 | EvaluableExpression.go | starcoder |
package shape
// Aligner type aligns multiple shapes
type Aligner struct{}
// HAlignCenter aligns shape[1:] to shape[0] center coordinates horizontally
func (Aligner) HAlignCenter(shapes ...Shape) { hAlign(Center, shapes...) }
// HAlignTop aligns shape[1:] to shape[0] top coordinates horizontally
func (Aligner) HAli... | shape/align.go | 0.68637 | 0.598342 | align.go | starcoder |
package hierarchy
import (
"fmt"
math "github.com/barnex/fmath"
"github.com/go-gl/gl"
"github.com/ungerik/go3d/vec3"
)
var (
posBase = vec3.T{3.0, -5.0, -40.0}
angBase float32 = -45.0
posBaseLeft = vec3.T{2.0, 0.0, 0.0}
posBaseRight = vec3.T{-2.0, 0.0, 0.0}
scaleBa... | tut06/hierarchy/crane.go | 0.638385 | 0.403714 | crane.go | starcoder |
package crypto
import (
"bytes"
"github.com/NebulousLabs/Sia/encoding"
"github.com/NebulousLabs/merkletree"
)
const (
// SegmentSize is the chunk size that is used when taking the Merkle root
// of a file. 64 is chosen because bandwidth is scarce and it optimizes for
// the smallest possible storage proofs. U... | crypto/merkle.go | 0.73029 | 0.515498 | merkle.go | starcoder |
package values
import (
"fmt"
)
// UIntValue is a struct that holds a uint value
type UIntValue struct {
value uint
}
// IsEqualTo returns true if the value is equal to the expected value, else false
func (i UIntValue) IsEqualTo(expected interface{}) bool {
return i.equals(NewUIntValue(expected))
}
// IsGreaterT... | internal/pkg/values/uint_value.go | 0.826362 | 0.731346 | uint_value.go | starcoder |
package operator
import (
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/vm/process"
"golang.org/x/exp/constraints"
)
// If operator supported format like that
// If(<boolean operator>, <value operator>, <va... | pkg/sql/plan2/function/operator/if.go | 0.552781 | 0.55266 | if.go | starcoder |
// Package alignfor provides functions that align elements.
package alignfor
import (
"fmt"
"image"
"strings"
"github.com/mum4k/termdash/align"
"github.com/mum4k/termdash/internal/runewidth"
"github.com/mum4k/termdash/internal/wrap"
)
// hAlign aligns the given area in the rectangle horizontally.
func hAlign(... | internal/alignfor/alignfor.go | 0.853364 | 0.562237 | alignfor.go | starcoder |
package iqfeed
import (
"strings"
"time"
)
// FundamentalMsg cannot be customized and is used to provide detail of a particular matched symbol.
type FundamentalMsg struct {
Symbol string // The Symbol ID to match with watch request
ExchaangeID string // Deprecated Use Listed Market (field... | fundamental.go | 0.588889 | 0.662756 | fundamental.go | starcoder |
package random
import (
"errors"
"math/rand"
)
// ProteinSequence returns a random protein sequence string of a given length and seed.
// All returned sequences start M (Methionine) and end with * (stop codon).
func ProteinSequence(length int, seed int64) (string, error) {
//The length needs to be greater than two... | random/random.go | 0.727879 | 0.565779 | random.go | starcoder |
package czml
// Model describes a 3D model
// https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Model
type Model struct {
Show *bool `json:"show,omitempty"`
Gltf *Uri `json:"uri"`
Scale *float64 ... | model.go | 0.914209 | 0.403978 | model.go | starcoder |
package ent
import (
"Joalarm/app/post/service/internal/data/ent/post"
"fmt"
"strings"
"time"
"entgo.io/ent/dialect/sql"
)
// Post is the model entity for the Post schema.
type Post struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Content holds the value of the "content" field.
... | app/post/service/internal/data/ent/post.go | 0.651466 | 0.410284 | post.go | starcoder |
package freespacetree
// Node represents a range of free space in the tree.
type Node struct {
from uint64
to uint64
left *Node
right *Node
}
// NewNode returns a pointer to a new Node with the specified range of free space.
func NewNode(from, to uint64) *Node {
inst := &Node{
left: nil,
right: nil,
... | node.go | 0.815012 | 0.602412 | node.go | starcoder |
package keyproof
import (
"github.com/privacybydesign/gabi/big"
"github.com/privacybydesign/gabi/internal/common"
)
type (
expStepStructure struct {
bitname string
stepa expStepAStructure
stepb expStepBStructure
}
expStepCommit struct {
isTypeA bool
acommit expStepACommit
aproof ExpStepA... | keyproof/expstep.go | 0.565299 | 0.449453 | expstep.go | starcoder |
package scale
import (
"fmt"
"sort"
"github.com/gvallee/collective_profiler/tools/internal/pkg/unit"
)
/*
func intsScaleDown(unitType int, unitScale int, values []int) (int, int, []int) {
if unitScale == -1 {
// Unit not recognized, nothing we can do
return unitType, unitScale, values
}
newUnitScale := u... | tools/internal/pkg/scale/scale_ints.go | 0.716516 | 0.442877 | scale_ints.go | starcoder |
package jigo
import (
"bytes"
"fmt"
"strconv"
)
var textFormat = "%s" // Changed to "%q" in tests for better error messages.
type NodeType int
func (t NodeType) Type() NodeType {
return t
}
type Node interface {
Type() NodeType
String() string
// Copy does a deep copy of the Node and all its components.
Co... | ast.go | 0.601008 | 0.449695 | ast.go | starcoder |
// Package geogen provides utilities for generating various geospatial types.
package geogen
import (
"math"
"math/rand"
"sort"
"github.com/cockroachdb/cockroach/pkg/geo"
"github.com/cockroachdb/cockroach/pkg/geo/geopb"
"github.com/cockroachdb/cockroach/pkg/geo/geoprojbase"
"github.com/cockroachdb/errors"
"g... | pkg/geo/geogen/geogen.go | 0.688783 | 0.604107 | geogen.go | starcoder |
package common
import (
"github.com/kaxap/gozxing"
)
type DefaultGridSampler struct{}
func NewDefaultGridSampler() GridSampler {
return DefaultGridSampler{}
}
func (s DefaultGridSampler) SampleGrid(image *gozxing.BitMatrix, dimensionX, dimensionY int,
p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY float6... | common/default_grid_sampler.go | 0.793586 | 0.576929 | default_grid_sampler.go | starcoder |
package DG2D
import (
"fmt"
"math"
"github.com/notargets/gocfd/DG1D"
"github.com/notargets/gocfd/utils"
)
type RTElement struct {
N int // Order of element
Np int // Number of points in element
Nedge, Nint int // Number of Edge and Interior points
A ... | DG2D/RaviartThomasElement.go | 0.606615 | 0.618377 | RaviartThomasElement.go | starcoder |
package generator
func (g *Grid) medusa(verbose uint) (res bool) {
var pairMaps [10]map[pair]bool
g.unitPairs(&pairMaps)
strongLinks := make(map[pair]cell)
for d := 1; d <= 9; d++ {
for p := range pairMaps[d] {
strongLinks[p] |= 1 << d
}
}
linkEnds := make(map[point][]pair)
for p := range strongLinks {... | generator/3dMedusa.go | 0.615088 | 0.460835 | 3dMedusa.go | starcoder |
package packet
import (
"encoding/json"
"fmt"
"io"
"math"
"github.com/google/uuid"
"github.com/tsatke/nbt"
"github.com/tsatke/mcserver/game/chat"
"github.com/tsatke/mcserver/game/id"
)
// Encoder is a decorating struct, which uses specialized algorithms to
// write data into an underlying io.Writer.
type En... | network/packet/encoder.go | 0.566258 | 0.465934 | encoder.go | starcoder |
package geojson_to_shape
import (
"github.com/skyhookml/skyhookml/skyhook"
"github.com/skyhookml/skyhookml/exec_ops"
"log"
"github.com/paulmach/go.geojson"
gomapinfer "github.com/mitroadmaps/gomapinfer/common"
)
func GeoJsonToShape(url string, outputDataset skyhook.Dataset, task skyhook.ExecTask) error {
// L... | exec_ops/geojson_to_shape/to_shape.go | 0.651355 | 0.502319 | to_shape.go | starcoder |
package emulator
import (
"image/color"
"strconv"
"gopkg.in/yaml.v2"
)
type ColourMap struct {
backgroundColour color.RGBA
defaultColour color.RGBA
spriteColours map[int]color.RGBA
}
type ColourMapYaml struct {
BackgroundColour int `yaml:"background"`
DefaultColour int `yaml:"... | pkg/emulator/colours.go | 0.702632 | 0.448124 | colours.go | starcoder |
package intellijel
import (
"github.com/jsleeio/go-eagle/pkg/format/eurorack"
"github.com/jsleeio/go-eagle/pkg/panel"
)
// based on https://intellijel.com/support/1u-technical-specifications/
const (
// PanelHeight1U represents the total height of an Intellijel 1U panel, in
// millimetres
PanelHeight1U = 39.65... | pkg/format/intellijel/intellijel.go | 0.831725 | 0.594021 | intellijel.go | starcoder |
package muxgo
import (
"encoding/json"
)
// InputSettings An array of objects that each describe an input file to be used to create the asset. As a shortcut, `input` can also be a string URL for a file when only one input file is used. See `input[].url` for requirements.
type InputSettings struct {
// The web addr... | model_input_settings.go | 0.894577 | 0.533337 | model_input_settings.go | starcoder |
package render
import (
"image"
"image/color"
"math"
"github.com/200sc/go-dist/colorrange"
)
// Todo:
// Our current concept of thickness expands out in both directions,
// so it's impossible to draw a even-pixel thick line. This is probably
// okay for an easy syntax like this but we might want to add in a
// "... | render/line.go | 0.676192 | 0.536374 | line.go | starcoder |
package Test
import (
"math"
"math/rand"
)
type Vector struct {
X, Y, Z float64
}
func V(x, y, z float64) Vector {
return Vector{x, y, z}
}
func RandomUnitVector() Vector {
for {
x := rand.Float64()*2 - 1
y := rand.Float64()*2 - 1
z := rand.Float64()*2 - 1
if x*x+y*y+z*z > 1 {
continue
}
return ... | vector.go | 0.893219 | 0.771843 | vector.go | starcoder |
package tasks
import (
"fmt"
"strings"
)
// ListRecord is a record in double-linked priority list of tasks
type ListRecord struct {
prev *ListRecord
next *ListRecord
Task *Task
// Estimation of Task potential to lead to the best solution
// This is a sum of Task.ActualDistance and Task.ProjectedDistance
Dist... | solver/tasks/list.go | 0.763131 | 0.48499 | list.go | starcoder |
//nolint:lll // multiple regex is not possible broken lines
package csharp
import (
"regexp"
"github.com/ZupIT/horusec-devkit/pkg/enums/confidence"
"github.com/ZupIT/horusec-devkit/pkg/enums/severities"
engine "github.com/ZupIT/horusec-engine"
"github.com/ZupIT/horusec-engine/text"
)
func NewCommandInjection(... | internal/services/engines/csharp/rules.go | 0.546012 | 0.421195 | rules.go | starcoder |
package qhull
import (
"fmt"
"github.com/engoengine/glm"
"github.com/EngoEngine/math"
)
const (
epsilonbase = 0.0001 // arbitrary value that will require testing
)
type (
// Edge is a quickhull utility struct for edges
Edge struct {
Tail int
Prev, Next, Twin *Edge
Face *Face
}
/... | geo/internal/qhull/qhull.go | 0.643441 | 0.458773 | qhull.go | starcoder |
package fractal
import (
"image"
"image/color"
"math"
)
const (
N int = 8
QUALITY int = 0
)
var (
zigZag8 = [64]struct {row, col int} {
{0, 0},
{0, 1}, {1, 0},
{2, 0}, {1, 1}, {0, 2},
{0, 3}, {1, 2}, {2, 1}, {3, 0},
{4, 0}, {3, 1}, {2, 2}, {1, 3}, {0, 4},
{0, 5}, {1, 4}, {2, 3}, {3, 2}, {4, 1}, {5... | _vendor/src/github.com/pointlander/compress/fractal/dct.go | 0.548674 | 0.599368 | dct.go | starcoder |
package bintree
import (
"strconv"
"strings"
)
// New creates and initializes a new binary tree
func New(value ...interface{}) *Tree {
return new(Tree).Init(value...)
}
// Tree is a binary tree
type Tree struct {
Value interface{}
left, right *Tree
}
// Init initializes and clears tree
func (t *Tree) Ini... | tree/bintree/binaryTree.go | 0.821939 | 0.48054 | binaryTree.go | starcoder |
// Useful test functions for validating (mostly) string outputs match
// what is expected.
package assert
import (
"bytes"
"strings"
"testing"
)
type expectedError struct {
expected string
}
func NewExpectedError(expect string) *expectedError {
return &expectedError{expected: expect}
}
func (e *expectedError... | testutils/assert/assert.go | 0.694821 | 0.697854 | assert.go | starcoder |
package rule
import (
"github.com/lawrencewoodman/ddataset"
"github.com/lawrencewoodman/dlit"
"github.com/vlifesystems/rhkit/description"
"sort"
)
// InFV represents a rule determining if field is equal to
// any of the supplied values when represented as a string
type InFV struct {
field string
values []*dli... | rule/infv.go | 0.636918 | 0.451992 | infv.go | starcoder |
package experiments
import (
"flag"
"github.com/Yunpeng-J/HLF-2.2/core/ledger/kvledger/benchmark/chainmgmt"
)
// txConf captures the transaction related configurations
// numTotalTxs specifies the total transactions that should be executed and committed across chains
// numParallelTxsPerChain specifies the paralle... | core/ledger/kvledger/benchmark/experiments/conf.go | 0.752831 | 0.410461 | conf.go | starcoder |
package animation
/*
Contains definitions of various animation effects that can be applied. These
effects should implement interface Animation
*/
import (
"image/color"
"log"
"math"
"os"
"time"
colorful "github.com/lucasb-eyer/go-colorful"
)
// RGBAFromRGBHex converts a 24-bit hex color value into a color.RGB... | vendor/github.com/TeamNorCal/animation/effects.go | 0.871475 | 0.409634 | effects.go | starcoder |
package dataframe
import (
"fmt"
"logarithmotechnia/vector"
"strconv"
"strings"
)
func (df *Dataframe) InnerJoin(with *Dataframe, options ...vector.Option) *Dataframe {
conf := vector.MergeOptions(options)
columns := df.determineColumns(conf, with)
if len(columns) == 0 {
return df
}
rootDfTree := &joinNo... | dataframe/joins.go | 0.514888 | 0.494263 | joins.go | starcoder |
package pgbuilder
import (
"fmt"
"github.com/go-courier/sqlx/v2"
"github.com/go-courier/sqlx/v2/builder"
)
func RecordCollectionFrom(db sqlx.DBExecutor, model builder.Model, columnsCouldBeZeroValue ...*builder.Column) *RecordCollection {
t := db.T(model)
zeroFields := make([]string, 0)
for i := range columnsC... | pgbuilder/record_collection.go | 0.641647 | 0.411879 | record_collection.go | starcoder |
package apivideosdk
import (
//"encoding/json"
)
// Account struct for Account
type Account struct {
Quota *AccountQuota `json:"quota,omitempty"`
// Deprecated. What features are enabled for your account. Choices include: app.dynamic_metadata - the ability to dynamically tag videos to better segment and understand... | model_account.go | 0.764188 | 0.445952 | model_account.go | starcoder |
package shadow
import (
"fmt"
"unsafe"
"github.com/chrsan/shadow/internal"
)
type Path struct {
c *internal.Context
ptr int32
}
func (p *Path) Dispose() {
if p != nil {
p.c.SkiaPathDestroy(p.ptr)
p = nil
}
}
type PathFillType uint8
const (
PathFillTypeWinding PathFillType = iota
PathFillTypeEvenOdd... | path.go | 0.522202 | 0.489686 | path.go | starcoder |
package editor
import (
"strings"
)
// basic represents a basic editor.
// Valid positions are in range [0, len(e.buf)].
type basic struct {
pos int
buf []rune
}
// move moves the position to the given position.
// Given an invalid position, move sets the position at the end of the buffer.
func (e *basic) move(to... | editor/basic.go | 0.687525 | 0.769189 | basic.go | starcoder |
package geogoth
// LineStringLength counts lenght of LineString
func LineStringLength(feature *Feature) float64 {
var length float64
coords := (feature.Geom.Coordinates).([][]float64) // Convert interface to [][][]float64
lineCoords := make([][]float64, 0) // Creates slice for coords of one line
... | geojson/lengths.go | 0.79732 | 0.554712 | lengths.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.