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 schema
// GitoliteSchemaJSON is the content of the file "gitolite.schema.json".
const GitoliteSchemaJSON = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "gitolite.schema.json#",
"title": "GitoliteConnection",
"description": "Configuration for a connection to Gitolite.",
"allowComme... | schema/gitolite_stringdata.go | 0.766294 | 0.423637 | gitolite_stringdata.go | starcoder |
package datadog
import (
"encoding/json"
"fmt"
)
// LogsGroupByHistogram Used to perform a histogram computation (only for measure facets). Note: At most 100 buckets are allowed, the number of buckets is (max - min)/interval.
type LogsGroupByHistogram struct {
// The bin size of the histogram buckets
Interval fl... | api/v2/datadog/model_logs_group_by_histogram.go | 0.748352 | 0.475118 | model_logs_group_by_histogram.go | starcoder |
package transform
import (
"fmt"
"github.com/RoaringBitmap/roaring/roaring64"
"github.com/golang/protobuf/proto"
pbbstream "github.com/streamingfast/pbgo/sf/bstream/v1"
)
// blockIndex is a generic index for existence of certain keys at certain block heights
type blockIndex struct {
// kv is the main data struc... | transform/block_index.go | 0.670177 | 0.529081 | block_index.go | starcoder |
package core
import (
"fmt"
b3 "github.com/magicsea/behavior3go"
"github.com/magicsea/behavior3go/config"
)
/**
* The BehaviorTree class, as the name implies, represents the Behavior Tree
* structure.
*
* There are two ways to construct a Behavior Tree: by manually setting the
* root node, or by loading it f... | lab051/lab001/vendor/github.com/magicsea/behavior3go/core/BehaviorTree.go | 0.79053 | 0.510313 | BehaviorTree.go | starcoder |
package analyzer
import (
"github.com/Sndav/go-mysql-server/sql"
"github.com/Sndav/go-mysql-server/sql/expression"
"github.com/Sndav/go-mysql-server/sql/plan"
)
// applyIndexesForSubqueryComparisons converts a `Filter(id = (SELECT ...),
// Child)` or a `Filter(id in (SELECT ...), Child)` to be iterated lookups on... | sql/analyzer/apply_indexes_for_subquery_comparisons.go | 0.590071 | 0.402862 | apply_indexes_for_subquery_comparisons.go | starcoder |
package ai
import (
"math"
"math/rand"
// anonymous import for png decoder
"image/color"
_ "image/png"
"github.com/hajimehoshi/ebiten/v2"
"github.com/jtbonhomme/asteboids/internal/physics"
"github.com/jtbonhomme/asteboids/internal/vector"
"github.com/sirupsen/logrus"
)
const (
boidMaxForce float64 = ... | internal/ai/boid.go | 0.699357 | 0.620392 | boid.go | starcoder |
package enumerate
import (
"sync"
"golang.org/x/exp/constraints"
. "github.com/noxer/nox/dot"
"github.com/noxer/nox/set"
"github.com/noxer/nox/tuple"
)
type enumMapper[T, S any] struct {
e Enumerable[T]
f func(T) S
}
func (e *enumMapper[T, S]) Next() bool {
return e.e.Next()
}
func (e *enumMapper[T, S]) V... | enumerate/enumerate.go | 0.730001 | 0.46642 | enumerate.go | starcoder |
package assert
import (
"testing"
"github.com/ppapapetrou76/go-testing/internal/pkg/values"
"github.com/ppapapetrou76/go-testing/types"
)
// SliceOpt is a configuration option to initialize an AssertableAny Slice
type SliceOpt func(*AssertableStringSlice)
// AssertableStringSlice is the implementation of Asserta... | assert/string_slice.go | 0.854415 | 0.659559 | string_slice.go | starcoder |
package digit
// LinkRelation represents a relationship as definedin RFC5988
type LinkRelation struct {
RelationName string
Description string
Reference string
}
// LinkRelations returns an array of all link relations defined in RFC5988
func LinkRelations() []LinkRelation {
return []LinkRelation{
{
Rela... | linkRelation.go | 0.76105 | 0.533337 | linkRelation.go | starcoder |
// An implementation of Fortune's algorithm to get Voronoi edges for a set of
// points.
package voronoi
import (
"container/heap"
"fmt"
"math"
)
type Point struct {
X float64
Y float64
}
func Pt(x float64, y float64) *Point {
return &Point{X: x, Y: y}
}
type Vertices []*Point
type Edge struct {
Start ... | voronoi.go | 0.685739 | 0.582075 | voronoi.go | starcoder |
package main
import "errors"
/* relationship labels.
*region* is the reference of a course grained physical location.
*vpc* is an abstract reference to a group of resources.
*az* is a medium grained reference to an isolated location (DC/floor/whatever).
*subnet* is an abstract reference to a fixed range pool of ... | graph.go | 0.585338 | 0.462473 | graph.go | starcoder |
package util
import (
"bytes"
"fmt"
"io"
"io/ioutil"
)
const (
// Once initialized, capacity will never drop below this number.
initialGrowableByteSliceCapacity = 1024
)
/*
Buffer is used to hold file data in memory.
Slightly different and simpler behavior than bytes.Buffer.
Wraps a byte slice, and can grow it... | internal/util/growable_byte_slice.go | 0.667256 | 0.464112 | growable_byte_slice.go | starcoder |
// Package ristretto allows simple and abstracted operations in the Ristretto255 group
package ristretto
import (
"github.com/gtank/ristretto255"
"github.com/bytemare/crypto/group/internal"
)
const canonicalEncodingLength = 32
// Scalar implements the Scalar interface for Ristretto255 group scalars.
type Scalar ... | group/ristretto/scalar.go | 0.876125 | 0.494019 | scalar.go | starcoder |
package output
import (
"github.com/Jeffail/benthos/v3/internal/docs"
"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/output/writer"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeff... | lib/output/kafka.go | 0.717408 | 0.483831 | kafka.go | starcoder |
package compiler
import (
"fmt"
"regexp"
"github.com/influxdata/flux/ast"
"github.com/influxdata/flux/semantic"
"github.com/influxdata/flux/values"
"github.com/pkg/errors"
)
type Func interface {
Type() semantic.Type
Eval(input values.Object) (values.Value, error)
}
type Evaluator interface {
Type() semant... | compiler/runtime.go | 0.682997 | 0.440289 | runtime.go | starcoder |
package processor
import (
"encoding/json"
"fmt"
"strconv"
"time"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/types"
"github.com/Jeffail/benthos/lib/util/text"
"github.com/opentracing/opentracing-go"
)
//-------------------------------------... | lib/processor/number.go | 0.815012 | 0.718138 | number.go | starcoder |
package result
import "github.com/medmouine/gomad/maybe"
/*
Result aims at abstracting all logic related to operations susceptible to failures, such as external API calls, etc.
It offers constructors and methods to safely manipulate the result in case of success and handle errors gracefully in case of failure.
*/
typ... | result/result.go | 0.586523 | 0.487124 | result.go | starcoder |
package enigma
import (
"fmt"
)
// RotorConfig contains full configuration of a rotor
type RotorConfig = struct {
Model RotorModel
WheelPosition byte
RingPosition int
}
type rotor struct {
model RotorModel
wiringMapIn map[int]int // In = first pass through the rotors (from the ... | rotor.go | 0.720073 | 0.452294 | rotor.go | starcoder |
package main
import "reflect"
var dirs = []struct{ x, y int }{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}
func colorBorder_dfs(grid [][]int, row, col, color int) [][]int {
m, n := len(grid), len(grid[0])
type point struct{ x, y int }
borders := []point{}
originalColor := grid[row][col]
vis := make([][]bool, m)
for i := ... | 1034_color_border/color_border.go | 0.510741 | 0.424472 | color_border.go | starcoder |
package main
import (
"github.com/nsf/termbox-go"
"math"
"time"
)
const framedelay = 20
const thetaspacing = 0.02
const phispacing = 0.02
const R1 = 0.9
const R2 = 1.8
const K2 = 8.0
type Screen struct {
dim int
lum24 [][]int
data [][]byte
zoom float64
transition int
}
func newZBuf... | donut.go | 0.588771 | 0.414721 | donut.go | starcoder |
package common
import (
"bytes"
"io"
)
var (
// ErrIOEOF used for io.EOF.
ErrIOEOF = io.EOF
)
// Buffer represents the buffer tuple.
type Buffer struct {
pos int
seek int
cap int
buf []byte
}
// NewBuffer creates a new buffer.
func NewBuffer(cap int) *Buffer {
return &Buffer{pos: 0,
cap: cap,
buf: m... | sqlparser/depends/common/buffer.go | 0.566738 | 0.410166 | buffer.go | starcoder |
package mapstructure
import (
"strconv"
)
//PathPart is interface for different kinds of FieldPath elements.
type PathPart interface {
getDelimiter() string
String() string
}
//InStructPathPart is FieldPath element that represents field name in structure.
type InStructPathPart struct {
val string
}
func (p InSt... | field_path.go | 0.730097 | 0.431524 | field_path.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"strings"
)
/**hasBit returns true if the bit at position pos in the
binary representation of the number n is set to 1.*/
func hasBit(n int, pos int) bool {
val := n & (1 << pos)
return (val > 0)
}
/**clearBit returns the number n minus 2^pos*/
func clearBit(n int, pos in... | puzzle24/main.go | 0.800146 | 0.608623 | main.go | starcoder |
package creator
import (
"errors"
"fmt"
"strconv"
"github.com/pzduniak/unipdf/common"
"github.com/pzduniak/unipdf/model"
)
// Chapter is used to arrange multiple drawables (paragraphs, images, etc) into a single section.
// The concept is the same as a book or a report chapter.
type Chapter struct {
// The num... | bot/vendor/github.com/pzduniak/unipdf/creator/chapters.go | 0.713831 | 0.441492 | chapters.go | starcoder |
package fastrlp
import (
"bytes"
"encoding/binary"
"fmt"
"math/big"
"sync"
)
// bufPool to convert int to bytes
var bufPool = sync.Pool{
New: func() interface{} {
buf := make([]byte, 8)
return &buf
},
}
type cache struct {
buf [8]byte
vs []Value
size uint64
indx uint64
}
func (c *cache) reset() {
... | vendor/github.com/umbracle/fastrlp/encode.go | 0.670824 | 0.466481 | encode.go | starcoder |
package update
import (
"encoding/json"
"testing"
"github.com/nlopes/slack"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/infracloudio/botkube/pkg/config"
"github.com/infracloudio/botkube/pkg/no... | test/e2e/notifier/update/update.go | 0.516352 | 0.472379 | update.go | starcoder |
package backendbase
import (
"fmt"
"math"
)
type Vec [2]float64
func (v Vec) String() string {
return fmt.Sprintf("[%f,%f]", v[0], v[1])
}
func (v Vec) Add(v2 Vec) Vec {
return Vec{v[0] + v2[0], v[1] + v2[1]}
}
func (v Vec) Sub(v2 Vec) Vec {
return Vec{v[0] - v2[0], v[1] - v2[1]}
}
func (v Vec) Mul(v2 Vec) V... | backend/backendbase/math.go | 0.742982 | 0.563678 | math.go | starcoder |
package raylib
//#include "raylib.h"
//#include <stdlib.h>
import "C"
import "unsafe"
import "math"
//Matrix A representation of a 4 x 4 matrix
type Matrix struct {
M0 float32
M1 float32
M2 float32
M3 float32
M4 float32
M5 float32
M6 float32
M7 float32
M8 float32
M9 float32
M10 float32
M11 float... | raylib/matrix.go | 0.703448 | 0.42054 | matrix.go | starcoder |
package cards
import (
"encoding/json"
"fmt"
"math/rand"
"reflect"
"time"
)
// Card information is originally defined in a JSON file - however, in order to make this simpler for the user (and so they
// don't have to worry about having specific files in the right place), we can bundle the contents of the `cards.... | internal/cards/cards.go | 0.683314 | 0.404831 | cards.go | starcoder |
package main
import (
"fmt"
"image"
"image/color"
"image/png"
"log"
"os"
)
func max(a int, b int) int {
if a > b {
return a
} else {
return b
}
}
func min(a int, b int) int {
if a < b {
return a
} else {
return b
}
}
func getIdentityFilter() ([][]float64, float64, float64) {
return [][]flo... | filter.go | 0.625667 | 0.513668 | filter.go | starcoder |
package unit
import (
"bytes"
"fmt"
"reflect"
"runtime"
"strings"
"testing"
)
func Run(fixture interface{}, t *testing.T) {
fixtureType := reflect.TypeOf(fixture)
for x := 0; x < fixtureType.NumMethod(); x++ {
testMethodName := fixtureType.Method(x).Name
if strings.HasPrefix(testMethodNam... | vendor/github.com/smartystreets/assertions/internal/unit/fixture.go | 0.54819 | 0.437944 | fixture.go | starcoder |
package cmd
import (
"fmt"
"github.com/aurumbot/flags"
"github.com/aurumbot/lib/dat"
f "github.com/aurumbot/lib/foundation"
dsg "github.com/bwmarrin/discordgo"
"strings"
)
func init() {
Cmd["botcfg"] = &f.Command{
Name: "Bot configuration tool",
Help: `Info: Allows administrators to set lower level configu... | handler/botcfg.go | 0.573201 | 0.410225 | botcfg.go | starcoder |
package model
// TypeExpr provides a type name that may be rewritten to use a package name.
import (
"fmt"
"go/ast"
)
type TypeExpr struct {
Expr string // The unqualified type expression, e.g. "[]*MyType"
PkgName string // The default package idenifier
pkgIndex int // The index where the package identif... | model/type_expr.go | 0.649023 | 0.437343 | type_expr.go | starcoder |
package privacy
import (
"crypto/elliptic"
"encoding/json"
"math/big"
"errors"
"github.com/incognitochain/incognito-chain/common"
"github.com/incognitochain/incognito-chain/common/base58"
)
var InvalidXCoordErr = errors.New("X is not an abscissa of a point on the elliptic curve")
var IsNotAnEllipticPointErr = ... | privacy/ec.go | 0.774839 | 0.505066 | ec.go | starcoder |
package rpc
import (
"fmt"
"math"
"time"
"github.com/ebay/beam/api"
"github.com/ebay/beam/logentry"
)
// KGObjectFromAPI returns a new KGObject instance that is equivilent to the
// supplied API representation of a KGObject. The rpc.KGObject encapsulates
// a binary encoding of the KGObject
func KGObjectFromAP... | src/github.com/ebay/beam/rpc/kgobject_new.go | 0.79158 | 0.532425 | kgobject_new.go | starcoder |
package mmap
import (
"math"
"github.com/alexeymaximov/go-bio/segment"
"github.com/alexeymaximov/go-bio/transaction"
)
// MaxInt is the maximum platform dependent signed integer.
const MaxInt = int(^uint(0) >> 1)
// Mode is a mapping mode.
type Mode int
const (
// Share this mapping and allow the read-only acc... | mmap/mmap.go | 0.76986 | 0.528168 | mmap.go | starcoder |
package types
// An object that defines a message that contains text formatted using Amazon
// Pinpoint Voice Instructions markup.
type CallInstructionsMessageType struct {
// The language to use when delivering the message. For a complete list of
// supported languages, see the Amazon Polly Developer Guide.
Text... | service/pinpointsmsvoice/types/types.go | 0.716119 | 0.565659 | types.go | starcoder |
package bitfield
import "encoding/hex"
// Bitfield provides operations for reading and manipulating bits in group of bytes.
type Bitfield struct {
b []byte
length uint32
}
// New creates a new empty Bitfield of length bits.
func New(length uint32) *Bitfield {
return &Bitfield{make([]byte, (length+7)/8), leng... | vendor/github.com/cenk/bitfield/bitfield.go | 0.794982 | 0.560373 | bitfield.go | starcoder |
package main
import (
"log"
"math/rand"
"time"
. "github.com/jakecoffman/cp"
"github.com/jakecoffman/cp/examples"
)
var (
tankBody, tankControlBody *Body
)
const (
width = 640
height = 480
hwidth = width / 2
hheight = height / 2
)
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
rand.Seed(... | examples/tank/tank.go | 0.644784 | 0.451689 | tank.go | starcoder |
package operator
import (
"fmt"
"math"
"github.com/chewxy/math32"
"gorgonia.org/gorgonia/internal/exprgraph"
)
var (
/* float64 */
// non differentiable
absf64 = sf64UnaryOperator(math.Abs)
signf64 = sf64UnaryOperator(_signf64)
ceilf64 = sf64UnaryOperator(math.Ceil)
floorf64 = sf64UnaryOperator(math.F... | internal/op/operator/operatorPointwise_unary_const.go | 0.539226 | 0.435481 | operatorPointwise_unary_const.go | starcoder |
package main
import (
"fmt"
"log"
torch "github.com/wangkuiyi/gotorch"
nn "github.com/wangkuiyi/gotorch/nn"
F "github.com/wangkuiyi/gotorch/nn/functional"
"github.com/wangkuiyi/gotorch/nn/initializer"
"github.com/wangkuiyi/gotorch/vision/datasets"
"github.com/wangkuiyi/gotorch/vision/transforms"
)
var device... | example/dcgan/dcgan.go | 0.756717 | 0.416263 | dcgan.go | starcoder |
package utils
import (
"bytes"
"encoding/gob"
"fmt"
"github.com/pkg/errors"
"strings"
)
// DefaultWidth defaults to a default screen dumps size
const DefaultWidth = 51
// boxLineOverheat Overheat per line when drawing boxes
const boxLineOverheat = 1 + 1
// Dump dumps a 46 char wide hex string
func BoxedDump(n... | plc4go/internal/plc4go/spi/utils/hex.go | 0.603114 | 0.443239 | hex.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
)
// HStoreArrayFromStringMapSlice returns a driver.Valuer that produces a PostgreSQL hstore[] from the given Go []map[string]string.
func HStoreArrayFromStringMapSlice(val []map[string]string) driver.Valuer {
return hstoreArrayFromStringMapSlice{val: val... | pgsql/hstorearr.go | 0.678433 | 0.506469 | hstorearr.go | starcoder |
package examples
import (
"io"
"os"
"path"
"github.com/kva3umoda/goecharts"
"github.com/kva3umoda/goecharts/model"
"github.com/kva3umoda/goecharts/render"
)
func lineBasicLineChart() *goecharts.Charts {
weeks := []string{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}
value := []int32{150, 230, 224, 218, 13... | examples/examples/line.go | 0.654011 | 0.440168 | line.go | starcoder |
This example program shows how the `finder` and `property` packages can
be used to navigate a vSphere inventory structure using govmomi.
*/
package main
import (
"flag"
"fmt"
"net/url"
"os"
"strings"
"text/tabwriter"
"github.com/vmware/govmomi"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/pro... | Godeps/_workspace/src/github.com/vmware/govmomi/examples/datastores/main.go | 0.736969 | 0.439326 | main.go | starcoder |
package plan
import (
"github.com/Sndav/go-mysql-server/sql"
"github.com/Sndav/go-mysql-server/sql/expression"
)
// TransformUp applies a transformation function to the given tree from the
// bottom up.
func TransformUp(node sql.Node, f sql.TransformNodeFunc) (sql.Node, error) {
if o, ok := node.(sql.OpaqueNode);... | sql/plan/transform.go | 0.68342 | 0.479869 | transform.go | starcoder |
package db
import "time"
type TimePeriod struct {
Start time.Time
End time.Time
}
func (tp TimePeriod) Includes(u time.Time) bool {
return u.Sub(tp.Start) >= 0 && tp.End.Sub(u) > 0
}
func (tp TimePeriod) Equal(o TimePeriod) bool {
return tp.Start.Equal(o.Start) && tp.End.Equal(o.End)
}
type TimeOfDayPeriod ... | db/calendar.go | 0.777427 | 0.566139 | calendar.go | starcoder |
package pos
import "github.com/chewxy/lingo"
type perceptron struct {
// weights map[feature]*[lingo.MAXTAG]float64 // it's a pointer to a static array because map values are immutable, and cannot be edited
weightsSF map[singleFeature]*[lingo.MAXTAG]float64
weightsTF map[tupleFeature]*[lingo.MAXTAG]float64
tota... | pos/perceptron.go | 0.5794 | 0.506164 | perceptron.go | starcoder |
package manta
import (
"math"
)
type fieldDecoder func(*reader) interface{}
type fieldFactory func(*field) fieldDecoder
var fieldTypeFactories = map[string]fieldFactory{
"float32": floatFactory,
"CNetworkedQuantizedFloat": quantizedFactory,
"Vector": vectorFactory(3),
"Vector2... | field_decoder.go | 0.595845 | 0.416381 | field_decoder.go | starcoder |
package merkle
import (
"errors"
"fmt"
"math"
"strings"
"github.com/ravdin/programmingbitcoin/util"
)
// Tree represents a merkle tree.
type Tree struct {
Total int
MaxDepth int
Nodes [][][]byte
CurrentDepth int
CurrentIndex int
}
// NewTree initializes a new merkle tree.
// total: numbe... | merkle/tree.go | 0.703142 | 0.440229 | tree.go | starcoder |
package buffer
// View is a slice of a buffer, with convenience methods
type View []byte
// NewView allocates a new buffer and returns an initialized view that convers
// the whole buffer
func NewView(size int) View {
return make(View, size)
}
// CapLength irreversibly reduces the length of the visible section of t... | buffer/view.go | 0.89058 | 0.729447 | view.go | starcoder |
package dh
import (
"crypto/rand"
"encoding/hex"
curve "gitlab.com/yawning/x448.git"
)
// dhlen448 defines the DHLEN for x448.
const dhlen448 = 56
// publicKey448 implements the PublicKey interface.
type publicKey448 struct {
raw [dhlen448]byte
}
// Bytes turns the underlying bytes array into a slice.
func (pk... | dh/curve448.go | 0.865849 | 0.457197 | curve448.go | starcoder |
package google
import (
"fmt"
"github.com/infracost/infracost/internal/schema"
"github.com/shopspring/decimal"
)
type NetworkEgressUsage struct {
Address string
Region string
PrefixName string
}
type StorageBucketNetworkEgressUsage struct {
SameContinent *float64 `infracost_usage:"same_continent"`
As... | internal/resources/google/network_egress_internal.go | 0.516595 | 0.440289 | network_egress_internal.go | starcoder |
package parsers
import (
"fmt"
"sort"
"strings"
)
// IntRange is a representation of a range that has a lower and upper bound (Min, Max).
// Min and Max are elements of the range.
type IntRange struct {
Min int
Max int
}
func (ir *IntRange) String() string {
return fmt.Sprintf("[%d:%d]", ir.Min, ir.Max)
}
fun... | parsers/helpers_ranges.go | 0.684264 | 0.499695 | helpers_ranges.go | starcoder |
package graph
import (
"bytes"
"errors"
"fmt"
"log"
"math/rand"
"strconv"
"time"
)
type Graph struct {
nodes int
edges int
}
func New(numberOfNodes, numberOfEdges int) Graph {
return Graph{numberOfNodes, numberOfEdges}
}
func (graph Graph) NumberOfNodes() int {
return graph.nodes
}
func (graph Graph) Nu... | graph/graph.go | 0.656768 | 0.521227 | graph.go | starcoder |
package raytrace
import (
"math"
"math/rand"
"github.com/markzuber/zgotrace/raytrace/vectorextensions"
"github.com/go-gl/mathgl/mgl64"
)
var ranFloat [256]float64
var ranVector [256]mgl64.Vec3
var permX [256]int
var permY [256]int
var permZ [256]int
func perlinGenerate() [256]float64 {
var p [256]float64
for... | raytrace/perlin.go | 0.569134 | 0.400837 | perlin.go | starcoder |
package simplify
type Matrix struct {
x00, x01, x02, x03 float64
x10, x11, x12, x13 float64
x20, x21, x22, x23 float64
x30, x31, x32, x33 float64
}
func (a Matrix) QuadricError(v Vector) float64 {
return (v.X*a.x00*v.X + v.Y*a.x10*v.X + v.Z*a.x20*v.X + a.x30*v.X +
v.X*a.x01*v.Y + v.Y*a.x11*v.Y + v.Z*a.x21*v.Y ... | matrix.go | 0.808974 | 0.784855 | matrix.go | starcoder |
package websocket
import (
"encoding/binary"
"math/bits"
)
func maskBytesGo(key32 uint32, b []byte) uint32 {
if len(b) >= 16 {
key64 := uint64(key32) | uint64(key32)<<32
// At some point in the future we can clean these unrolled loops up.
// See https://github.com/golang/go/issues/31586#issuecomment-4874364... | mask.go | 0.571527 | 0.472744 | mask.go | starcoder |
package internal
import "github.com/mokiat/gomath/sprec"
const (
initialShapePointCount = 1024
initialShapeSubShapeCount = 4
)
func newShape() *Shape {
return &Shape{
points: make([]ShapePoint, 0, initialShapePointCount),
subShapes: make([]SubShape, 0, initialShapeSubShapeCount),
}
}
type Shape struct... | framework/opengl/ui/internal/shape.go | 0.531209 | 0.581422 | shape.go | starcoder |
package transformer
import (
"gopkg.in/Clever/optimus.v3"
"gopkg.in/Clever/optimus.v3/transforms"
)
// A Transformer allows you to easily chain multiple transforms on a table.
type Transformer struct {
table optimus.Table
}
// Table returns the terminating Table in a Transformer chain.
func (t Transformer) Table(... | plugins/data/transform/optimus/transformer/transformer.go | 0.82925 | 0.504578 | transformer.go | starcoder |
package accumulator
import (
"bytes"
"fmt"
"sort"
"time"
"github.com/FactomProject/factomd/util/atomic"
"github.com/PaulSnow/ValidatorAccumulator/ValAcc/database"
"github.com/PaulSnow/ValidatorAccumulator/ValAcc/merkleDag"
"github.com/PaulSnow/ValidatorAccumulator/ValAcc/node"
"github.com/PaulSnow/Validato... | ValAcc/accumulator/accumulator.go | 0.601945 | 0.546194 | accumulator.go | starcoder |
package main
import (
"fmt"
"strconv"
"strings"
)
/*
Problem:
Implement atoi which converts a string to an integer.
The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus... | Programs/008String to Integer (atoi)/008String to Integer (atoi).go | 0.544317 | 0.697596 | 008String to Integer (atoi).go | starcoder |
package gql
import (
"github.com/graphql-go/graphql"
"time"
"math/rand"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
func ResultTypeConfig() graphql.ObjectConfig {
return graphql.ObjectConfig{
Name: "Result",
Fields: graphql.Fields{
"result": &graphql.Field{
Type: graphql.String,
},
"me... | gql/gql.go | 0.536313 | 0.418637 | gql.go | starcoder |
package colorgrad
// Diverging
func BrBG() Gradient {
colors := []string{"#543005", "#8c510a", "#bf812d", "#dfc27d", "#f6e8c3", "#f5f5f5", "#c7eae5", "#80cdc1", "#35978f", "#01665e", "#003c30"}
return presetSpline(colors)
}
func PRGn() Gradient {
colors := []string{"#40004b", "#762a83", "#9970ab", "#c2a5cf", "#e7... | vendor/github.com/mazznoer/colorgrad/preset.go | 0.61115 | 0.582075 | preset.go | starcoder |
package bunbig
import (
"database/sql"
"database/sql/driver"
"fmt"
"math/big"
"gopkg.in/yaml.v3"
)
type Int big.Int
func NewInt() *Int {
return new(Int)
}
func newBigint(x *big.Int) *Int {
return (*Int)(x)
}
// same as NewBigint()
func FromMathBig(x *big.Int) *Int {
return (*Int)(x)
}
func FromInt64(x int... | extra/bunbig/int.go | 0.609059 | 0.400017 | int.go | starcoder |
package main
/*
* Quadtree will give us a primitive for spatially indexing pointers of game objects; our primary use case for
* this data structure will be in the world map where we will lean on it for lookups instead of using the usual
* room character/object/entity lists for a given room.
*/
type QuadTree struct... | src/quad_tree.go | 0.846165 | 0.415551 | quad_tree.go | starcoder |
package ta
type MovingAverage interface {
Study
ma()
}
type implMA struct {
noMulti
}
func (implMA) ma() {}
// MovingAverageFunc defines a function that returns am updatable moving average for the given period
type MovingAverageFunc func(period int) MovingAverage
func (ta *TA) MovingAverage(fn MovingAverageFunc... | studies_ma.go | 0.850903 | 0.457924 | studies_ma.go | starcoder |
package math
import (
"math"
"strconv"
"github.com/flowonyx/functional/option"
"golang.org/x/exp/constraints"
)
type numeric interface {
constraints.Float | constraints.Integer
}
// Abs returns the absolute value of x.
func Abs[T constraints.Signed](x T) T {
if x < 0 {
return -x
}
return x
}
// RoundInt ... | math/math.go | 0.900307 | 0.699588 | math.go | starcoder |
package jsonlogic
// customOperators holds custom operators
var customOperators = make(map[string]func(values, data interface{}) (result interface{}))
// AddOperator allows for custom operators to be used
func AddOperator(key string, cb func(values, data interface{}) (result interface{})) {
customOperators[key] = cb... | operation.go | 0.517571 | 0.522385 | operation.go | starcoder |
package checks
const searchChecksYAML = `
- name: unmount-volume
description: Checks if Mesos agents had problems unmounting local persistent volumes. MESOS-8830
fileTypeName: mesos-agent-log
errorPattern: 'Failed to remove rootfs mount point'
cure: Please, refer to the KB article https://support.d2iq.com/s/ar... | checks/search_checks_yaml.go | 0.794425 | 0.405037 | search_checks_yaml.go | starcoder |
package smd
import (
"math"
"os"
"time"
"github.com/ChristopherRabotin/ode"
kitlog "github.com/go-kit/kit/log"
"github.com/gonum/matrix/mat64"
)
const (
transitionPhiOnly = false
)
// OrbitEstimate is an ode.Integrable which allows to propagate an orbit via its initial estimate.
type OrbitEstimate struct {
... | estimate.go | 0.61231 | 0.48121 | estimate.go | starcoder |
package qdb
/*
#include <qdb/ts.h>
*/
import "C"
import (
"math"
"time"
"unsafe"
)
// TsInt64Point : timestamped int64 data point
type TsInt64Point struct {
timestamp time.Time
content int64
}
// Timestamp : return data point timestamp
func (t TsInt64Point) Timestamp() time.Time {
return t.timestamp
}
// C... | entry_timeseries_int64.go | 0.725162 | 0.402744 | entry_timeseries_int64.go | starcoder |
package adt
import "github.com/solo-io/cue/cue/token"
// Op indicates the operation at the top of an expression tree of the expression
// use to evaluate a value.
type Op int
func (o Op) String() string {
return opToString[o]
}
// Values of Op.
const (
NoOp Op = iota
AndOp
OrOp
SelectorOp
IndexOp
SliceOp
... | internal/core/adt/op.go | 0.725162 | 0.447521 | op.go | starcoder |
package sudokuconv
import (
"math"
"math/bits"
"sort"
"github.com/pkg/errors"
)
var (
// symbolMasks extract 3 bits a symbol (must be zero based and <8)
symbolMasks = [3]uint8{4, 2, 1}
// bitMasks extract each bit of a byte/uint8
bitMasks = [8]uint8{128, 64, 32, 16, 8, 4, 2, 1}
)
// ToBytes converts a 9x9 s... | sudokuconv.go | 0.692226 | 0.461441 | sudokuconv.go | starcoder |
package lsmt
import (
"fmt"
)
type TreeNode struct {
Elem Element
Left *TreeNode
Right *TreeNode
Size int
}
// NewTree accepts a sorted element slice and returns a binary tree representation.
func NewTree(elems []Element) *TreeNode {
size := len(elems)
if size == 0 {
return nil
}
root := &TreeN... | LSM-Tree-main/binary_tree.go | 0.837055 | 0.464416 | binary_tree.go | starcoder |
package balance
import (
"fmt"
"math/big"
"runtime/debug"
)
/*
Coin starts here
*/
// Coin is the basic amount, specified in integers, at the smallest increment (i.e. a satoshi, not a bitcoin)
type Coin struct {
Currency Currency `json:"currency"`
Amount *big.Int `json:"amount,string"`
}
// See if the coin i... | data/balance/coin.go | 0.71423 | 0.472014 | coin.go | starcoder |
package models
// IsType returns whether the field is a type.
func (f *Field) IsType() bool {
return f.Parent == nil
}
// basicMap contains a list of basic types.
var (
basicMap = map[string]bool{
"invalid": true,
"bool": true,
"int": true,
"int8": true,
"int16": true,
"int32"... | cli/models/category.go | 0.878939 | 0.402744 | category.go | starcoder |
package values
import (
"fmt"
)
type Scope interface {
// Lookup a name in the scope.
Lookup(name string) (Value, bool)
// LocalLookup a name in current scope only.
LocalLookup(name string) (Value, bool)
// Set binds a variable in the current scope.
Set(name string, v Value)
// Nest creates a new scope by ... | values/scope.go | 0.629547 | 0.485417 | scope.go | starcoder |
package classifier
import (
"encoding/json"
"io"
deep "github.com/patrikeh/go-deep"
"github.com/patrikeh/go-deep/training"
"github.com/bububa/facenet/core"
)
// Neural represents neural classifier
type Neural struct {
ml *deep.Neural
threshold float64
}
// Name return sclassifier name
func (n *Neural... | classifier/deep.go | 0.81571 | 0.415254 | deep.go | starcoder |
package stacks_queues
/*
You are given two non-empty zero-indexed arrays A and B consisting of N integers.
Arrays A and B represent N voracious fish in a river, ordered downstream along the flow of the river.
The fish are numbered from 0 to N − 1. If P and Q are two fish and P < Q, then fish P is initially
upstream o... | stacks-queues/Fish.go | 0.851922 | 0.921957 | Fish.go | starcoder |
package core
import . "don/syntax"
// DType
// DTypes form a Boolean algebra
// Conceptually, a DType is a set of []string
type DType struct {
NoUnit bool
Positive bool
Fields map[string]DType
}
// Get DType
var UnknownType DType
var UnitType = DType{Positive: true}
var FieldsType = DType{NoUnit: true}
var ... | src/core/dType.go | 0.6137 | 0.515071 | dType.go | starcoder |
package chaikin
import (
"github.com/MicahParks/go-ad"
"github.com/MicahParks/go-ma"
)
const (
// ShortEMA is the number of periods in the short EMA of the Accumulation Distribution Line results. For the Chaikin
// Oscillator.
ShortEMA = 3
// LongEMA is the number of periods in the long EMA of the Accumulation... | float64.go | 0.723016 | 0.545467 | float64.go | starcoder |
package kalman
import (
"math"
mat "github.com/mrfyo/matrix"
)
type CubatureKalmanFilter struct {
DimX int // n
DimZ int // m
Dt float64 // collect duration
Fx FilterFun // (n, 1)
Hx FilterFun // (m, 1)
X Matrix // (n, 1)
P Matrix // (n, n)
R Matrix // ... | ckf.go | 0.555194 | 0.44746 | ckf.go | starcoder |
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/hm-edu/domain-rest-interface/ent/delegation"
"github.com/hm-edu/domain-rest-interface/ent/domain"
)
// Delegation is the model entity for the Delegation schema.
type Delegation struct {
config `json:"-"`
// ID of the ent.
ID... | backend/domain-rest-interface/ent/delegation.go | 0.662796 | 0.419886 | delegation.go | starcoder |
package nbc
import (
"sort"
)
type Classifier struct {
trainingSet map[string]map[string]float64
labelWeights map[string]float64
minWeight float64
validationRate float64
}
func (c *Classifier) Train(items []ClassItem) {
c.trainingSet = make(map[string]map[string]float64)
c.labelWeights = make(map[st... | classifier.go | 0.55929 | 0.452052 | classifier.go | starcoder |
package main
const ddcContents string = `<ddc>
<class number="000" description="Computer science, information & general works">
<division number="000" description="Computer science, knowledge & systems">
<section number="000" description="Computer science, information & general works"></section... | ddc.go | 0.567337 | 0.459986 | ddc.go | starcoder |
package segment
import (
"encoding/binary"
"io"
)
// ReadWriterAt is the interface that groups the basic io.ReadAt and io.WriteAt methods.
type ReadWriterAt interface {
io.ReaderAt
io.WriterAt
}
// Segment is a data segment.
// Supported data types are uint8, uint16, uint32 and uint64.
// All numeric values in t... | segment/segment.go | 0.668772 | 0.45175 | segment.go | starcoder |
package tort
import (
"fmt"
"strconv"
"time"
)
// TimeAssertion accepts time.Time extensions.
type TimeAssertion interface {
// Assert returns the underlying time.Time value.
Assert() time.Time
}
// TimeAssertions are tests around time values.
type TimeAssertions struct {
Assertions
name string
time time.Tim... | times.go | 0.818628 | 0.761028 | times.go | starcoder |
package main
type sufIndexed struct {
str string
idx int
}
func newSufIndexed(s string) sufIndexed {
if len(s) != 0 && s[0] == '.' {
return sufIndexed{s, suffixIndex(s[1:])}
}
return sufIndexed{s, suffixIndex(s)}
}
func isAlpha(c byte) bool {
return (((c) | 32) - 'a') < 26
}
func isAlnum(c byte) bool {
ret... | filevercmp.go | 0.557604 | 0.401306 | filevercmp.go | starcoder |
package decimal
var DecByteToString = [256]string{
0: `000`,
1: `001`,
2: `002`,
3: `003`,
4: `004`,
5: `005`,
6: `006`,
7: `007`,
8: `008`,
9: `009`,
10: `010`,
11: `011`,
12: `012`,
13: `013`,
14: `014`,
15: `015`,
16: `016`,
17: `017`,
18: `018`,
19: `019`,
20: `0... | pkg/reader/byteFormatters/decimal/dec_lookup.go | 0.63375 | 0.459501 | dec_lookup.go | starcoder |
package ui
import (
"github.com/BurntSushi/xgb/shape"
"github.com/BurntSushi/xgb/xproto"
"github.com/BurntSushi/xgbutil"
"github.com/BurntSushi/xgbutil/xwindow"
"github.com/BurntSushi/xgbutil/xrect"
"log"
)
// extract the top-left and bottom-right points of an xrect as a 4-tuple: x, y, x2, ... | ui/shape.go | 0.759582 | 0.48749 | shape.go | starcoder |
package shape
import (
"fmt"
"io"
"math"
"github.com/gregoryv/draw/xy"
"github.com/gregoryv/nexus"
)
func NewArrow(x1, y1, x2, y2 int) *Arrow {
head := NewTriangle()
head.SetX(x2)
head.SetY(y2)
head.SetClass("arrow-head")
return &Arrow{
Start: xy.Point{x1, y1},
End: xy.Point{x2, y2},
Head: head,
... | shape/arrow.go | 0.776369 | 0.430207 | arrow.go | starcoder |
package medtronic
import (
"fmt"
"time"
)
// CGMRecordType represents a CGM record type.
type CGMRecordType byte
//go:generate stringer -type CGMRecordType
// Events stored in the pump's CGM history pages.
const (
CGMDataEnd CGMRecordType = 0x01
CGMWeakSignal CGMRecordType = 0x02
CGMCal CGMR... | cgmrecord.go | 0.563138 | 0.587233 | cgmrecord.go | starcoder |
package yasup
import (
crypto "crypto/rand"
"math/big"
"math/rand"
)
var zeroValueComplex64 complex64
//Complex64Insert will append elem at the position i. Might return ErrIndexOutOfBounds.
func Complex64Insert(sl *[]complex64, elem complex64, i int) error {
if i < 0 || i > len(*sl) {
return ErrIndexOutOfBoun... | complex64Slices.go | 0.711331 | 0.467696 | complex64Slices.go | starcoder |
package main
import (
"fmt"
"image"
"image/color"
"image/png"
"math"
"os"
"strconv"
"time"
)
// WIDTH defines the width of the created image
const WIDTH = 640
// HEIGHT defines the height of the created image
const HEIGHT = 400
func euclideanDistance(x1, y1, x2, y2 int) float64 {
return math.Sqrt(math.Pow(... | randimg/random_image.go | 0.670608 | 0.447702 | random_image.go | starcoder |
package ksmooth
import (
"errors"
"github.com/iamthebot/gostat/stat"
"math"
)
type NWDPSmoother struct {
Bandwidth float64
Radius int
Kernel func(float64, float64) float64
}
//Allocates a new Nadraya-Watson kernel smoother using gaussian kernel
func NewNWDPGaussianSmoother(bandwidth float64, density floa... | smoother.go | 0.77586 | 0.448245 | smoother.go | starcoder |
package main
import (
"fmt"
"math"
"strconv"
"strings"
)
type Direction struct {
DeltaX int
DeltaY int
TurnLeft func() *Direction
TurnRight func() *Direction
}
type Command struct {
TurnDirection string
MoveDistance int
}
type Vector struct {
X int
Y int
}
func (v Vector) String() string {
ret... | day1/part2/part2.go | 0.594787 | 0.439266 | part2.go | starcoder |
package deque
type (
// Deque basic generic deque (double-ended queue) implementation based on double-linked list
Deque[T any] struct {
head *node[T]
tail *node[T]
length int
}
// node is a generic double-linked list node use for Deque implementation
node[T any] struct {
Value T
Next *node[T]
P... | containers/deque/deque.go | 0.597256 | 0.525917 | deque.go | starcoder |
package gates
import "math"
// basic unit type to recreate the simpe neural network
type Unit struct {
Value float64
Gradient float64
}
// interface for all gate types
type Gate interface {
Forward()
Backward()
}
// MultiplyGate structure and traits
type MultiplyGate struct {
U0 *Unit
U1 *... | src/go_NN/gates/gates.go | 0.851259 | 0.402451 | gates.go | starcoder |
package datastructs
type BSTNode struct {
Value int
LeftChild *BSTNode
RightChild *BSTNode
Parent *BSTNode
}
type BSTree struct {
RootNode BSTNode
}
func MakeBSTree(rootVal int) BSTree {
return BSTree{RootNode: BSTNode{Value: rootVal, LeftChild: nil, RightChild: nil, Parent: nil}}
}
func (tree *BSTr... | datastructs/binary_tree.go | 0.553023 | 0.587263 | binary_tree.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.