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 blockchain
import (
"github.com/bloXroute-Labs/gateway/blockchain/network"
"github.com/bloXroute-Labs/gateway/types"
)
// NoOpBxBridge is a placeholder bridge that still operates as a Converter
type NoOpBxBridge struct {
Converter
}
// NewNoOpBridge is a placeholder bridge implementation for starting the ... | blockchain/noopbridge.go | 0.704973 | 0.430267 | noopbridge.go | starcoder |
package base
import (
"fmt"
"github.com/arborlang/ArborGo/internal/parser/ast"
)
// VisitorHider is a simple way to set and hide the visitor
type VisitorHider interface {
SetVisitor(v *VisitorAdapter)
}
// VisitorAdapter represents a top level VisitorAdapter that walks the tree but does nothing. Useful for doing... | internal/parser/visitors/base/adapter.go | 0.728362 | 0.521471 | adapter.go | starcoder |
package dt
import (
"fmt"
"time"
)
var location *time.Location
type Datime struct {
value time.Time
}
func init() {
location = time.Now().Location()
fmt.Println("*", location)
}
func New() Datime {
return Datime{value: time.Now()}
}
func NewUnix(seconds int64) Datime {
return Datime{value: time.Unix(second... | shared/dt/dt.go | 0.662469 | 0.606848 | dt.go | starcoder |
package tink
import (
"fmt"
tinkpb "github.com/google/tink/proto/tink_proto"
)
// Entry represents a single entry in the keyset. In addition to the actual primitive,
// it holds the identifier and status of the primitive.
type Entry struct {
primitive interface{}
identifier string
status ... | go/tink/primitive_set.go | 0.778565 | 0.424054 | primitive_set.go | starcoder |
package graph
import (
// "math"
// "image"
"image/color"
"image/draw"
"sort"
// "log"
)
type Point2D struct {
x,y int
}
type Triangle2D struct {
verts []Point2D
}
func (self *Triangle2D) SortByY() {
sort.SliceStable(self.verts, func(i, j int) bool {
return self.verts[i].... | graph/triangle.go | 0.738103 | 0.512083 | triangle.go | starcoder |
package gart
import (
"image"
)
// Line is a set of two image.Points
type Line struct {
x1, x2 image.Point
}
// Crosses returns true if the other line crosses line.
// Basically, line intersection but looking at end points.
func (l Line) Crosses(other Line) bool {
return Crosses(l.x1, l.x2, other.x1, other.x2)
}
... | line.go | 0.851336 | 0.583233 | line.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
)
// * ParamModePosition -> Use the value found at slice[n]
// * ParamModeImmediate -> Use the value n
// * ParamModeRelative -> Use the value found at slice[BASE+n]
const (
paramModePosition = iota
paramModeImmediate
paramModeRelative
)
cons... | 15/go/main.go | 0.6705 | 0.431285 | main.go | starcoder |
package types
// Value is a type of simple value.
type Value byte
// simple value types.
const (
I32 Value = 0x7F
I64 Value = 0x7E
F32 Value = 0x7C
F64 Value = 0x7D
)
// FunctionSig is a signature of function.
type FunctionSig struct {
Form byte
Params []Value
Returns []Value
}
// External is a type of e... | vm/wasm/types/types.go | 0.596668 | 0.430925 | types.go | starcoder |
package streams
import "constraints"
func zero[T any]() T {
var t T
return t
}
func More[T any](t T) (T, bool) { return t, true }
func Done[T any]() (T, bool) { return zero[T](), false }
type Stream[T any] func() (T, bool)
func Elements[T any, Slice ~[]T](s Slice) Stream[T] {
return Map(Indices[T](s), func(i i... | streams.go | 0.538012 | 0.675462 | streams.go | starcoder |
package hll
func divideBy8RoundUp(i int) int {
result := i >> 3
if remainder := i & 0x7; remainder > 0 {
result++
}
return result
}
// readBits reads nBits from the provided address in the byte array and returns
// them as the LSB of a uint64. The address is the 0-indexed bit position where
// 0 equates to the... | util.go | 0.652463 | 0.456713 | util.go | starcoder |
package search
import (
"github.com/chewxy/math32"
"github.com/zhenghaoz/gorse/base"
"github.com/zhenghaoz/gorse/base/floats"
"go.uber.org/zap"
"modernc.org/sortutil"
"reflect"
"sort"
)
type Vector interface {
Distance(vector Vector) float32
Terms() []string
IsHidden() bool
}
type DenseVector struct {
da... | base/search/index.go | 0.672547 | 0.454048 | index.go | starcoder |
package matrix
import (
"encoding/json"
"errors"
"fmt"
"math/rand"
"time"
)
//MappingFunction ...
type MappingFunction func(val float64, i, j int) float64
//Matrix ...
type Matrix struct {
rows, cols int
data [][]float64
}
//New ...
func New(rows, cols int) *Matrix {
mat := &Matrix{rows: rows,
cols:... | internal/matrix/matrix.go | 0.631026 | 0.446133 | matrix.go | starcoder |
package netfilter
import (
"encoding/binary"
"fmt"
"github.com/mdlayher/netlink"
)
// NewAttributeDecoder instantiates a new netlink.AttributeDecoder
// configured with a Big Endian byte order.
func NewAttributeDecoder(b []byte) (*netlink.AttributeDecoder, error) {
ad, err := netlink.NewAttributeDecoder(b)
if e... | vendor/github.com/ti-mo/netfilter/attribute.go | 0.832373 | 0.449393 | attribute.go | starcoder |
package identifiers
import (
"errors"
"go.dedis.ch/onet/v3/log"
"regexp"
"strconv"
)
/*
Defines and manipulates the identifiers that are meant to be encrypted by Unlynx for the purpose of answering queries.
Convention: 64 bits integers.
Genomic variant:
1 bit (2): flag genomic variant (1)
5 bits ... | loader/identifiers/identifiers.go | 0.637031 | 0.417034 | identifiers.go | starcoder |
package core
import (
"math"
)
func calculateLinearRegressionCoefficients(points []Point) (float64, float64) {
average := calculateAveragePoint(points)
aNumerator := 0.0
aDenominator := 0.0
for i := 0; i < len(points); i++ {
aNumerator += (points[i].X - average.X) * (points[i].Y - average.Y)
aDenominator +... | core/ltd.go | 0.732209 | 0.447581 | ltd.go | starcoder |
package limiters
import (
"fmt"
"time"
"github.com/garyburd/redigo/redis"
)
// RateRedisCounter represents redis-based sharded counter
type RateRedisCounter struct {
timer timer
period time.Duration
resolution time.Duration
bucketsCount int
prefix string
conn redis.Conn
}
// NewRateRedisCounter in... | limiters/redis.go | 0.731634 | 0.495972 | redis.go | starcoder |
package main
import (
"fmt"
"math"
"os"
"github.com/unixpickle/essentials"
"github.com/unixpickle/model3d/model3d"
"github.com/unixpickle/model3d/render3d"
)
func main() {
// Join all the objects into a mega-object.
object := render3d.JoinedObject{
// Mirror ball.
&render3d.ColliderObject{
Collider: &... | examples/renderings/cornell_box/main.go | 0.559771 | 0.404625 | main.go | starcoder |
package expect
import (
"github.com/tinyhubs/et/et"
"testing"
)
// PassValue is used to check if exp equals to got.
func Equal(t *testing.T, exp, got interface{}) {
et.ExpectInner(t, "", &et.Equal{exp, got}, 2)
}
func Equali(t *testing.T, message string, exp, got interface{}) {
et.ExpectInner(t, message, &et.Equ... | expect/expect.go | 0.562898 | 0.597637 | expect.go | starcoder |
package pgbatch
import (
"fmt"
)
// Command format for sending a batch of sql commands.
// Query is the sql query to execute (required).
// ArgsFunc is called before execution for query arguments (optional).
// Args are query parameters (optional). Ignored if ArgsFunc is non-nil.
// ScanOnce is the scan function for... | batch.go | 0.538741 | 0.439687 | batch.go | starcoder |
package english
import (
"sort"
"strings"
)
// Words returns sorted list of all the English words defined by this
// package.
func Words() []string { return _words }
func splitWords() []string {
all := make(map[string]int)
for _, words := range []string{
SinglePrepositionWords,
HowAdverbWords,
WhenAdverb... | words.go | 0.651909 | 0.424173 | words.go | starcoder |
package fake
import (
"fmt"
"strconv"
"strings"
)
// OsdLsOutput returns JSON output from 'ceph osd ls' that can be used for unit tests. It
// returns output for a Ceph cluster with the number of OSDs given as input starting with ID 0.
// example: numOSDs = 5 => return: "[0,1,2,3,4]"
func OsdLsOutput(numOSDs in... | pkg/daemon/ceph/client/fake/osd.go | 0.694821 | 0.404272 | osd.go | starcoder |
package aeadcrypter
import (
"crypto/cipher"
"fmt"
)
const (
// TagSize is the tag size in bytes for AES-128-GCM-SHA256,
// AES-256-GCM-SHA384, and CHACHA20-POLY1305-SHA256.
TagSize = 16
// NonceSize is the size of the nonce in number of bytes for
// AES-128-GCM-SHA256, AES-256-GCM-SHA384, and CHACHA20-POLY130... | internal/record/internal/aeadcrypter/common.go | 0.702836 | 0.416619 | common.go | starcoder |
package main
import (
"strconv"
"strings"
)
func Compatible(a, b Type) bool {
if a.Equals(b) || b.Equals(a) {
return true
}
switch a.(type) {
case IntLitType:
switch b.(type) {
case IntLitType, FloatLitType, NumericType:
return true
}
case FloatLitType:
switch b.(type) {
case IntLitType, FloatLi... | types.go | 0.654453 | 0.472318 | types.go | starcoder |
package game
import "tipsy/tools"
const (
//BoardSize the size of the board
BoardSize = 7
)
//Board : the board of tipsy game
type Board struct {
Nodes []Node
Edges []Edge
}
//NewBoard initialize an empty board with obstacles and exits
func NewBoard() Board {
var board Board
initNodes(&board)
initEdges(&boa... | src/tipsy/game/board.go | 0.579638 | 0.683538 | board.go | starcoder |
package common
func MinI(a, b int) int {
if a < b {
return a
}
return b
}
func MaxI(a, b int) int {
if a > b {
return a
}
return b
}
func AbsI(a int) int {
if a < 0 {
return -a
}
return a
}
// DecimalDigits returns a slice of digits representing the different decimal
// positions from most significan... | cmd/common/math.go | 0.829768 | 0.493775 | math.go | starcoder |
package turbot
import (
"context"
"fmt"
"strconv"
"github.com/turbot/steampipe-plugin-sdk/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/plugin"
"github.com/turbot/steampipe-plugin-sdk/plugin/transform"
)
func tableTurbotPolicyValue(ctx context.Context) *plugin.Table {
return &plugin.Table{
Name: ... | turbot/table_turbot_policy_value.go | 0.63443 | 0.400222 | table_turbot_policy_value.go | starcoder |
package block
import (
"fmt"
"sort"
"strings"
"time"
"github.com/m3db/m3/src/query/models"
)
// Metadata is metadata for a block, describing size and common tags across
// constituent series.
type Metadata struct {
// Bounds represents the time bounds for all series in the block.
Bounds models.Bounds
// Tag... | src/query/block/meta.go | 0.849129 | 0.421433 | meta.go | starcoder |
package indicators
// Sma calculates simple moving average of a slice for a certain
// number of time periods.
func (slice mfloat) SMA(period int) []float64 {
var smaSlice []float64
for i := period; i <= len(slice); i++ {
smaSlice = append(smaSlice, Sum(slice[i-period:i])/float64(period))
}
return smaSlice
}
... | indicators.go | 0.856302 | 0.706773 | indicators.go | starcoder |
package cpu
import (
"os"
log "pajalic.go.emulator/packages/logger"
)
/*
PC - Program counter, where in memory(address) the processor should read from
SP - In 8086, the main "stack register" is called stack pointer. Tracks the operations of the stack and
stores address of the last program request.
F - 8Bit registe... | packages/cpu/cpu.go | 0.516352 | 0.463991 | cpu.go | starcoder |
package adapter
import (
"time"
rpc "github.com/googleapis/googleapis/google/rpc"
)
type (
// QuotasAspect handles quotas and rate limits within Mixer.
QuotasAspect interface {
Aspect
// Alloc allocates the specified amount or fails when not available.
Alloc(QuotaArgsLegacy) (QuotaResultLegacy, error)
... | mixer/pkg/adapter/quotas.go | 0.748812 | 0.500854 | quotas.go | starcoder |
package mahjong
import sort2 "sort"
type Tile struct {
TileType
Id int8
}
func (tile Tile) IsRed() bool {
return tile.Id == 0 && (tile.TileType == Dots5 || tile.TileType == Bamboo5 || tile.TileType == Characters5)
}
func (tileType TileType) IsSuit() bool {
if tileType > Characters9 || tileType < Dots1 {
retur... | tiles.go | 0.551332 | 0.49048 | tiles.go | starcoder |
package lib
// heuristics.go provides a number of heuristics to order the edges by. The goal is to potentially speed up the
// computation of hypergraph decompositions
import (
"math"
"math/rand"
"sort"
"time"
)
// GetMSCOrder produces the Maximal Cardinality Search Ordering.
// Implementation is based det-k-dec... | lib/heuristics.go | 0.673406 | 0.519399 | heuristics.go | starcoder |
// Package bulletproof implements the zero knowledge protocol bulletproofs as defined in https://eprint.iacr.org/2017/1066.pdf
package bulletproof
import (
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/coinbase/kryptology/pkg/core/curves"
)
// InnerProductProver is the struct used to create Inner... | pkg/bulletproof/ipp_prover.go | 0.855218 | 0.47658 | ipp_prover.go | starcoder |
package urts
import (
"time"
"github.com/iotaledger/hive.go/app"
)
// ParametersTipsel contains the definition of the parameters used by Tipselection.
type ParametersTipsel struct {
// the config group used for the non-lazy tip-pool
NonLazy struct {
// Defines the maximum amount of current tips for which "CfgT... | plugins/urts/params.go | 0.522446 | 0.418637 | params.go | starcoder |
package hipathsys
import (
"fmt"
"strings"
)
var UCUMSystemURI = NewString("http://unitsofmeasure.org")
var QuantityTypeSpec = newAnyTypeSpec("Quantity")
type quantityType struct {
baseAnyType
value DecimalAccessor
unit StringAccessor
}
type QuantityAccessor interface {
AnyAccessor
Comparator
Stringifier... | hipathsys/quantity_type.go | 0.620852 | 0.485173 | quantity_type.go | starcoder |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func isLeapYear(year int) bool {
return (year%400 == 0) || (year%4 == 0 && year%100 != 0)
}
func fixDay(year int, day int) int {
leap := leapYearInt(year)
if day > 60-leap {
return day - 60
}
return day + 305
}
func fixYear(year int) int {
... | ddc.go | 0.625438 | 0.40645 | ddc.go | starcoder |
package main
import (
"fmt"
)
// Function type alias
type calcFunc func(float64) float64
func calcWithTax(price float64) float64 {
return price + (price * 0.2)
}
func calcWithoutTax(price float64) float64 {
return price
}
// Functions as return types
func selectCalculator(price float64) calcFunc {
if price > 1... | courses/pro-go/function-types/main.go | 0.736874 | 0.426142 | main.go | starcoder |
package simulation
import "github.com/pointlesssoft/godevs/pkg/modeling"
type Simulator struct {
AbstractSimulator // It complies the AbstractSimulator interface.
model modeling.Atomic // Atomic Model associated to the Simulator.
}
// NewSimulator returns a pointer to a new Simulator.
f... | pkg/simulation/simulator.go | 0.770119 | 0.512266 | simulator.go | starcoder |
package packed
// Efficient sequential read/write of packed integers.
type BulkOperationPacked7 struct {
*BulkOperationPacked
}
func newBulkOperationPacked7() BulkOperation {
return &BulkOperationPacked7{newBulkOperationPacked(7)}
}
func (op *BulkOperationPacked7) decodeLongToInt(blocks []int64, values []int32, i... | core/util/packed/bulkOperation7.go | 0.582135 | 0.6419 | bulkOperation7.go | starcoder |
package input
import (
"bufio"
"io"
"strconv"
"strings"
)
// ToInt is used to convert a stream into an integer. This function takes a stream
// of type io.Reader as input. It returns an integer and nil or 0 and an error if
// one occurred.
func ToInt(stream io.Reader) (int, error) {
scanner := bufio.NewScanner(s... | pkg/input/parse.go | 0.816187 | 0.427397 | parse.go | starcoder |
package leaf
import (
"encoding/json"
"math"
"time"
)
type model struct {
Alpha float64
Beta float64
T float64
}
// Ebisu implements ebisu SSR algorithm.
type Ebisu struct {
LastReviewedAt time.Time
Alpha float64
Beta float64
Interval float64
Historical []IntervalSnapshot... | ebisu.go | 0.860765 | 0.4436 | ebisu.go | starcoder |
package adaptivetable
type AdaptiveTable struct {
values []uint64
initSize int
maxSize int
threshold int
relativePercentage bool
}
func NewAdaptiveTable(initSize int) AdaptiveTable {
return AdaptiveTable{
initSize: initSize,
maxSize: initSize,
threshold: initSi... | adaptive_table.go | 0.620622 | 0.587233 | adaptive_table.go | starcoder |
package plaid
import (
"encoding/json"
)
// WalletTransactionCounterpartyNumbers The counterparty's bank account numbers
type WalletTransactionCounterpartyNumbers struct {
Bacs WalletTransactionCounterpartyBACS `json:"bacs"`
}
// NewWalletTransactionCounterpartyNumbers instantiates a new WalletTransactionCounterp... | plaid/model_wallet_transaction_counterparty_numbers.go | 0.642769 | 0.408572 | model_wallet_transaction_counterparty_numbers.go | starcoder |
package graphs
import (
"errors"
"fmt"
"math"
"github.com/TectusDreamlab/go-common-utils/datastructure/shared"
"github.com/TectusDreamlab/go-common-utils/datastructure/trees"
)
// DirectedWeightedGraph defines a directed wegithed graph
type DirectedWeightedGraph struct {
DirectedGraph
adjacentEdges [][]Direct... | datastructure/graphs/directed_weighted_graph.go | 0.707203 | 0.678681 | directed_weighted_graph.go | starcoder |
package test
import (
"testing"
"time"
"github.com/libp2p/go-libp2p-core/peer"
pstore "github.com/libp2p/go-libp2p-core/peerstore"
ma "github.com/multiformats/go-multiaddr"
"github.com/textileio/go-textile-core/thread"
tstore "github.com/textileio/go-textile-core/threadstore"
)
var addressBookSuite = map[stri... | test/addr_book_suite.go | 0.513425 | 0.535463 | addr_book_suite.go | starcoder |
package plan
import "github.com/wolffcm/flux/values"
// EmptyBounds is a time range containing only a single point
var EmptyBounds = &Bounds{
Start: values.Time(0),
Stop: values.Time(0),
}
// Bounds is a range of time
type Bounds struct {
Start values.Time
Stop values.Time
}
// BoundsAwareProcedureSpec is any... | plan/bounds.go | 0.845465 | 0.461866 | bounds.go | starcoder |
package dependencygraph2
import (
"context"
"fmt"
"math"
"github.com/google/gapid/gapis/api"
"github.com/google/gapid/gapis/capture"
)
// Node represents a node in the dependency graph, and holds data about the
// associated command or memory observation.
type Node interface {
dependencyNode()
}
// CmdNode i... | gapis/resolve/dependencygraph2/dependency_graph.go | 0.68437 | 0.426202 | dependency_graph.go | starcoder |
package materials
import (
"math"
"math/rand"
"github.com/go-gl/mathgl/mgl64"
"github.com/markzuber/zgotrace/raytrace"
"github.com/markzuber/zgotrace/raytrace/vectorextensions"
)
type DialectricMaterial struct {
refractionIndex float64
}
func NewDialectricMaterial(refractionIndex float64) raytrace.Material {
... | raytrace/materials/dialectricmaterial.go | 0.817283 | 0.451447 | dialectricmaterial.go | starcoder |
package ogórek
import (
"encoding/binary"
"fmt"
"io"
"math"
"reflect"
)
// An Encoder encodes Go data structures into pickle byte stream
type Encoder struct {
w io.Writer
}
// NewEncoder returns a new Encoder struct with default values
func NewEncoder(w io.Writer) *Encoder {
return &Encoder{w: w}
}
// Encode... | encode.go | 0.664214 | 0.446253 | encode.go | starcoder |
package flux
import "github.com/influxdata/flux/ast"
// File creates a new *ast.File.
func File(name string, imports []*ast.ImportDeclaration, body []ast.Statement) *ast.File {
return &ast.File{
Name: name,
Imports: imports,
Body: body,
}
}
// GreaterThan returns a greater than *ast.BinaryExpression.
f... | notification/flux/ast.go | 0.865181 | 0.523847 | ast.go | starcoder |
package protocol
import (
"image/color"
)
const (
MapObjectTypeEntity = iota
MapObjectTypeBlock
)
// MapTrackedObject is an object on a map that is 'tracked' by the client, such as an entity or a block. This
// object may move, which is handled client-side.
type MapTrackedObject struct {
// Type is the type of t... | minecraft/protocol/map.go | 0.668339 | 0.411998 | map.go | starcoder |
package utils
import (
"math"
"time"
)
var (
K = math.Pow(10, 3)
M = math.Pow(10, 6)
G = math.Pow(10, 9)
T = math.Pow(10, 12)
)
func roundOffNearestTen(num float64, divisor float64) float64 {
x := num / divisor
return math.Round(x*10) / 10
}
func RoundValues(num1, num2 float64, inBytes bool) ([]float64, str... | src/utils/dataFormat.go | 0.772874 | 0.440529 | dataFormat.go | starcoder |
package trie
// builder builds Succinct Trie.
type builder struct {
valueWidth uint32
totalCount int
// LOUDS-Sparse bitvecs, pooling
lsLabels [][]byte
lsHasChild [][]uint64
lsLoudsBits [][]uint64
// value
values [][]byte
valueCounts []uint32
// prefix
hasPrefix [][]uint64
prefixes [][][]byte... | pkg/trie/builder.go | 0.719975 | 0.494751 | builder.go | starcoder |
package bitutils
import (
"encoding/binary"
"fmt"
)
// ParseByte4 parses 4 bits of data from the data array, starting at the given index
func ParseByte4(data []byte, bitStartIndex uint) (byte, error) {
startByte := bitStartIndex / 8
bitStartOffset := bitStartIndex % 8
if bitStartOffset < 5 {
if uint(len(data))... | bitutils/bitutils.go | 0.674801 | 0.53443 | bitutils.go | starcoder |
package main
import (
"fmt"
"sort"
)
type (
Point [3]float64
Face []int
Edge struct {
pn1 int // point number 1
pn2 int // point number 2
fn1 int // face number 1
fn2 int // face number 2
cp Point // center point
}
PointEx struct {
... | lang/Go/catmull-clark-subdivision-surface.go | 0.599954 | 0.700479 | catmull-clark-subdivision-surface.go | starcoder |
package df
import (
"math/big"
"fmt"
)
// SquareProver proves that the commitment hides the square. Given c,
// prove that c = g^(x^2) * h^r (mod n).
type SquareProver struct {
*EqualityProver
// We have two commitments with the same value: SmallCommitment = g^x * h^r1 and
// c = SmallCommitment^x * h^r2. Also ... | df/square_commitment.go | 0.678007 | 0.433921 | square_commitment.go | starcoder |
package util
import (
"math"
)
const (
_pi = math.Pi
_2pi = 2 * math.Pi
_3pi4 = (3 * math.Pi) / 4.0
_4pi3 = (4 * math.Pi) / 3.0
_3pi2 = (3 * math.Pi) / 2.0
_5pi4 = (5 * math.Pi) / 4.0
_7pi4 = (7 * math.Pi) / 4.0
_pi2 = math.Pi / 2.0
_pi4 = math.Pi / 4.0
_d2r = (math.Pi / 180.0)
_r2d = (180.0 / math... | util/math.go | 0.839635 | 0.525551 | math.go | starcoder |
package expr
import (
"encoding/binary"
"errors"
"fmt"
"strings"
"github.com/genjidb/genji/document"
)
// Functions represents a map of builtin SQL functions.
type Functions struct {
m map[string]func(args ...Expr) (Expr, error)
}
// BuiltinFunctions returns default map of builtin functions.
func BuiltinFunct... | sql/query/expr/function.go | 0.744656 | 0.407628 | function.go | starcoder |
package otto
import (
"math"
"math/rand"
)
// Math
func builtinMath_abs(call FunctionCall) Value {
number := call.Argument(0).float64()
return toValue_float64(math.Abs(number))
}
func builtinMath_acos(call FunctionCall) Value {
number := call.Argument(0).float64()
return toValue_float64(math.Acos(number))
}
... | vendor/github.com/robertkrimen/otto/builtin_math.go | 0.601359 | 0.579103 | builtin_math.go | starcoder |
package iso20022
// Provides the elements related to the interest amount calculation.
type InterestAmount2 struct {
// Amount of money representing an interest payment.
AccruedInterestAmount *ActiveCurrencyAndAmount `xml:"AcrdIntrstAmt"`
// Agreed date for the interest payment.
ValueDate *DateAndDateTimeChoice `... | InterestAmount2.go | 0.866472 | 0.614481 | InterestAmount2.go | starcoder |
package values
import (
"regexp"
"sort"
"github.com/influxdata/flux/codes"
"github.com/influxdata/flux/internal/errors"
"github.com/influxdata/flux/semantic"
)
// Array represents an sequence of elements
// All elements must be the same type
type Array interface {
Value
Get(i int) Value
Set(i int, v Value)
... | values/array.go | 0.675872 | 0.503906 | array.go | starcoder |
package operators
import (
"github.com/galaxia-team/void/void/src/exception"
"github.com/galaxia-team/void/void/src/types"
"math"
"fmt"
)
var (
StringOps = map[string]func(string, string) string {
"+": AddS,
}
IntOps = map[string]func(int, int) int {
"+": AddI,
"-":... | void/src/operators/operators.go | 0.546012 | 0.457621 | operators.go | starcoder |
// Package costs gets billing information from an ElasticSearch.
package es
import (
"time"
"github.com/olivere/elastic"
)
const maxAggregationSize = 0x7FFFFFFF
// getDateForDailyReport returns the end and the begining of the date of the report based on a date
func getDateForDailyReport(date time.Time) (begin, e... | usageReports/es/es_request_constructor.go | 0.618665 | 0.447762 | es_request_constructor.go | starcoder |
package engine
import (
"math"
"math/rand"
)
func init() {
DeclFunc("ext_makegrains", Voronoi, "Voronoi tesselation (grain size, num regions)")
}
func Voronoi(grainsize float64, numRegions, seed int) {
Refer("Lel2014")
SetBusy(true)
defer SetBusy(false)
t := newTesselation(grainsize, numRegions, int64(seed))... | engine/ext_makegrains.go | 0.736211 | 0.576631 | ext_makegrains.go | starcoder |
package strmatcher
import (
"errors"
"regexp"
"strings"
)
// FullMatcher is an implementation of Matcher.
type FullMatcher string
func (FullMatcher) Type() Type {
return Full
}
func (m FullMatcher) Pattern() string {
return string(m)
}
func (m FullMatcher) String() string {
return "full:" + m.Pattern()
}
fu... | common/strmatcher/matchers.go | 0.822118 | 0.432723 | matchers.go | starcoder |
package topologyAlgorithm
import (
"github.com/astaxie/beego/orm"
"github.com/netsec-ethz/scion-coord/models"
)
// performance score thresholds
const (
BW1 = 0.05
BW2 = 0.1
BW3 = 0.5
RTT1 = 10
RTT2 = 50
RTT3 = 100
)
// number of neighbors chosen for each AS
const (
CHOSEN_NEIGHBORS uint16 = 3
)
// maxi... | utility/topologyAlgorithm/topology.go | 0.652906 | 0.447943 | topology.go | starcoder |
package day17
type dir int
const (
up dir = 0
right dir = 1
down dir = 2
left dir = 3
)
type coordinate struct {
x, y int
}
type robot struct {
x,y int
dir dir
dead bool
}
type scaffold struct {
cells [][]byte // row, col
robot *robot
}
func (s *scaffold) extent() (cols, rows int) {
rows = len(... | v19/internal/day17/map.go | 0.569972 | 0.40751 | map.go | starcoder |
Package twitscrape is a library for scraping tweets from the twitter archive.
The archive is publicly available and can be searched through at:
https://twitter.com/search-advanced?lang=en
No authentication is required and the package can be run without any
prior configurations.
You can start scraping by creati... | doc.go | 0.678433 | 0.4206 | doc.go | starcoder |
package event
type Point struct {
X, Y int
}
func (p Point) Magnitude() int {
return abs(p.X) + abs(p.Y)
}
func (p Point) Distance(o Point) int {
return abs(p.X - o.X) + abs(p.Y - o.Y)
}
func abs(x int) int {
if x < 0 {
return -x
}
return x
}
func (p Point) Offset(x, y int) Point {
return Point{p.X + x, p... | v19/internal/event/segment.go | 0.79158 | 0.476762 | segment.go | starcoder |
package pcpeasy
import (
"github.com/ryandoyle/pcpeasygo/pmapi"
"fmt"
"reflect"
)
type metricInfo struct {
semantics string
units metricUnits
_type reflect.Kind
}
type metricUnits struct {
domain string
_range string
}
type pmDescAdapter interface {
toMetricInfo(pm_desc pmapi.PmDesc) metricInfo
}
type pm... | pcpeasy/metric_units.go | 0.639061 | 0.537102 | metric_units.go | starcoder |
package msboard
import (
"errors"
"fmt"
"io"
"math/rand"
"os"
)
// Location : zero-based cell location, {0,0} is upper left
type Location struct {
row, col int
}
// NewLocation -- public interface to create a Location struct
func NewLocation(row, col int) Location {
retval := Location{row, col}
return retval... | msboard/Board.go | 0.676192 | 0.489381 | Board.go | starcoder |
package sgd
import (
"fmt"
"math"
"gonum.org/v1/gonum/mat"
"github.com/jamOne-/kiwi-zero/utils"
)
type OptimizeFn func(Xs []*mat.VecDense, ys []float64, weights *mat.VecDense) (float64, *mat.VecDense)
type SGDReturn struct {
BestWeights *mat.VecDense
TestSetErrorRate float64
BestValidError... | sgd/sgd.go | 0.598077 | 0.416381 | sgd.go | starcoder |
package padx
import (
"time"
"github.com/rakyll/launchpad"
)
// Custom represents a custom widget and all its hits (x, y) for behing paint
type Custom struct {
OffsetX int
OffsetY int
Width int
Height int
Hits []launchpad.Hit
}
// NewCustom initializes a custom widget
func NewCustom(lines []string) Cus... | custom.go | 0.584983 | 0.415966 | custom.go | starcoder |
package linear
import (
"math"
)
const (
BLOCK_SIZE int = 52
)
/**
* Cache-friendly implementation of RealMatrix using a flat arrays to store
* square blocks of the matrix.
*
* This implementation is specially designed to be cache-friendly. Square blocks are
* stored as small arrays and allow efficient traver... | block_real_matrix.go | 0.81841 | 0.721167 | block_real_matrix.go | starcoder |
package octopi
type Int2 struct {
x int
y int
}
func make_int2(x int, y int) Int2 {
return Int2{x, y}
}
func (a Int2) Add(b Int2) Int2 {
return Int2{a.x + b.x, a.y + b.y}
}
type Octopus struct {
pos Int2
energy int
virtual bool
}
type Stack struct {
stack []Int2
}
func (s *St... | Day_11/octopi/common.go | 0.553747 | 0.441372 | common.go | starcoder |
package cmd
import (
"fmt"
"sort"
"github.com/jaredbancroft/aoc2020/pkg/boarding"
"github.com/jaredbancroft/aoc2020/pkg/helpers"
"github.com/spf13/cobra"
)
// day5Cmd represents the day5 command
var day5Cmd = &cobra.Command{
Use: "day5",
Short: "Advent of Code 2020 - Day 5: Binary Boarding",
Long: `
Adven... | cmd/day5.go | 0.708213 | 0.577912 | day5.go | starcoder |
package output
import (
"fmt"
"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"
)
//---------------------------------------------------... | lib/output/elasticsearch.go | 0.752468 | 0.440349 | elasticsearch.go | starcoder |
package bsonkit
import (
"bytes"
"math"
"strings"
"github.com/shopspring/decimal"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// Compare will compare two bson values and return their order according to the
// BSON type comparison order specification:
// https://docs.mongod... | bsonkit/compare.go | 0.710226 | 0.441673 | compare.go | starcoder |
package nutriscore
// ScoreType is the type of the scored product
type ScoreType int
const (
// Food is used when calculating nutritional score for general food items
Food ScoreType = iota
// Beverage is used when calculating nutritional score for beverages
Beverage
// Water is used when calculating nutritional ... | nutriscore.go | 0.699152 | 0.463505 | nutriscore.go | starcoder |
// Package checks contains checks for differentially private functions.
package checks
import (
"fmt"
"math"
log "github.com/golang/glog"
)
// CheckEpsilonVeryStrict returns an error if ε is +∞ or less than 2⁻⁵⁰.
func CheckEpsilonVeryStrict(epsilon float64) error {
if epsilon < math.Exp2(-50.0) || math.IsInf(ep... | go/checks/checks.go | 0.868771 | 0.607285 | checks.go | starcoder |
package execute
import (
"fmt"
"strings"
"github.com/influxdata/flux"
"github.com/influxdata/flux/values"
)
type groupKey struct {
cols []flux.ColMeta
values []values.Value
}
func NewGroupKey(cols []flux.ColMeta, values []values.Value) flux.GroupKey {
return &groupKey{
cols: cols,
values: values,
}
... | execute/group_key.go | 0.718693 | 0.430566 | group_key.go | starcoder |
package decisiontrees
import (
"code.google.com/p/goprotobuf/proto"
"fmt"
pb "github.com/ajtulloch/decisiontrees/protobufs"
"github.com/golang/glog"
"math"
"sort"
)
type labelledPrediction struct {
Label bool
Prediction float64
}
type labelledPredictions []labelledPrediction
func (l labelledPredictions... | evaluation_metrics.go | 0.727975 | 0.483344 | evaluation_metrics.go | starcoder |
package cbor
import (
"encoding/json"
"fmt"
"math"
)
// AppendNull inserts a 'Nil' object into the dst byte array.
func AppendNull(dst []byte) []byte {
return append(dst, byte(majorTypeSimpleAndFloat|additionalTypeNull))
}
// AppendBeginMarker inserts a map start into the dst byte array.
func AppendBeginMarker(d... | vendor/github.com/rs/zerolog/internal/cbor/types.go | 0.703448 | 0.407274 | types.go | starcoder |
package v1
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Creates a cluster, consisting of the specified number and type of Google Compute Engine instances. By default, the cluster is created in the project's [default network](https://cloud.google.com/compute/docs/networks-and-fire... | sdk/go/google/container/v1/cluster.go | 0.731251 | 0.428951 | cluster.go | starcoder |
package iso20022
// Payment obligation contracted between two financial institutions related to the financing of a commercial transaction.
type PaymentObligation1 struct {
// Bank that has to pay under the obligation.
ObligorBank *BICIdentification1 `xml:"OblgrBk"`
// Bank that will be paid under the obligation.
... | PaymentObligation1.go | 0.774498 | 0.63665 | PaymentObligation1.go | starcoder |
package graphics
import (
"github.com/markov/gojira2d/pkg/utils"
"log"
"github.com/go-gl/gl/v4.1-core/gl"
"github.com/go-gl/mathgl/mgl32"
)
const FLOAT32_SIZE = 4
type ModelMatrix struct {
mgl32.Mat4
size mgl32.Mat4
translation mgl32.Mat4
rotation mgl32.Mat4
scale mgl32.Mat4
anchor m... | pkg/graphics/primitive_2d.go | 0.689828 | 0.477311 | primitive_2d.go | starcoder |
package bitset
import (
"fmt"
)
// Bitset represents a bitset of fixed length
type Bitset struct {
bitvec []int32
length int
bitlength int
}
// New creates a new bitset instance with length l.
func New(l int) Bitset {
return Bitset{
bitvec: make([]int32, l),
length: (l / 32) + 1,
bitlength: l,... | bitset/bitset.go | 0.76074 | 0.467149 | bitset.go | starcoder |
package chatbot
import (
"fmt"
"net/http"
"os"
"strings"
"sync"
"time"
"github.com/go-chat-bot/bot"
)
const (
invalidDeploySyntax = "Deploy command requires 4 parameters: " +
"```!deploy %s your_app your_container your/docker:image``` \nGot: ```!deploy %s```"
invalidImageFormat = "```Invalid image format,... | commands.go | 0.537527 | 0.529203 | commands.go | starcoder |
package machine
import (
"errors"
"github.com/offchainlabs/arbitrum/packages/arb-util/protocol"
)
type AssertionDefender struct {
assertion *protocol.Assertion
precondition *protocol.Precondition
initState Machine
}
func NewAssertionDefender(assertion *protocol.Assertion, precondition *protocol.Precondit... | packages/arb-util/machine/defender.go | 0.628635 | 0.474388 | defender.go | starcoder |
package gamemap
import (
"math"
"math/rand"
"time"
)
// Vector3 代码位置的3D矢量
type Vector3 struct {
X float64
Y float64
Z float64
}
// NewVector3 创建一个新的矢量
func NewVector3(x, y, z float64) Vector3 {
return Vector3{
x,
y,
z,
}
}
// Vector3_Zero 返回零值
func Vector3Zero() Vector3 {
return Vector3{
0,
0,
... | gamemap/vector3.go | 0.583559 | 0.603581 | vector3.go | starcoder |
package syntaxtree
import (
"bytes"
"github.com/manishmeganathan/tunalang/lexer"
)
// A structure that represents a Let statement token
type LetStatement struct {
// Represents the lexological token 'LET'
Token lexer.Token
// Represents the identifier in the let statement
Name *Identifier
// Represents the ... | syntaxtree/statements.go | 0.830147 | 0.459622 | statements.go | starcoder |
package iso20022
// Parameters applied to the settlement of a security.
type FundSettlementParameters11 struct {
// Date and time at which the securities are to be delivered or received.
SettlementDate *ISODate `xml:"SttlmDt,omitempty"`
// Place where the settlement of the transaction will take place. In the cont... | FundSettlementParameters11.go | 0.798972 | 0.444565 | FundSettlementParameters11.go | starcoder |
package plaid
import (
"encoding/json"
)
// SecurityOverride Specify the security associated with the holding or investment transaction. When inputting custom security data to the Sandbox, Plaid will perform post-data-retrieval normalization and enrichment. These processes may cause the data returned by the Sandbox... | plaid/model_security_override.go | 0.849191 | 0.499939 | model_security_override.go | starcoder |
package fn
import (
"math"
)
func NewTan(x Operand) *UnaryElementwise {
return &UnaryElementwise{
x: x,
f: tan,
df: tanDeriv,
}
}
func NewTanh(x Operand) *UnaryElementwise {
return &UnaryElementwise{
x: x,
f: tanh,
df: tanhDeriv,
}
}
func NewSigmoid(x Operand) *UnaryElementwise {
return &Unar... | pkg/ml/ag/fn/misc.go | 0.7874 | 0.565479 | misc.go | starcoder |
package namegen
// NameGenerator is a set of names to use
type NameGenerator struct {
MaleFirstNames []string
FemaleFirstNames []string
LastNames []string
}
// NameGeneratorFromType sets up types of names
func NameGeneratorFromType(origin, gender string) NameGenerator {
nameGenerators := map[string]NameG... | namegen.go | 0.526343 | 0.450964 | namegen.go | starcoder |
package tt
import (
"fmt"
"path"
"reflect"
"regexp"
"runtime"
"testing"
)
// isEqual returns whether val1 is equal to val2 taking into account Pointers, Interfaces and their underlying types
func isEqual(val1, val2 interface{}) bool {
v1 := reflect.ValueOf(val1)
v2 := reflect.ValueOf(val2)
if v1.Kind() == r... | utils.go | 0.590543 | 0.418697 | utils.go | starcoder |
package measurements
import (
"fmt"
"math"
"sync"
)
// SimpleExponentialMovingAverage implements a simple exponential moving average
// this implementation only uses a single alpha value to determine warm-up time and provides a mean
// approximation
type SimpleExponentialMovingAverage struct {
alpha float6... | measurements/moving_average.go | 0.879755 | 0.494568 | moving_average.go | starcoder |
package p336
/**
Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.
Example 1:
Given words = ["bat", "tab", "cat"]
Return [[0, 1], [1, 0]]
The palindromes are ["battab", "tabbat"]
Example 2:
G... | algorithms/p336/336.go | 0.779616 | 0.474996 | 336.go | starcoder |
package yamlpath
import (
"errors"
"strings"
"unicode/utf8"
"github.com/dprotaso/go-yit"
"gopkg.in/yaml.v3"
)
// Path is a compiled YAML path expression.
type Path struct {
f func(node, root *yaml.Node) yit.Iterator
}
// Find applies the Path to a YAML node and returns the addresses of the subnodes which matc... | pkg/yamlpath/path.go | 0.631367 | 0.425128 | path.go | starcoder |
package cal
import (
"math"
"strconv"
"strings"
"time"
"github.com/kudrykv/latex-yearly-planner/app/components/header"
"github.com/kudrykv/latex-yearly-planner/app/components/hyper"
"github.com/kudrykv/latex-yearly-planner/app/tex"
)
type Weeks []*Week
type Week struct {
Days [7]Day
Weekday time.Weekday
... | app/components/cal/week.go | 0.579162 | 0.415314 | week.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.