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 subscribe
import "encoding/binary"
var LimitMaxValue uint64 = 0x100000000 //2^32
type BitMap interface {
Existed(value uint64) bool
Put(value uint64) error
Remove(value uint64)
Resize(value uint64) error
Range() (min, max uint64)
Size() int
Count() int
}
func indexAndMask(value uint64) (index uint64,... | sxg/subscribe/bitmap.go | 0.580233 | 0.45647 | bitmap.go | starcoder |
package portable
import (
"image"
"image/color"
"math"
)
func bilinear(src image.Image, x, y float32) color.Color {
switch src := src.(type) {
case *image.RGBA:
return bilinearRGBA(src, x, y)
case *image.Alpha:
return bilinearAlpha(src, x, y)
case *image.Uniform:
return src.C
default:
return bilinear... | vendor/src/golang.org/x/mobile/sprite/portable/bilinear.go | 0.804175 | 0.729387 | bilinear.go | starcoder |
package practice
/*
Practice Recursion, Memoization and Goroutines:
Fib: Fib(n) = Fib(n - 1) + Fib(n - 2) where Fib(0) = 0 and Fib(1) = 1
Fib(0) = 0
Fib(1) = 1
Fib(2) = 1
Fib(3) = 2
Fib(4) = 3
Fib(5) = 5
Fib(6) = 8
Fib(7) = 13
Fib(8) = 21
*/
//RecursiveFib -- Typical recursive solution
func RecursiveFib(num int) in... | chapter8/practice/practice.go | 0.612657 | 0.441553 | practice.go | starcoder |
package bn256
import (
"errors"
"math/big"
"github.com/MadBase/MadNet/crypto/bn256/cloudflare"
)
// numBytes specifies the number of bytes in a GFp object
const numBytes = 32
// ErrNotUint256 occurs when we work with a uint with more than 256 bits
var ErrNotUint256 = errors.New("big.Ints are not at most 256-bit ... | crypto/bn256/bn256.go | 0.662687 | 0.479138 | bn256.go | starcoder |
package geom
import (
"fmt"
"math"
"strconv"
"strings"
)
var Origin = Vec{0, 0, 0}
// Vec holds x, y, z values.
type Vec struct {
X, Y, Z float64
}
func ArrayToVec(a [3]float64) Vec {
return Vec{a[0], a[1], a[2]}
}
// Scaled multiplies by a scalar
func (a Vec) Scaled(n float64) Vec {
return Vec{a.X * n, a.Y... | pkg/geom/vec.go | 0.875095 | 0.690592 | vec.go | starcoder |
package mvt
import (
"log"
"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 the
// (square) tile in pixels usually 4096, see DefaultExtent.
// This fun... | vendor/github.com/go-spatial/geom/encoding/mvt/prepare.go | 0.672117 | 0.684646 | prepare.go | starcoder |
package sprite
import (
"golang-games/PuzzleBlock/vec3"
"github.com/veandco/go-sdl2/img"
"github.com/veandco/go-sdl2/sdl"
)
// Sprite is a struct that contains the basic building blocks for game entities
type Sprite struct {
Tex *sdl.Texture
Src *sdl.Rect
Dst *sd... | PuzzleBlock/sprite/sprite.go | 0.733261 | 0.401629 | sprite.go | starcoder |
package safe
import "math"
type Int struct{}
func (i Int) Add(x, y int) (int, bool) {
r := x + y
// Overflow if both arguments have the opposite sign of the result
if ((x ^ r) & (y ^ r)) < 0 {
return r, false
}
return r, true
}
func (i Int) Subtract(x, y int) (int, bool) {
r := x - y
// Overflow iff the ar... | safe.go | 0.732783 | 0.509398 | safe.go | starcoder |
package metrics
// Recall measures the fraction of times a true class was predicted.
type Recall struct {
Class float64
}
// Apply Recall.
func (recall Recall) Apply(yTrue, yPred, weights []float64) (float64, error) {
var cm, err = MakeConfusionMatrix(yTrue, yPred, weights)
if err != nil {
return 0, err
}
var ... | metrics/recall.go | 0.935132 | 0.494934 | recall.go | starcoder |
package raycaster
import (
"github.com/mattkimber/gorender/internal/geometry"
"github.com/mattkimber/gorender/internal/manifest"
"math"
)
func getRenderDirection(angle float64, elevationAngle float64) geometry.Vector3 {
x, y, z := -math.Cos(geometry.DegToRad(angle)), math.Sin(geometry.DegToRad(angle)), math.Sin(g... | internal/raycaster/setup.go | 0.887516 | 0.791741 | setup.go | starcoder |
package shapes
import (
"github.com/eriklupander/pathtracer/internal/app/geom"
"github.com/eriklupander/pathtracer/internal/app/material"
"math"
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
func NewSphere() *Sphere {
return &Sphere{
Basic: Basic{
Id: rand.Int63(),
... | internal/app/shapes/sphere.go | 0.788298 | 0.485112 | sphere.go | starcoder |
package vec
import (
"errors"
"math"
)
// Length returns the length of u-v.
func Length(u, v I2) float64 {
v = v.Sub(u)
return math.Sqrt(float64(v.Dot(v)))
}
// Edge describes an edge between two I2 vertices.
type Edge struct {
U, V I2
}
// Length is the length of the edge.
func (e Edge) Length() float64 {
v... | graph.go | 0.830628 | 0.553807 | graph.go | starcoder |
package apimodel
import (
"github.com/alexandre-normand/glukit/app/util"
"time"
)
const (
INSULIN_TAG = "Insulin"
)
// Injection represents an insulin injection
type Injection struct {
Time Time `json:"time" datastore:"time,noindex"`
Units float32 `json:"units" datastore:"units,noindex"`
Insuli... | app/apimodel/injection.go | 0.753104 | 0.459197 | injection.go | starcoder |
package dsc
import (
"database/sql"
"reflect"
"time"
)
//Scanner represents a datastore data scanner. This abstraction provides the ability to convert and assign datastore record of data to provided destination
type Scanner interface {
//Returns all columns specified in select statement.
Columns() ([]string, err... | api.go | 0.615897 | 0.47591 | api.go | starcoder |
package si5351
// OutputIndex indicates one of the output clocks.
type OutputIndex int
// The output clocks.
const (
Clk0 OutputIndex = iota
Clk1
Clk2
Clk3
Clk4
Clk5
Clk6
Clk7
)
// Output describes the properties common to all of the Si5351's output clocks.
type Output struct {
Register OutputRegister
P... | pkg/si5351/output.go | 0.793106 | 0.40157 | output.go | starcoder |
package ytbx
import (
"fmt"
yamlv3 "gopkg.in/yaml.v3"
)
// Grab gets the value from the provided YAML tree using a path to traverse
// through the tree structure
func Grab(node *yamlv3.Node, pathString string) (*yamlv3.Node, error) {
path, err := ParsePathString(pathString, node)
if err != nil {
return nil, e... | getting.go | 0.702632 | 0.432543 | getting.go | starcoder |
package plan
import (
"io"
"reflect"
"github.com/opentracing/opentracing-go"
"github.com/liquidata-inc/go-mysql-server/sql"
)
// An IndexedJoin is a join that uses index lookups for the secondary table.
type IndexedJoin struct {
// The primary and secondary table nodes. The normal meanings of Left and
// Righ... | sql/plan/indexed_join.go | 0.598077 | 0.423398 | indexed_join.go | starcoder |
package ptr
import "time"
// ToDef returns the value of the int pointer passed in or default value if the pointer is nil.
func ToDef[T any](v *T, def T) T {
if v == nil {
return def
}
return *v
}
// ToIntDef returns the value of the int pointer passed in or default value if the pointer is nil.
func ToIntDef(v *... | todef.go | 0.742422 | 0.434581 | todef.go | starcoder |
package tdigest
import (
"encoding/binary"
"errors"
"fmt"
"math"
)
const smallEncoding int32 = 2
// Marshal serializes the digest into a byte array so it can be
// saved to disk or sent over the wire. buf is used as a backing array, but
// the returned array may be different if it does not fit.
func (t TDigest) ... | serialization.go | 0.646683 | 0.486697 | serialization.go | starcoder |
package meta
import (
"encoding/json"
"fmt"
"math"
"math/rand"
"time"
"github.com/MaxHalford/xgp"
"github.com/MaxHalford/xgp/metrics"
)
// GradientBoosting implements gradient boosting on top of genetic programming.
type GradientBoosting struct {
xgp.GPConfig
NRounds uint
NEarlyStoppingRounds ... | meta/gradient_boosting.go | 0.748168 | 0.446736 | gradient_boosting.go | starcoder |
package bungieapigo
// If you're showing an unlock value in the UI, this is the format in which it should be shown. You'll
// have to build your own algorithms on the client side to determine how best to render these
// options.
type DestinyUnlockValueUIStyle int
const (
// Generally, Automatic means "Just show the... | pkg/models/DestinyUnlockValueUiStyle.go | 0.615435 | 0.602529 | DestinyUnlockValueUiStyle.go | starcoder |
package shuffle
const constA = 654188429
const constB = 104729
// A FeistelWord abstract the underlying unsigned type to represent a word in the Feistel context.
type FeistelWord uint64
// MaxFeistelWord is the maximum possible value of the FesitelWord type.
const MaxFeistelWord = ^FeistelWord(0)
// A FeistelFunc i... | feistel.go | 0.7773 | 0.572723 | feistel.go | starcoder |
package tiles
import "errors"
// Tile is a simple struct for holding the XYZ coordinates for use in mapping
type Tile struct {
X, Y, Z int
}
// ToPixel return the NW pixel of this tile
func (t Tile) ToPixel() Pixel {
return Pixel{
X: t.X * TileSize,
Y: t.Y * TileSize,
Z: t.Z,
}
}
// ToPixelWithOffset retur... | tile.go | 0.811564 | 0.564399 | tile.go | starcoder |
package compare_expressions
import (
"fmt"
"github.com/Knetic/govaluate"
"github.com/pkg/errors"
"regexp"
"strings"
)
/**
This is the main function that is to be called to verify if 2 expressions are duplicate or not.
Usage:
parameters: expr1 a == 1 && b == 1 , expr1 b == 1 && a == 1
return (true, nil)
Note... | compare_expressions.go | 0.625667 | 0.473901 | compare_expressions.go | starcoder |
//go:generate go run generate.go
// Documentation source: "Event reference" by Mozilla Contributors, https://developer.mozilla.org/en-US/docs/Web/Events, licensed under CC-BY-SA 2.5.
//Package events defines the event binding system for Haiku(https://github.com/influx6/Haiku)
package events
import (
"github.com/in... | trees/events/event.gen.go | 0.807537 | 0.449695 | event.gen.go | starcoder |
// Package ledger implements a modified map with three unique characteristics:
// 1. every unique state of the map is given a unique hash
// 2. prior states of the map are retained for a fixed period of time
// 2. given a previous hash, we can retrieve a previous state from the map, if it is still retained.
package le... | ledger/ledger.go | 0.840684 | 0.610076 | ledger.go | starcoder |
package squarestore
import "log"
/*Square represents the SquareStore structure, pointing to its first and last Nodes*/
type Square struct {
first *Node
last *Node
maxroot int64
}
/*Insert allows to insert an element at the end of the structure*/
func (s *Square) Insert(c interface{}) {
var n Node
if s.fi... | square.go | 0.559049 | 0.415966 | square.go | starcoder |
package knadapt
// Chan describes one channel type of sodium-gated adaptation, with a specific
// set of rate constants.
type Chan struct {
On bool `desc:"if On, use this component of K-Na adaptation"`
Rise float32 `viewif:"On" desc:"Rise rate of fast time-scale adaptation as function of Na concentration -- dir... | knadapt/knadapt.go | 0.856017 | 0.460653 | knadapt.go | starcoder |
package Common
import (
"time"
)
const tmFmtWithMS = "2006-01-02 15:04:05.999"
const tmFmtMissMS = "2006-01-02 15:04:05"
// format a time.Time to string as 2006-01-02 15:04:05.999
func FormatTime(t time.Time) string {
return t.Format(tmFmtWithMS)
}
// format a time.Time to string as 2006-01-02 15:04:05
func Forma... | Common/Time.go | 0.737253 | 0.472257 | Time.go | starcoder |
package data
type attributer interface {
track(g *Graph)
}
// Attributable provides functionality for objects that can have attributes.
type attributable struct {
firstAtt uint32
aMap attributeMap // map stores the vertex's attributes by label
}
func (v *attributable) FirstAttribute(g *Graph) *Attribute ... | data/attributable.go | 0.750553 | 0.497192 | attributable.go | starcoder |
package driver
import (
"math"
"github.com/edgexfoundry/go-mod-core-contracts/v2/v2"
"github.com/spf13/cast"
)
// checkValueInRange checks value range is valid
func checkValueInRange(valueType string, reading interface{}) bool {
isValid := false
if valueType == v2.ValueTypeString || valueType == v2.ValueTypeB... | internal/driver/readingchecker.go | 0.538255 | 0.474996 | readingchecker.go | starcoder |
package oslice
import "strings"
func New(less func(interface{}, interface{}) bool) *Slice {
return &Slice{less: less}
}
func NewStringSlice() *Slice {
return &Slice{less: func(a, b interface{}) bool {
return a.(string) < b.(string)
}}
}
func NewCaseFoldedSlice() *Slice {
return &Slice{less:... | src/oslice/oslice.go | 0.847999 | 0.613584 | oslice.go | starcoder |
package measurements
import (
"math"
"sync"
)
// SimpleMovingVariance implements a simple moving variance calculation based on the simple moving average.
type SimpleMovingVariance struct {
average *SimpleExponentialMovingAverage
variance *SimpleExponentialMovingAverage
stdev float64 // square root of the ... | measurements/moving_variance.go | 0.863176 | 0.596227 | moving_variance.go | starcoder |
package pe
import (
"log"
"sync"
"time"
"github.com/gonum/matrix/mat64"
)
/*
physicsengine.go
by <NAME>
Package is geared towards processing physics based information. It's meant to be integrated with TSP for networking purposes.append
Ideally, this package is optimized for quick networking capabilities.
... | physicsengine.go | 0.542863 | 0.410638 | physicsengine.go | starcoder |
package cards
type CardSuit byte
const (
Clubs CardSuit = iota
Diamonds
Hearts
Spades
)
type CardValue byte
const (
Ace CardValue = iota
Two
Three
Four
Five
Six
Seven
Eight
Nine
Ten
Jack
Queen
King
)
type Card struct {
Suit CardSuit
Value CardValue
}
type Rectangle struct {
X, Y, Width, Heigh... | src/cards/cards.go | 0.707 | 0.476823 | cards.go | starcoder |
package bpf
import (
"encoding/binary"
"fmt"
)
func aluOpConstant(ins ALUOpConstant, regA uint32) uint32 {
return aluOpCommon(ins.Op, regA, ins.Val)
}
func aluOpX(ins ALUOpX, regA uint32, regX uint32) (uint32, bool) {
// Guard against division or modulus by zero by terminating
// the program, as the OS BPF VM ... | vendor/golang.org/x/net/bpf/vm_instructions.go | 0.667473 | 0.542015 | vm_instructions.go | starcoder |
package storage
import (
"github.com/tiglabs/raft/proto"
)
// Storage is an interface that may be implemented by the application to retrieve log entries from storage.
// If any Storage method returns an error, the raft instance will become inoperable and refuse to participate in elections;
// the application is re... | vendor/github.com/tiglabs/raft/storage/storage.go | 0.546496 | 0.407658 | storage.go | starcoder |
package datastore
import (
"io"
"log"
dsq "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/query"
)
// Here are some basic datastore implementations.
// MapDatastore uses a standard Go map for internal storage.
type MapDatastore struct {
values map[Key][]byte
}
// NewMapDatastore constructs... | vendor/gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/basic_ds.go | 0.68941 | 0.595757 | basic_ds.go | starcoder |
package matrix
import (
"github.com/mcanalesmayo/jacobi-go/utils"
)
const (
// Hot is the value of a hot state of a cell
Hot = 1.0
// Cold is the value a cold state of a cell
Cold = 0.0
// TwoDimDividedMatrixType is the code to represent a TwoDimMatrix which is not ensured to be contiguous in memory
TwoDimDivi... | model/matrix/matrix.go | 0.814016 | 0.714416 | matrix.go | starcoder |
package types
import (
"fmt"
"github.com/DataDrake/csv-analyze/tests"
"io"
"strconv"
"strings"
)
const boolResultFormat = "\tBoolean: True - %v, False - %v \n"
var possibleTrue = []string{"true", "t", "yes", "y"}
var possibleFalse = []string{"false", "f", "no", "n"}
func contains(vals []string, match string) ... | tests/types/bool.go | 0.560734 | 0.409752 | bool.go | starcoder |
package o
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Omg Interface Definition Language lexer.
var OmgIdlLexer = internal.Register(MustNewLazyLexer(
&Config{
Name: "OmgIdl",
Aliases: []string{ "omg-idl", },
Filenam... | lexers/o/omg_idl.go | 0.539469 | 0.419053 | omg_idl.go | starcoder |
package messages
import (
util "github.com/IBM/ibmcloud-volume-interface/lib/utils"
)
// messagesEn ...
var messagesEn = map[string]util.Message{
"AuthenticationFailed": {
Code: AuthenticationFailed,
Description: "Failed to authenticate the user.",
Type: util.Unauthenticated,
RC: 400,... | common/messages/messages_en.go | 0.520009 | 0.467089 | messages_en.go | starcoder |
package interpreter
import (
"errors"
"fmt"
"math"
)
func getArity(fn string) (int, error) {
// minimum arity
if fn == "min" { return 2, nil }
if fn == "max" { return 2, nil }
// exact arity
if fn == "pow" { return 2, nil }
if fn == "abs" { return 1, nil }
if fn == "floor" { re... | printerscript/interpreter/utils.go | 0.511473 | 0.406332 | utils.go | starcoder |
package q
import (
"fmt"
"math"
"github.com/itsubaki/q/pkg/math/matrix"
"github.com/itsubaki/q/pkg/math/rand"
"github.com/itsubaki/q/pkg/quantum/gate"
"github.com/itsubaki/q/pkg/quantum/qubit"
)
type Qubit int
func (q Qubit) Index() int {
return int(q)
}
func Index(qb ...Qubit) []int {
index := make([]int,... | q.go | 0.752559 | 0.524577 | q.go | starcoder |
package gocbcore
const (
// Legacy flag format for JSON data.
lfJSON = 0
// Common flags mask
cfMask = 0xFF000000
// Common flags mask for data format
cfFmtMask = 0x0F000000
// Common flags mask for compression mode.
cfCmprMask = 0xE0000000
// Common flag format for sdk-private data.
cfFmtPrivate = 1 << 24... | commonflags.go | 0.629319 | 0.524638 | commonflags.go | starcoder |
package margaid
import (
"math"
"strconv"
"time"
"github.com/erkkah/margaid/svg"
)
// Ticker provides tick marks and labels for axes
type Ticker interface {
label(value float64) string
start(axis Axis, series *Series, steps int) float64
next(previous float64) (next float64, hasMore bool)
}
// TimeTicker retu... | tickers.go | 0.837188 | 0.491944 | tickers.go | starcoder |
package layers
import (
"encoding/binary"
"errors"
"github.com/photostorm/gopacket"
)
// PPP is the layer for PPP encapsulation headers.
type PPP struct {
BaseLayer
PPPType PPPType
HasPPTPHeader bool
}
// PPPEndpoint is a singleton endpoint for PPP. Since there is no actual
// addressing for the two en... | layers/ppp.go | 0.645232 | 0.416797 | ppp.go | starcoder |
package decoder
import (
"errors"
"fmt"
"github.com/IvanZagoskin/wkt/geometry"
"github.com/IvanZagoskin/wkt/parser"
"github.com/golang/geo/s2"
"io"
)
type Decoder struct {
parser *parser.Parser
}
func GeomString(g geometry.Type) string {
switch g {
case geometry.UndefinedGT: retur... | decoder.go | 0.758242 | 0.594816 | decoder.go | starcoder |
package dbkit
import (
"fmt"
"sort"
"strings"
)
// DataType represents the various data types allowed for table columns
type DataType int
const (
// DataTypeAutoID maps to an auto increment id or closest matching construct in the database. A table can only have one AutoID columns and it must be the only column i... | dbkit/schema.go | 0.657209 | 0.530541 | schema.go | starcoder |
package datastore
import "errors"
// Query is a query used to search for and return entities from a datastore
type Query interface {
// Execute performs the query and returns an Results to the results. For now this query is specific to the
// underlying Connection and Driver implementation.
Execute(query interf... | datastore/query.go | 0.787686 | 0.402099 | query.go | starcoder |
package channel
import (
"fmt"
"gitlab.com/gomidi/midi/internal/midilib"
)
// NoteOffVelocity is offered as an alternative to NoteOff for
// a "real" noteoff message (type 8) that has velocity.
type NoteOffVelocity struct {
NoteOff
velocity uint8
}
// Velocity returns the velocity of the note-off message
func (... | midimessage/channel/noteoff.go | 0.840913 | 0.404155 | noteoff.go | starcoder |
package iso20022
// Chain of parties involved in the settlement of a transaction, including receipts and deliveries, book transfers, treasury deals, or other activities, resulting in the movement of a security or amount of money from one account to another.
type ReceivingPartiesAndAccount1 struct {
// Party that buy... | ReceivingPartiesAndAccount1.go | 0.654784 | 0.485295 | ReceivingPartiesAndAccount1.go | starcoder |
package transform
import (
"bufio"
"encoding/json"
"errors"
"fmt"
"io"
"log"
"os"
"strconv"
"strings"
"github.com/Jeffail/gabs"
)
var truncationLength = 512
// InputToCommands reads from the given io.Reader (e.g. os.Stdin) and uses the
// data there to replace values like $1.uuid in the args. It returns ... | transform/transform.go | 0.618204 | 0.41117 | transform.go | starcoder |
package core
import (
"sync"
"github.com/OneOfOne/cmap/hashers"
)
// shardCount must be a power of 2.
// Higher shardCount will improve concurrency but will consume more memory.
const shardCount = 1 << 8
// shardMask is the mask we apply to hash functions below.
const shardMask = shardCount - 1
// targetMap is ... | src/core/cmap_targets.go | 0.720958 | 0.414721 | cmap_targets.go | starcoder |
package graph
import (
"sort"
)
// ID is a unique ID of the Vertex/Node in the graph
type ID int
// byID implements sort.Interface for []ID
type byID []ID
func (a byID) Len() int { return len(a) }
func (a byID) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a byID) Less(i, j int) bool { return a[i... | pkg/graph/graph.go | 0.737064 | 0.475666 | graph.go | starcoder |
package cmd
import (
"testing"
"github.com/gomodule/redigo/redis"
"github.com/stretchr/testify/assert"
)
//ExampleKey verify the key command
type ExampleKey struct {
conn redis.Conn
}
//NewExampleKey create key object
func NewExampleKey(conn redis.Conn) *ExampleKey {
return &ExampleKey{
conn: conn,
}
}
//D... | tools/autotest/cmd/key.go | 0.618089 | 0.65971 | key.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPTypeNameStandard291 struct for BTPTypeNameStandard291
type BTPTypeNameStandard291 struct {
BTPTypeName290
BtType *string `json:"btType,omitempty"`
Type *string `json:"type,omitempty"`
}
// NewBTPTypeNameStandard291 instantiates a new BTPTypeNameStandard291 object
... | onshape/model_btp_type_name_standard_291.go | 0.639286 | 0.521167 | model_btp_type_name_standard_291.go | starcoder |
package test_function
func assert(want int, act int, code string)
func println(frmt ...string)
func ret3() int {
return 3
return 5
}
func add2(x int, y int) int {
return x + y
}
func sub2(x int, y int) int {
return x - y
}
func add6(a int, b int, c int, d int, e int, f int) int {
return a + b + c + d + e + f
... | testdata/esc/functions.go | 0.578567 | 0.466359 | functions.go | starcoder |
package terraform
import (
"bytes"
htmltemplate "html/template"
"strings"
texttemplate "text/template"
"github.com/Masterminds/sprig/v3"
)
const (
// DefaultPlanTemplate is a default template for terraform plan
DefaultPlanTemplate = `
{{template "plan_title" .}}
{{if .Link}}[CI link]({{.Link}}){{end}}
{{if ... | pkg/terraform/template.go | 0.579043 | 0.403567 | template.go | starcoder |
package vm
func MultFunc(left, right func(Context) (Value, error)) func(Context) (Value, error) {
return func(ctx Context) (Value, error) {
leftValue, err := left(ctx)
if err != nil {
return Null(), err
}
rightValue, err := right(ctx)
if err != nil {
return Null(), err
}
switch rightValue.Type {
... | vm/mul.go | 0.609873 | 0.701851 | mul.go | starcoder |
package telog
import (
"crypto/sha256"
"fmt"
)
type hashPointer struct {
pointer *block
hash string
}
type block struct {
hashPointer hashPointer
data string
}
type Telog struct {
head hashPointer
count int
}
// Init initializes an empty head used for the tamper evident log with SHA-256.
func (t *Telog) In... | telog/telog.go | 0.679285 | 0.410756 | telog.go | starcoder |
package main
import "fmt"
import "bufio"
import "os"
import "strings"
/*
Write a program which allows the user to create a set of animals and to get information about those animals. Each animal has a name and can be either a cow, bird, or snake. With each command, the user can either create a new animal of one of the... | course-2/animals-2/animals.go | 0.555435 | 0.422445 | animals.go | starcoder |
package qunit
//GopherJS Bindings for qunitjs.com
import "github.com/gopherjs/gopherjs/js"
type QUnitAssert struct {
*js.Object
}
type DoneCallbackObject struct {
*js.Object
Failed int `js:"failed"`
Passed int `js:"passed"`
Total int `js:"total"`
Runtime int `js:"runtime"`
}
type LogCallbackObject struct ... | vendor/github.com/rusco/qunit/qunit.go | 0.748904 | 0.456773 | qunit.go | starcoder |
package opencl
// Convolution self-test, performed once at the start of each simulation
import (
"math/rand"
data "github.com/seeder-research/uMagNUS/data"
util "github.com/seeder-research/uMagNUS/util"
)
// Compares FFT-accelerated convolution against brute-force on sparse data.
// This is not really needed but... | opencl/conv_selftest.go | 0.765155 | 0.504028 | conv_selftest.go | starcoder |
package gg
import (
"image"
"image/color"
"github.com/golang/freetype/truetype"
)
type LineCap int
const (
LineCapRound LineCap = iota
LineCapButt
LineCapSquare
)
type LineJoin int
const (
LineJoinRound LineJoin = iota
LineJoinBevel
)
type FillRule int
const (
FillRuleWinding FillRule = iota
FillRuleE... | context.go | 0.701917 | 0.528533 | context.go | starcoder |
package function
import (
"errors"
"fmt"
"regexp"
"time"
"github.com/dolthub/go-mysql-server/sql"
)
var offsetRegex = regexp.MustCompile(`(?m)^(\+|\-)(\d{2}):(\d{2})$`) // (?m)^\+|\-(\d{2}):(\d{2})$
type ConvertTz struct {
dt sql.Expression
fromTz sql.Expression
toTz sql.Expression
}
var _ sql.Funct... | sql/expression/function/convert_tz.go | 0.746139 | 0.454533 | convert_tz.go | starcoder |
package types
import "encoding/binary"
// Encoder stores the information necessary for the encoding functions
type Encoder struct {
data []byte
}
// NewEncoder returns an empty Encoder struct
func NewEncoder() Encoder {
return Encoder{
data: []byte{},
}
}
// GetEncodedData returns the `data` byte slice contain... | x/sunchain/types/encoder.go | 0.831554 | 0.566798 | encoder.go | starcoder |
package detour
/// Defines polygon filtering and traversal costs for navigation mesh query operations.
/// @ingroup detour
type DtQueryFilter struct {
m_areaCost [DT_MAX_AREAS]float32 ///< Cost per area type. (Used by default implementation.)
m_includeFlags uint16 ///< Flags for polygons that can... | vendor/github.com/fananchong/recastnavigation-go/Detour/DetourNavMeshQuery.go | 0.872958 | 0.570032 | DetourNavMeshQuery.go | starcoder |
package parser
import (
"strconv"
"strings"
"github.com/census-ecosystem/opencensus-experiments/go/iot/protocol"
"github.com/pkg/errors"
)
type TextParser struct {
}
// In this function, it firstly transform the input byte stream into a map of string -> interface{}.
// If it manages so, it would extract the req... | go/iot/protocol/parser/textParser.go | 0.617397 | 0.402333 | textParser.go | starcoder |
package solver
import (
"bufio"
"fmt"
"io"
"strconv"
"strings"
)
// ParseCardConstrs parses the given cardinality constraints.
// Will panic if a zero value appears in the literals.
func ParseCardConstrs(constrs []CardConstr) *Problem {
var pb Problem
for _, constr := range constrs {
card := constr.AtLeast
... | vendor/github.com/crillab/gophersat/solver/parser_pb.go | 0.645455 | 0.419588 | parser_pb.go | starcoder |
package brickcolor
import "image/color"
var (
White = BrickColor{Hex: "#F2F3F3", Number: 1, RGBA: color.RGBA{242, 243, 243, 255}, Name: "White"}
Grey = BrickColor{Hex: "#A1A5A2", Number: 2, RGBA: color.RGBA{161, 165, 162, 255}, Name: "Grey"}
LightYellow = BrickColor{Hex: "#... | generated.go | 0.77907 | 0.459501 | generated.go | starcoder |
package main
import (
. "github.com/9d77v/leetcode/pkg/algorithm/math"
. "github.com/9d77v/leetcode/pkg/algorithm/stack"
)
/*
题目:柱状图中最大的矩形
给定 n 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。
求在该柱状图中,能够勾勒出来的矩形的最大面积
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/largest-rectangle-in-histogram/
*/
/*
方法一:暴力方法
时间复杂度:... | internal/leetcode/84.largest-rectangle-in-histogram/main.go | 0.600891 | 0.403302 | main.go | starcoder |
package canvas
import (
"math"
)
// Rectangle returns a rectangle with width w and height h.
func Rectangle(w, h float64) *Path {
if equal(w, 0.0) || equal(h, 0.0) {
return &Path{}
}
p := &Path{}
p.LineTo(w, 0.0)
p.LineTo(w, h)
p.LineTo(0.0, h)
p.Close()
return p
}
// RoundedRectangle returns a rectangle... | shapes.go | 0.895624 | 0.630031 | shapes.go | starcoder |
package types
import (
"github.com/lyraproj/puppet-evaluator/eval"
"io"
"strconv"
)
type CallableType struct {
paramsType eval.Type
returnType eval.Type
blockType eval.Type // Callable or Optional[Callable]
}
var Callable_Type eval.ObjectType
func init() {
Callable_Type = newObjectType(`Pcore::CallableType`... | types/callabletype.go | 0.521959 | 0.455683 | callabletype.go | starcoder |
package stripe
import (
"context"
"github.com/stripe/stripe-go"
"github.com/turbot/steampipe-plugin-sdk/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/plugin"
"github.com/turbot/steampipe-plugin-sdk/plugin/transform"
)
func tableStripeInvoice(ctx context.Context) *plugin.Table {
return &plugin.Table{
N... | stripe/table_stripe_invoice.go | 0.634204 | 0.413418 | table_stripe_invoice.go | starcoder |
package gosom
import (
"encoding/csv"
"encoding/json"
"io"
"math"
"math/rand"
"strconv"
"github.com/gonum/floats"
)
// A Matrix holds and extends a two dimensional float slice.
type Matrix struct {
Data [][]float64
Rows int
Columns int
Minimums []float64
Maximums []float64
Minimum float64
Max... | matrix.go | 0.809577 | 0.477311 | matrix.go | starcoder |
package pspec
import (
"fmt"
"github.com/lyraproj/issue/issue"
"github.com/lyraproj/pcore/pcore"
"github.com/lyraproj/pcore/px"
"github.com/lyraproj/pcore/types"
"github.com/lyraproj/puppet-evaluator/evaluator"
"github.com/lyraproj/puppet-evaluator/pdsl"
"github.com/lyraproj/puppet-parser/parser"
)
type (
I... | pspec/example.go | 0.670932 | 0.419767 | example.go | starcoder |
package store
import (
"bufio"
"encoding/binary"
"fmt"
"os"
"sync"
)
// Store is an interface for the byte store.
type Store interface {
// Append persists the given bytes to the store. Returns the number of
// written bytes, the position where the store holds the record and an error.
Append(record []byte) (n... | internal/log/store/store.go | 0.73431 | 0.45538 | store.go | starcoder |
package network
import (
"github.com/jrecuero/go-cli/grafo"
)
// Network represents ...
type Network struct {
*grafo.Grafo
}
// AddNode is ...
func (net *Network) AddNode(parent grafo.IVertex, child grafo.IVertex, weight int) error {
if parent == nil {
parent = net.GetRoot()
}
var edge grafo.IEdge = NewWeight... | grafo/network/network.go | 0.667906 | 0.435841 | network.go | starcoder |
package xnumber
import (
"fmt"
"math"
"strconv"
)
// accuracy
type Accuracy func() float64
// Default accuracy, use 1e-3.
var DefaultAccuracy = NewAccuracy(1e-3)
func NewAccuracy(eps float64) Accuracy {
return func() float64 {
return eps
}
}
func (eps Accuracy) Equal(a, b float64) bool {
return math.Abs(a... | xnumber/xnumber.go | 0.811078 | 0.51818 | xnumber.go | starcoder |
package simulation
import (
"math"
)
type ypFunc func(t, y float64) float64 // dy/dt definition
type ypStepFunc func(t, y, dt float64) float64 // step function for computing dy/dt
// newRKStep takes a function representing an ODE
// and returns a function that performs a single step of the 4th order
// Rung... | internal/common/simulation/ode.go | 0.832203 | 0.879613 | ode.go | starcoder |
package iso20022
// Conversion between the currency of a card acceptor and the currency of a card issuer, provided by a dedicated service provider. The currency conversion has to be accepted by the cardholder.
type CurrencyConversion1 struct {
// Identification of the currency conversion operation for the service pr... | CurrencyConversion1.go | 0.831143 | 0.527986 | CurrencyConversion1.go | starcoder |
package core
import (
"image/color"
"math"
"reflect"
)
type Color struct {
R, G, B byte
}
var Black = Color{0, 0, 0}
var BlackRGBA = color.RGBA{0, 0, 0, 255}
func (c Color) RGBA() (r, g, b, a uint32) {
return color.RGBA{c.R, c.G, c.B, 255}.RGBA()
}
func (c Color) ToRGBA() color.RGBA {
return color.RGBA{
c.R... | unicornify/core/color.go | 0.798265 | 0.411466 | color.go | starcoder |
package rfm69
// http://www.hoperf.com/upload/rf/RFM69HCW-V1.1.pdf
const (
// FXOSC is the radio's oscillator frequency in Hertz.
FXOSC = 32000000
// SPIWriteMode is used to encode register addresses for SPI writes.
SPIWriteMode = 1 << 7
)
// Common Configuration Registers
const (
RegFifo = 0x00 // FIFO ... | rfm69.go | 0.500488 | 0.513059 | rfm69.go | starcoder |
package num
import (
"math"
"github.com/cpmech/gosl/chk"
"github.com/cpmech/gosl/fun"
"github.com/cpmech/gosl/io"
"github.com/cpmech/gosl/la"
"github.com/cpmech/gosl/utl"
)
// NlSolver implements a solver to nonlinear systems of equations
// References:
// [1] G.Forsythe, M.Malcolm, C.Moler, Computer met... | num/nlsolver.go | 0.622115 | 0.523968 | nlsolver.go | starcoder |
package birnn
import (
"encoding/gob"
"sync"
"github.com/nlpodyssey/spago/ag"
"github.com/nlpodyssey/spago/mat"
"github.com/nlpodyssey/spago/nn"
)
// MergeType is the enumeration-like type used for the set of merging methods
// which a BiRNN model Processor can perform.
type MergeType int
const (
// Concat m... | nn/birnn/birnn.go | 0.639286 | 0.50116 | birnn.go | starcoder |
package ivg
import (
"image/color"
)
const Magic = "\x89IVG"
var MagicBytes = []byte(Magic)
const (
MidViewBox = 0
MidSuggestedPalette = 1
)
const (
// Min aligns min of ViewBox with min of rect
Min = 0.0
// Mid aligns mid of ViewBox with mid of rect
Mid = 0.5
// Max aligns max of ViewBox with ma... | ivg.go | 0.710929 | 0.450722 | ivg.go | starcoder |
package bmath
import (
"github.com/go-gl/mathgl/mgl32"
"github.com/wieku/danser-go/settings"
)
type Rectangle struct {
MinX, MinY, MaxX, MaxY float64
}
type Camera struct {
screenRect Rectangle
projection mgl32.Mat4
view mgl32.Mat4
projectionView mgl32.Mat4
invProjectionView mgl... | bmath/camera.go | 0.800419 | 0.582194 | camera.go | starcoder |
package effect
import (
"korok.io/korok/math/f32"
"korok.io/korok/gfx"
"korok.io/korok/math"
)
// FireSimulator can simulate the fire effect.
type FountainSimulator struct {
Pool
RateController
LifeController
VisualController
velocity Channel_v2
deltaColor Channel_v4
deltaRot Channel_f32
// Configuratio... | effect/sim_fountain.go | 0.714628 | 0.404272 | sim_fountain.go | starcoder |
package model
// ColumnType describes the possible types that a column may take
type ColumnType int
// List of possible ColumnType values
const (
ColumnTypeInvalid ColumnType = iota
ColumnTypeBit
ColumnTypeTinyInt
ColumnTypeSmallInt
ColumnTypeMediumInt
ColumnTypeInt
ColumnTypeInteger
ColumnTypeBigInt
Column... | model/columns_gen.go | 0.705075 | 0.530784 | columns_gen.go | starcoder |
package ast
import (
"bytes"
"fmt"
"github.com/geode-lang/geode/pkg/lexer"
)
// ExpressionComponents are nodes that make up the expression
// component system defined in parseExpression.go
// ExpComponent is a representation of complex compound expressions
// like call()[1]().foo().bar[12] for example. It is mea... | pkg/ast/ExpressionComponents.go | 0.717309 | 0.425486 | ExpressionComponents.go | starcoder |
package main
import (
"bufio"
"fmt"
"log"
"math"
"os"
)
type Vec2d struct{ x, y int }
func (v Vec2d) Add(v0 Vec2d) Vec2d {
return Vec2d{
x: v.x + v0.x,
y: v.y + v0.y,
}
}
var directions []Vec2d = []Vec2d{
/*UP*/
Vec2d{0, 1},
/*LEFT*/ Vec2d{-1, 0}, Vec2d{1, 0}, /*RIGHT*/... | 2019/Day-18/Many-Worlds_Interpretation/main.go | 0.639061 | 0.452657 | main.go | starcoder |
// Package unicode provides a mockable wrapper for unicode.
package unicode
import (
unicode "unicode"
)
var _ Interface = &Impl{}
var _ = unicode.In
type Interface interface {
In(r rune, ranges ...*unicode.RangeTable) bool
Is(rangeTab *unicode.RangeTable, r rune) bool
IsControl(r rune) bool
IsDigit(r rune) bo... | unicode/unicode.go | 0.734405 | 0.420838 | unicode.go | starcoder |
package week
import (
"database/sql/driver"
)
// NullWeek is a nullable Week representation.
type NullWeek struct {
Week Week
Valid bool
}
// NewNullWeek creates a new NullWeek.
func NewNullWeek(week Week, valid bool) NullWeek {
return NullWeek{Week: week, Valid: valid}
}
// NullWeekFrom creates a new NullWeek... | null.go | 0.719384 | 0.479077 | null.go | starcoder |
package isc
import (
"reflect"
)
//ListFilter filter specificated item in a list
func ListFilter[T any](list []T, f func(T) bool) []T {
var dest []T
return ListFilterTo(list, &dest, f)
}
//ListFilterNot Returns a list containing all elements not matching the given predicate.
func ListFilterNot[T any](list []T, pr... | isc/filter.go | 0.695545 | 0.501282 | filter.go | starcoder |
package encryption
import (
"crypto/cipher"
"fmt"
)
type CipherCrypt struct {
Block cipher.Block
}
//Encrypt encrypts src to dst with cipher & iv, if failed return error
//src the original source bytes
//c the defined cipher type,now support CBC,CFB,OFB,ECB
//ivs the iv for CBC,CFB,OFB mode
//dst the encrypted by... | pkg/encryption/cipher.go | 0.584864 | 0.403126 | cipher.go | starcoder |
package starwars_characters
var Schema = `
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
type Mutation {
}
type Subscription{
}
"The query type, represents the entry points related to characters in the Starwars universe."
type Query {
hero(episode: Episode = NEWHOPE): Character
... | examples/starwars_characters/schema.go | 0.721743 | 0.499695 | schema.go | starcoder |
package ais
import (
"bytes"
"fmt"
"time"
)
// Window is used to create a convolution algorithm that slides down a RecordSet
// and performs analysis on Records that are within the a time window.
type Window struct {
leftMarker, rightMarker time.Time
timeIndex int
width time.Dura... | window.go | 0.831074 | 0.449211 | window.go | starcoder |
package main
import (
"fmt"
"math"
"math/cmplx"
"math/rand"
"sort"
"time"
"github.com/ldsec/lattigo/ckks"
)
func randomFloat(min, max float64) float64 {
return min + rand.Float64()*(max-min)
}
func randomComplex(min, max float64) complex128 {
return complex(randomFloat(min, max), randomFloat(min, max))
}
... | examples/ckks/examples_ckks.go | 0.681939 | 0.421105 | examples_ckks.go | starcoder |
package grid
// Interface used as a generic
type T interface{}
// Grid is a dwo dimentional array that can be walked
// Left(), Right(), Up(), Down() cell by cell infinitely
type Grid struct {
cells []T
dim int
}
// Make new Grid by providing length of one side, Grid will be dim x dim
// If dim = 3, Grid will be... | grid.go | 0.813794 | 0.560132 | grid.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.