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 pcapng
import (
"bytes"
"encoding/hex"
"fmt"
"net"
"strings"
"github.com/bearmini/pcapng-go/pcapng/blocktype"
"github.com/bearmini/pcapng-go/pcapng/linktype"
"github.com/bearmini/pcapng-go/pcapng/optioncode"
"github.com/pkg/errors"
)
/*
4.2. Interface Description Block
An Interface Description ... | pcapng/interface_description_block.go | 0.680879 | 0.565599 | interface_description_block.go | starcoder |
package expression
import (
"fmt"
"regexp"
"gopkg.in/sqle/sqle.v0/sql"
)
type Comparison struct {
BinaryExpression
ChildType sql.Type
}
func (*Comparison) Type() sql.Type {
return sql.Boolean
}
func (*Comparison) Name() string {
return ""
}
type Equals struct {
Comparison
}
func NewEquals(left sql.Expres... | sql/expression/comparison.go | 0.531209 | 0.496216 | comparison.go | starcoder |
package term
import (
"github.com/gdamore/tcell"
)
// Flushable contains content that can be flushed to a screen.
type Flushable interface {
// FlushTo flushes content to the screen. It should only write to the
// areas of the screen that it has been assigned to (generally via being
// Resizable).
FlushTo(scree... | promq/term/split.go | 0.62601 | 0.481393 | split.go | starcoder |
package render
import (
"image"
"image/draw"
"sync"
"github.com/oakmound/oak/v2/alg/floatgeom"
)
// A CompositeR is equivalent to a CompositeM for Renderables instead of
// Modifiables. CompositeRs also implements Stackable.
type CompositeR struct {
LayeredPoint
toPush []Renderable
toUndraw []Renderab... | render/compositeR.go | 0.751101 | 0.513546 | compositeR.go | starcoder |
package coldata
// zeroedNulls is a zeroed out slice representing a bitmap of size BatchSize.
// This is copied to efficiently set all nulls.
var zeroedNulls [(BatchSize-1)/8 + 1]byte
// filledNulls is a slice representing a bitmap of size BatchSize with every
// single bit set.
var filledNulls [(BatchSize-1)/8 + 1]... | pkg/sql/exec/coldata/nulls.go | 0.761893 | 0.568116 | nulls.go | starcoder |
package adf
import (
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/stat"
"github.com/yungtrizzle/ridge"
"math"
)
const (
LPenalty = 0.0001 // L penalty to pass to ridge regression
DefaultPValue = -3.45 // Test p-value threshold
)
// An instance of an ADF test
type ADF struct {
Series []float64 ... | adf.go | 0.731155 | 0.454109 | adf.go | starcoder |
package conditions
import (
"math"
"sort"
"yunion.io/x/onecloud/pkg/monitor/tsdb"
)
type Reducer interface {
Reduce(series *tsdb.TimeSeries) *float64
GetType() string
}
// queryReducer reduces an timeseries to a float
type queryReducer struct {
// Type is how the timeseries should be reduced.
// Ex: avg, su... | pkg/monitor/alerting/conditions/reducer.go | 0.695958 | 0.407392 | reducer.go | starcoder |
package world
// GameMode represents a game mode that may be assigned to a player. Upon joining the world, players will be
// given the default game mode that the world holds.
// Game modes specify the way that a player interacts with and plays in the world.
type GameMode interface {
// AllowsEditing specifies if a p... | server/world/game_mode.go | 0.745491 | 0.711313 | game_mode.go | starcoder |
package geometry
import (
"github.com/schidstorm/engine/gls"
"github.com/schidstorm/engine/math32"
"math"
)
// NewSphere creates a sphere geometry with the specified radius and number of radial segments in each dimension.
func NewSphere(radius float64, widthSegments, heightSegments int) *Geometry {
return NewSph... | geometry/sphere.go | 0.863204 | 0.709397 | sphere.go | starcoder |
package walk
import "vimagination.zapto.org/javascript"
// Handler is used to process javascript types
type Handler interface {
Handle(javascript.Type) error
}
// HandlerFunc wraps a func to implement Handler interface
type HandlerFunc func(javascript.Type) error
// Handle implements the Handler interface
func (h ... | walk/walk.go | 0.553264 | 0.518241 | walk.go | starcoder |
package physics
import (
"math"
"github.com/gen2brain/raylib-go/raylib"
)
// ShapeType type
type ShapeType int
// Physics shape types
const (
// Circle type
CircleShape ShapeType = iota
// Polygon type
PolygonShape
)
// Polygon type
type Polygon struct {
// Current used vertex and normals count
VertexCount... | physics/physics.go | 0.790369 | 0.684027 | physics.go | starcoder |
package ebml
import (
"bytes"
"encoding/binary"
"errors"
"io"
"math"
"strings"
"time"
)
const (
// DateEpochInUnixtime is the Unixtime of EBML date epoch.
DateEpochInUnixtime = 978307200
// SizeUnknown is the longest unknown size value.
SizeUnknown = 0xffffffffffffff
)
// ErrInvalidFloatSize means that a... | value.go | 0.588298 | 0.403743 | value.go | starcoder |
package tsm1
// String encoding uses snappy compression to compress each string. Each string is
// appended to byte slice prefixed with a variable byte length followed by the string
// bytes. The bytes are compressed using snappy compressor and a 1 byte header is used
// to indicate the type of encoding.
import (
... | tsdb/engine/tsm1/string.go | 0.839471 | 0.481332 | string.go | starcoder |
package aic_package
import (
"image"
"image/color"
_ "embed"
imgManip "github.com/TheZoraiz/ascii-image-converter/image_manipulation"
"github.com/golang/freetype/truetype"
"github.com/fogleman/gg"
)
/*
Unlike createImageToSave(), this function is optimized to maintain original image dimensions and shrink asc... | aic_package/create_ascii_gif.go | 0.724481 | 0.516961 | create_ascii_gif.go | starcoder |
package internal
import (
"fmt"
"math"
"strconv"
"gopkg.in/yaml.v3"
"github.com/lyraproj/dgo/dgo"
)
type (
// intVal is an int64 that implements the dgo.Value interface
intVal int64
integerType int
exactIntegerType int64
integerRange struct {
min int64
max int64
inclusive bool
}
)
/... | internal/integer.go | 0.758332 | 0.441252 | integer.go | starcoder |
package dataframe
import (
"encoding/json"
"fmt"
"strconv"
"go.starlark.net/starlark"
)
// rowIter iterates a DataFrame's body one row at a time, with an optional ordering
type rowIter struct {
idx int
df *DataFrame
limit int
// optionally, a rowIter can have an order to change how the rows are traverse... | dataframe/row_iter.go | 0.723993 | 0.482917 | row_iter.go | starcoder |
package main
import (
"fmt"
"sort"
"strconv"
"strings"
)
var locations []string
var distanceMap = make(map[string]map[string]int)
func main() {
distances := strings.Split(Input, "\n")
for _, distanceString := range distances {
location1, location2, distance := ParseDistance(distanceString)
if _, ok := d... | 9.go | 0.533397 | 0.432363 | 9.go | starcoder |
Contains functions that prepare data for output.
*/
package summarize
import (
"fmt"
"regexp"
"sort"
"strconv"
"strings"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/klog/v2"
"k8s.io/test-infra/triage/utils"
)
// jsonOutput represents the output as it will be written to the JSON.
type jsonOutput struct {
Cl... | triage/summarize/output.go | 0.604632 | 0.403684 | output.go | starcoder |
package main
import (
"errors"
"fmt"
"log"
)
type Node struct {
Value string
Data string
Left *Node
Right *Node
}
func (n *Node) findMax(parent *Node) (*Node, *Node) {
if n.Right == nil {
return n, parent
}
return n.Right.findMax(n)
}
func (n *Node) replaceNode(parent, replacement *Node) error {
if n... | binary-search-tree/binary-search-tree.go | 0.508056 | 0.48121 | binary-search-tree.go | starcoder |
package nlp
import (
"container/heap"
"fmt"
"gonum.org/v1/gonum/mat"
)
// Comparer is a type of function that compares two *mat.Vector types and
// returns a value indicating how similar they are.
type Comparer func(a, b mat.Vector) float64
// CosineSimilarity calculates the distance between the angles of 2 vec... | vendor/github.com/james-bowman/nlp/utils.go | 0.866937 | 0.601008 | utils.go | starcoder |
package sim
import (
"fmt"
"image/color"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
"gonum.org/v1/plot/vg/draw"
)
// New2DPlot creates new plot of the simulation from the three data sources:
// model: idealised model values
// measure: measurement values
... | sim/plot.go | 0.779112 | 0.424531 | plot.go | starcoder |
package som
import (
"math/rand"
"sort"
)
type DataVector []float64
// DataSet is in-memory collection of data vectors.
type DataSet struct {
Vectors []DataVector
}
// Add adds vector to this data-set.
func (ds *DataSet) Add(vector DataVector) {
if len(ds.Vectors) != 0 && ds.Width() != len(vector) {
panic("da... | som/dataset.go | 0.673299 | 0.698477 | dataset.go | starcoder |
// Package webassert contains test helpers to the check the rooms web pages for certain aspects.
package webassert
import (
"fmt"
"net/http"
"net/url"
"testing"
"github.com/PuerkitoBio/goquery"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mindeco.de/http/tester"
)
type Loca... | web/webassert/asserts.go | 0.698844 | 0.44354 | asserts.go | starcoder |
package main
/*
You're minding your own business on a ship at sea when the overboard alarm goes off!
You rush to see if you can help. Apparently, one of the Elves tripped and accidentally
sent the sleigh keys flying into the ocean!
Before you know it, you're inside a submarine the Elves keep ready for situations like... | day1/day1.go | 0.555435 | 0.484441 | day1.go | starcoder |
package resize
import (
"image"
"image/color"
)
type colorArray [4]float32
// converter allows to retrieve
// a colorArray for points of an image
type converter interface {
at(x, y int) colorArray
}
type genericConverter struct {
src image.Image
}
func replicateBorder1d(x, min, max int) int {
if x < min {
x... | imaging/resize/converter.go | 0.666497 | 0.418519 | converter.go | starcoder |
package vector
// IntVector is a specialization of Vector that hides the wrapping of Elements around ints.
type IntVector struct {
Vector;
}
// Init initializes a new or resized vector. The initial length may be <= 0 to
// request a default length. If initial_len is shorter than the current
// length of the Int... | src/pkg/container/vector/intvector.go | 0.853699 | 0.803019 | intvector.go | starcoder |
package toms
import (
"github.com/dreading/gospecfunc/machine"
"github.com/dreading/gospecfunc/utils"
"math"
)
// DEBYE1 calculates the Debye function of order 1, defined as
// ∫ 0 to x of t/(exp(t)-1) dt] / x
// The code uses Chebyshev expansions with the coefficients
// given to 20 decimal places
func DEBYE1(... | integrals/internal/toms/debye.go | 0.621426 | 0.427935 | debye.go | starcoder |
package rda
import (
"encoding/json"
"fmt"
"io"
"sort"
"strconv"
"strings"
"github.com/pkg/errors"
)
// rdaGraph is the representation that the RDA API uses for describing a graph/template.
type rdaGraph struct {
ID string `json:",omitempty"`
DefaultNodeID string `json:"defaultNodeId"`
Ed... | rda/pkg/rda/graph.go | 0.694199 | 0.423041 | graph.go | starcoder |
package feature
import "fmt"
/*
Feature represents a property that can be observed
*/
type Feature interface {
Name() string
Valid(interface{}) (bool, error)
}
/*
DiscreteFeature represents a property that can be observed and that can only
take a value among a finite set.
*/
type DiscreteFeature struct {
name ... | feature/feature.go | 0.79732 | 0.411288 | feature.go | starcoder |
package nplot
import (
"github.com/hneemann/nplot/vg"
"time"
)
var _ Ticker = &DenseTimeTicks{}
// DenseTimeTicks creates tick marks as dense as possible
type DenseTimeTicks struct {
// Format is used to format the date
Format string
// Time takes a float64 value and converts it into a time.Time.
// If nil, U... | denseTimeTicker.go | 0.712632 | 0.642671 | denseTimeTicker.go | starcoder |
package square
// Contains all information related to a single order to process with Square, including line items that specify the products to purchase. Order objects also include information on any associated tenders, refunds, and returns. All Connect V2 Transactions have all been converted to Orders including all a... | square/model_order.go | 0.77907 | 0.404596 | model_order.go | starcoder |
package sintervaltree
import "sort"
// // Intervals slice of Interval
// type Intervals []Interval
type node struct {
mid Endpoint // middle point
left *node // left child, intervals fully left of mid
right *node // right child, intervals fully right of mid
overlapAsecLeft []Interval // those interva... | DSA/intervaltree/static/node.go | 0.610105 | 0.490541 | node.go | starcoder |
package vec3
import (
"fmt"
math "github.com/ungerik/go3d/fmath"
"github.com/ungerik/go3d/generic"
)
var (
// Zero holds a zero vector.
Zero = T{}
// UnitX holds a vector with X set to one.
UnitX = T{1, 0, 0}
// UnitY holds a vector with Y set to one.
UnitY = T{0, 1, 0}
// UnitZ holds a vector with Z set ... | vec3/vec3.go | 0.871311 | 0.620277 | vec3.go | starcoder |
package mysql
import (
"errors"
"fmt"
"strconv"
"strings"
"time"
)
// For MySQL DATE type
type Date struct {
Year int16
Month, Day byte
}
func (dd Date) String() string {
return fmt.Sprintf("%04d-%02d-%02d", dd.Year, dd.Month, dd.Day)
}
// True if date is 0000-00-00
func (dd Date) IsZero() bool {
ret... | third_party/github.com/ziutek/mymysql/mysql/types.go | 0.596668 | 0.467879 | types.go | starcoder |
package day3
import (
"fmt"
"strconv"
"strings"
)
const (
up = iota
right
down
left
)
type instruction struct {
direction int
distance int
}
type wire []instruction
type input struct {
wire1 wire
wire2 wire
}
type pos [2]int
type intersection struct {
pos pos
steps1 int
steps2 int
}
// Run run... | day3/day3.go | 0.632503 | 0.490053 | day3.go | starcoder |
package cubecode
// conversion table: cubecode → unicode (i.e. using the cubecode code point as index)
// cubecode is a small subset of unicode containing selected characters from the Basic Latin, Latin-1 Supplement,
// Latin Extended-A and Cyrillic blocks, that can be represented in 8-bit space. characters included f... | pkg/protocol/cubecode/conversion.go | 0.625781 | 0.576304 | conversion.go | starcoder |
package loader
import (
"context"
"regexp"
"github.com/xo/xo/models"
xo "github.com/xo/xo/types"
)
func init() {
Register(&Loader{
Driver: "oracle",
Mask: ":%d",
GoType: OracleGoType,
Schema: models.OracleSchema,
Procs: models.OracleProcs,
ProcPar... | loader/oracle.go | 0.550124 | 0.536313 | oracle.go | starcoder |
package wx200
import (
"errors"
"math"
"time"
)
func combineDecimal(b [2]byte) uint8 {
return uint8(b[0]*10 + b[1])
}
// subDecimal takes a byte b and extracts a subset of bits and returns the decimal number they represent
// For example subDecimal('\xf0', 1, 5) would take byte '\xf0' (represented as binary 1111... | pkg/wx200/utils.go | 0.800302 | 0.52074 | utils.go | starcoder |
package collections
import (
"fmt"
"sort"
"strings"
"unicode"
)
// StringArray is an implementation of a array of class String objects.
type StringArray []String
// Strings convert array of String objects to an array of regular go string.
func (as StringArray) Strings() []string { return ToStrings(as) }
// Str ... | collections/string_array.go | 0.734596 | 0.512571 | string_array.go | starcoder |
package samples
func init() {
sampleDataProposalCreateOperation[47] = `{
"expiration_time": "2016-09-02T14:55:00",
"extensions": [],
"fee": {
"amount": 2368424,
"asset_id": "1.3.0"
},
"fee_paying_account": "1.2.298",
"proposed_ops": [
{
"op": [
14,
{
"asset_to... | gen/samples/proposalcreateoperation_47.go | 0.58166 | 0.452596 | proposalcreateoperation_47.go | starcoder |
package types
import (
"github.com/jcmturner/gofork/encoding/asn1"
)
// Reference: https://www.ietf.org/rfc/rfc4120.txt
// Section: 5.2.6
/*
AuthorizationData
-- NOTE: AuthorizationData is always used as an OPTIONAL field and
-- should not be empty.
AuthorizationData ::= SEQUENCE OF SEQUENCE {
... | vendor/github.com/elastic/beats/vendor/gopkg.in/jcmturner/gokrb5.v7/types/AuthorizationData.go | 0.614625 | 0.407039 | AuthorizationData.go | starcoder |
package packed
import (
"github.com/gzg1984/golucene/core/util"
)
// Direct wrapping of 8-bits values to a backing array.
type Direct8 struct {
*MutableImpl
values []byte
}
func newDirect8(valueCount int) *Direct8 {
ans := &Direct8{
values: make([]byte, valueCount),
}
ans.MutableImpl = newMutableI... | core/util/packed/direct8.go | 0.614972 | 0.47725 | direct8.go | starcoder |
package boids
import (
"fmt"
"github.com/goldsborough/goboids/point"
"github.com/goldsborough/goboids/world"
"math"
)
type Boid struct {
id int
position point.Point
velocity point.Point
}
type Constants struct {
Cohesion, Alignment, Separation, Bounce, Center, Perturb float64
VelocityClip int
}
typ... | boids/boids.go | 0.639511 | 0.450178 | boids.go | starcoder |
package shapes
import (
"math"
"github.com/factorion/graytracer/pkg/primitives"
)
// Cylinder Represents a cylinder
type Cylinder struct {
ShapeBase
closed bool
}
// MakeCylinder Make a regular cylinder with an identity matrix for transform
func MakeCylinder(closed bool) *Cylinder {
return &Cylinder{MakeShapeBa... | pkg/shapes/cylinder.go | 0.871857 | 0.490846 | cylinder.go | starcoder |
package ds3Testing
import (
"testing"
"github.com/SpectraLogic/ds3_go_sdk/ds3/models"
"reflect"
)
// Asserts if a specified bool pointer has the expected value. If not, Fatal.
func AssertNonNilBoolPtr(t *testing.T, label string, expected bool, actual *bool) {
if actual == nil {
t.Fatalf("Expe... | ds3_utils/ds3Testing/assertUtil.go | 0.764628 | 0.688854 | assertUtil.go | starcoder |
package Warp10Exporter
import (
"bytes"
"fmt"
"net/url"
"strconv"
"strings"
"time"
)
// Datapoint are datapoint in a GTS
type Datapoint struct {
Timestamp time.Time
Value interface{}
}
// Datapoints are a slice of Datapoint
type Datapoints []Datapoint
// GTS are GeoTimeSeries
type GTS struct {
Classnam... | gts.go | 0.724481 | 0.4133 | gts.go | starcoder |
package timepoints
import (
"fmt"
"sort"
"time"
medcomodels "github.com/ldsec/medco/connector/models"
"github.com/sirupsen/logrus"
)
// patientAndEndEvents take the patient-to-start-event map and the patient-to-end-event-candidates.
// For each patient in the in the first map, it checks its presence in the seco... | connector/server/survivalanalysis/timepoints/sequential_data.go | 0.541651 | 0.439567 | sequential_data.go | starcoder |
package align
import (
"fmt"
"github.com/craiglowe/gonomics/common"
"github.com/craiglowe/gonomics/dna"
"github.com/craiglowe/gonomics/fasta"
)
// the data structure is a 3d slice where the first index is 0,1,2 and represents
// the match, gap in x (first seq), and gap in y (second seq).
func initAffineScoringAnd... | align/affineGap.go | 0.551332 | 0.401746 | affineGap.go | starcoder |
package common
import (
"fmt"
"math"
)
type Point2D struct{
X int
Y int
}
func Point2DI(x, y int) Point2D {
return Point2D {
X: x,
Y: y,
}
}
func (p1 Point2D) Manhattan(p2 Point2D) int {
return AbsI(p1.X - p2.X) + AbsI(p1.Y - p2.Y)
}
// Determines the slope from one to the other as a reduced fraction
f... | cmd/common/2d.go | 0.833257 | 0.606324 | 2d.go | starcoder |
package goutilh
import (
"fmt"
"github.com/apaxa-go/helper/strconvh"
"go/ast"
"go/printer"
"go/token"
"io"
"strconv"
)
const astThreshold = 1024 // Maximum number of elements in slice for using Ast implementation
// WriteBytes convert given slice of bytes to GoLang source code representation and write it to g... | goh/goutilh/source.go | 0.793186 | 0.427217 | source.go | starcoder |
package measurement
import (
"regexp"
"strconv"
"strings"
"github.com/wayn3h0/gop/decimal"
"github.com/wayn3h0/gop/errors"
)
// WeightUnit represents the unit of weight.
type WeightUnit int
// Weight Units.
const (
Gram WeightUnit = 1 // base
Kilogram WeightUnit = 1000
Tonne WeightUnit = 1000000
)
v... | measurement/weight.go | 0.819821 | 0.441854 | weight.go | starcoder |
package vectormath
import "fmt"
func QCopy(result, quat *Quat) {
result.X = quat.X
result.Y = quat.Y
result.Z = quat.Z
result.W = quat.W
}
func QMakeFromElems(result *Quat, x, y, z, w float32) {
result.X = x
result.Y = y
result.Z = z
result.W = w
}
func QMakeFromV3Scalar(result *Quat, xyz *Vector3, w float... | quat_aos.go | 0.710126 | 0.511656 | quat_aos.go | starcoder |
package primitives
import ("fmt"
"math"
"log")
var (
PlaneXY = Plane{OriginPoint, AxisZ}
PlaneYZ = Plane{OriginPoint, AxisX}
PlaneXZ = Plane{OriginPoint, AxisY}
)
type Plane struct {
P Point
N Vector
}
func (p Plane) String() string {
return fmt.Sprintf("P%s N%s", p.P.String(), p.N.String())
}
func (p Pl... | primitives/plane.go | 0.61555 | 0.556339 | plane.go | starcoder |
package timex
import "time"
// RangeDate returns a function which returns a time
// between "start" and "end". When the iteration finishes
// the returned time is zero.
func RangeDate(start, end time.Time) func() time.Time {
y, m, d := start.Date()
start = time.Date(y, m, d, 0, 0, 0, 0, start.Location())
y, m, d =... | x/timex/weekday.go | 0.830078 | 0.624637 | weekday.go | starcoder |
package ray
import (
"fmt"
"math"
)
type vec3 struct {
x, y, z, w float64
}
var zero = NewVec(0, 0, 0)
func newTuple(x, y, z, w float64) Vector {
return vec3{
x: x,
y: y,
z: z,
w: w,
}
}
func NewVec(x, y, z float64) Vector {
return newTuple(x, y, z, 0)
}
func NewPoint(x, y, z float64) Vector {
retu... | go/internal/ray/vec3.go | 0.886813 | 0.569374 | vec3.go | starcoder |
package array
import (
"fmt"
)
// Array is a fixed size slice
type Array struct {
values []interface{}
}
// New creates a new array with passed size
func New(size int) *Array {
return &Array{values: make([]interface{}, size, size)}
}
// NewFromArray creates a new array from another array, and copy its values
fun... | ds/array/array.go | 0.849129 | 0.669314 | array.go | starcoder |
package logic_gate
import "context"
func ComplexFullAdder(ctx context.Context) (g Gate) {
xor1 := XorGate(ctx)
xor2 := XorGate(ctx)
and1 := AndGate(ctx)
and2 := AndGate(ctx)
or := OrGate(ctx)
inputDigit0 := BasicGate(ctx)
inputDigit1 := BasicGate(ctx)
inputCarry := BasicGate(ctx)
Connect(inputDigit0.Outp... | application.go | 0.612541 | 0.464416 | application.go | starcoder |
package block
import (
"github.com/go-gl/mathgl/mgl64"
"github.com/sunproxy/sunfly/dragonfly/item"
"github.com/sunproxy/sunfly/dragonfly/world"
"github.com/sunproxy/sunfly/dragonfly/world/particle"
)
// Sponge is a block that can be used to remove water around itself when placed, turning into a wet sponge in the
... | dragonfly/block/sponge.go | 0.692746 | 0.421909 | sponge.go | starcoder |
package plaid
import (
"encoding/json"
)
// ExternalPaymentScheduleGet The schedule that the payment will be executed on. If a schedule is provided, the payment is automatically set up as a standing order. If no schedule is specified, the payment will be executed only once.
type ExternalPaymentScheduleGet struct {
... | plaid/model_external_payment_schedule_get.go | 0.798658 | 0.654412 | model_external_payment_schedule_get.go | starcoder |
package options
import (
"fmt"
"reflect"
"github.com/femaref/helper/mapstruct"
"github.com/hashicorp/go-multierror"
)
type Options map[string]interface{}
type Expectation struct {
Field string
Type reflect.Type
Def interface{}
Optional bool
}
func New() *Expectations {
return &Expectations{}
}... | options.go | 0.622804 | 0.405979 | options.go | starcoder |
package lucene42
import (
. "github.com/gzg1984/golucene/core/codec/spi"
. "github.com/gzg1984/golucene/core/index/model"
"github.com/gzg1984/golucene/core/util/packed"
)
// lucene42/Lucene42DocValuesFormat.java
/*
Lucene 4.2 DocValues format.
Encodes the four per-document value types (Numeric, Binary, Sorted,
S... | core/codec/lucene42/docValuesFormat.go | 0.728555 | 0.582877 | docValuesFormat.go | starcoder |
package commercetools
import (
"net/url"
"strconv"
)
// QueryInput provides the data required to query types.
type QueryInput struct {
// The queryable APIs support ad-hoc filtering of resources through flexible
// predicates. They do so via the where query parameter that accepts a
// predicate expression to det... | commercetools/client_queryinput.go | 0.690559 | 0.410874 | client_queryinput.go | starcoder |
package common
import (
"fmt"
"math"
"github.com/m3db/m3/src/query/graphite/errors"
"github.com/m3db/m3/src/query/graphite/ts"
)
// TransformFunc is used by Transform to apply a function
// to all values in a series.
type TransformFunc func(float64) float64
// TransformFuncFactory creates transformation functi... | src/query/graphite/common/transform.go | 0.848565 | 0.58439 | transform.go | starcoder |
package vida
// Bool models binary boolean values true, false
type Bool bool
// Interface Value
func (b Bool) TypeName() string {
return "Bool"
}
func (b Bool) Description() string {
if b {
return "true"
}
return "false"
}
func (b Bool) Equals(other Value) bool {
if value, ok := other.(Bool); ok {
return b... | vida/boolean.go | 0.829803 | 0.497742 | boolean.go | starcoder |
package libnova
// NewPopulatedBTree Will return a populated a btree
func NewPopulatedBTree() *BinarySearchTree {
btree := NewBinarySearchTree("Nóva")
btree.Insert(&NodeBinary{
Node: Node{
Key: "seventy seven",
Value: 77,
},
})
btree.Insert(&NodeBinary{
Node: Node{
Key: "sixty nine",
Value: 6... | libnova/ds_binarySearchTreeStatic.go | 0.528047 | 0.453504 | ds_binarySearchTreeStatic.go | starcoder |
package record
import (
"io"
"github.com/insolar/insolar/core"
)
// State is a state of lifeline records.
type State int
const (
// StateUndefined is used for special cases.
StateUndefined = State(iota)
// StateActivation means it's an activation record.
StateActivation
// StateAmend means it's an amend reco... | ledger/record/result.go | 0.764364 | 0.514705 | result.go | starcoder |
package series
import (
"fmt"
"log"
"sort"
"github.com/ptiger10/pd/internal/values"
"github.com/ptiger10/pd/options"
)
// Rename the Series.
func (s *Series) Rename(name string) {
s.name = name
}
// Convert a Series and return as new Series.
func (s *Series) Convert(datatype string) *Series {
s = s.Copy()
... | series/modify.go | 0.714329 | 0.421046 | modify.go | starcoder |
package fptower
import (
"github.com/consensys/gnark-crypto/ecc/bw6-761/fp"
)
// E2 is a degree-two finite field extension of fp.Element
type E2 struct {
A0, A1 fp.Element
}
// Equal returns true if z equals x, fasle otherwise
func (z *E2) Equal(x *E2) bool {
return z.A0.Equal(&x.A0) && z.A1.Equal(&x.A1)
}
// S... | ecc/bw6-761/internal/fptower/e2.go | 0.778607 | 0.464234 | e2.go | starcoder |
package bitfield
import (
"encoding/binary"
"math/bits"
)
var _ = Bitfield(Bitvector64{})
// Bitvector64 is a bitfield with a fixed defined size of 64. There is no length bit
// present in the underlying byte array.
type Bitvector64 []byte
const bitvector64ByteSize = 8
const bitvector64BitSize = bitvector64ByteSi... | bitvector64.go | 0.786131 | 0.466846 | bitvector64.go | starcoder |
package collision
import (
"github.com/teomat/mater/vect"
"log"
"math"
)
type collisionHandler func(contacts *[MaxPoints]Contact, sA, sB *Shape) int
var collisionHandlers = [numShapes][numShapes]collisionHandler{
ShapeType_Circle: [numShapes]collisionHandler{
ShapeType_Circle: circle2circle,
ShapeType_Segme... | collision/collide.go | 0.66236 | 0.405213 | collide.go | starcoder |
package element
import (
"fmt"
"math"
)
type Matrix struct {
ele []float64
stride int
}
func MatrixFromRows(rows [][]float64) Matrix {
if len(rows) == 0 {
return Matrix{nil, 0}
}
m := Matrix{make([]float64, len(rows)*len(rows[0])), len(rows[0])}
for rx, row := range rows {
... | lang/Go/element-wise-operations-1.go | 0.85747 | 0.744563 | element-wise-operations-1.go | starcoder |
package monitoring
import (
"fmt"
"github.com/gravitational/trace"
humanize "github.com/dustin/go-humanize"
)
// StorageConfig describes checker configuration
type StorageConfig struct {
// Path represents volume to be checked
Path string
// WillBeCreated when true, then all checks will be applied to first ex... | vendor/github.com/gravitational/satellite/monitoring/storage.go | 0.700997 | 0.40392 | storage.go | starcoder |
package noise
import (
"math"
)
// Implements the Open Simplex version of the simplex noise algorithm
// Code adapted from the Open Simplex 2 Algorithm courtesy of github user KdotJPG
// Source code at : https://github.com/KdotJPG/OpenSimplex2/blob/master/java/OpenSimplex2F.java#L190
var LOOKUP3d *lattice = newLatt... | pkg/noise/simplex.go | 0.689828 | 0.474509 | simplex.go | starcoder |
package parser
import (
"github.com/Zac-Garby/radon/ast"
"github.com/Zac-Garby/radon/token"
)
func (p *Parser) parseStatement() ast.Statement {
var node ast.Statement
switch p.cur.Type {
case token.Semi:
return nil
case token.Return:
return p.parseReturn()
case token.Break:
return new(ast.Break)
cas... | parser/statements.go | 0.64646 | 0.517144 | statements.go | starcoder |
// Extended by <NAME> according to exercises in the _GOPL_
// book. See `EXERCISES.adoc`.
// Package intset provides a set of integers based on a bit vector.
package intset
import (
"bytes"
"strconv"
"strings"
)
// An IntSet is a set of small non-negative integers.
// Its zero value represents the empty set.
typ... | intset.go | 0.812867 | 0.410047 | intset.go | starcoder |
package pack
import (
"encoding/json"
"fmt"
"math/rand"
"reflect"
"github.com/renproject/surge"
)
type List struct {
T Type
Elems []Value
}
func EmptyList(t Type) List {
return List{
T: t,
Elems: []Value{},
}
}
func NewList(vs ...Value) (List, error) {
if len(vs) == 0 {
return List{}, fmt.E... | list.go | 0.65368 | 0.452717 | list.go | starcoder |
package graphbox
// DividerShape determines which shape to use for the divider
type DividerShape int
const (
// DSFullRect is a rectangle which will span the entire graphic from end to end.
// The text will be centered in front of it.
DSFullRect DividerShape = iota
// DSFramedRect is like FullRect but using a fr... | seqdiagram/graphbox/divider.go | 0.788094 | 0.462291 | divider.go | starcoder |
package basen
import (
"fmt"
"math"
"math/big"
)
// Base58Encoding is the standard base58 encoding, which is the alternate base64 encoding defined in RFC 4648
// modified to avoid both non-alphanumeric characters and letters which might look ambiguous when printed.
// It is designed for human users who manually en... | basen.go | 0.73029 | 0.421552 | basen.go | starcoder |
package vbge
// Location represents a two-dimensional point in a matrix. It's values are
// zero-based. Therfore (0, 0) is the first point in the upper left.
type Location struct {
X int `json:"x"`
Y int `json:"y"`
}
func newLocation(y, x int) *Location {
return &Location{
X: x,
Y: y,
}
}
// DeepCopy allocat... | vbge/location.go | 0.87444 | 0.644952 | location.go | starcoder |
package main
import (
"fmt"
"log"
"math"
"os"
"strconv"
"github.com/TomasCruz/projecteuler"
)
/*
Problem 39; Integer right triangles
If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions
for p = 120.
{20,48,52}, {24,45,51}, {30,40,50}
For whic... | 001-100/031-040/039/main.go | 0.562177 | 0.441312 | main.go | starcoder |
package main
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/matgd/advent2021/utils"
)
type coordinate struct {
x, y int
}
func loadCoordinates() [][]coordinate {
input := utils.GetStringsFromInputFile("input.txt")
coordsStrings := make([][]string, len(input))
coords := make([][]coordinate, len(input... | day05/main.go | 0.563618 | 0.414366 | main.go | starcoder |
package board
// Checks whether the area contains a unit.
func (area Area) IsEmpty() bool {
return area.Unit.Type == ""
}
// Checks whether the area is controlled by a player.
func (area Area) IsControlled() bool {
return area.Control != ""
}
// Returns an area's neighbor of the given name, and whether it was foun... | game/board/utils_areas.go | 0.917004 | 0.728 | utils_areas.go | starcoder |
package hlc18
type Bitset256 [4]uint64
type Bitset128 [2]uint64
func (p *Bitset256) Set(bit byte) {
p[bit/64] = p[bit/64] | (1 << (bit % 64))
}
func (p *Bitset256) Get(bit byte) bool {
return 1 == ((p[bit/64] >> (bit % 64)) & 0x01)
}
func (p *Bitset256) Contains(p2 *Bitset256) bool {
return (p[0]&p2[0] == p2[0])... | vendor/dsmnko.org/hlc18/bitset.go | 0.659844 | 0.531209 | bitset.go | starcoder |
package effect
import (
"korok.io/korok/math/f32"
"korok.io/korok/gfx"
"korok.io/korok/math"
)
// FireSimulator can simulate the fire effect.
type ExplosionSimulator struct {
Pool
RateController
LifeController
VisualController
velocity Channel_v2
deltaColor Channel_v4
// Configuration.
Config struct{
... | effect/sim_explosion.go | 0.707 | 0.402275 | sim_explosion.go | starcoder |
package math
type min struct{}
var Min = min{}
func (m min) Float32(value float32, valueList ...float32) float32 {
result := value
for _, x := range valueList {
if result > x {
result = x
}
}
return result
}
func (m min) Float64(value float64, valueList ...float64) float64 {
result := value
for _, x :=... | math/min.go | 0.627609 | 0.404802 | min.go | starcoder |
package gosolarpos
import (
"math"
"time"
)
// EstimateDeltaT returns an inter- or extrapolated estimate of Delta T for the
// given time. This is based on Espenak and Meeus, "Five Millennium Canon of
// Solar Eclipses: -1999 to +3000" (NASA/TP-2006-214141).
func EstimateDeltaT(forDate time.Time) (deltaTSeconds flo... | deltat.go | 0.657318 | 0.589835 | deltat.go | starcoder |
package container
import (
"github.com/pkg/errors"
)
type Vector struct {
Array []interface{}
}
func (v *Vector) PushBack(value interface{}) {
v.Array = append(v.Array, value)
}
func (v *Vector) PopBack() (interface{}, error) {
stackLen := len(v.Array)
if stackLen == 0 {
return nil, errors.New("stack is empt... | container/vector.go | 0.626353 | 0.451145 | vector.go | starcoder |
// Package graph implements graph data structures and associated
// algorithms.
package graph
import (
"bufio"
"fmt"
"io"
)
// UniGraph represents a uni-directional graph of vertices and edges
type UniGraph struct {
vertCount int // number of vertices
edgeCount int // number of edges
adj ... | graph/graph.go | 0.747892 | 0.447581 | graph.go | starcoder |
package client
import (
"encoding/json"
)
// V3APISupplierCatalogUnit struct for V3APISupplierCatalogUnit
type V3APISupplierCatalogUnit struct {
// The order price in cents for the item per unit. For example, a currency of GBP with unit 5L and price 850 means a 5L item can be ordered for £8.50.
PriceCents *int32 ... | client/model_v3_api_supplier_catalog_unit.go | 0.763131 | 0.489809 | model_v3_api_supplier_catalog_unit.go | starcoder |
package cascades
import (
"container/list"
)
// ExprIter enumerates all the equivalent expressions in the group according to
// the expression pattern.
type ExprIter struct {
// group and element solely identify a group expression.
group *Group
element *list.Element
// matched indicates whether the current g... | planner/cascades/expr_iterator.go | 0.624294 | 0.499329 | expr_iterator.go | starcoder |
package balance
import (
"fmt"
"math/big"
"runtime/debug"
)
/*
Coin starts here
*/
// Coin is the basic amount, specified in integers, at the smallest increment (i.e. a satoshi, not a bitcoin)
type Coin struct {
Currency Currency `json:"currency"`
Amount *Amount `json:"amount,string"`
}
// See if the coin i... | data/balance/coin.go | 0.761627 | 0.471041 | coin.go | starcoder |
package curve
import (
"math/big"
)
type Curve struct {
A *big.Int // A y^2=x^3+Ax+B
B *big.Int // B y^2=x^3+Ax+B
P *big.Int // P is the prime number of finite field
G *Point // G generator point
N *big.Int // N prime number of points in the group
}
func NewCurve(A, B, P, N *big.Int, G *Point) *Curve {
if P... | foundation_math/ecc/curve/curve.go | 0.748444 | 0.566678 | curve.go | starcoder |
package leetcode
import (
"errors"
"math"
)
// Point in 2D.
type Point struct {
X int
Y int
}
// Board for playing chess.
type Board struct {
Size int
Queens []Point
}
// NewEmptyBoard creates an empty board of the given size.
func NewEmptyBoard(size int) *Board {
return &Board{
Size: size,
}
}
// Plac... | queens.go | 0.798619 | 0.458773 | queens.go | starcoder |
package sort
import (
"strings"
)
func QuickSortInt(slice []int, ascOrDsc string) bool {
if strings.EqualFold("asc", ascOrDsc) {
QuickSortAscInt(slice)
return true
} else if strings.EqualFold("dsc", ascOrDsc) {
QuickSortDscInt(slice)
return true
} else {
return false
}
}
func QuickSortFloat64(slice []... | quickSort.go | 0.645343 | 0.517266 | quickSort.go | starcoder |
package metrics
import (
"context"
"fmt"
"net/url"
"path"
"strconv"
"sync"
"time"
influx "github.com/influxdata/influxdb1-client/v2"
"github.com/pkg/errors"
"github.com/wavesplatform/gowaves/pkg/crypto"
"github.com/wavesplatform/gowaves/pkg/proto"
"go.uber.org/zap"
)
const (
defaultTimeout = 5 * time.Se... | pkg/metrics/metrics.go | 0.647464 | 0.505005 | metrics.go | starcoder |
package main
/**
* WriteLimiter is a generic interface that controls how many bytes
* of log lines are written and when to advance the line timestamp.
*
* There are two implementions, RateBasedLimiter and FixedDelayLimiter.
* You generally should not need to work directly with these classes,
* but just get a ref... | rate_limiter.go | 0.930205 | 0.602442 | rate_limiter.go | starcoder |
package aiplatform
import (
context "context"
cmpopts "github.com/google/go-cmp/cmp/cmpopts"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protocmp "google.golang.org/protobuf/testing/protocmp"
fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
assert "gotest.tools/v... | proto/gen/googleapis/cloud/aiplatform/v1/metadata_service_aiptest.pb.go | 0.61832 | 0.510435 | metadata_service_aiptest.pb.go | starcoder |
package aoc2020
/*
https://adventofcode.com/2020/day/14
--- Day 14: Docking Data ---
As your ferry approaches the sea port, the captain asks for your help again. The computer system that runs this port isn't compatible with the docking program on the ferry, so the docking parameters aren't being correctly initialize... | app/aoc2020/aoc2020_14.go | 0.74512 | 0.757906 | aoc2020_14.go | starcoder |
package mat
import (
"fmt"
"math/rand"
"strconv"
"strings"
"time"
"gonum.org/v1/gonum/mat"
)
var globalRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))
func NewSymmetricMatrix(a *mat.Dense) *mat.Dense {
r, c := a.Dims()
result := mat.NewDense(r, c, nil)
result.Add(a, a.T())
for i := 0;... | mat/matrix.go | 0.623262 | 0.408572 | matrix.go | starcoder |
package command
import (
"github.com/inkyblackness/res/geometry"
)
func SaveVertices(writer *Writer, container geometry.VertexContainer) {
positions := make([]geometry.Vector, container.VertexCount())
for i := 0; i < len(positions); i++ {
positions[i] = container.Vertex(i).Position()
}
lastDissimilar := len(p... | geometry/command/SaveVertices.go | 0.561936 | 0.615232 | SaveVertices.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.