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 events
// A middleware event callback
type MiddlewareCallback func(string, ...interface{})
// Create a middleware callback adapter that adapts an event message to a single bool
func MiddlewareBoolify(callback func(string, bool)) MiddlewareCallback {
return func(channel string, data ...interface{}) {
var va... | middleware.go | 0.794704 | 0.47317 | middleware.go | starcoder |
package filecache implements a simple file cache.
A file cache can be created with either the NewDefaultCache() function to
get a cache with the defaults set, or NewCache() to get a new cache with
0 values for everything; you will not be able to store items in this cache
until the values are changed; sp... | doc.go | 0.692538 | 0.499329 | doc.go | starcoder |
package querybuilder
import (
"fmt"
"strconv"
"strings"
)
// QueryBuilder builds an insert query based on the number of arguments, how many values to insert,
// and an initial query defined as `insert into table_name(arg1, ..., argn) values %s;`.
// QueryBuilder maintains a map of queries that have already been bu... | app/gateways/db/querybuilder/query_builder.go | 0.781247 | 0.454654 | query_builder.go | starcoder |
package colorx
import (
"image/color"
"math"
)
// HSLA is an implementation of the HSV (Hue, Saturation and Value) color model. HSV is also known as HSB (Hue,
// Saturation, Brightness).
type HSLA struct {
H float64 // Hue ∈ [0, 360)
S float64 // Saturation ∈ [0, 1]
L float64 // Lightness ∈ [0, 1]
A float64 // ... | hsl.go | 0.858985 | 0.489931 | hsl.go | starcoder |
package data
import (
"image/color"
"math"
)
// g : Gravity constant
const g = 6.67428e-11
// Body : A celestial body, star or planet
type Body struct {
IsStar bool // IsStar : Is this the star of the system
Name string // Name : The name of the star/planet
Radius float64 // Radius : The... | internal/data/body.go | 0.836555 | 0.55923 | body.go | starcoder |
package utils
import (
"fmt"
"reflect"
"strconv"
"strings"
"time"
)
var TimeFormats = []string{"1/2/2006", "1/2/2006 15:4:5", "2006-1-2 15:4:5", "2006-1-2 15:4", "2006-1-2", "1-2", "15:4:5", "15:4", "15", "15:4:5 Jan 2, 2006 MST"}
// Decoder is the interface that wraps the basic Read method.
type Decoder interf... | utils/decode.go | 0.61855 | 0.473475 | decode.go | starcoder |
package epoch_processing
import (
. "github.com/protolambda/zrnt/eth2/beacon"
)
func ProcessEpochJustification(state *BeaconState) {
previousEpoch := state.PreviousEpoch()
currentEpoch := state.Epoch()
// epoch numbers are trusted, no errors
previousBoundaryBlockRoot, _ := state.GetBlockRoot(previousEpoch.GetSt... | eth2/beacon/epoch_processing/epoch_justification.go | 0.63375 | 0.400251 | epoch_justification.go | starcoder |
package push_relabel
import (
"container/heap"
"math"
"sort"
)
// Arc defines an edge along which flow may occur in a flow network. Arcs are
// created in pairs: every Arc on a Node with positive Capacity, Flow, and
// Priority, has a reciprocal Arc on the target Node with Capacity of zero, and
// negative Flow an... | allocator/push_relabel/push_relabel.go | 0.719778 | 0.584449 | push_relabel.go | starcoder |
package bulletproof
import (
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/coinbase/kryptology/pkg/core/curves"
)
// VerifyBatched verifies a given batched range proof.
// It takes in a list of commitments to the secret values as capV instead of a single commitment to a single point
// when compar... | pkg/bulletproof/range_batch_verifier.go | 0.801781 | 0.470068 | range_batch_verifier.go | starcoder |
package main
// ---------------------------------------------------------------------------------
// Representation of elements stored in the ledger
// ---------------------------------------------------------------------------------
// AssetType is use to check the type of an asset
type AssetType uint8
// Const re... | chaincode/ledger.go | 0.655777 | 0.425546 | ledger.go | starcoder |
package sequtil
import (
"github.com/dmiller/go-seq/iseq"
"reflect"
)
// DefaultCompareFn is a default function to use for comparisons.
// Handles identity, nils, strings, numerics, and things implementing the iseq.Comparer interface.
func DefaultCompareFn(k1 interface{}, k2 interface{}) int {
if k1 == k2 {
ret... | sequtil/compare.go | 0.664976 | 0.466299 | compare.go | starcoder |
package collect
import (
"github.com/sxyazi/go-collection/types"
"golang.org/x/exp/constraints"
"math"
"math/rand"
"reflect"
"sort"
"time"
)
/**
* Any slice
*/
func Each[T ~[]E, E any](items T, callback func(value E, index int)) {
for index, value := range items {
callback(value, index)
}
}
func Same[T... | functional.go | 0.693888 | 0.430387 | functional.go | starcoder |
package statistics
import (
"sort"
"github.com/ShoshinNikita/budget-manager/internal/db"
"github.com/ShoshinNikita/budget-manager/internal/pkg/money"
)
type SpentBySpendTypeDataset []SpentBySpendTypeData
type SpentBySpendTypeData struct {
SpendTypeName string `json:"spend_type_name"`
Spent money.M... | internal/web/pages/statistics/spent_by_spend_type.go | 0.596551 | 0.458955 | spent_by_spend_type.go | starcoder |
package hipathsys
import (
"fmt"
"github.com/shopspring/decimal"
"math"
"math/big"
"strconv"
)
var IntegerTypeSpec = newAnyTypeSpec("Integer")
type integerType struct {
baseAnyType
value int32
decimalValue DecimalAccessor
}
type IntegerAccessor interface {
NumberAccessor
Primitive() int32
}
func ... | hipathsys/integer_type.go | 0.681727 | 0.471406 | integer_type.go | starcoder |
package generation
import (
mat "github.com/nlpodyssey/spago/pkg/mat32"
)
// Hypotheses provides hypotheses data for a generation Scorer.
type Hypotheses struct {
config GeneratorConfig
beams []Hypothesis
worstScore mat.Float
}
// Hypothesis represents a single generation hypothesis, which is a sequenc... | pkg/nlp/transformers/generation/hypotheses.go | 0.744935 | 0.618608 | hypotheses.go | starcoder |
package ast
import (
"bytes"
"github.com/global-soft-ba/decisionTable/ast"
"reflect"
"strconv"
"time"
)
func checkDataTypePrecedence(typ1 ast.Node, typ2 ast.Node) reflect.Type {
if reflect.TypeOf(typ1) == reflect.TypeOf(typ2) {
return reflect.TypeOf(typ1)
}
switch typ1.(type) {
case Integer:
if reflect.T... | lang/sfeel/ast/DataTypes.go | 0.617282 | 0.414958 | DataTypes.go | starcoder |
package hplot
import (
"image/color"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
"gonum.org/v1/plot/vg/draw"
)
// VertLine draws a vertical line at X and colors the
// left and right portions of the plot with the provided
// colors.
type VertLine struct {
X float64
Line draw.L... | hplot/line.go | 0.82308 | 0.477737 | line.go | starcoder |
package cmd
import (
"fmt"
"regexp"
"strings"
"github.com/jaredbancroft/aoc2020/pkg/helpers"
"github.com/jaredbancroft/aoc2020/pkg/passport"
"github.com/spf13/cobra"
)
// day4Cmd represents the day4 command
var day4Cmd = &cobra.Command{
Use: "day4",
Short: "Advent of Code 2020 - Day 4: Passport Processing"... | cmd/day4.go | 0.652906 | 0.402128 | day4.go | starcoder |
package core
// Arguments represents a structured set of arguments passed to a predicate.
// It allows destructive operations to internal properties because it is
// guaranteed by Thunks that arguments objects are never reused as a function
// call creates a Thunk.
type Arguments struct {
positionals []Value
expand... | src/lib/core/arguments.go | 0.764012 | 0.464173 | arguments.go | starcoder |
package fake
import (
"strings"
)
// Character generates random character in the given language
func Character() string {
return f.Character()
}
// CharactersN generates n random characters in the given language
func CharactersN(n int) string {
return f.CharactersN(n)
}
// Characters generates from 1 to 5 charac... | lorem_ipsum.go | 0.714429 | 0.426859 | lorem_ipsum.go | starcoder |
package clust
import (
"fmt"
"math"
"math/rand"
"github.com/emer/etable/etensor"
"github.com/emer/etable/norm"
"github.com/emer/etable/simat"
"github.com/goki/ki/indent"
)
// Node is one node in the cluster
type Node struct {
Idx int `desc:"index into original distance matrix -- only valid for for t... | clust/clust.go | 0.661048 | 0.472927 | clust.go | starcoder |
// Package flexpolyline contains tools to encode and decode FlexPolylines
// This file defines data structures to store FlexPolylines
package flexpolyline
import (
"fmt"
"math"
)
// FlexPolyline specification version
const FormatVersion uint = 1
// Number of decimal digits after the comma
type Precision uint8
f... | golang/flexpolyline/data.go | 0.842798 | 0.626681 | data.go | starcoder |
package jsonmatch
import (
"errors"
"reflect"
)
// Canonicalization of types: For slices and maps the jsonmatch system uses
// []interface{} and map[string]interface{} respectively. The client may
// use any type alias they want for these types, but we need to convert them
// to their canoncial types while processi... | canonical_types.go | 0.616128 | 0.418697 | canonical_types.go | starcoder |
package types
import (
"fmt"
"github.com/src-d/go-mysql-server/sql"
dtypes "github.com/liquidata-inc/dolt/go/store/types"
)
type ValueToSql func(dtypes.Value) (interface{}, error)
type SqlToValue func(interface{}) (dtypes.Value, error)
type SqlType interface {
// NomsKind is the underlying NomsKind that this ... | go/libraries/doltcore/sqle/types/types.go | 0.589716 | 0.457985 | types.go | starcoder |
package iso20022
// Specifies rates.
type CorporateActionRate2 struct {
// Percentage of a cash distribution that will be withheld by a tax authority.
WithholdingTax *RateFormat1Choice `xml:"WhldgTax,omitempty"`
// Rate at which the income will be withheld by the jurisdiction in which the income was originally pa... | CorporateActionRate2.go | 0.806662 | 0.562056 | CorporateActionRate2.go | starcoder |
package store
import (
"strings"
"sync"
)
// Trigram represents a sequence of 3 strings.
type Trigram [3]string
// TrigramMap is a 3-dimensional map which represents the frequency of each trigram.
type TrigramMap map[string]map[string]map[string]int
// TrigramStore is represents the storage of trigrams found unti... | store/store.go | 0.713332 | 0.441613 | store.go | starcoder |
package exec
import "math"
func I32DivS(i1, i2 int32) int32 {
if i1 == math.MinInt32 && i2 == -1 {
panic(TrapIntegerOverflow)
}
return i1 / i2
}
func I64DivS(i1, i2 int64) int64 {
if i1 == math.MinInt64 && i2 == -1 {
panic(TrapIntegerOverflow)
}
return i1 / i2
}
func Fmax(z1, z2 float64) float64 {
if mat... | exec/numerics.go | 0.575588 | 0.448728 | numerics.go | starcoder |
package metrics
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"regexp"
"sort"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/log"
)
//------------------------------------------------------------------------------
func init() {
Constructors[TypeRename] = TypeSpec{
co... | lib/metrics/rename.go | 0.843283 | 0.636042 | rename.go | starcoder |
package values
import (
"bytes"
"fmt"
"strings"
"github.com/shanzi/gexpr/types"
)
type OperatorInterface interface {
// Arithmetic Operators
ADD(a, b Value) Value // +
SUB(a, b Value) Value // -
MUL(a, b Value) Value // *
DIV(a, b Value) Value // /
MOD(a, b Value) Value // %
// Binary Operators
AND(a, b... | values/operators.go | 0.653238 | 0.425187 | operators.go | starcoder |
package waktu
import (
"time"
)
// Time struct.
type Time struct {
time.Time
}
// LastDay func.
func LastDay() Time {
return Now().LastDay()
}
// Now func.
func Now() Time {
loc, _ := time.LoadLocation("Asia/Jakarta")
return Time{time.Now().In(loc)}
}
// Parse func.
func Parse(layout, value string) (Time, err... | time.go | 0.741112 | 0.551393 | time.go | starcoder |
package levenshtein2
import (
"crypto/md5"
"encoding/json"
"log"
"math"
)
type ParametricState struct {
shapeID uint32
offset uint32
}
func newParametricState() ParametricState {
return ParametricState{}
}
func (ps *ParametricState) isDeadEnd() bool {
return ps.shapeID == 0
}
type Transition struct {
de... | parametric_dfa.go | 0.710327 | 0.462473 | parametric_dfa.go | starcoder |
package main
import (
"image"
"image/color"
"github.com/disintegration/imaging"
"github.com/gdamore/tcell"
)
type subimage interface {
SubImage(r image.Rectangle) image.Image
}
type mapper struct {
img image.Image // Original image
width int // Width of terminal window
height int ... | mapper.go | 0.620966 | 0.445831 | mapper.go | starcoder |
package ionhash
import (
"math"
"testing"
"github.com/amzn/ion-go/ion"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func compareReaders(t *testing.T, reader1, reader2 ion.Reader) {
for hasNext(t, reader1, reader2) {
type1 := reader1.Type()
type2 := reader2.Type()
require.E... | testing_utilities.go | 0.699768 | 0.671962 | testing_utilities.go | starcoder |
package geometry
import (
"github.com/dlespiau/dax"
"github.com/dlespiau/dax/math"
)
// Box is a rectangular cuboid centered around (0, 0, 0) with sizes Width,
// Height and Depth on the X, Y and Z axis respectively. Some control over the
// tesselation of each face is given through the number of segments on each
/... | geometry/box.go | 0.814238 | 0.61607 | box.go | starcoder |
package gofun
import "fmt"
// Either represents one of two values.
type Either struct {
isRight bool
x interface{}
}
// EitherOrElse returns x if x is Either pointer, otherwise y.
func EitherOrElse(x interface{}, y *Either) *Either {
z, isOk := x.(*Either)
if isOk {
return z
} else {
... | either.go | 0.783368 | 0.455683 | either.go | starcoder |
package semantic
import "fmt"
// Visit invokes visitor for all the children of the supplied node.
func Visit(node Node, visitor func(Node)) {
Replace(node, func(n Node) Node { visitor(n); return n })
}
// Replace invokes visitor for all the children of the supplied node, replacing
// the node with the returned val... | gapil/semantic/visit.go | 0.520253 | 0.613873 | visit.go | starcoder |
package cl
import (
"math/big"
binaryquadraticform "github.com/getamis/alice/crypto/binaryquadraticform"
bqForm "github.com/getamis/alice/crypto/binaryquadraticform"
"github.com/getamis/alice/crypto/utils"
)
const (
// d = 90 Fig. 6 in paper. But a = 2^(40)*s. If we want to get 90, then we set it to be 90-40=5... | crypto/homo/cl/public_key.go | 0.641871 | 0.414425 | public_key.go | starcoder |
package astutil
import (
"bytes"
"fmt"
"go/ast"
"go/parser"
"go/printer"
"go/token"
"go/types"
"strconv"
"github.com/pkg/errors"
)
// Expr converts a template expression into an ast.Expr node.
func Expr(template string) ast.Expr {
expr, err := parser.ParseExpr(template)
if err != nil {
panic(err)
}
r... | directives/interp/astutil/astutil.go | 0.709925 | 0.402451 | astutil.go | starcoder |
package simpdf
import (
"fmt"
"math"
"strings"
"github.com/braddschick/simpdf/internal"
"github.com/braddschick/simpdf/pkg/models"
)
// Tables struct is a simple object for inclusion of a Table into the PDF document.
type Tables struct {
// Headers simple striing list of the headers with the alignment**content... | tables.go | 0.753104 | 0.463444 | tables.go | starcoder |
package statsd
import (
"math"
"strconv"
"strings"
"github.com/atlassian/gostatsd"
)
const (
histogramThresholdsTagPrefix = "gsd_histogram:"
histogramThresholdsSeparator = "_"
)
func latencyHistogram(timer gostatsd.Timer, bucketLimit uint32) map[gostatsd.HistogramThreshold]int {
result := emptyHistogram(time... | pkg/statsd/latency_histogram.go | 0.669096 | 0.45847 | latency_histogram.go | starcoder |
package condition
import (
"fmt"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
jmespath "github.com/jmespath/go-jmespath"
)
//------------------------------------------------------------------------------
func init() {
Constructo... | lib/condition/jmespath.go | 0.670285 | 0.788746 | jmespath.go | starcoder |
package bsegtree
import (
"github.com/templexxx/bsegtree/internal/bitmap"
)
type BSTree struct {
count int // Number of intervals
root *node
// interval stack
base []Interval
// Min value of all intervals
min uint64
// Max value of all intervals
max uint64
// sum of To - from in intervals.
totalDeltas u... | bstree.go | 0.718199 | 0.422088 | bstree.go | starcoder |
package main
import (
// "fmt"
"math"
"strconv"
"strings"
)
// Coord is a combination of two integers that represent a coordiate.
type Coord struct {
x, y int
}
// GetManhattanDistance will get the Manhattan Distance for two points
func GetManhattanDistance(inputString string) (lowestDistance int) {
intersecti... | shart/day03/day03.go | 0.622115 | 0.481088 | day03.go | starcoder |
package curve
import (
"github.com/syahrul12345/secp256k1/fieldelement"
"github.com/syahrul12345/secp256k1/utils"
"github.com/bitherhq/go-bither/common/hexutil"
)
type testpoint struct {
X *fieldelement.FieldElement
Y *fieldelement.FieldElement
A fieldelement.FieldElement
B fieldelement.FieldElement
}
//NewT... | curve/curveTestClasses.go | 0.731059 | 0.445107 | curveTestClasses.go | starcoder |
package xnumber
import (
"fmt"
"math"
)
// Accuracy represents an accuracy with some compare methods in accuracy.
type Accuracy func() float64
// NewAccuracy creates an Accuracy, using eps as its accuracy.
func NewAccuracy(eps float64) Accuracy {
return func() float64 {
return eps
}
}
// Equal checks eq betwe... | xnumber/xnumber.go | 0.890264 | 0.727903 | xnumber.go | starcoder |
package common
import (
"encoding/binary"
"encoding/hex"
"fmt"
"math"
)
// Sha1Hash is a convenient wrapper around the 20 bytes that make up a sha1Hash. Should be passed
// by pointer to avoid making copies.
type Sha1Hash struct {
Data [20]byte // The underlying data in the hash. Should not be manipulated direct... | common/sha1Hash.go | 0.812086 | 0.452838 | sha1Hash.go | starcoder |
package arrow
import (
"fmt"
"strconv"
"time"
)
type BooleanType struct{}
func (t *BooleanType) ID() Type { return BOOL }
func (t *BooleanType) Name() string { return "bool" }
func (t *BooleanType) String() string { return "bool" }
// BitWidth returns the number of bits required to store a single elemen... | go/arrow/datatype_fixedwidth.go | 0.912397 | 0.442456 | datatype_fixedwidth.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPStatementThrow1080 struct for BTPStatementThrow1080
type BTPStatementThrow1080 struct {
BTPStatement269
BtType *string `json:"btType,omitempty"`
Value *BTPExpression9 `json:"value,omitempty"`
}
// NewBTPStatementThrow1080 instantiates a new BTPStatementThrow1080 o... | onshape/model_btp_statement_throw_1080.go | 0.709824 | 0.469763 | model_btp_statement_throw_1080.go | starcoder |
package lzma
// treeCodec encodes or decodes values with a fixed bit size. It is using a
// tree of probability value. The root of the tree is the most-significant bit.
type treeCodec struct {
probTree
}
// makeTreeCodec makes a tree codec. The bits value must be inside the range
// [1,32].
func makeTree... | vendor/github.com/ulikunitz/xz/lzma/treecodecs.go | 0.643105 | 0.463748 | treecodecs.go | starcoder |
package p18
import (
"fmt"
"hash/fnv"
"math"
c "s13g.com/euler/common"
)
// --- Day 18: Settlers of The North Pole ---
// http://adventofcode.com/2018/day/18
func Solve(input string) (string, string) {
lines := c.SplitByNewline(input)
return c.ToString(solveA(parseWorld(lines))), c.ToString(solveB(parseWorld(l... | go/aoc18/p18/p18.go | 0.589007 | 0.434881 | p18.go | starcoder |
package convnet
import (
"encoding/json"
"math"
"math/rand"
)
// Vol is the basic building block of all data in a net.
// it is essentially just a 3D volume of numbers, with a
// width (sx), height (sy), and depth (depth).
// it is used to hold data for all filters, all volumes,
// all weights, and also stores all... | vol.go | 0.688259 | 0.603815 | vol.go | starcoder |
package treemap
import (
"math"
)
// Position is an X, Y, Z tuple.
type Position struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Z float64 `json:"z,omitempty"`
}
// Add returns the 3D vector p + q
func (p Position) Add(q Position) Position {
return Position{X: p.X + q.X, Y: p.Y + q.Y, Z: p.Z + q.Z}
}
// Til... | position.go | 0.895211 | 0.435721 | position.go | starcoder |
package elastic
import (
"fmt"
"math"
"gopkg.in/olivere/elastic.v3"
"github.com/unchartedsoftware/veldt/binning"
"github.com/unchartedsoftware/veldt/tile"
)
// Bivariate represents an elasticsearch implementation of the bivariate tile.
type Bivariate struct {
tile.Bivariate
}
// GetQuery returns the tiling q... | generation/elastic/bivariate.go | 0.820037 | 0.458531 | bivariate.go | starcoder |
package interval
import (
"fmt"
"math"
"github.com/influxdata/flux/values"
)
const (
MaxTime = math.MaxInt64
MinTime = math.MinInt64
)
type Bounds struct {
start values.Time
stop values.Time
// index keeps track of how many windows have been added or subtracted as additional
// windows are added to or sub... | interval/bounds.go | 0.802865 | 0.558989 | bounds.go | starcoder |
package chart
import (
"math/rand"
"time"
)
var (
// Sequence contains some sequence utilities.
// These utilities can be useful for generating test data.
Sequence = &sequence{}
)
type sequence struct{}
// Float64 produces an array of floats from [start,end] by optional steps.
func (s sequence) Float64(start, ... | vendor/github.com/nicholasjackson/bench/vendor/github.com/wcharczuk/go-chart/sequence.go | 0.693265 | 0.605537 | sequence.go | starcoder |
package diff
import (
"github.com/antzucaro/matchr"
)
// VanillaLCS computes the reserences between two strings using the LCS
// algortithm from https://en.m.wikipedia.org/wiki/Longest_common_subsequence_problem
func VanillaLCS(l, r []string) Result {
return diffLCS(l, r)
}
func diffLCS(l, r []string, refiners ...... | diff/lcs.go | 0.557123 | 0.406862 | lcs.go | starcoder |
package rendering
import (
. "github.com/balpha/go-unicornify/unicornify/core"
"math"
)
// ------- ShadowCastingTracer -------
type ShadowCastingTracer struct {
WorldView, LightView WorldView
SourceTracer, LightTracer Tracer
LightProjection SphereProjection
Lighten, Darken float64
}
f... | unicornify/rendering/shadowcastingtracer.go | 0.81134 | 0.424293 | shadowcastingtracer.go | starcoder |
package dpsort
import "sort"
const insertionSortThreshold = 27
func dataequal(data sort.Interface, i, k int) bool {
return !(data.Less(i, k) || data.Less(k, i))
}
func insertionSort(data sort.Interface, lo, hi int) {
for i := lo + 1; i <= hi; i++ {
for k := i; k > lo && data.Less(k, k-1); k-- {
... | sorts/dpsort/sort.go | 0.708112 | 0.435301 | sort.go | starcoder |
package ast
import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/pkg/errors"
"strings"
)
// NotExprNode implements logical NOT on a wrapped boolean expression
type NotExprNode struct {
expr BoolNode
}
func (node *NotExprNode) Accept(visitor Visitor) {
visitor.VisitNotExprNodeStart(node)
node.expr.Acc... | storage/ast/node_expr.go | 0.767864 | 0.491639 | node_expr.go | starcoder |
package iso20022
// Specifies the details of the first leg in a two leg transaction process.
type TwoLegTransactionDetails1 struct {
// Specifies the date/time on which the trade was executed.
TradeDate *TradeDate1Choice `xml:"TradDt,omitempty"`
// Unambiguous identification of the reference assigned in the first... | TwoLegTransactionDetails1.go | 0.848941 | 0.495911 | TwoLegTransactionDetails1.go | starcoder |
package shape
import "github.com/oakmound/oak/v3/alg/intgeom"
// Condense finds a set of rectangles that covers the shape.
// Used to return a minimal set of rectangles in an appropriate time.
func Condense(sh Shape, w, h int) []intgeom.Rect2 {
condensed := []intgeom.Rect2{}
remainingSpaces := make(map[intgeom.Poin... | shape/condense.go | 0.553988 | 0.4474 | condense.go | starcoder |
package testutil
import (
"testing"
"github.com/stretchr/testify/require"
datatransfer "github.com/filecoin-project/go-data-transfer"
"github.com/filecoin-project/go-data-transfer/encoding"
)
//go:generate cbor-gen-for FakeDTType
// FakeDTType simple fake type for using with registries
type FakeDTType struct {... | testutil/fakedttype.go | 0.738763 | 0.478224 | fakedttype.go | starcoder |
package types
// Uints is a slice of uint.
type Uints []uint
// Reset the slice.
func (s *Uints) Reset() {
*s = []uint{}
}
// Add new elements to the slice.
func (s *Uints) Add(values ...uint) {
*s = append(*s, values...)
}
// Contains say if "s" contains "values".
func (s Uints) Contains(values ...uint) bool {
... | uints.go | 0.765944 | 0.44897 | uints.go | starcoder |
package fsm
import (
"reflect"
"golang.org/x/xerrors"
)
// VerifyStateParameters verifies if the Parameters for an FSM specification are sound
func VerifyStateParameters(parameters Parameters) error {
environmentType := reflect.TypeOf(parameters.Environment)
stateType := reflect.TypeOf(parameters.StateType)
sta... | fsm/verification.go | 0.623148 | 0.521654 | verification.go | starcoder |
package should
import "github.com/smartystreets/assertions"
var (
Equal = assertions.ShouldEqual
NotEqual = assertions.ShouldNotEqual
AlmostEqual = assertions.ShouldAlmostEqual
NotAlmostEqual = assertions.ShouldNotAlmostEqual
EqualJSON = assertions.ShouldEqualJSON
Resemble ... | vendor/github.com/smartystreets/assertions/should/should.go | 0.580114 | 0.559591 | should.go | starcoder |
package api
import (
"fmt"
"image"
"image/color"
"io/ioutil"
"math"
"math/rand"
"github.com/fogleman/gg"
"golang.org/x/image/font/opentype"
)
// Params defines the parameters used to draw a vizualization
type Params struct {
N int
Max int32
Filename string
Format ImageFormat
Width int
Height ... | api/draw.go | 0.665519 | 0.468547 | draw.go | starcoder |
package grid
import (
"math"
"github.com/forestgiant/eff"
"github.com/forestgiant/eff/util"
)
// Grid eff.Shape container that places children in a grid pattern
type Grid struct {
eff.Shape
rows int
cols int
padding int
cellHeight int
}
func (g *Grid) rectForIndex(index int) eff.Rect {
round... | component/grid/grid.go | 0.83363 | 0.556761 | grid.go | starcoder |
// Package images provides template functions for manipulating images.
package images
import (
"github.com/disintegration/gift"
"github.com/spf13/cast"
)
// Increment for re-generation of images using these filters.
const filterAPIVersion = 0
type Filters struct{}
// Overlay creates a filter that overlays src at... | resources/images/filters.go | 0.897831 | 0.722099 | filters.go | starcoder |
package models
import (
"strings"
)
// MapZebedeeDataToSearchDataImport Performs default mapping of zebedee data to a SearchDataImport struct.
// It also optionally takes a limit which truncates the keywords to the desired amount. This value can be -1 for no
// truncation.
func MapZebedeeDataToSearchDataImport(zebed... | models/mapper.go | 0.749087 | 0.435241 | mapper.go | starcoder |
package gostat
import "fmt"
// bucket keep track of segmented data
type bucket struct {
// used later for statistics
sum, sum2 float64
// center and width of bucket. Bucket contains from c - w/2 to c+ w/2, both ends INCLUDED.
// There is always at leaset a data point on each end, unless the bucket is empty.
c, w... | bucket.go | 0.713132 | 0.591635 | bucket.go | starcoder |
package mod256
// The ExpBase type contains lookup tables allowing fast repeated modular exponentiation with the same base value.
type ExpBase struct {
h, l [16]Residue
}
// FromResidue initialises ExpBase from a residue.
// It performs 224 squarings and 22 multiplications.
func (z *ExpBase) FromResidue(x *Residue)... | exp.go | 0.581065 | 0.414069 | exp.go | starcoder |
package parser
import (
"fmt"
"strings"
)
type NodeType string
const (
// PathNode is a string segment of a path.
PathNode NodeType = "Path"
// ListNode is an array element of a path.
ListNode NodeType = "List"
// ObjectNode is the final Node in a path, what is being referenced.
ObjectNode NodeType = "Object... | pkg/mutation/path/parser/node.go | 0.687525 | 0.425546 | node.go | starcoder |
package main
import (
"math"
"github.com/gmlewis/pt/examples/utron/enclosure"
"github.com/gmlewis/pt/examples/utron/half-magnet"
"github.com/gmlewis/pt/examples/utron/half-utron"
. "github.com/gmlewis/pt/pt"
)
// All dimensions in mm
const (
utronEdge = 50.0
magnetHeight = 25.4
innerGap = 70.0
magne... | examples/utron/main.go | 0.671147 | 0.40251 | main.go | starcoder |
package paxi
// Quorum records each acknowledgement and check for different types of quorum satisfied
type Quorum struct {
size int
acks map[ID]bool
zones map[int]int
nacks map[ID]bool
}
// NewQuorum returns a new Quorum
func NewQuorum() *Quorum {
q := &Quorum{
size: 0,
acks: make(map[ID]bool),
zones: ... | quorum.go | 0.680879 | 0.401219 | quorum.go | starcoder |
package ln
import "math"
type Mesh struct {
Box Box
Triangles []*Triangle
Tree *Tree
}
func NewMesh(triangles []*Triangle) *Mesh {
box := BoxForTriangles(triangles)
return &Mesh{box, triangles, nil}
}
func (m *Mesh) Compile() {
if m.Tree == nil {
shapes := make([]Shape, len(m.Triangles))
for i,... | ln/mesh.go | 0.704872 | 0.488893 | mesh.go | starcoder |
package vm
import (
"fmt"
"github.com/goby-lang/goby/compiler/bytecode"
)
type callObject struct {
method *MethodObject
receiverPtr int
argCount int
argSet *bytecode.ArgSet
argIndex int
lastArgIndex int
callFrame *normalCallFrame
sourceLine int
}
func newCallObject(receiver Object... | vm/call_object.go | 0.63375 | 0.406273 | call_object.go | starcoder |
package entoas
import (
"entgo.io/ent/entc/gen"
"github.com/bionicstork/contrib/entoas/serialization"
)
type (
// Edge wraps a gen.Edge and denotes an edge to be returned in an operation response. It recursively defines
// edges to load on the gen.Type the wrapped edge is pointing at.
Edge struct {
*gen.Edge
... | entoas/edges.go | 0.713831 | 0.515681 | edges.go | starcoder |
package core
import (
"fmt"
"math"
)
type Shape interface {
IntersectCircle(c Circle) bool
IntersectRectangle(r Rectangle) bool
Pos() (x, y float64)
String() string
}
func NewDefSingleTarget(ind int, typ TargettableType) AttackPattern {
var arr [TargettableTypeCount]bool
arr[typ] = true
return AttackPattern... | pkg/core/hitbox.go | 0.72952 | 0.446012 | hitbox.go | starcoder |
package gocountry
import (
"fmt"
"strings"
)
// Country defines and stores the known identifiers for a given country.
type Country struct {
full string
codeTwo string
codeThree string
num string
}
// Full returns the full name of the country.
func (c *Country) Full() string {
return c.full
}
// ... | country.go | 0.710226 | 0.607634 | country.go | starcoder |
package common
import (
"encoding/json"
"fmt"
"strconv"
)
// Label is attached to, and identifies a claim (or a set of claims). A label
// can be either an integer or a string.
type Label struct {
intValue int
strValue string
isInt bool
}
// Value returns the value of the label an interface{}. The underlyin... | common/label.go | 0.801159 | 0.465691 | label.go | starcoder |
package mockstore
import (
"bytes"
"time"
)
type expectedDelete struct {
inputToken string
returnErr error
}
type expectedFind struct {
inputToken string
returnB []byte
returnFound bool
returnErr error
}
type expectedCommit struct {
inputToken string
inputB []byte
inputExpiry time.Time
ret... | mockstore/store.go | 0.644896 | 0.438905 | store.go | starcoder |
package stringset
// A stringset is a map from a string to an empty struct. We choose empty structs because they have a size
// of zero and make it fairly clear that this shouldn't be treated as a map.
type StringSet map[string]struct{}
// New creates a new stringset with the specified strings in it
func New(strings ... | stringset/stringset.go | 0.837753 | 0.44565 | stringset.go | starcoder |
package avl
import (
"fmt"
"github.com/pkg/errors"
"github.com/alexander-yu/stream/quantile/order"
)
// Node represents a node in an AVL tree.
type Node struct {
left *Node
right *Node
val float64
height int
size int
}
func max(x int, y int) int {
if x > y {
return x
}
return y
}
// NewNode i... | quantile/ost/avl/node.go | 0.847542 | 0.544801 | node.go | starcoder |
package data
import (
"math"
)
// Interface defines methods required for type wishing to use SpacialTree.
type Interface interface {
// get the n-dimensional location of an item
Location() []float64
}
// SpacialTree defines the interface for use in n-dimension space
// partitoning trees, such as k-d trees and qua... | data/tree.go | 0.701611 | 0.500244 | tree.go | starcoder |
package cmd
import (
"testing"
"github.com/gomodule/redigo/redis"
"github.com/stretchr/testify/assert"
)
//ExampleList the key command
//mapList record the key and value of the operation
type ExampleList struct {
mapList map[string][]string
conn redis.Conn
}
//NewExampleList create list object
func NewExamp... | tools/autotest/cmd/list.go | 0.611498 | 0.667757 | list.go | starcoder |
package alphavantage
import (
"fmt"
"io"
"net/http"
"net/url"
"github.com/pkg/errors"
)
// NewTimeSeriesService https://www.alphavantage.co/documentation/#time-series-data
// This suite of APIs provide realtime and historical global equity data in 4 different temporal resolutions:
// (1) daily, (2) weekly, (3) ... | stockTimeSeries.go | 0.751648 | 0.457561 | stockTimeSeries.go | starcoder |
package model
import (
"container/list"
"math"
)
// DeduplicateVerticesNoSorting is an O(n*n) algorithm for deduplicating an array of vertices, and returning a copy of the array containing only the unique vertices.
// This function does not modify the supplied array of vertices.
// Note 1: the order that vertices a... | model/utilsvertex.go | 0.832509 | 0.749729 | utilsvertex.go | starcoder |
package av
import (
"fmt"
"math"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/stat"
"github.com/matrix-profile-foundation/go-matrixprofile/util"
)
type AV string
const (
Default AV = "default" // Default is the default annotation vector of all ones
Complexity AV = "complexity" // Complexity is the ... | av/annotation_vector.go | 0.72662 | 0.476458 | annotation_vector.go | starcoder |
package nepcal
import (
"fmt"
"io"
"text/tabwriter"
)
// helper to generate a formatted string representation of a
// calendar for any given date.
type calendar struct {
// state that determines how far along the iteration process
// we have gotten, in generating the calendar for the month
iter int
// the tim... | nepcal/calendar.go | 0.739986 | 0.427337 | calendar.go | starcoder |
package yijing
import (
"fmt"
"io"
"github.com/bitfield/qrand"
)
// Tails represents a coin toss resulting in tails.
const Tails = 2
// Heads represents a coin toss resulting in heads.
const Heads = 3
// Coin represents the result of a coin toss (Heads or Tails).
type Coin int
// CoinSet represents the three C... | yijing.go | 0.776623 | 0.495606 | yijing.go | starcoder |
package dynamicstruct
// A FieldType indicates which member of the Field union struct should be used
// and how it should be serialized.
type FieldType uint8
const (
// UnknownType is the default field type.
UnknownType FieldType = iota
// BinaryType indicates that the field carries an opaque binary blob.
BinaryT... | field.go | 0.551815 | 0.506164 | field.go | starcoder |
package local
import "sort"
type totalStat struct {
TotalUpload uint64
TotalDownload uint64
}
type highestStat struct {
HighestLastSecondBps uint64
HighestLastMinuteBps uint64
HighestLastTenMinutesBps uint64
HighestLastHourBps uint64
}
type lastStat struct {
LastSecondBps uint64
LastMinu... | local/stat.go | 0.516595 | 0.467332 | stat.go | starcoder |
// Package f64s provides common operations on float64 slices.
package f64s
import (
"fmt"
)
var (
errLength = fmt.Errorf("f64s: length mismatch")
errSortedIndices = fmt.Errorf("f64s: indices not sorted")
errDuplicateIndices = fmt.Errorf("f64s: duplicate indices")
)
// Filter creates a slice with al... | sliceop/f64s/f64s.go | 0.756178 | 0.561455 | f64s.go | starcoder |
package draw2d
import (
"math"
)
var (
CurveRecursionLimit = 32
CurveCollinearityEpsilon = 1e-30
CurveAngleToleranceEpsilon = 0.01
)
/*
The function has the following parameters:
approximationScale :
Eventually determines the approximation accuracy. In practice we need to transform points from t... | draw2d/curves.go | 0.760917 | 0.739105 | curves.go | starcoder |
package packet
import (
"bufio"
"bytes"
"encoding/binary"
"fmt"
"math"
)
// Packet is allows the reading of properties out of raw binary formats
// Each method on this interface when called will scan forwards through the bytes specified.
type Packet interface {
// Bool read a bool value from the packet
// Adva... | packet.go | 0.797399 | 0.487734 | packet.go | starcoder |
package raph
import (
"math"
)
// Dijkstra instance is used to compute Dijkstra algorithm.
type Dijkstra struct {
G Graph
Q []string
Costs map[string]float64
PredsV map[string]string
PredsE map[string]string
}
// NewDijkstra initializes and returns a Dijkstra instance with graph g.
func NewDijkstra(... | raph/dijkstra.go | 0.795618 | 0.4917 | dijkstra.go | starcoder |
package advent
import (
"math"
"strings"
)
var _ Problem = &extendedPolymerization{}
type extendedPolymerization struct {
dailyProblem
}
func NewExtendedPolymerization() Problem {
return &extendedPolymerization{
dailyProblem{
day: 14,
},
}
}
func (e *extendedPolymerization) Solve() interface{} {
input... | internal/advent/day14.go | 0.785432 | 0.683053 | day14.go | starcoder |
package hard100
type MedianFinderOfZeroToHundred struct {
Arr []int
Length int
n int
}
func NewMedianFinderOfZeroToHunder() *MedianFinderOfZeroToHundred {
m := new(MedianFinderOfZeroToHundred)
m.Arr = make([]int, 101)
m.Length = 101
return m
}
func (m *MedianFinderOfZeroToHundred) FindKth(k int) int {... | hard100/find_median_from_data_stream_initnite.go | 0.569733 | 0.516839 | find_median_from_data_stream_initnite.go | starcoder |
package gohotdraw
import (
_ "fmt"
"math"
)
type Dimension struct {
Width int
Height int
}
type Point struct {
X int
Y int
}
type Rectangle struct {
X int
Y int
Width int
Height int
}
func NewRectangle() *Rectangle {
return &Rectangle{0, 0, 0, 0}
}
func NewRectangleFromRect(r *Rectangle) *R... | code/gohotdraw-master/util.go | 0.575946 | 0.58166 | util.go | starcoder |
package accumcolor
import "image/color"
// An AccumNRGBA is a color.Color that supports accumulation of
// non-alpha-premultiplied RGBA color values. An invariant maintained
// by all methods is that either all fields are zero or each of R, G,
// B, and A divided by Tally produces a value in the range [0, 255].
type... | accumcolor/accumcolor.go | 0.808294 | 0.665781 | accumcolor.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.