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 engine
import (
"fmt"
"math"
)
type Vector struct {
X, Y, Z float32
}
var (
Zero = Vector{0, 0, 0}
Up = Vector{0, 1, 0}
Down = Vector{0, -1, 0}
Left = Vector{-1, 0, 0}
Right = Vector{1, 0, 0}
Forward = Vector{0, 0, 1}
Backward = Vector{0, 0, -1}
One = Vector{1, 1, 1}
Mi... | engine/Vector.go | 0.635449 | 0.538316 | Vector.go | starcoder |
package sql
import (
"math"
"reflect"
"github.com/tobgu/qframe/internal/math/float"
"github.com/tobgu/qframe/qerrors"
)
// Column implements the sql.Scanner interface
// and allows arbitrary data types to be loaded from
// any database/sql/driver into a QFrame.
type Column struct {
kind reflect.Kind
nulls in... | internal/io/sql/column.go | 0.587233 | 0.46132 | column.go | starcoder |
package sql
import (
"fmt"
"github.com/dolthub/vitess/go/vt/proto/query"
"github.com/dolthub/go-mysql-server/sql/values"
)
// ConvertToValue converts the interface to a sql value.
func ConvertToValue(v interface{}) (Value, error) {
switch v := v.(type) {
case nil:
return Value{
Typ: query.Type_NULL_TYPE,
... | sql/convert_value.go | 0.565179 | 0.505188 | convert_value.go | starcoder |
package match
import (
"fmt"
"reflect"
"github.com/tidwall/gjson"
)
// JSON will perform some matches on the given JSON body, returning an error on a mis-match.
// It can be assumed that the bytes are valid JSON.
type JSON func(body []byte) error
// JSONKeyEqual returns a matcher which will check that `wantKey` ... | internal/match/json.go | 0.759225 | 0.492371 | json.go | starcoder |
package easycsv
import (
"fmt"
"reflect"
"strconv"
)
var predefinedDecoders = map[string]func(t reflect.Type) interface{}{
"hex": func(t reflect.Type) interface{} {
return createIntConverter(t, 16)
},
"oct": func(t reflect.Type) interface{} {
return createIntConverter(t, 8)
},
"deci": func(t reflect.Type)... | encode.go | 0.532668 | 0.417628 | encode.go | starcoder |
package iso20022
// Fund Processing Passsport (FPP) is a fully harmonised document with all key operational information that fund promoters should provide on their investment funds in order to facilitate their trading.
type FundProcessingPassport1 struct {
// Date of last revision.
UpdatedDate *UpdatedDate `xml:"Up... | FundProcessingPassport1.go | 0.648244 | 0.469703 | FundProcessingPassport1.go | starcoder |
package graphdb
func addedge(ids []NodeId, id NodeId) ([]NodeId, bool) {
// An empty list is easily defined as a single new edge.
if ids == nil {
ids = make([]NodeId, 0, 1)
}
// Make sure the edge does not already exist in the list.
for _, edge := range ids {
if edge == id {
return ids, false
}
}
ret... | pkg/sdsai/graphdb/edge.go | 0.541651 | 0.436142 | edge.go | starcoder |
package gokd
import (
"errors"
"math"
"sort"
)
// KDTree represents a static miltidimensional binary search tree
type KDTree struct {
dimensions int
root *Node
nodes int64
}
// Node represents a single leaf or edge node within a KDTree
type Node struct {
Coordinates []float64
Left *Node
Ri... | main.go | 0.810779 | 0.582877 | main.go | starcoder |
package plaid
import (
"encoding/json"
)
// TransactionBase A representation of a transaction
type TransactionBase struct {
// Please use the `payment_channel` field, `transaction_type` will be deprecated in the future. `digital:` transactions that took place online. `place:` transactions that were made at a phy... | plaid/model_transaction_base.go | 0.878588 | 0.568296 | model_transaction_base.go | starcoder |
package qspp
import "github.com/privacybydesign/keyproof/common"
import "github.com/privacybydesign/gabi/big"
type AlmostSafePrimeProductProof struct {
Nonce *big.Int
Commitments []*big.Int
Responses []*big.Int
}
type AlmostSafePrimeProductCommit struct {
Nonce *big.Int
Commitments []*big.Int
Log... | qspp/almostsafeprimeproduct.go | 0.512937 | 0.423816 | almostsafeprimeproduct.go | starcoder |
package geometry
import (
"github.com/go-gl/mathgl/mgl32"
)
type Quad struct {
Vertices [4]mgl32.Vec3
VertexBuffer []float32
}
func NewQuad(corners [4]mgl32.Vec3) *Quad {
vertices := make([][]float32, 4)
for i := 0; i < 4; i++ {
vertices[i] = []float32{corners[i].X(), corners[i].Y(), corners[i].Z()}
}
... | geometry/quad.go | 0.727201 | 0.528777 | quad.go | starcoder |
package sema
import (
"github.com/onflow/cadence/runtime/ast"
"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/runtime/errors"
)
func (checker *Checker) VisitBinaryExpression(expression *ast.BinaryExpression) ast.Repr {
// The left-hand side is always evaluated.
// However, the right-hand s... | runtime/sema/check_binary_expression.go | 0.772101 | 0.492737 | check_binary_expression.go | starcoder |
package ast
// Location contains location information about where an AST type is in a document.
type Location struct {
Line int
Column int
}
// @wg:field self
const (
PathNodeKindString PathNodeKind = iota
PathNodeKindInt
)
// PathNodeKind an enum type that defines the type of data stored in a PathNode.
type P... | ast/ast.go | 0.719679 | 0.494385 | ast.go | starcoder |
package buildroot
import (
"github.com/0xPolygon/polygon-edge/helper/keccak"
itrie "github.com/0xPolygon/polygon-edge/state/immutable-trie"
"github.com/0xPolygon/polygon-edge/types"
"github.com/umbracle/fastrlp"
)
var arenaPool fastrlp.ArenaPool
// CalculateReceiptsRoot calculates the root of a list of receipts
... | types/buildroot/buildroot.go | 0.679179 | 0.400192 | buildroot.go | starcoder |
package ot
type OpType int
const (
OpRetain OpType = iota
OpInsert
OpDelete
)
type Op interface {
Type() OpType
Span() int
IsZero() bool
}
type RetainOp int
func (p RetainOp) Type() OpType {
return OpRetain
}
func (p RetainOp) Span() int {
return int(p)
}
func (p RetainOp) IsZero() bool {
return p == 0
... | ot/op.go | 0.568655 | 0.576482 | op.go | starcoder |
package chart
import (
"math"
util "github.com/leesjensen/go-chart/util"
)
// YAxis is a veritcal rule of the range.
// There can be (2) y-axes; a primary and secondary.
type YAxis struct {
Name string
NameStyle Style
Style Style
Zero GridLine
AxisType YAxisType
Ascending bool
ValueFormatter Value... | yaxis.go | 0.704668 | 0.476823 | yaxis.go | starcoder |
package lib
import "math"
import "sort"
import "fmt"
import "strings"
import "strconv"
// HistogramInt64 statistical histogram.
type HistogramInt64 struct {
// stats
n int64
minval int64
maxval int64
sum int64
sumsq float64
histogram []int64
// setup
init bool
from int64
till int... | lib/htgint.go | 0.63273 | 0.432183 | htgint.go | starcoder |
package atlas
import (
"image"
"github.com/PieterD/crap/roguelike/game/atlas/aspect"
"github.com/PieterD/crap/roguelike/grid"
"github.com/PieterD/crap/roguelike/vision"
"github.com/PieterD/crap/roguelike/wallify"
"math/rand"
"time"
)
type Glyph struct {
Code int
Fore grid.Color
Back grid.Color
}
func Tran... | roguelike/game/atlas/atlas.go | 0.611382 | 0.449211 | atlas.go | starcoder |
package selectpeers
import (
"fmt"
"math"
"github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/types"
)
// minValidators is a minimum number of validators needed in order to execute the selection
// algorithm. For less than this number, we connect to all validators.
const minValidators... | dash/quorum/selectpeers/dip6.go | 0.855972 | 0.477067 | dip6.go | starcoder |
package pigo
import (
"bytes"
"encoding/binary"
"math"
"math/rand"
"sort"
"unsafe"
)
// Puploc contains all the information resulted from the pupil detection
// needed for accessing from a global scope.
type Puploc struct {
Row int
Col int
Scale float32
Perturbs int
}
// PuplocCascade is a gen... | core/puploc.go | 0.550124 | 0.508544 | puploc.go | starcoder |
package raycast
import (
"image"
"image/color"
"image/draw"
"math"
"github.com/faiface/pixel"
)
// Player is the camera
type Player struct {
Position pixel.Vec
Direction pixel.Vec
Plane pixel.Vec
}
// NewPlayer is the constructor
func NewPlayer(posX, posY, dirX, dirY, planeX, planeY float64) Player {
... | raycast/player.go | 0.675765 | 0.411702 | player.go | starcoder |
package functions
import (
"reflect"
)
type functionType int
const (
// Predicate is any function taking one argument and returning a bool.
// f: X -> bool
Predicate functionType = iota
// Consumer is any function taking one argument and returning none.
// Use this to produce side effects.
Consumer
// Ma... | functions/functions.go | 0.678433 | 0.59561 | functions.go | starcoder |
package content
import (
"github.com/nboughton/go-roll"
"github.com/nboughton/swnt/content/format"
"github.com/nboughton/swnt/content/table"
)
// Encounter represents an encounter
type Encounter struct {
Type string
Fields [][]string
}
// NewEncounter creates a new encounter
func NewEncounter(wilderness bool)... | content/encounter.go | 0.523177 | 0.453746 | encounter.go | starcoder |
package mlp3
import (
"encoding/json"
"errors"
"fmt"
"github.com/r9y9/nnet"
"math/rand"
"os"
"time"
)
const (
Bias = 1.0
)
// NeuralNetwork represents a Feed-forward Neural Network.
type NeuralNetwork struct {
OutputLayer []float64
HiddenLayer []float64
InputLayer []float64
OutputWeight [][]float64
... | mlp3/mlp3.go | 0.772015 | 0.403156 | mlp3.go | starcoder |
package aug
import (
ts "github.com/sugarme/gotch/tensor"
)
// Normalize normalizes a tensor image with mean and standard deviation.
// Given mean: ``(mean[1],...,mean[n])`` and std: ``(std[1],..,std[n])`` for ``n``
// channels, this transform will normalize each channel of the input
// ``torch.*Tensor`` i.e.,
// ``... | vision/aug/normalize.go | 0.86378 | 0.510313 | normalize.go | starcoder |
package tetra3d
import (
"image/color"
"math"
)
// Color represents a color, containing R, G, B, and A components, each expected to range from 0 to 1.
type Color struct {
R, G, B, A float32
}
// NewColor returns a new Color, with the provided R, G, B, and A components expected to range from 0 to 1.
func NewColor(... | color.go | 0.920781 | 0.732735 | color.go | starcoder |
package cryptypes
import "database/sql/driver"
// EncryptedByteSlice supports encrypting ByteSlice data
type EncryptedByteSlice struct {
Field
Raw []byte
}
// Scan converts the value from the DB into a usable EncryptedByteSlice value
func (s *EncryptedByteSlice) Scan(value interface{}) error {
return decrypt(valu... | cryptypes/type_byte_slice.go | 0.816918 | 0.677724 | type_byte_slice.go | starcoder |
package algebra
import "constraints"
// Additive is a type that can use `+` operator.
type Additive interface {
constraints.Integer | constraints.Float | constraints.Complex | ~string
}
// Multiplicative is a type that can use `*` operator.
type Multiplicative interface {
constraints.Integer | constraints.Float | ... | classes/algebra/algebra.go | 0.858689 | 0.525978 | algebra.go | starcoder |
package similgraph
import (
"sort"
"github.com/pkg/errors"
)
//go:generate gorewrite
//SimilGraph represents a cosine similarity graph whose edges are computed on the fly
type SimilGraph struct {
bigraphEdges []implicitEdge
vertexSlices []uint32
vertexCount uint32
}
//VertexCount return the count of the vert... | similgraph.go | 0.675872 | 0.691562 | similgraph.go | starcoder |
package daycount
import (
"math"
"time"
"github.com/fxtlabs/date"
)
// DayCounter computes the year fraction between a from and a to date
// according to a predefined day-count convention.
// All DayCounter functions assume that from is never later than to.
type DayCounter func(from, to date.Date) float64
// New... | daycount.go | 0.779028 | 0.665832 | daycount.go | starcoder |
package dsp
// region Complex Fir Filter
type CTFirFilter struct {
taps []complex64
sampleHistory []complex64
tapsLen int
decimation int
}
func MakeCTFirFilter(taps []complex64) *CTFirFilter {
return &CTFirFilter{
taps: taps,
sampleHistory: make([]complex64, len(taps)),
tapsLen:... | dsp/ComplexFir.go | 0.535584 | 0.448607 | ComplexFir.go | starcoder |
package finverse
import (
"encoding/json"
)
// IncomeTotal struct for IncomeTotal
type IncomeTotal struct {
EstimatedMonthlyIncome *IncomeEstimate `json:"estimated_monthly_income,omitempty"`
// Number of transactions counted towards income
TransactionCount float32 `json:"transaction_count"`
Mont... | finverse/model_income_total.go | 0.769514 | 0.560734 | model_income_total.go | starcoder |
package keyproof
import (
"strings"
"github.com/privacybydesign/gabi/big"
)
type (
expStepAStructure struct {
bitname string
prename string
postname string
myname string
bitRep RepresentationProofStructure
equalityRep RepresentationProofStructure
}
ExpStepAProof struct {
Bit ... | keyproof/expstepa.go | 0.612657 | 0.457985 | expstepa.go | starcoder |
package convnet
import (
"errors"
"math"
)
// MaxPool apply max pooling to the matrix with a max-pool filter of size filter_size (square)
// and a stride (movement of the filter), the filter applied outside the original matrix use as paddings "0s"
func (matrix *Matrix) MaxPool(filterSize int, stride int) (*Matrix, ... | cnn_functions.go | 0.747155 | 0.490846 | cnn_functions.go | starcoder |
package league
import (
"fmt"
"net/http"
pandascore "github.com/vahill-corp/pandascore-go"
)
// League resources is the interface on the library to interact with the league section of the pandascore API.
// More info here : https://developers.pandascore.co/doc/#tag/Leagues
type League struct {
Backend *pandascor... | league/client.go | 0.625095 | 0.431584 | client.go | starcoder |
package main
func search(nums []int, target int) int {
return helper3(nums, 0, len(nums), target)
}
// helper3 takes the array `nums` and two int `a` `b`
// to find the `target`
// 0 <= a <= b <= len(Nums)
// search area [a, b)
func helper3(nums []int, a, b int, target int) int {
lenAB := b - a
// short enough, di... | leetcode/0033_search-in-rotated-sorted-array/main.go | 0.686055 | 0.634727 | main.go | starcoder |
package Solution
func lengthOfLongestSubstring_3(s string) int {
ans, left, m := 0, 0, map[rune]int{}
for right, v := range s {
if _, ok := m[v]; !ok {
m[v] = right
} else {
if m[v]+1 > left {
left = m[v] + 1
}
m[v] = right
}
ans = max(ans, right-left+1)
}
return ans
}
func lengthOfLongest... | leetcode/1-100/0003.Longest-Substring-Without-Repeating-Characters/Solution.go | 0.566019 | 0.459925 | Solution.go | starcoder |
package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
"strings"
)
/**
Let us assume the following formula for displacement s as a function of time t, acceleration a, initial velocity vo, and initial displacement so.
s =½ a t2 + vot + so
Write a program which first prompts the user to enter values for acce... | course-2/displacement/displacement.go | 0.791176 | 0.680255 | displacement.go | starcoder |
package xy
import (
"sort"
"github.com/twpayne/go-geom"
"github.com/twpayne/go-geom/bigxy"
"github.com/twpayne/go-geom/sorting"
"github.com/twpayne/go-geom/xy/internal"
"github.com/twpayne/go-geom/xy/orientation"
)
type convexHullCalculator struct {
layout geom.Layout
stride int
inputPts []float64
}
fu... | vendor/github.com/whosonfirst/go-whosonfirst-static/vendor/github.com/whosonfirst/go-whosonfirst-readwrite-sqlite/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-features/vendor/github.com/twpayne/go-geom/xy/convex_hull.go | 0.62601 | 0.413714 | convex_hull.go | starcoder |
package binaryheap
import (
"fmt"
"github.com/kevinpollet/go-datastructures/errors"
)
type node struct {
value interface{}
priority int
}
// BinaryHeap implements the PriorityQueue ADT.
type BinaryHeap struct {
tree []*node
}
// Clear removes all values from the heap.
// Complexity: O(1)
func (heap *Binary... | priorityqueue/binaryheap/binary_heap.go | 0.8398 | 0.442877 | binary_heap.go | starcoder |
package core
import (
"reflect"
)
type NormalizedValue struct {
Value interface{}
OriginalKind reflect.Kind
IsNil bool
}
// TODO: Normalize slices to arrays?
func normalizeInternal(value interface{}, isNil bool) (*NormalizedValue, error) {
reflectedValue := reflect.ValueOf(value)
kind := reflect... | core/normalization.go | 0.512937 | 0.447581 | normalization.go | starcoder |
package frm
// DatabaseType is the database type definition.
// DatabaseType is the engine of current table, see enum legacy_db_type
type DatabaseType int
const (
// DatabaseTypeUnknown is the unknown database type
DatabaseTypeUnknown DatabaseType = 0
// DatabaseTypeDiabIsam is the diab_isam database type
Databa... | pkg/reader/frm/constants.go | 0.52342 | 0.49585 | constants.go | starcoder |
package types
import (
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/hash"
)
type List struct {
seq indexedSequence
h *hash.Hash
}
func newList(seq indexedSequence) List {
return List{seq, &hash.Hash{}}
}
// NewList creates a new List where the type is computed from the elements in the li... | go/types/list.go | 0.678753 | 0.492859 | list.go | starcoder |
package gaussian
// https://github.com/freethenation/gaussian
// free-gaussian
// MIT License
import (
"math"
)
// prop
//mean: the mean (μ) of the distribution
//variance: the variance (σ^2) of the distribution
//standardDeviation: the standard deviation (σ) of the distribution
// combination
//mul(d): returns th... | vendor/github.com/chobie/go-gaussian/gaussian.go | 0.913874 | 0.673896 | gaussian.go | starcoder |
package parts
import (
"bytes"
"fmt"
"github.com/google/shenzhen-go/model"
"github.com/google/shenzhen-go/model/pin"
)
func init() {
model.RegisterPartType("Gather", "Flow", &model.PartType{
New: func() model.Part { return &Gather{InputNum: 2} },
Panels: []model.PartPanel{
{
Name: "Gather",
Edit... | parts/gather.go | 0.591015 | 0.49347 | gather.go | starcoder |
package inject
import "reflect"
// TypedInjector returns an Injector utilizing valueMaker, which should implement one or more *Maker interfaces.
func TypedInjector(valueMaker interface{}) Injector {
return &typedInjector{valueMaker}
}
// A typedInjector adapts valueMaker to Injector.
type typedInjector struct {
//... | inject/typed.go | 0.704872 | 0.526891 | typed.go | starcoder |
package optional
import (
"errors"
"reflect"
)
type optional struct {
v interface{}
empty bool
}
// Test if an input is the default zero value
func isZeroed(in interface{}, t reflect.Type) bool {
return in == reflect.Zero(t).Interface()
}
// Test if nil depending on its type
func isNil(in interface{}) bool... | optional/optional.go | 0.742982 | 0.438545 | optional.go | starcoder |
package pkg
import (
"fmt"
"github.com/juju/errors"
"reflect"
)
// ValueAdd will try to do a mathematical addition between two values.
// It will return another value as the result and an error if between the two values are not compatible for Addition
func ValueAdd(a, b reflect.Value) (reflect.Value, error) {
aBk... | pkg/reflectmath.go | 0.677474 | 0.698239 | reflectmath.go | starcoder |
package xcom
import (
"github.com/DomBlack/advent-of-code-2018/lib/vectors"
"log"
"sort"
)
type FloodMap map[vectors.Vec2]int
func (m *Map) NewFloodMap(starting *Unit) FloodMap {
type FloodCell struct {
position vectors.Vec2
cost int
}
toVisit := []FloodCell{{starting.Position, 0}}
visited := make(ma... | day-15/xcom/FloodMap.go | 0.740268 | 0.485173 | FloodMap.go | starcoder |
package ids
// SoundEffectInfo describes one sound effect in the game.
type SoundEffectInfo struct {
// Name is the unique identifier for the effect source.
Name string
// Index refers to the audio index. Multiple effects may use the same audio. -1 indicates no audio mapped.
AudioIndex int
}
// SoundEffectsForAud... | ss1/world/ids/Sounds.go | 0.650578 | 0.604807 | Sounds.go | starcoder |
package gots
import "math"
// PTS constants
const (
PTS_DTS_INDICATOR_BOTH = 3 // 11
PTS_DTS_INDICATOR_ONLY_PTS = 2 // 10
PTS_DTS_INDICATOR_NONE = 0 // 00
// MaxPtsValue is the highest value the PTS can hold before it rolls over, since its a 33 bit timestamp.
MaxPtsValue = (1 << 33) - 1 // 2^33 - 1 = 85... | pts.go | 0.657868 | 0.52683 | pts.go | starcoder |
package stats
import (
"fmt"
"regexp"
"github.com/turbinelabs/nonstdlib/arrays/indexof"
)
const (
transformTagsDesc = `
Defines one or more transformations for tags. A tag with a specific name whose value matches
a regular expression can be transformed into one or more tags with values extracted from
subexpressi... | vendor/github.com/turbinelabs/stats/tag_transformer.go | 0.780077 | 0.636692 | tag_transformer.go | starcoder |
package creator
import (
"github.com/pzduniak/unipdf/contentstream/draw"
"github.com/pzduniak/unipdf/model"
)
// Ellipse defines an ellipse with a center at (xc,yc) and a specified width and height. The ellipse can have a colored
// fill and/or border with a specified width.
// Implements the Drawable interface an... | bot/vendor/github.com/pzduniak/unipdf/creator/ellipse.go | 0.825976 | 0.439687 | ellipse.go | starcoder |
package texture
import (
"math"
)
// FixedNormal provides a fixed VectorField.
type FixedNormal struct {
Val []float64
}
// DefaultNormal describes the unit normal point straight up from the XY plane.
var DefaultNormal = &FixedNormal{[]float64{0, 0, 1}}
// Eval2 implements
func (n *FixedNormal) Eval2(x, y float64... | vector.go | 0.909184 | 0.747524 | vector.go | starcoder |
package value
import (
"strconv"
"strings"
)
type compareUIntFunc func(a, b uint64) bool
// UIntSlice holds a slice of uint64 values
type UIntSlice struct {
valsPtr *[]uint64
}
// NewUIntSlice makes a new UIntSlice with the given uint64 values.
func NewUIntSlice(vals ...uint64) *UIntSlice {
slice := make([]uint... | value/uintslice.go | 0.840292 | 0.644812 | uintslice.go | starcoder |
package constraint
import (
"fmt"
"github.com/sineatos/deag/base"
"github.com/sineatos/deag/benchmarks"
)
// Float64Constraint defines the functions of constraint
type Float64Constraint interface {
// AdjustAndEvolve checks individual and adjusts it if it is not feasible
AdjustAndEvolve(individual *base.Float64I... | tools/constraint/constraint.go | 0.733738 | 0.421552 | constraint.go | starcoder |
package generator
import (
"flag"
"fmt"
"math/rand"
"reflect"
"runtime"
"sort"
"strconv"
"strings"
"time"
)
type (
// Grid is the primary data structure for the generator. It contains the candidates for each cell in the 9 x 9 puzzle.
Grid struct {
orig [rows][cols]bool
cells [rows][cols]cell
}
poin... | generator/grid.go | 0.661158 | 0.449091 | grid.go | starcoder |
package main
import (
"encoding/hex"
"errors"
"fmt"
"regexp"
"strconv"
"strings"
"unicode/utf16"
"unicode/utf8"
"github.com/google/der-ascii/internal"
)
// A position describes a location in the input stream.
type position struct {
Offset int // offset, starting at 0
Line int // line number, starting a... | cmd/ascii2der/scanner.go | 0.53048 | 0.400046 | scanner.go | starcoder |
package bcnutil
import (
"github.com/bcndev/bytecoin-go"
)
func TreeHash(hashes []bytecoin.Hash) bytecoin.Hash {
count := len(hashes)
switch count {
case 0:
return bytecoin.Hash{}
case 1:
return hashes[0]
case 2:
return FastHash(hashes[0][:], hashes[1][:])
}
cnt := 1
for cnt*2 < count {
cnt *= 2
... | bcnutil/merkle.go | 0.51879 | 0.406214 | merkle.go | starcoder |
package basic
// DropLastTest is template to generate itself for different combination of data type.
func DropLastTest() string {
return `
func TestDropLast<FTYPE>(t *testing.T) {
list := []<TYPE>{1, 2, 3, 4, 5}
expectedList := []<TYPE>{1, 2, 3, 4}
actualList := DropLast<FTYPE>(list)
if !reflect.DeepEqual(expecte... | internal/template/basic/droplasttest.go | 0.620622 | 0.601067 | droplasttest.go | starcoder |
package cp
import "math"
type Transform struct {
a, b, c, d, tx, ty float64
}
func NewTransformIdentity() Transform {
return Transform{1, 0, 0, 1, 0, 0}
}
func NewTransform(a, c, tx, b, d, ty float64) Transform {
return Transform{a, b, c, d, tx, ty}
}
func NewTransformTranspose(a, c, tx, b, d, ty float64) Trans... | transform.go | 0.81582 | 0.644631 | transform.go | starcoder |
package bps
import (
"fmt"
"math"
"math/big"
"strings"
)
// Denominators for each parts
const (
DenomPPM int64 = 1000
DenomDeciBasisPoint = DenomPPM * 10
DenomHalfBasisPoint = DenomDeciBasisPoint * 5
DenomBasisPoint = DenomHalfBasisPoint * 2
DenomPercentage = DenomB... | bps/construct.go | 0.733833 | 0.409457 | construct.go | starcoder |
package geo
import (
"errors"
"fmt"
"math"
)
// BBox describes a simple bounding box.
type BBox interface {
Xcenter() float64
Ycenter() float64
Width() float64
Height() float64
Xmin() float64
Xmax() float64
Ymin() float64
Ymax() float64
Contains(x, y float64) bool
fmt.Stringer
}
type bbox struct {
xmin... | geo/bbox.go | 0.824991 | 0.449091 | bbox.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTFeatureTypeFilter962AllOf struct for BTFeatureTypeFilter962AllOf
type BTFeatureTypeFilter962AllOf struct {
BtType *string `json:"btType,omitempty"`
FeatureType *string `json:"featureType,omitempty"`
}
// NewBTFeatureTypeFilter962AllOf instantiates a new BTFeatureTyp... | onshape/model_bt_feature_type_filter_962_all_of.go | 0.674479 | 0.418697 | model_bt_feature_type_filter_962_all_of.go | starcoder |
package nn
import (
"fmt"
"reflect"
"time"
)
// Model is a neural network model.
type Model interface {
Layers() []Layer
Fit(x, y []*Tensor, epochs, batchSize int)
Predict([]*Tensor) []*Tensor
Build(Loss) error
}
// Sequential is a model that stack of layers.
type Sequential struct {
inputShape Shape
... | nn/model.go | 0.88462 | 0.485295 | model.go | starcoder |
package common
import (
"github.com/BoltApp/sleet"
)
// CURRENCIES maps the precision to the currency symbol used for lookups for some PsP providers that rely on these values for amount calculation
// One example is Braintree which uses its own amount structure requiring the precision of a currency
var CURRENCIES = ... | common/currency_list.go | 0.595728 | 0.564339 | currency_list.go | starcoder |
package oliviere_v6
/** oliviere_v6 is a helper to identify the shard and server on which a document exists.
It can be used to group together large BulkRequests in Bulks that hit only a specific shard.
This should be faster because the coordinator role will be simplified, as each bulk only hits one server and one sha... | oliviere-v6/oliviere.go | 0.765944 | 0.416085 | oliviere.go | starcoder |
package di
import (
"fmt"
"reflect"
)
type injector struct {
values map[reflect.Type]reflect.Value
}
// MARK: Struct's constructors
func Injector() IInjector {
injector := injector{values: make(map[reflect.Type]reflect.Value)}
return &injector
}
// MARK: IInjector's members
func (i *injector) Invoke(function i... | inject.go | 0.527073 | 0.496399 | inject.go | starcoder |
package deepcopy
type Copyable interface {
DeepCopy() interface{}
}
// DeepCopy will create a deep copy of the source object.
// Maps and slices will be taken into account when copying.
func DeepCopy(object interface{}) interface{} {
switch t := object.(type) {
case Copyable, *Copyable:
var value Copyable
if... | deepcopy.go | 0.591605 | 0.4831 | deepcopy.go | starcoder |
package fsm
import (
"fmt"
"sort"
)
// VisualizeType the type of the visualization
type VisualizeType string
const (
// GRAPHVIZ the type for graphviz output (http://www.webgraphviz.com/)
GRAPHVIZ VisualizeType = "graphviz"
// MERMAID the type for mermaid output (https://mermaid-js.github.io/mermaid/#/stateDiag... | visualizer.go | 0.610105 | 0.650509 | visualizer.go | starcoder |
package gjp
//--------------------
// IMPORTS
//--------------------
import (
"encoding/json"
"github.com/tideland/golib/errors"
"github.com/tideland/golib/stringex"
)
//--------------------
// DOCUMENT
//--------------------
// PathValue is the combination of path and value.
type PathValue struct {
Path str... | gjp/gjp.go | 0.709824 | 0.513668 | gjp.go | starcoder |
package find_minimum_in_rotated_sorted_array
/*
33. 搜索旋转排序数组 https://leetcode-cn.com/problems/search-in-rotated-sorted-array/
假设按照升序排序的数组在预先未知的某个点上进行了旋转。
( 例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] )。
搜索一个给定的目标值,如果数组中存在这个目标值,则返回它的索引,否则返回 -1 。
你可以假设数组中不存在重复的元素。
你的算法时间复杂度必须是 O(log n) 级别。
示例 1:
输入: nums = [4,5,6,... | solutions/find-minimum-in-rotated-sorted-array/d.go | 0.699973 | 0.514888 | d.go | starcoder |
// Build Instructions:
// go get "github.com/alexflint/go-arg"
// go get "robpike.io/filter"
// go build csvslim.go
// Usage:
// ./csvslim -c [COLUMN1,COLUMN2,...] < input.csv
// Where COLUMN is the number corresponding to that column (starting at 0).
// It can also include a comparison operator (> and <).
... | csvslim.go | 0.706697 | 0.409988 | csvslim.go | starcoder |
package schema
import (
"go/ast"
"go/token"
"go/types"
"github.com/bflad/tfproviderlint/helper/astutils"
)
const (
TypeNameStateUpgradeFunc = `StateUpgradeFunc`
)
// IsFuncTypeStateUpgradeFunc returns true if the FuncType matches expected parameters and results types
func IsFuncTypeStateUpgradeFunc(node ast.No... | vendor/github.com/bflad/tfproviderlint/helper/terraformtype/helper/schema/type_stateupgradefunc.go | 0.622689 | 0.417925 | type_stateupgradefunc.go | starcoder |
package sketchy
import (
_ "container/heap"
"fmt"
"math"
"math/rand"
"time"
)
var (
Pi = math.Pi
Tau = 2 * math.Pi
Sqrt2 = math.Sqrt2
Sqrt3 = math.Sqrt(3)
Smol = 1e-9
)
// Greatest common divisor
func Gcd(a int, b int) int {
if b == 0 {
return a
} else {
return Gcd(b, a%b)
}
}
// Linear inter... | util.go | 0.828315 | 0.520862 | util.go | starcoder |
package fpeUtils
import (
"fmt"
"math/big"
)
// Num constructs a big.Int from an array of uint16, where each element represents
// one digit in the given radix. The array is arranged with the most significant digit in element 0,
// down to the least significant digit in element len-1.
func Num(s []uint16, radix ui... | fpeUtils/numeral.go | 0.724188 | 0.624208 | numeral.go | starcoder |
package yasup
import (
crypto "crypto/rand"
"math/big"
"math/rand"
)
var zeroValueByte byte
//ByteInsert will append elem at the position i. Might return ErrIndexOutOfBounds.
func ByteInsert(sl *[]byte, elem byte, i int) error {
if i < 0 || i > len(*sl) {
return ErrIndexOutOfBounds
}
*sl = append(*sl, elem)... | byteSlices.go | 0.667581 | 0.450178 | byteSlices.go | starcoder |
// Package oracle handles schema and data migrations from oracle.
package oracle
import (
"regexp"
"github.com/cloudspannerecosystem/harbourbridge/common/constants"
"github.com/cloudspannerecosystem/harbourbridge/internal"
"github.com/cloudspannerecosystem/harbourbridge/schema"
"github.com/cloudspannerecosystem... | sources/oracle/toddl.go | 0.640523 | 0.429489 | toddl.go | starcoder |
package goforjj
//***************************************
// JSON data structure of plugin input.
// See plugin-actions.go about how those structs are managed.
// PluginReqData define the API data request to send to forjj plugins
type PluginReqData struct {
// Collection of Forjj flags requested by the plugin or giv... | plugin-req-data.go | 0.61115 | 0.426381 | plugin-req-data.go | starcoder |
package data
import (
"encoding/binary"
"math"
"math/big"
)
type DecimalTraits interface {
NumDigits() int
ByteWidth() int
IsSparse() bool
MaxPrecision() int
}
var (
Decimal28DenseTraits decimal28DenseTraits
Decimal38DenseTraits decimal38DenseTraits
Decimal28SparseTraits decimal28SparseTraits
Decimal38S... | internal/data/decimal_utils.go | 0.511961 | 0.446736 | decimal_utils.go | starcoder |
package raster
import "math"
func (g *Grmap) KernelFilter3(k []float64) *Grmap {
if len(k) != 9 {
return nil
}
r := NewGrmap(g.cols, g.rows)
r.Comments = append([]string{}, g.Comments...)
// Filter edge pixels with minimal code.
// Execution time per pixel is high but there are few edg... | lang/Go/image-convolution-2.go | 0.568655 | 0.478163 | image-convolution-2.go | starcoder |
package business
import "context"
// BusinessContract declares the service that can create new edge cluster, read, update
// and delete existing edge clusters.
type BusinessContract interface {
// CreateEdgeCluster creates a new edge cluster.
// context: Mandatory The reference to the context
// request: Mandatory... | services/business/contract.go | 0.577495 | 0.400398 | contract.go | starcoder |
package porousmedia
import "math"
// PorousMedium contains a set of parameters that
// describe the transport properties of porour media
// Currently only supporting Campbell (1974) parameterization
// ref: Campbell, G.S., 1974. A simple method for determining unsaturated conductivity from moisture retention data. So... | porousmedia/porousmedia.go | 0.573201 | 0.425546 | porousmedia.go | starcoder |
package tempfuncs
// Parsers is the mapping between parsing name and its functions.
var Parsers = map[string]StringParserFunc{
ParserFloat64: ParseFloat64,
ParserFloat32: ParseFloat32,
ParserInt64: ParseInt64,
ParserInt: ParseInt,
ParserInt32: ParseInt32,
ParserInt16: ParseInt16... | internal/tempfuncs/parser.go | 0.709523 | 0.425128 | parser.go | starcoder |
package contracts
import (
"context"
"sync"
"testing"
"github.com/adamluzsi/frameless"
"github.com/adamluzsi/frameless/contracts/assert"
"github.com/adamluzsi/frameless/doubles"
"github.com/adamluzsi/frameless/extid"
"github.com/adamluzsi/testcase"
"github.com/stretchr/testify/require"
)
type MetaAccessor s... | contracts/MetaAccessor.go | 0.617513 | 0.581362 | MetaAccessor.go | starcoder |
package statmodel
import (
"fmt"
"math"
)
// Focuser restricts a model to one parameter.
type Focuser interface {
NumParams() int
NumObs() int
Focus(int, []float64, []float64) RegFitter
LogLike(Parameter, bool) float64
Score(Parameter, []float64)
Hessian(Parameter, HessType, []float64)
}
// FitL1Reg fits the... | statmodel/l1reg.go | 0.8059 | 0.421909 | l1reg.go | starcoder |
package streams
// Node represents a topology node.
type Node interface {
// Name gets the node name.
Name() string
// AddChild adds a child node to the node.
AddChild(n Node)
// Children gets the nodes children.
Children() []Node
// Processor gets the nodes processor.
Processor() Processor
}
var _ = (Node)(&... | topology.go | 0.758242 | 0.435781 | topology.go | starcoder |
package conversion
import (
"fmt"
"github.com/galaco/Lambda/internal/model/valve/world"
"github.com/galaco/gosigl"
"github.com/galaco/lambda-core/material"
lambdaMesh "github.com/galaco/lambda-core/mesh"
lambdaModel "github.com/galaco/lambda-core/model"
)
func SolidToModel(solid *world.Solid) *lambdaModel.Model... | internal/renderer/conversion/solid.go | 0.674694 | 0.515986 | solid.go | starcoder |
package btree
//Index interface of data container of Node
type Index interface {
LessThan(Index) bool
EqualsTo(Index) bool
}
//Node Tree element struct
type Node struct {
Data Index
Score int
Edges [2]*Node
}
// Public
// Insert a node into the AVL tree.
func Insert(tree **Node, data Index) {
*tree, _ = inse... | btree/btree.go | 0.655005 | 0.641647 | btree.go | starcoder |
package lit
import (
"github.com/mb0/xelf/bfr"
"github.com/mb0/xelf/cor"
"github.com/mb0/xelf/typ"
)
// BreakIter is a special error value that can be returned from iterators.
// It indicates that the iteration should be stopped even though no actual failure occurred.
var BreakIter = cor.StrError("break iter")
//... | lit/lit.go | 0.80213 | 0.430088 | lit.go | starcoder |
package iso20022
// Details of the closing of the securities financing transaction.
type SecuritiesFinancingTransactionDetails3 struct {
// Unambiguous identification of the underlying securities financing trade as assigned by the instructing party. The identification is common to all collateral pieces (one or many)... | SecuritiesFinancingTransactionDetails3.go | 0.852874 | 0.469338 | SecuritiesFinancingTransactionDetails3.go | starcoder |
// Sample program that takes a stream of bytes and looks for the bytes
// “elvis” and when they are found, replace them with “Elvis”. The code
// cannot assume that there are any line feeds or other delimiters in the
// stream and the code must assume that the stream is of any arbitrary length.
// The solution cannot ... | topics/go/packages/io/example4/example4.go | 0.682468 | 0.581927 | example4.go | starcoder |
package apitest
import (
"fmt"
"net/http"
"github.com/stretchr/testify/assert"
)
// TestingT is an interface to wrap the native *testing.T interface, this allows integration with GinkgoT() interface
// GinkgoT interface defined in https://github.com/onsi/ginkgo/blob/55c858784e51c26077949c81b6defb6b97b76944/ginkgo... | assert.go | 0.823683 | 0.446314 | assert.go | starcoder |
package cryptoapis
import (
"encoding/json"
)
// BlockMinedDataItem Defines an `item` as one result.
type BlockMinedDataItem struct {
// Represents the specific blockchain protocol name, e.g. Ethereum, Bitcoin, etc.
Blockchain string `json:"blockchain"`
// Represents the name of the blockchain network used; bloc... | model_block_mined_data_item.go | 0.811825 | 0.452959 | model_block_mined_data_item.go | starcoder |
package geom
func NewBoundingBox(leftBottom *LngLat, rightTop *LngLat) *BoundingBox {
if leftBottom == nil || rightTop == nil {
return nil
}
return BoundingBox{LeftBottom: leftBottom, RightTop: leftBottom}.Extend(&BoundingBox{
LeftBottom: rightTop,
RightTop: rightTop,
})
}
fu... | go/pkg/mojo/geom/bounding_box.go | 0.875401 | 0.553324 | bounding_box.go | starcoder |
// x2j_valuesAt.go: Extract values from an arbitrary XML doc that are at same level as "key".
// Tag path can include wildcard characters.
package x2j
import (
"strings"
)
// ------------------- sweep up everything for some point in the node tree ---------------------
// ValuesAtTagPath - delive... | vendor/github.com/clbanning/x2j/x2j_valuesAt.go | 0.509032 | 0.418162 | x2j_valuesAt.go | starcoder |
package grpc
import (
"fmt"
"reflect"
"github.com/opencontainers/runtime-spec/specs-go"
)
func copyValue(to, from reflect.Value) error {
toKind := to.Kind()
fromKind := from.Kind()
if !from.IsValid() {
return nil
}
if toKind == reflect.Ptr {
// If the destination is a pointer, we need to allocate a ne... | vendor/github.com/kata-containers/agent/protocols/grpc/utils.go | 0.683842 | 0.452173 | utils.go | starcoder |
package cwe
var data = map[string]*Weakness{
"118": {
ID: "118",
Description: "The software does not restrict or incorrectly restricts operations within the boundaries of a resource that is accessed using an index or pointer, such as memory or files.",
Name: "Incorrect Access of Indexable Resour... | cwe/data.go | 0.663124 | 0.667415 | data.go | starcoder |
package tracetranslator
import (
"encoding/binary"
"go.opentelemetry.io/collector/consumer/pdata"
)
// UInt64ToByteTraceID takes a two uint64 representation of a TraceID and
// converts it to a []byte representation.
func UInt64ToTraceID(high, low uint64) pdata.TraceID {
traceID := [16]byte{}
binary.BigEndian.P... | translator/trace/big_endian_converter.go | 0.741861 | 0.683938 | big_endian_converter.go | starcoder |
package internal
import (
"fmt"
"time"
)
// Validator is used for testing.
type Validator interface {
Error(...interface{})
}
func validateStringField(v Validator, fieldName, v1, v2 string) {
if v1 != v2 {
v.Error(fieldName, v1, v2)
}
}
// WantMetric is a metric expectation. If Data is nil, then any data va... | vendor/github.com/newrelic/go-agent/internal/expect.go | 0.531939 | 0.400163 | expect.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.