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 points
import (
"fmt"
"math"
"github.com/go-spatial/tegola"
"github.com/go-spatial/tegola/basic"
"github.com/go-spatial/tegola/internal/log"
"github.com/go-spatial/tegola/maths"
)
type BoundingBox [4]float64
func (bb BoundingBox) PointAt(i int) maths.Pt {
if i >= 4 {
i = i % 4
}
switch i {
case ... | maths/points/bbox.go | 0.630116 | 0.555857 | bbox.go | starcoder |
package liblinear
import (
"fmt"
)
// Parameter contains the weights for solving
type Parameter struct {
c float64
eps float64 // Stopping criteria
MaxIters int
solverType *SolverType
weight []float64
weightLabel []int
P float64
InitSol []float64
}
// NewParameter co... | liblinear/parameter.go | 0.840062 | 0.437103 | parameter.go | starcoder |
package xlsx
import (
"fmt"
)
// Row represents a single Row in the current Sheet.
type Row struct {
Hidden bool // Hidden determines whether this Row is hidden or not.
Sheet *Sheet // Sheet is a reference back to the Sheet that this Row is within.
Height float64 // Height is the current he... | row.go | 0.739705 | 0.485844 | row.go | starcoder |
package gitdiff
import (
"encoding/csv"
"errors"
"io"
"code.gitea.io/gitea/modules/util"
)
const unmappedColumn = -1
const maxRowsToInspect int = 10
const minRatioToMatch float32 = 0.8
// TableDiffCellType represents the type of a TableDiffCell.
type TableDiffCellType uint8
// TableDiffCellType possible value... | services/gitdiff/csv.go | 0.55941 | 0.422147 | csv.go | starcoder |
// Package types declares the types and implements the algorithms for
// type inference for programs written using the asyncpi package.
package types
import (
"bytes"
"fmt"
"go.nickng.io/asyncpi"
)
// A Type represents a type in asyncpi.
// All types implement the Type interface.
type Type interface {
// Underl... | types/type.go | 0.821689 | 0.466116 | type.go | starcoder |
package exprcore
import (
"fmt"
"math"
"math/big"
"strconv"
"github.com/lab47/exprcore/syntax"
)
// Int is the type of a exprcore int.
type Int struct {
// We use only the signed 32 bit range of small to ensure
// that small+small and small*small do not overflow.
small int64 // minint32 <= small <= maxi... | exprcore/int.go | 0.720172 | 0.544014 | int.go | starcoder |
// fltimg provides image.Image implementations for the float32- and float64-image encodings of FITS.
package fltimg
import (
"encoding/binary"
"image"
"image/color"
"math"
)
const (
gamma = 1 / 2.2
)
type f32Gray float32
func (c f32Gray) RGBA() (r, g, b, a uint32) {
f := math.Pow(float64(c), gamma)
switch {... | fltimg/image.go | 0.754553 | 0.480662 | image.go | starcoder |
package adaptive
import (
"fmt"
"math"
"time"
)
// Sketches represents an set of Adaptive Count-Min Sketch algorithm (Ada-CMS),
// which is just CMS but with the update and query mechanisms adapted to use the pre-emphasis and de-emphasis mechanism.
type Sketches struct {
sketches []*ACMS
maxDuration time.Dura... | sketches.go | 0.613121 | 0.566078 | sketches.go | starcoder |
package cryptostring
import (
"errors"
"regexp"
"strings"
"github.com/darkwyrm/b85"
)
// This module contains the Go implementation of CryptoString. It is very similar to the
// implementation in PyAnselus, but also includes some special sauce to make interaction with
// Go's libsodium API, which is less than id... | cryptostring/cryptostring.go | 0.737442 | 0.410284 | cryptostring.go | starcoder |
// Note: this Lamport clock implementation is different than the algorithms you can find, notably Wikipedia or the
// original Serf implementation. The reason is lie to what constitute an event in this distributed system.
// Commonly, events happen when messages are sent or received, whereas in git-bug eve... | lamport/mem_clock.go | 0.73173 | 0.448547 | mem_clock.go | starcoder |
package geocube
import (
pb "github.com/airbusgeo/geocube/internal/pb"
)
//go:generate enumer -json -sql -type Compression -trimprefix Compression
// Compression defines how the data is compressed in the file
type Compression int32
// Supported compression
const (
CompressionNO Compression = iota
CompressionLOSS... | internal/geocube/consolidation_params.go | 0.636127 | 0.472988 | consolidation_params.go | starcoder |
package types
import . "github.com/shopspring/decimal"
var INT_ROUNDING_CONST = NewFromFloat(0.5)
func RoundToInt(valueDec Decimal) int32 {
roundRet := valueDec.Abs().Add(INT_ROUNDING_CONST).Floor()
if valueDec.LessThan(Zero) {
return int32(roundRet.Neg().IntPart())
}
return int32(roundRet.IntPart())
}
func R... | internal/types/operations_round.go | 0.7237 | 0.473536 | operations_round.go | starcoder |
package stats
import (
"time"
log "github.com/Sirupsen/logrus"
"github.com/signalfx/golib/datapoint"
"github.com/signalfx/metricproxy/dp/dpsink"
"golang.org/x/net/context"
)
// A Keeper contains datapoints that describe its state and can be reported upstream
type Keeper interface {
Stats() []*datapoint.Datapoi... | vendor/github.com/signalfx/metricproxy/stats/keeper.go | 0.598077 | 0.413122 | keeper.go | starcoder |
package termloop
// Entity provides a general Drawable to be rendered.
type Entity struct {
canvas Canvas
x int
y int
width int
height int
}
// NewEntity creates a new Entity, with position (x, y) and size
// (width, height).
// Returns a pointer to the new Entity.
func NewEntity(x, y, width, height i... | entity.go | 0.840684 | 0.570989 | entity.go | starcoder |
package dpll
import (
"fmt"
"math"
"strconv"
)
// Helpful constants
const (
VarUndef = Var(0)
LitUndef = Lit(0)
VarMax = math.MaxUint32 / 2
// unlike miniSAT a lit_Error analogue is unnecessary because go supports
// multiple return types.
)
// Var is a propositional variable. Variables begin at 1.
type ... | lit.go | 0.727975 | 0.409752 | lit.go | starcoder |
package datadog
import (
"encoding/json"
)
// SLOCorrectionResponseData The data object associated with the SLO correction
type SLOCorrectionResponseData struct {
Attributes *SLOCorrectionResponseAttributes `json:"attributes,omitempty"`
// The ID of the SLO correction
Id *string `json:"id,omitempty"`
// Should ... | api/v1/datadog/model_slo_correction_response_data.go | 0.761982 | 0.425904 | model_slo_correction_response_data.go | starcoder |
package cluster
import (
"sort"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
// UnstructuredSlice is a sortable slice of k8s unstructured.Unstructured objects
type UnstructuredSlice []*unstructured.Unstructured
// Sort sorts an UnstructuredSlice
func (u UnstructuredSlice) Sort() {
sort.Stable(u)
}
func... | pkg/cluster/sort.go | 0.637821 | 0.434161 | sort.go | starcoder |
package genetic
import (
"fmt"
"math/rand"
"time"
)
// Creature defines an element of a pool for the genetic algorithm
type Creature interface {
Fitness() float32
Mutate()
CrossOver(Creature) (Creature, Creature)
}
// Pool defines a pool containing creatures and for running a genetic algorithm
type Pool interf... | genetic.go | 0.674265 | 0.439627 | genetic.go | starcoder |
package polynomial
import (
"fmt"
"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
)
// MultilinearByValues represents a multilinear polynomial by its values
type MultilinearByValues struct {
Table []frontend.Variable
}
// AllocateMultilinear returns an empty multilinear wi... | snark/polynomial/multilinear.go | 0.750004 | 0.536616 | multilinear.go | starcoder |
package genericadapter
import (
amodel "SLALite/assessment/model"
"SLALite/model"
"math"
"time"
)
// all values are read-only but index and last
type mountCtx struct {
// metric series
values map[model.Variable][]model.MetricValue
// last known values for each variable
last map[string]model.MetricValue
// in... | assessment/monitor/genericadapter/interpolation.go | 0.625438 | 0.484563 | interpolation.go | starcoder |
package decoder
import (
"fmt"
"time"
"github.com/influxdata/telegraf/metric"
)
// U32 answers a directive for 32bit Unsigned Integers
func U32() ValueDirective {
return &valueDirective{value: new(uint32)}
}
// U64 answers a directive for 64bit Unsigned Integers
func U64() ValueDirective {
return &valueDirecti... | plugins/inputs/sflow/decoder/funcs.go | 0.81841 | 0.50116 | funcs.go | starcoder |
package enumerable
import (
"fmt"
"github.com/asynkron/gofun/set"
"golang.org/x/exp/constraints"
)
var (
emptySequenceError = fmt.Errorf("sequence is empty")
)
func FromSlice[T any](items []T) Enumerable[T] {
return &SliceEnumerable[T]{items}
}
func Min[T constraints.Ordered](enum Enumerable[T]) T {
min := F... | enumerable/functions.go | 0.64232 | 0.530601 | functions.go | starcoder |
package osgb
import (
"math"
)
type projection struct {
scaleFactor float64
geodeticTrueOrigin geographicCoord
mapTrueOrigin planeCoord
}
var (
nationalGridProjection = &projection{
scaleFactor: 0.9996012717,
geodeticTrueOrigin: geographicCoord{
lat: degreesToRadians(49.0),
lon: degreesToR... | projection.go | 0.648355 | 0.520496 | projection.go | starcoder |
package continuous
import (
"github.com/jtejido/ggsl/specfunc"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
smath "github.com/jtejido/stats/math"
"math"
"math/rand"
)
// Erlang distribution
// https://en.wikipedia.org/wiki/Erlang_distribution
type Erlang struct {
baseContinuousWithSource
shape in... | dist/continuous/erlang.go | 0.781956 | 0.446555 | erlang.go | starcoder |
package spec
import (
"fmt"
"strings"
"time"
)
type NodeCheck interface {
CheckNode(Node) error
}
/* ========================================================================== */
type HasCategoryNodeCheck struct{}
/* Nodes must specify a category. */
func (check HasCategoryNodeCheck) CheckNode(node Node) error... | request-manager/spec/node-check.go | 0.699665 | 0.438304 | node-check.go | starcoder |
package merkletree
import (
"crypto/sha256"
"math/bits"
)
// MTH returns the Merkle Tree Hash, given an ordered list of n inputs _D_.
// Reference implementation as per https://tools.ietf.org/html/rfc6962#section-2.1
func MTH(D [][]byte) [sha256.Size]byte {
n := uint64(len(D))
if n == 0 {
return sha256.Sum256(n... | vendor/github.com/codenotary/merkletree/mth.go | 0.712632 | 0.514949 | mth.go | starcoder |
package muxgo
import (
"encoding/json"
)
// InputSettingsOverlaySettings An object that describes how the image file referenced in url should be placed over the video (i.e. watermarking).
type InputSettingsOverlaySettings struct {
// Where the vertical positioning of the overlay/watermark should begin from. Defaul... | model_input_settings_overlay_settings.go | 0.870583 | 0.58522 | model_input_settings_overlay_settings.go | starcoder |
package main
import (
"fmt"
"text/template"
)
type templateData struct {
Datetime string
System systemInfo
Tests []*Test
}
var (
rootTmpl *template.Template
)
func init() {
rootTmpl = template.New("")
template.Must(rootTmpl.New("results").Funcs(template.FuncMap{
"formatTimeUs": formatTimeUs,
"form... | template.go | 0.746416 | 0.738315 | template.go | starcoder |
package space
import (
"github.com/arbori/population.git/population/rule"
)
type PointError struct {
msg string
}
func (pe PointError) Error() string {
return pe.msg
}
type Point struct {
X []int
Dim int
}
func NewPoint(x ...int) Point {
result := Point{}
result.Dim = len(x)
result.X = make([]int, resul... | space/space.go | 0.60871 | 0.485417 | space.go | starcoder |
package expression
import (
"github.com/pingcap/parser/ast"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
"github.com/zhihu/zetta/tablestore/mysql/sctx"
)
// Expression represents all scalar expression in SQL.
type Expression interface {
// Eval evaluates an expression through a row.
Eval... | tablestore/mysql/bexpression/expression.go | 0.73782 | 0.406921 | expression.go | starcoder |
package vm
import (
"time"
)
func MinusFunc(left, right func(Context) (Value, error)) func(Context) (Value, error) {
return func(ctx Context) (Value, error) {
leftValue, err := left(ctx)
if err != nil {
return Null(), err
}
rightValue, err := right(ctx)
if err != nil {
return Null(), err
}
swit... | vm/minus.go | 0.696681 | 0.593609 | minus.go | starcoder |
package parser
import "fmt"
// FunctionType stores the types of a function signature
type FunctionType struct {
Signature []DataType
Names []string
ReturnType DataType
}
var functionTypes map[string]FunctionType
// ParamStmt is the equivalent of [PARAM stmt.Name stmt.Type]
type ParamStmt struct {
*BasicSt... | old/parser/functions.go | 0.658418 | 0.558748 | functions.go | starcoder |
package tareekh
import (
"fmt"
"math"
"time"
)
// TimeZone uses whichever is the default unless specified
var TimeZone = ""
const (
// LeastPossibleDays in a month
LeastPossibleDays = 28
// DefaultDateFormat is the golang date format used by default
DefaultDateFormat = "2006-01-02"
)
// Now returns time.Now... | tareekh.go | 0.82425 | 0.471162 | tareekh.go | starcoder |
package sandbox
import (
"encoding/json"
)
// SandboxInsertAirStatsRequestDataTrafficStatsMap struct for SandboxInsertAirStatsRequestDataTrafficStatsMap
type SandboxInsertAirStatsRequestDataTrafficStatsMap struct {
S1Fast *SandboxDataTrafficStats `json:"s1.fast,omitempty"`
S1Minimum *SandboxDataTrafficStats `json... | openapi/sandbox/model_sandbox_insert_air_stats_request_data_traffic_stats_map.go | 0.723993 | 0.438845 | model_sandbox_insert_air_stats_request_data_traffic_stats_map.go | starcoder |
package hexgrid
import (
"math"
morton "github.com/gojuno/go.morton"
)
type Point struct {
x float64
y float64
}
type Hex struct {
q int64
r int64
}
type FractionalHex struct {
q float64
r float64
}
type Orientation struct {
f [4]float64
b [4]float64
startAngle float64
sinuses [6]... | hexgrid.go | 0.815343 | 0.473292 | hexgrid.go | starcoder |
package service
// Stability is a type that represents the relative stability of a service
// module
type Stability int
const (
// StabilityAlpha represents relative stability of the most immature and
// experimental service modules
StabilityAlpha Stability = iota
// StabilityBeta represents relative stability of... | pkg/service/types.go | 0.707708 | 0.55447 | types.go | starcoder |
package ln
import "math"
type Direction int
const (
Above Direction = iota
Below
)
type Function struct {
Function func(x, y float64) float64
Box Box
Direction Direction
}
func NewFunction(function func(x, y float64) float64, box Box, direction Direction) Shape {
return &Function{function, box, direct... | ln/function.go | 0.777933 | 0.527377 | function.go | starcoder |
package webmercator
import (
"math"
"log"
)
func PLonToX(lon float64) float64 {
rad := DegToRad(lon)
val := rad * EarthRadius
if val == math.NaN() {
log.Println("We have an issue with lon", lon,
"rad", rad,
"val = EarthRadius * rad", val,
)
return 0
}
return val
}
func PLatToY(lat float64) float... | maths/webmercator/pseudo.go | 0.671901 | 0.505127 | pseudo.go | starcoder |
package utils
import (
"fmt"
"strings"
"time"
)
// DateFormat pattern rules.
var datePatterns = []string{
// year
"Y", "2006", // A full numeric representation of a year, 4 digits Examples: 1999 or 2003
"y", "06", // A two digit representation of a year Examples: 99 or 03
// month
"m", "01", // Numeric r... | back-end/gin-idiary-appui/library/utils/time.go | 0.552057 | 0.546859 | time.go | starcoder |
package dominoes
type Domino [2]int
// MakeChain returns a chain and true if the dominoes in input
// can be arranged in a legal chain; otherwise it returns nil, false.
func MakeChain(input []Domino) (chain []Domino, ok bool) {
switch len(input) {
case 0:
return []Domino{}, true
case 1:
// A single is legal if... | exercises/dominoes/example.go | 0.666388 | 0.468912 | example.go | starcoder |
package tin
import (
"fmt"
"math"
"math/rand"
)
type DelaunayTriangle struct {
Anchor *QuadEdge
Next *DelaunayTriangle
pool *Pool
index int
}
func NewDelaunayTriangle(p *Pool) *DelaunayTriangle {
ptr := &DelaunayTriangle{pool: p, index: len(p.Values)}
p.Values = append(p.Values, ptr)
return ptr
}
fun... | delaunay.go | 0.567937 | 0.552721 | delaunay.go | starcoder |
package goquery
import (
"github.com/devacto/grobot/Godeps/_workspace/src/github.com/andybalholm/cascadia"
"github.com/devacto/grobot/Godeps/_workspace/src/golang.org/x/net/html"
)
// Filter reduces the set of matched elements to those that match the selector string.
// It returns a new Selection object for this su... | Godeps/_workspace/src/github.com/PuerkitoBio/goquery/filter.go | 0.81841 | 0.434401 | filter.go | starcoder |
package mlsbset
import (
"errors"
"fmt"
"math/big"
"github.com/cloudflare/circl/internal/conv"
)
// EltG is a group element.
type EltG interface{}
// EltP is a precomputed group element.
type EltP interface{}
// Group defines the operations required by MLSBSet exponentiation method.
type Group interface {
Ide... | math/mlsbset/mlsbset.go | 0.654011 | 0.476214 | mlsbset.go | starcoder |
package layout
import (
"math"
"fyne.io/fyne"
"fyne.io/fyne/theme"
)
// Declare conformity with Layout interface
var _ fyne.Layout = (*gridLayout)(nil)
type gridLayout struct {
Cols int
vertical, adapt bool
}
// NewAdaptiveGridLayout returns a new grid layout which uses columns when horizontal but ... | vendor/fyne.io/fyne/layout/gridlayout.go | 0.818447 | 0.473657 | gridlayout.go | starcoder |
package xmobilebackend
import (
"image"
"math"
"unsafe"
"github.com/tfriedel6/canvas/backend/backendbase"
"golang.org/x/mobile/gl"
)
func (b *XMobileBackend) Clear(pts [4][2]float64) {
b.activate()
// first check if the four points are aligned to form a nice rectangle, which can be more easily
// cleared us... | backend/xmobilebackend/fill.go | 0.584271 | 0.547041 | fill.go | starcoder |
package types
// NomsKind allows a TypeDesc to indicate what kind of type is described.
type NomsKind uint8
// All supported kinds of Noms types are enumerated here.
// The ordering of these (especially Bool, Float and String) is important for ordering of values.
const (
BoolKind NomsKind = iota
FloatKind
StringK... | go/store/types/noms_kind.go | 0.754373 | 0.471102 | noms_kind.go | starcoder |
package sod_shock_tube
import (
"math"
)
type State struct {
rho, p, u, gamma float64
}
func (s State) C() float64 {
return math.Sqrt(s.gamma * s.p / s.rho)
}
type SOD_Exact struct {
gamma float64
x_min, x_max, x0, x1, x2, x3, x4 float64
rho_middle float64
t ... | model_problems/Euler1D/sod_shock_tube/analytic_sod.go | 0.585812 | 0.487307 | analytic_sod.go | starcoder |
package internal
import (
"fmt"
"math"
"github.com/valyala/fastrand"
//"time"
)
// Basic statistics on data arrays
type BasicStats struct {
Min float32 // Minimum
Max float32 // Maximum
Mean float32 // Mean (average)
StdDev float32 // Standard deviation (norm 2, sigma)
Location float32 // Sele... | internal/stats.go | 0.666171 | 0.40439 | stats.go | starcoder |
package rtree
// BulkItem is an item that can be inserted for bulk loading.
type BulkItem struct {
Box Box
RecordID int
}
// BulkLoad bulk loads multiple items into a new R-Tree. The bulk load
// operation is optimised for creating R-Trees with minimal node overlap. This
// allows for fast searching.
func Bulk... | rtree/bulk.go | 0.82011 | 0.569673 | bulk.go | starcoder |
package mesh
import (
"bytes"
"github.com/adamcolton/geom/d3"
"github.com/adamcolton/geom/d3/shape/polygon"
"github.com/adamcolton/geom/d3/solid"
)
// Mesh defines a solid with polygon facets
type Mesh struct {
Pts []d3.Pt
Polygons [][]uint32
}
// Face tranlates the index values in a face into Pts.
func ... | d3/solid/mesh/mesh.go | 0.712232 | 0.60842 | mesh.go | starcoder |
package iso20022
// Execution of the redemption part, in a switch between investment funds or investment fund classes.
type SwitchRedemptionLegExecution4 struct {
// Unique technical identifier for the instance of the leg within a switch.
LegIdentification *Max35Text `xml:"LegId,omitempty"`
// Unique identifier f... | SwitchRedemptionLegExecution4.go | 0.848314 | 0.426083 | SwitchRedemptionLegExecution4.go | starcoder |
package semantic
import (
"fmt"
"strings"
"github.com/influxdata/flux/ast"
"github.com/pkg/errors"
)
// GenerateConstraints walks the graph and generates constraints between type vairables provided in the annotations.
func GenerateConstraints(node Node, annotator Annotator, importer Importer) (*Constraints, erro... | vendor/github.com/influxdata/flux/semantic/constraints.go | 0.713831 | 0.404743 | constraints.go | starcoder |
package hbook
// Bin2D models a bin in a 2-dim space.
type Bin2D struct {
XRange Range
YRange Range
Dist Dist2D
}
// Rank returns the number of dimensions for this bin.
func (Bin2D) Rank() int { return 2 }
// func (b *Bin2D) scaleW(f float64) {
// b.Dist.scaleW(f)
// }
func (b *Bin2D) fill(x, y, w float64) {... | hbook/bin2d.go | 0.934768 | 0.788461 | bin2d.go | starcoder |
package nlenc
import (
"fmt"
"unsafe"
)
// PutUint16 encodes a uint16 into b using the host machine's native endianness.
// If b is not exactly 2 bytes in length, PutUint16 will panic.
func PutUint16(b []byte, v uint16) {
if l := len(b); l != 2 {
panic(fmt.Sprintf("PutUint16: unexpected byte slice length: %d", l... | src/github.com/mdlayher/netlink/nlenc/int.go | 0.795022 | 0.418994 | int.go | starcoder |
package des
// The DES block size in bytes.
const BlockSize = 8
// Cipher is an instance of DES encryption.
type Cipher struct {
subkeys [16]uint64
}
// NewCipher creates and returns a new Cipher.
func NewCipher(key uint64) *Cipher {
c := new(Cipher)
c.generateSubkeys(key)
return c
}
func (c *Cipher) EncryptBl... | des/cipher.go | 0.825132 | 0.530297 | cipher.go | starcoder |
package txnbuild
import (
"github.com/stellar/go/support/errors"
"github.com/stellar/go/xdr"
)
// Preconditions is a container for all transaction preconditions.
type Preconditions struct {
// Transaction is only valid during a certain time range (units are seconds).
TimeBounds TimeBounds
// Transaction is valid... | txnbuild/preconditions.go | 0.682045 | 0.462473 | preconditions.go | starcoder |
package cbl
import (
"fmt"
"math"
"time"
)
func StartOfDay(t time.Time) time.Time {
return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
}
func EndOfDay(t time.Time) time.Time {
return time.Date(t.Year(), t.Month(), t.Day(), 23, 59, 59, int(time.Second)-1, t.Location())
}
// StartOfMonth mo... | date.go | 0.580114 | 0.539469 | date.go | starcoder |
package interpreter
import (
"github.com/google/cel-go/common/types/ref"
)
// EvalState tracks the values associated with expression ids during execution.
type EvalState interface {
// GetRuntimeExpressionId returns the runtime id corresponding to the
// expression id from the AST.
GetRuntimeExpressionId(exprId ... | interpreter/evalstate.go | 0.633183 | 0.435781 | evalstate.go | starcoder |
package examplefuzz
import (
"bufio"
"testing"
"github.com/thepudds/fzgen/fuzzer"
)
func Fuzz_A_PtrMethodNoArg(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
var r *A
fz := fuzzer.NewFuzzer(data)
fz.Fill(&r)
if r == nil {
return
}
r.PtrMethodNoArg()
})
}
func Fuzz_A_PtrMethodWithArg(f... | testdata/inject_ctor_false_exported_local_pkg.go | 0.511961 | 0.416203 | inject_ctor_false_exported_local_pkg.go | starcoder |
package state
// State represents the state of the rocket.
// Each bit of State represent a status (on/off).
type State uint8
type Item uint8
const (
I1 Item = 0b0000_0001 << iota
I2
I3
I4
I5
I6
I7
I8
)
func (s State) All() []bool {
slice := make([]bool, 8)
for i := 0; i < 8; i++ {
slice[i] = (s & (0b00... | data/packet/state/states.go | 0.894244 | 0.440951 | states.go | starcoder |
package indicators
import (
"errors"
"github.com/jaybutera/gotrade"
)
// An Average Directional Index (Adx), no storage, for use in other indicators
type AdxWithoutStorage struct {
*baseIndicatorWithFloatBounds
// private variables
periodCounter int
dx *DxWithoutStorage
currentDX float64
sumDX... | indicators/adx.go | 0.784113 | 0.445469 | adx.go | starcoder |
package bundle
import (
"errors"
"fmt"
"os"
"path/filepath"
"strings"
catalog "github.com/operator-framework/operator-sdk/internal/generate/olm-catalog"
"github.com/operator-framework/operator-sdk/internal/util/projutil"
"github.com/blang/semver"
"github.com/operator-framework/operator-registry/pkg/lib/bun... | cmd/operator-sdk/bundle/create.go | 0.679072 | 0.417153 | create.go | starcoder |
package semantic
import "github.com/google/gapid/gapil/ast"
var (
// BuiltinThreadGlobal represents the $Thread global variable.
BuiltinThreadGlobal = &Global{
Type: Uint64Type,
Named: "$Thread",
Default: Uint64Value(0),
}
// BuiltinGlobals is the list of all builtin globals.
BuiltinGlobals = []*Glo... | gapil/semantic/expression.go | 0.784402 | 0.505493 | expression.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_decision_stump
#include <capi/decision_stump.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type DecisionStumpOptionalParam struct {
BucketSize int
InputModel *dsModel
Labels *mat.Dense
Test *mat.Dense... | decision_stump.go | 0.619701 | 0.517632 | decision_stump.go | starcoder |
package blockchain
const reserveABI = `[
{
"constant": false,
"inputs": [],
"name": "enableTrade",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inpu... | blockchain/reserve_abi.go | 0.574156 | 0.426799 | reserve_abi.go | starcoder |
package order
import (
"github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/wallet/txrules"
"github.com/lightninglabs/pool/poolscript"
"github.com/lightninglabs/pool/terms"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
)... | order/tradingfees.go | 0.735071 | 0.631651 | tradingfees.go | starcoder |
package indexspace
import (
"errors"
"fmt"
)
/*
DoC = Domain of Computation.
DoC is the set of constraints defining the domain of computation
of a system of recurrence equations. The domain flow language defines
the domains for the system of recurrences, but individual recurrences
interact with the domain through ... | indexspace/constraintset.go | 0.672009 | 0.469703 | constraintset.go | starcoder |
package mat2
import (
"fmt"
"github.com/gmlewis/go3d/generic"
"github.com/gmlewis/go3d/vec2"
)
var (
// Zero holds a zero matrix.
Zero = T{}
// Ident holds an ident matrix.
Ident = T{
vec2.T{1, 0},
vec2.T{0, 1},
}
)
// T represents a 2x2 matrix.
type T [2]vec2.T
// From copies a T from a generic.T imp... | mat2/mat2.go | 0.846324 | 0.687466 | mat2.go | starcoder |
package gowindow
import (
"errors"
"math"
)
// Group6 is adjustable windows.
// https://en.wikipedia.org/wiki/Window_function#Adjustable_windows
type gaussianFunction struct {
SDt float64
L float64
HalfN float64
}
// G is Gaussian function
func (g *gaussianFunction) G(x float64) float64 {
return math.Ex... | window_group6.go | 0.918453 | 0.644561 | window_group6.go | starcoder |
// Package offset provides a helper converting byte offsets in a string into (line, column) pairs,
// where 'column' represents the number of runes from the beginning of the line.
package offset
import (
"fmt"
"sort"
"unicode/utf8"
)
var (
errInvalidLine = fmt.Errorf("invalid line number")
errInvalidColumn = ... | thirdparty/golang/parsers/util/offset/offset.go | 0.798383 | 0.575827 | offset.go | starcoder |
package tdigest
import (
"fmt"
"math"
"github.com/ajwerner/tdigest/internal/scale"
"github.com/ajwerner/tdigest/internal/tdigest"
)
// Sketch is an
type Sketch interface {
Reader
Recorder
}
// Recorder is the write interface to a Sketch.
type Recorder interface {
Add(mean, count float64)
}
// Reader provide... | tdigest.go | 0.779909 | 0.524029 | tdigest.go | starcoder |
package limits
import "fmt"
// Any storage is limited, so we have to be sure that data we are going to store would fit underlaying storage structures
// We could delegate this job to a specific storage plugin, but in this case it has to know too much about job/test descriptor etc
// Another approach is just fail on ... | pkg/storage/limits/limits.go | 0.740644 | 0.484807 | limits.go | starcoder |
package numerical
import (
"math"
"math/rand"
)
// A Vec3 is a 3-dimensional tuple of floats.
type Vec3 [3]float64
// NewVec3RandomNormal creates a random normal vector.
func NewVec3RandomNormal() Vec3 {
return Vec3{
rand.NormFloat64(),
rand.NormFloat64(),
rand.NormFloat64(),
}
}
// Add returns v + v1.
fu... | numerical/types.go | 0.881168 | 0.540499 | types.go | starcoder |
package bebop
import (
"github.com/stevebargelt/mygobot"
)
const (
// Flying event
Flying = "flying"
)
// Driver is gobot.Driver representation for the Bebop
type Driver struct {
name string
connection gobot.Connection
gobot.Eventer
}
// NewDriver creates an Bebop Driver.
func NewDriver(connection *Adap... | platforms/parrot/bebop/bebop_driver.go | 0.77373 | 0.438244 | bebop_driver.go | starcoder |
package form
import (
"fmt"
"io"
"io/ioutil"
"net/url"
"reflect"
"strconv"
"time"
)
// NewDecoder returns a new form decoder.
func NewDecoder(r io.Reader) *decoder {
return &decoder{r: r}
}
// decoder decodes data from a form (application/x-www-form-urlencoded).
type decoder struct {
r io.Reade... | vendor/github.com/ajg/form/decode.go | 0.691393 | 0.481332 | decode.go | starcoder |
package main
import "fmt"
type matrix [][]int
type sliceOfMatrix []matrix
// input scrambled puzzle
var inputPuzzle matrix
// the final required output puzzle
var outputPuzzle matrix
// the steps taken to reach from scrambled puzzle to required output puzzle
var solvedSteps sliceOfMatrix
// heap stores the list o... | algorithms/a_star/8_puzzle/8_puzzle.go | 0.541651 | 0.574604 | 8_puzzle.go | starcoder |
package isaac
import "unsafe"
// Isaac represents ISAAC random generator
type Isaac struct {
randrsl [256]uint32
randmem [256]uint32
randcnt uint32
aa uint32
bb uint32
cc uint32
}
// NewIsaac returns a new instance of ISAAC.
func NewIsaac() *Isaac {
return &Isaac{
randmem: [256]uint32{},
r... | isaac.go | 0.539105 | 0.474936 | isaac.go | starcoder |
package neuralnet
import "fmt"
type MultiLayerNN struct {
structure *NNStructure
wts WeightVector
L []int
}
func (nn *MultiLayerNN) PackedWts() []float64 {
return nn.wts
}
func (nn *MultiLayerNN) wt_idx(layer int, j int, i int) int {
if layer >= len(nn.L)-1 {
panic(fmt.Sprintf("layer index too ... | src/neuralnet/multilayer_nn.go | 0.636014 | 0.436982 | multilayer_nn.go | starcoder |
package v1alpha2
import (
v1alpha2 "github.com/seldonio/seldon-core/operator/api/v1alpha2"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// SeldonDeploymentLister helps list SeldonDeployments.
type SeldonDeploymentLister interface {
// List lists all Seld... | operator/client/listers/core/v1alpha2/seldondeployment.go | 0.52683 | 0.447641 | seldondeployment.go | starcoder |
package core
import (
"fmt"
"strings"
)
// Vision is
type Vision struct {
X1, Y1 int // the left and top point
X2, Y2 int // the left and top point
X, Y int
}
func (v *Vision) String() string {
return fmt.Sprintf("%-2d,%-2d %-2d,%-2d %-2d,%-2d\n", v.X1, v.Y1, v.X2, v.Y2, v.X, v.Y)
}
// GetVision is
func Get... | src/core/vision.go | 0.695338 | 0.527377 | vision.go | starcoder |
package main
import (
"fmt"
"reflect"
"strconv"
"strings"
"github.com/google/go-cmp/cmp"
"github.com/pkg/errors"
)
const (
expectationPathSeparator = "."
expectationSearchSign = "~"
)
// GetByPath returns value by exact path line
func GetByPath(m interface{}, pathLine string) (interface{}, error) {
re... | matchers.go | 0.71113 | 0.459137 | matchers.go | starcoder |
package main
import (
r "github.com/go-pathtracer/renderer"
)
func main() {
options := r.RenderingOptions{
Width: 800,
Height: 600,
//Fov: 90,
Fov: 54.36,
MaxDepth: 5,
}
sampler := r.PathTracer{}
//sampler := r.RayTracer{}
camera, scene := createCornellBoxScene2()
r.Render(sampler, option... | main/main.go | 0.720467 | 0.520679 | main.go | starcoder |
package flagutil
import (
// "flag"
"fmt"
"strconv"
"strings"
)
// Implements the `flag.Value` and `flag.Getter` interfaces. Useful for
// passing to `flag.Var()` or `flagutil.Var()`. Used by `flagutil.Flag()` to
// implement flags as slices.
type MultiArgInt struct {
Args []int
Del string
}
... | values.go | 0.82925 | 0.423279 | values.go | starcoder |
package gween
// Sequence represents a sequence of Tweens, executed one after the other.
type Sequence struct {
Tweens []*Tween
index int
}
// NewSequence returns a new Sequence object.
func NewSequence(tweens ...*Tween) *Sequence {
seq := &Sequence{
Tweens: tweens,
}
return seq
}
// Add adds one or more Twe... | sequence.go | 0.878158 | 0.409162 | sequence.go | starcoder |
package chesseract
import (
"errors"
"fmt"
"time"
)
var PackageVersion string
var errInvalidFormat = errors.New("error parsing grid position")
var errIllegalMove = errors.New("illegal move")
// A Colour defines a chesspiece's colour
type Colour int8
// The PieceType represents the type of a chesspiece
type Pie... | chesseract/chesseract.go | 0.846863 | 0.462655 | chesseract.go | starcoder |
package value
import (
"math"
"github.com/google/gapid/core/math/interval"
"github.com/google/gapid/gapis/replay/protocol"
)
// Bool is a Value of type TypeBool.
type Bool bool
// Get returns TypeBool and 1 if the Bool is true, otherwise 0.
func (v Bool) Get(PointerResolver) (ty protocol.Type, val uint64, onSta... | gapis/replay/value/values.go | 0.874761 | 0.531635 | values.go | starcoder |
package transform
// Transform definition functions can be used to build a list of transforms
// The transform functions chain must be started with a From... function
// FromConstant returns a constant value (specified by 'param')
func FromConstant(value interface{}) *ColumnTransforms {
return &ColumnTransforms{Tra... | plugin/transform/transform.go | 0.91407 | 0.785267 | transform.go | starcoder |
package storagetesting
import (
"bytes"
"context"
"fmt"
"path/filepath"
"reflect"
"runtime"
"testing"
"github.com/kopia/kopia/repo/storage"
)
// AssertGetBlock asserts that the specified storage block has correct content.
func AssertGetBlock(ctx context.Context, t *testing.T, s storage.Storage, block string,... | repo/internal/storagetesting/asserts.go | 0.514644 | 0.414188 | asserts.go | starcoder |
package heap
import (
"github.com/nsnikhil/go-datastructures/functions/comparator"
)
func heapify(curr int, c comparator.Comparator, maxHeapify bool, data []interface{}, indexes map[interface{}]int) error {
return heapUtil(curr, c, maxHeapify, data, indexes)
}
func heapUtil(curr int, c comparator.Comparator, maxHe... | heap/heapify.go | 0.589835 | 0.484319 | heapify.go | starcoder |
// Package set implements the rec.set command,
// i.e. set an specimen record value.
package set
import (
"strconv"
"strings"
"time"
"github.com/js-arias/biodv/cmdapp"
"github.com/js-arias/biodv/geography"
"github.com/js-arias/biodv/records"
"github.com/pkg/errors"
)
var cmd = &cmdapp.Command{
UsageLine: "... | cmd/biodv/internal/records/set/set.go | 0.610221 | 0.41567 | set.go | starcoder |
package radable
import (
"github.com/galaco/bsp"
"strings"
"github.com/galaco/vmf"
"github.com/galaco/bsp/primitives/plane"
"github.com/galaco/bsp/primitives/texdata"
"github.com/go-gl/mathgl/mgl32"
"github.com/galaco/bsp/primitives/visibility"
"github.com/galaco/bsp/primitives/texinfo"
"github.com/galaco/bsp... | radable/parse.go | 0.645008 | 0.477676 | parse.go | starcoder |
package boid
import (
. "github.com/franeklubi/tie"
. "github.com/franeklubi/SimpleVector"
)
type Boid struct {
Pos, Vel, Acc SVector
Radius, MaxF, MaxS float64
}
func GenBoid(pos SVector, maxF, maxS float64) (Boid) {
empty := SVector{0, 0, 0}
return Boid{
pos, empty, empty,
... | franeklubi/flocking/boid/boid.go | 0.811974 | 0.684795 | boid.go | starcoder |
package matrices
import (
"fmt"
"image"
"image/color"
)
func matrixToImage(yxM [][]uint32) *image.CMYK {
x0, y0 := 0, 0
x1, y1 := len(yxM[0]), len(yxM)
img := image.NewCMYK(image.Rect(x0, y0, x1, y1))
for row := 0; row < len(yxM); row++ {
for col := 0; col < len(yxM[0]); col++ {
colorEncoded := yxM[row][c... | pkg/chapter-1/matrices/rotate.go | 0.603932 | 0.412116 | rotate.go | starcoder |
package helper
import (
"time"
"github.com/ozontech/allure-go/pkg/framework/asserts_wrapper/wrapper"
)
type a struct {
t ProviderT
asserts wrapper.AssertsWrapper
}
// Equal ...
func (a *a) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
a.asserts.Equal(a.t, expected, actual, ... | pkg/framework/asserts_wrapper/helper/helper.go | 0.639286 | 0.469763 | helper.go | starcoder |
package output
import (
"sync/atomic"
"time"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/types"
)
//------------------------------------------------------------------------------
func init() {
Constructors[TypeInproc] = TypeSpec{
constructor... | lib/output/inproc.go | 0.560012 | 0.482002 | inproc.go | starcoder |
package glmki3d
import (
"github.com/go-gl/gl/v3.3-core/gl"
"github.com/go-gl/mathgl/mgl32"
"github.com/mki1967/go-mki3d/mki3d"
)
// references to the objects defining the shape and parameters of mki3d object
// GLBufTr contains references to GL triangle buffers for triangle shader's input attributes
type GLBufTr... | glmki3d/gl-data.go | 0.600071 | 0.519217 | gl-data.go | starcoder |
package check
import (
"github.com/errata-ai/vale/core"
"github.com/jdkato/regexp"
)
// A Check implements a single rule.
type Check struct {
Extends string
Code bool
Level int
Rule ruleFn
Scope core.Selector
}
// Definition holds the common attributes of rule definitions.
type Definition struct {
... | check/defintions.go | 0.66454 | 0.538377 | defintions.go | starcoder |
package base58
//go:generate go run genalphabet.go
// Decode decodes a modified base58 string to a byte slice.
func Decode(input string) []byte {
if len(input) == 0 {
return []byte("")
}
// The max possible output size is when a base58 encoding consists of
// nothing but the alphabet character at index 0 whic... | base58.go | 0.70202 | 0.546799 | base58.go | starcoder |
package arrowutil
import (
"fmt"
"regexp"
"github.com/influxdata/flux"
"github.com/influxdata/flux/array"
"github.com/influxdata/flux/semantic"
"github.com/influxdata/flux/values"
)
func NewArrayValue(arr array.Interface, typ flux.ColType) values.Array {
switch elemType := flux.SemanticType(typ); elemType {
... | internal/arrowutil/array_values.gen.go | 0.68342 | 0.569464 | array_values.gen.go | starcoder |
package leetcode
// 大数乘法
// 思路:拆解成num2的每一位和num1相乘的结果相加 时间复杂度:O(M N)。M,NM,N 分别为 num1 和 num2 的长度。 (PS:此为横式乘法)
// 用时4ms,击败70%用户,内存3.2MB,击败40%用户
// FIXME 优化方案,使用竖式乘法,https://leetcode-cn.com/problems/multiply-strings/solution/you-hua-ban-shu-shi-da-bai-994-by-breezean/
func multiply(num1 string, num2 string) string {
if l... | algs/leetcode/43_multiply.go | 0.500732 | 0.435781 | 43_multiply.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.