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 r3
import (
"math"
"sort"
)
// Point represent a point in 3D space through cartesian coordinates.
type Point struct {
X, Y, Z float64
}
// Vector represent a vector in 3D space .
type Vector struct {
X, Y, Z float64
}
// Plane represent a plane in 3D space .
type Plane struct {
orig Point
normal Vec... | r3/r3.go | 0.91529 | 0.807271 | r3.go | starcoder |
package doboz
import (
"encoding/binary"
)
type Compressor struct {
dict Dictionary
}
// Returns the maximum compressed size of any block of data with the specified size
// This function should be used to determine the size of the compression destination buffer
func GetMaxCompressedSize(size int) int {
// The hea... | compressor.go | 0.846831 | 0.541773 | compressor.go | starcoder |
package types
import (
"fmt"
"github.com/tendermint/go-wire/data"
)
// Result is a common result object for ABCI calls.
// CONTRACT: a zero Result is OK.
type Result struct {
Code CodeType `json:"code"`
Data data.Bytes `json:"data"`
Log string `json:"log"` // Can be non-deterministic
}
func NewResult(co... | vendor/github.com/tendermint/abci/types/result.go | 0.72487 | 0.45647 | result.go | starcoder |
package dst
// Gamma distribution, helper functions, log versions.
func pgamma_raw_ln(x, shape float64) float64 {
// Here, assume that (x, shape) are not NA & shape > 0 .
var res, sum float64
if x <= 0 {
return negInf
}
if x >= posInf {
return 0
}
if x < 1 {
res = pgamma_smallx_ln(x, shape)
} el... | dst/gamma_aux_ln.go | 0.692954 | 0.625238 | gamma_aux_ln.go | starcoder |
package iso20022
// Chain of parties involved in the settlement of a transaction, including receipts and deliveries, book transfers, treasury deals, or other activities, resulting in the movement of a security or amount of money from one account to another.
type SettlementParties32 struct {
// First party in the set... | SettlementParties32.go | 0.694199 | 0.518363 | SettlementParties32.go | starcoder |
package slice
// IncludesString func
// Returns true if the input contains the one or more of the values
func IncludesString(input []string, values ...string) bool {
for _, value := range values {
idx := IndexOfString(value, input)
if idx > -1 {
return true
}
}
return false
}
/... | slice/includes.go | 0.823577 | 0.483039 | includes.go | starcoder |
package groups
import (
"math/big"
"fmt"
"github.com/xlab-si/emmy/crypto/common"
)
// QRRSA presents QR_N - group of quadratic residues modulo N where N is a product
// of two primes. This group is in general NOT cyclic (it is only when (P-1)/2 and (Q-1)/2 are primes,
// see QRSpecialRSA). The group QR_N is isom... | crypto/groups/qr_rsa.go | 0.760651 | 0.439326 | qr_rsa.go | starcoder |
package rbtree
// First returns the leftmost node in t, which is the first in-order node.
// If t is empty, it will return nil.
func (t *Tree) First() *Node {
if t.root == nil {
return nil
}
n := t.root
for n.left != nil {
n = n.left
}
return n
}
// Last returns the rightmost node in t, which is the last in... | rbtree/iter.go | 0.834407 | 0.538437 | iter.go | starcoder |
package assert
import (
"fmt"
"path/filepath"
"reflect"
"runtime"
"testing"
)
// Assert wraps a testing.TB for convenient asserting calls.
type Assert struct {
t testing.TB
}
// ObjectsAreEqual checks two interfaces with reflect.DeepEqual.
func ObjectsAreEqual(expected, actual interface{}) bool {
if expected ... | assert/assert.go | 0.719186 | 0.469642 | assert.go | starcoder |
package model
import (
"github.com/bdlm/errors"
"github.com/bdlm/std"
)
/*
Cur implements std.Iterator.
Cur reads the key and value at the current cursor postion into pK and pV
respectively. Cur will return false if no iteration has begun, including
following calls to Reset.
*/
func (mdl *Model) Cur(pK, pV *interf... | model.iterator.go | 0.583559 | 0.518546 | model.iterator.go | starcoder |
package filter
import "github.com/nerdynick/ccloud-go-sdk/telemetry/labels"
type Filter interface {
And(filters ...Filter) CompoundFilter
AndEqualTo(field labels.Label, value string) CompoundFilter
AndNotEqualTo(field labels.Label, value string) CompoundFilter
AndGreaterThan(field labels.Label, value string) Comp... | telemetry/query/filter/filter.go | 0.779532 | 0.637835 | filter.go | starcoder |
package lookup
import "fmt"
// Lookup ...
func Lookup(sortedDict []string, target string) (bool, error) {
if 0 == len(sortedDict) {
return false, fmt.Errorf("dict can not be empty")
}
if 0 == len(target) {
return false, fmt.Errorf("target can not be empty")
}
left, right := 0, len(sortedDict)-1
for left <... | pkg/dichotomy/lookup/lookup.go | 0.712732 | 0.574872 | lookup.go | starcoder |
package main
import (
"fmt"
"sync"
)
/*
We can change our pipeline to run two instances of `sq`, each reading from the same input
channel. We introduce a new function, merge, to fan in the results:
*/
func main() {
in := gen(2, 3)
// Distribute the `sq` work across 2 goroutines that both read from `in`:
c1 := s... | go/pipelines-and-cancellations/pipeline/fan-out-fan-in/main.go | 0.697815 | 0.480357 | main.go | starcoder |
package dotplotter
import (
"image"
"image/color"
"image/draw"
"image/png"
"os"
"path/filepath"
)
// DefaultColor exports default RGB values for common colors.
func DefaultColor(c string) color.RGBA {
m := map[string]color.RGBA{
"white": color.RGBA{255, 255, 255, 255},
"black": color.RGBA{0, 0, 0, 255},
... | dotplotter.go | 0.795975 | 0.480296 | dotplotter.go | starcoder |
package widgets
import (
"fmt"
"github.com/ricoberger/kubetop/pkg/api"
ui "github.com/gizak/termui/v3"
w "github.com/gizak/termui/v3/widgets"
)
// ListType is our custom type for the different list types (e.g. sort and filter)
type ListType string
const (
// ListTypeSort represents the the sorting list.
List... | pkg/term/widgets/list.go | 0.588653 | 0.484319 | list.go | starcoder |
package ch
const (
Infinity = float64(^uint(0) >> 1)
// Infinity = Infinity
)
// shortestPathsWithMaxCost Internal implementation of Dijkstra's algorithm to compute witness paths
func (graph *Graph) shortestPathsWithMaxCost(source int64, maxcost float64, previousOrderPos int64) {
// Heap to store traveled distance... | dijkstra_local.go | 0.649801 | 0.470189 | dijkstra_local.go | starcoder |
package kzg
import (
"go.dedis.ch/kyber/v3"
)
// Commit commits to vector vect[0], ...., vect[D-1]
// it is [f(s)]1 where f is polynomial in evaluation (Lagrange) form,
// i.e. with f(rou[i]) = vect[i], i = 0..D-1
// vect[k] == nil equivalent to 0
func (sd *TrustedSetup) Commit(vect []kyber.Scalar) kyber.Point {
r... | kzg/fun.go | 0.549399 | 0.420719 | fun.go | starcoder |
package main
import (
"math"
"math/rand"
"time"
)
type Point struct {
X float64 `json:"x"`
Y float64 `json:"y"`
}
type Vector struct {
X float64 `json:"x"`
Y float64 `json:"y"`
}
func MakePoint(x float64, y float64) *Point {
return &Point{RoundToPlaces(x, 1), RoundToPlaces(y, 1)}
}
func Round(f float64) fl... | hyperspace-app/server/maths.go | 0.891702 | 0.801897 | maths.go | starcoder |
package coords64
import (
"fmt"
"gotopo/geom"
)
type coords64 struct {
data []float64
dimensions uint8
}
var _ geom.ReadWriteCoords = NewCoords64() // Verify that *coords64 implements ReadWriteCoords
func NewCoords64() geom.ReadWriteCoords {
return NewCoords64WithDimensions(geom.DEFAULT_NUM_DIMENSIONS)
... | src/gotopo/geom/coords64/coords64.go | 0.71403 | 0.514583 | coords64.go | starcoder |
package circuit
import (
"gkr-mimc/common"
"gkr-mimc/polynomial"
"sync"
"github.com/consensys/gurvy/bn256/fr"
)
// Wire represent a single connexion between a gate,
// its output and its inputs
type Wire struct {
L, R, O int
Gate Gate
}
// Layer describes how a layer feeds its inputs
type Layer struct {
W... | circuit/layers.go | 0.66628 | 0.422981 | layers.go | starcoder |
package path
import (
"fmt"
"math"
"strings"
"github.com/dustismo/heavyfishdesign/dynmap"
)
const (
DefaultPrecision = 3 // how many decimal places do we want to consider
)
type Point struct {
X float64
Y float64
// t value on a curve. (This is optional,
// and we ignore 0 values for this)
t float64
}
ty... | path/path.go | 0.749546 | 0.463809 | path.go | starcoder |
package memory
import (
"github.com/blackchip-org/pac8/pkg/util/bits"
"github.com/blackchip-org/pac8/pkg/util/state"
)
// Memory is a chunk of 8-bit values accessed by a 16-bit address.
type Memory interface {
// Load returns the value from the address at addr.
Load(addr uint16) uint8
// Store puts the value of... | pkg/memory/memory.go | 0.769946 | 0.466177 | memory.go | starcoder |
package os
import (
"fmt"
"math"
"os"
"regexp"
"strconv"
"github.com/emc-advanced-dev/pkg/errors"
)
type DiskSize interface {
ToPartedFormat() string
ToBytes() Bytes
}
type Bytes int64
func (s Bytes) ToPartedFormat() string {
return fmt.Sprintf("%dB", uint64(s))
}
func (s Bytes) ToBytes() Bytes {
return... | pkg/os/device.go | 0.690246 | 0.421254 | device.go | starcoder |
package common
const (
// MeasurementsHeadCluster is the cluster row identifier in the measurement file.
MeasurementsHeadCluster = "cluster"
// MeasurementsHeadProvider is the provider row identifier in the measurement file.
MeasurementsHeadProvider = "provider"
// MeasurementsHeadSeed is the seed row identifi... | pkg/shoot-telemetry/common/definitions.go | 0.585812 | 0.401805 | definitions.go | starcoder |
package cmd
import (
"fmt"
"strconv"
"strings"
"github.com/jaredbancroft/aoc2020/pkg/helpers"
"github.com/spf13/cobra"
)
// day15Cmd represents the day15 command
var day15Cmd = &cobra.Command{
Use: "day15",
Short: "Advent of Code 2020 - Day15: Rambunctious Recitation",
Long: `
Advent of Code 2020
--- D... | cmd/day15.go | 0.58522 | 0.656438 | day15.go | starcoder |
package ast
import (
"akdjr/monkey/token"
"bytes"
"strings"
)
// Node represents a node in the AST. TokenLiteral() returns the literal value of the token that the node is associated with
type Node interface {
TokenLiteral() string
String() string
}
// Statement represents a statment in the AST. Statements do ... | ast/ast.go | 0.808597 | 0.420362 | ast.go | starcoder |
package terms
import (
"algex/factor"
"math/big"
"sort"
"strings"
)
// term is a product of a coefficient and a set of non-numerical factors.
type term struct {
coeff *big.Rat
fact []factor.Value
}
// Exp is a an expression or sum of terms.
type Exp struct {
terms map[string]term
}
// NewExp creates a new e... | src/algex/terms/terms.go | 0.504394 | 0.42913 | terms.go | starcoder |
package contracts
import (
"context"
"testing"
"github.com/adamluzsi/frameless"
"github.com/adamluzsi/frameless/extid"
"github.com/adamluzsi/testcase"
"github.com/stretchr/testify/require"
)
type FixtureFactory struct {
T interface{}
Subject func(testing.TB) frameless.FixtureFactory
Context func(test... | contracts/FixtureFactory.go | 0.626238 | 0.454109 | FixtureFactory.go | starcoder |
package goutils
import (
"fmt"
"strings"
)
func min(a, b int) int {
if a < b {
return a
}
return b
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
type BSTNode struct {
Value string
Data string
Left *BSTNode
Right *BSTNode
bal int
}
func (n *BSTNode) Insert(value, data string) bool... | bst.go | 0.559771 | 0.442335 | bst.go | starcoder |
package modbus
var NormalEndian normalEndian
type normalEndian struct{}
func (normalEndian) Uint16(b []byte) uint16 {
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
return uint16(b[1]) | uint16(b[0])<<8
}
func (normalEndian) PutUint16(b []byte, v uint16) {
_ = b[1] // early bounds check to... | collector/modbus/endian.go | 0.53437 | 0.415847 | endian.go | starcoder |
package spdx
// Snippet2_1 is a Snippet section of an SPDX Document for version 2.1 of the spec.
type Snippet2_1 struct {
// 5.1: Snippet SPDX Identifier: "SPDXRef-[idstring]"
// Cardinality: mandatory, one
SPDXIdentifier ElementID
// 5.2: Snippet from File SPDX Identifier
// Cardinality: mandatory, one
Snipp... | spdx/snippet.go | 0.591841 | 0.472744 | snippet.go | starcoder |
package schema
// ChangesetSpecSchemaJSON is the content of the file "changeset_spec.schema.json".
const ChangesetSpecSchemaJSON = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ChangesetSpec",
"description": "A changeset specification, which describes a changeset to be created or an existin... | schema/changeset_spec_stringdata.go | 0.765593 | 0.445469 | changeset_spec_stringdata.go | starcoder |
package types
import (
"fmt"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type (
// Commission defines a commission parameters for a given validator.
Commission struct {
CommissionRates
UpdateTime time.Time `json:"update_time"` // the last time the commission rate was changed
}
// CommissionRates de... | x/staking/types/commission.go | 0.82011 | 0.530054 | commission.go | starcoder |
package strings
import (
"errors"
"io"
"unicode/utf8"
"unsafe"
)
// A Builder is used to efficiently build a string using Write methods.
// It minimizes memory copying. The zero value is ready to use.
type Builder struct {
buf []byte
}
// String returns the accumulated string.
func (b *Builder) String() string... | src/strings/builder.go | 0.698124 | 0.426919 | builder.go | starcoder |
package iso20022
// Chain of parties involved in the settlement of a transaction, including receipts and deliveries, book transfers, treasury deals, or other activities, resulting in the movement of a security or amount of money from one account to another.
type SettlementParties23 struct {
// First party in the set... | SettlementParties23.go | 0.680985 | 0.528716 | SettlementParties23.go | starcoder |
package asciitable
import (
"bytes"
"fmt"
"strings"
"text/tabwriter"
)
// column represents a column in the table. Contains the maximum width of the
// column as well as the title.
type column struct {
width int
title string
}
// Table holds tabular values in a rows and columns format.
type Table struct {
col... | lib/asciitable/table.go | 0.642993 | 0.418637 | table.go | starcoder |
package clui
import (
"fmt"
xs "github.com/huandu/xstrings"
term "github.com/nsf/termbox-go"
"sync/atomic"
)
// BarData is info about one bar in the chart. Every
// bar can be customized by setting its own colors and
// rune to draw the bar. Use ColorDefault for Fg and Bg,
// and 0 for Ch to draw with BarChart de... | barchart.go | 0.622345 | 0.48688 | barchart.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPProcedureDeclarationBase266 struct for BTPProcedureDeclarationBase266
type BTPProcedureDeclarationBase266 struct {
BTPTopLevelNode286
BtType *string `json:"btType,omitempty"`
Arguments *[]BTPArgumentDeclaration232 `json:"arguments,omitempty"`
Body *BTPStatementBlo... | onshape/model_btp_procedure_declaration_base_266.go | 0.746324 | 0.515681 | model_btp_procedure_declaration_base_266.go | starcoder |
package test
import (
"fmt"
"image"
"image/png"
"os"
"path/filepath"
"testing"
"time"
"github.com/jesseduffield/fyne"
"github.com/jesseduffield/fyne/driver/desktop"
"github.com/jesseduffield/fyne/internal/cache"
"github.com/jesseduffield/fyne/internal/driver"
"github.com/stretchr/testify/assert"
"github... | test/util.go | 0.671901 | 0.448064 | util.go | starcoder |
// Package sortutil provides utilities supplementing the standard 'sort' package.
package sortutil
import "sort"
// ByteSlice attaches the methods of sort.Interface to []byte, sorting in increasing order.
type ByteSlice []byte
func (s ByteSlice) Len() int { return len(s) }
func (s ByteSlice) Less(i, j int... | third_party/github.com/cznic/sortutil/sortutil.go | 0.838944 | 0.553807 | sortutil.go | starcoder |
package ledgerstate
import (
"math"
)
// TransactionBalancesValid is an internal utility function that checks if the sum of the balance changes equals to 0.
func TransactionBalancesValid(inputs Outputs, outputs Outputs) (valid bool) {
consumedCoins := make(map[Color]uint64)
for _, input := range inputs {
input.B... | packages/ledgerstate/utils.go | 0.752831 | 0.53206 | utils.go | starcoder |
package iso20022
// List of elements which specify the opening of a non deliverable trade.
type OpeningData2 struct {
// Date at which the trading parties execute a treasury trade.
TradeDate *ISODate `xml:"TradDt"`
// Refers to the identification of a notification assigned by the trading side.
NotificationIdenti... | OpeningData2.go | 0.813313 | 0.529203 | OpeningData2.go | starcoder |
package main
import (
"math"
"github.com/go-gl/gl/v4.1-core/gl"
"github.com/go-gl/mathgl/mgl32"
)
// CameraData Maps camera state
type CameraData struct {
Camera mgl32.Mat4
CameraUniform int32
PositionEye mgl32.Vec3
PositionTarget mgl32.Vec3
InertiaDrag float64
InertiaTurn floa... | camera.go | 0.849878 | 0.545104 | camera.go | starcoder |
package easing
import (
"math"
)
// must map [0.0, 1.0] to [0.0, 1.0]
type EasingFun func(float64) float64
type Easing struct {
In, Out EasingFun
}
var (
Linear = Easing{
In: linearIn,
Out: linearOut,
}
QuadIn = Easing{
In: quadInIn,
Out: quadInOut,
}
QuadOut = Easing{
In: quadOutIn,
Out: quadO... | easing/easing.go | 0.739422 | 0.70117 | easing.go | starcoder |
package engo
const (
// AxisMax is the maximum value a joystick or keypress axis will reach
AxisMax float32 = 1
// AxisNeutral is the value an axis returns if there has been to state change.
AxisNeutral float32 = 0
// AxisMin is the minimum value a joystick or keypress axis will reach
AxisMin float32 = -1
)
// ... | input.go | 0.697094 | 0.45423 | input.go | starcoder |
package tort
import (
"fmt"
"reflect"
)
// SliceAssertions are tests around slice values.
type SliceAssertions struct {
Assertions
name string
slice []interface{}
}
// Slice identifies a slice variable value and returns test functions for its values. If the value
// isn't a slice, generates a fatal error.
fun... | slices.go | 0.828454 | 0.767211 | slices.go | starcoder |
package hashing
import (
"crypto/sha256"
"fmt"
"hash"
"golang.org/x/crypto/blake2b"
)
type Digest []byte
type Hasher interface {
Salted([]byte, ...[]byte) Digest
Do(...[]byte) Digest
Len() uint16
}
// XorHasher implements the Hasher interface and computes a 2 bit hash
// function. Handy for testing hash tre... | crypto/hashing/hash.go | 0.737442 | 0.491761 | hash.go | starcoder |
package util
// Pow2 returns the first power-of-two value >= to n.
// This can be used to create suitable texture dimensions.
func Pow2(n int) int {
x := uint32(n - 1)
x |= x >> 1
x |= x >> 2
x |= x >> 4
x |= x >> 8
x |= x >> 16
return int(x + 1)
}
// Min returns a iff a < b. otherwise returns b.
func Min(a, b... | util/util.go | 0.842604 | 0.604282 | util.go | starcoder |
package inspect
import (
"fmt"
"math"
"unsafe"
)
// The BlockOrder type represents the order of an allocation returned by the buddy allocator.
type BlockOrder uint64
const (
// Order0 is a constant representing allocations of order 0.
Order0 = BlockOrder(iota)
// Order1 is a constant representing allocations... | garnet/go/src/inspect/block.go | 0.730963 | 0.461259 | block.go | starcoder |
package validate
import (
stdliberr "errors"
"reflect"
"time"
"go.thethings.network/lorawan-stack/pkg/errors"
"go.thethings.network/lorawan-stack/pkg/types"
)
// IsZeroer is an interface, which reports whether it represents a zero value.
type IsZeroer interface {
IsZero() bool
}
var isZeroerType = reflect.Ty... | pkg/validate/required.go | 0.61855 | 0.51312 | required.go | starcoder |
package main
// ObjCustomDice builds a dice centered in the origin, the size of an edge is 2*(1+R)
func ObjCustomDice(matBody, matDots *Material, R, D float64) *Csg {
objects := []Groupable{}
add := func(object *Shape) {
objects = append(objects, object)
}
dice_edge := func(x, y, z, rotx, rotz float64) {
cy... | stock_shapes.go | 0.659515 | 0.605303 | stock_shapes.go | starcoder |
package iso20022
// Provides amounts taken in to account to calculate the collateral position.
type SummaryAmounts1 struct {
// Amount of unsecured exposure a counterparty will accept before issuing a margin call in the base currency.
ThresholdAmount *ActiveCurrencyAndAmount `xml:"ThrshldAmt,omitempty"`
// Specif... | SummaryAmounts1.go | 0.849504 | 0.464719 | SummaryAmounts1.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... | row.go | 0.789842 | 0.51501 | row.go | starcoder |
package geo
import (
"math"
)
const (
earthRadius = 6371e3
radians = math.Pi / 180
degrees = 180 / math.Pi
)
// DistanceTo return the distance in meteres between two point.
func DistanceTo(latA, lonA, latB, lonB float64) (meters float64) {
φ1 := latA * radians
λ1 := lonA * radians
φ2 := latB * radian... | vendor/github.com/tidwall/geojson/geo/geo.go | 0.679604 | 0.710531 | geo.go | starcoder |
package export
import (
"github.com/opendroid/hk/logger"
"go.uber.org/zap"
"sort"
"strconv"
"strings"
)
// WalkingDataElement for daily StepCount and DistanceWalkingRunning
type WalkingDataElement struct {
YYYYMMDD string `json:"yyyymmdd"` // CreationDate truncated to CreationDate in format "YYYY-MM-DD"
Sou... | export/walking.go | 0.521959 | 0.418103 | walking.go | starcoder |
package minmax
import "math"
// F64 represents a min / max range for float64 values.
// Supports clipping, renormalizing, etc
type F64 struct {
Min float64
Max float64
}
// Set sets the min and max values
func (mr *F64) Set(min, max float64) {
mr.Min, mr.Max = min, max
}
// SetInfinity sets the Min to +MaxFloat,... | minmax/minmax64.go | 0.853684 | 0.582105 | minmax64.go | starcoder |
package ring
import (
"encoding/binary"
"errors"
"math/bits"
)
// Poly is the structure containing the coefficients of a polynomial.
type Poly struct {
Coeffs [][]uint64 //Coefficients in CRT representation
}
// GetDegree returns the number of coefficients (degree) of the polynomial.
func (Pol *Poly) GetDegree()... | HE/ring/ring_object.go | 0.713332 | 0.521167 | ring_object.go | starcoder |
package processor
import (
"time"
"github.com/Jeffail/benthos/v3/lib/bloblang/x/mapping"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message"
"github.com/Jeffail/benthos/v3/lib/message/tracing"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/respons... | lib/processor/bloblang.go | 0.809577 | 0.746647 | bloblang.go | starcoder |
package evolution
import (
"fmt"
"math"
"math/rand"
"sort"
"sync"
)
const (
CrossoverSinglePoint = "CrossoverSinglePoint"
CrossoverFixedPoint = "CrossoverFixedPoint"
CrossoverKPoint = "CrossoverKPoint"
CrossoverUniform = "CrossoverUniform"
)
// CrossoverSinglePoint performs a single-point crossove... | evolution/reproduction.go | 0.61231 | 0.458712 | reproduction.go | starcoder |
package def
import (
"fmt"
)
type Direction int
// Directions
const (
NORTH Direction = iota
EAST
SOUTH
WEST
)
type Status int
// Health status
const (
ALIVE Status = iota
BROKEN
EATEN
)
type Action int
// Actions
const (
IDLE Action = iota
FACE_NORTH
FACE_EAST
FACE_SOUTH
FACE_WEST
MO... | def/simulation.go | 0.629661 | 0.492188 | simulation.go | starcoder |
package mimic
import (
"encoding/binary"
"fmt"
"github.com/cilium/ebpf/asm"
)
var _ VMMem = (*RingMemory)(nil)
// RingMemory is very similar to PlainMemory, except RingMemory will wrap around to the start when reading or writing
// out of bounds.
type RingMemory struct {
Backing []byte
ByteOrder binary.ByteO... | memory_ring.go | 0.849893 | 0.433802 | memory_ring.go | starcoder |
package flattree
import (
"errors"
"math/bits"
)
// Index returns the flat-tree of the node at the provided depth and offset
func Index(depth, offset uint64) uint64 {
return (offset << (depth + 1)) | ((1 << depth) - 1)
}
// Depth returns the depth of a given node
func Depth(n uint64) uint64 {
return uint64(bits.... | flat-tree.go | 0.863593 | 0.62111 | flat-tree.go | starcoder |
package bulletproofs
import (
"math/big"
)
/*
bprp structure contains 2 BulletProofs in order to allow computation of
generic Range Proofs, for any interval [A, B).
*/
type bprp struct {
A int64
B int64
BP1 BulletProofSetupParams
BP2 BulletProofSetupParams
}
/*
ProofBPRP stores the generic ZK... | crypto/vendor/ing-bank/zkrp/bulletproofs/bprp.go | 0.672117 | 0.442576 | bprp.go | starcoder |
package statsd
import "time"
// A NoopClient is a client that does nothing.
type NoopClient struct{}
// Close closes the connection and cleans up.
func (s *NoopClient) Close() error {
return nil
}
// Inc increments a statsd count type.
// stat is a string name for the metric.
// value is the integer value
// rate... | vendor/github.com/cactus/go-statsd-client/statsd/client_noop.go | 0.883726 | 0.550849 | client_noop.go | starcoder |
package ahrs
import (
"github.com/skelterjohn/go.matrix"
"math"
)
type Kalman1State struct {
State
}
func (s *Kalman1State) CalcRollPitchHeadingUncertainty() (droll float64, dpitch float64, dheading float64) {
droll, dpitch, dheading = VarFromQuaternion(s.E0, s.E1, s.E2, s.E3,
math.Sqrt(s.M.Get(6, 6)), math.Sq... | goflying/ahrs/ahrs_kalman1.go | 0.8557 | 0.57081 | ahrs_kalman1.go | starcoder |
package dataframe
import "fmt"
type DataFrame interface {
NRow() int
NCol() int
GetAllSeries() []Series
GetSeries(name string) (index int, s Series, ok bool)
SetSeries(series Series) error
// SetSeriesDirectly set series by index, without looking up by name of series.
SetSeriesDirectly(index int, series Serie... | dataframe.go | 0.694199 | 0.485295 | dataframe.go | starcoder |
package vkg
import (
"fmt"
vk "github.com/vulkan-go/vulkan"
)
// Buffer in vulkan are essentially a way of identifying and describing resources to the system. So for example
// you can have a buffer which holds vertex data in a specific format, or index data or a U.B.O (Uniform Buffer Object -
// which is data whi... | buffer.go | 0.720762 | 0.487307 | buffer.go | starcoder |
package diagnostics
import (
"context"
"fmt"
"time"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
diag_utils "github.com/dapr/dapr/pkg/diagnostics/utils"
)
var (
processStatusKey = tag.MustNewKey("process_status")
successKey = tag.MustNewKey("success")
topicKey ... | pkg/diagnostics/component_monitoring.go | 0.620047 | 0.404537 | component_monitoring.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// WorkbookRange
type WorkbookRange struct {
Entity
// Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. She... | models/microsoft/graph/workbook_range.go | 0.756447 | 0.646293 | workbook_range.go | starcoder |
package client
// Volume represents a named volume in a pod that may be accessed by any container in the pod.
type V1Volume struct {
// AWSElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage... | pkg/client/v1_volume.go | 0.85959 | 0.549882 | v1_volume.go | starcoder |
package toy
import (
"github.com/OpenWhiteBox/primitives/number"
)
// parasite represents the input or output mask of a single byte going into/out of an obfuscated affine layer.
type parasite struct {
frobenius int
scalar number.ByteFieldElem
}
func (p *parasite) Encode(in byte) byte {
temp := number.ByteFiel... | cryptanalysis/toy/parasite.go | 0.709221 | 0.412057 | parasite.go | starcoder |
package docs
import (
"errors"
"fmt"
"strconv"
"gopkg.in/yaml.v3"
)
func getFieldFromMapping(name string, createMissing bool, node *yaml.Node) (*yaml.Node, error) {
node.Kind = yaml.MappingNode
var foundNode *yaml.Node
for i := 0; i < len(node.Content)-1; i += 2 {
if node.Content[i].Value == name {
found... | internal/docs/yaml_path.go | 0.554953 | 0.40157 | yaml_path.go | starcoder |
package match
import (
"reflect"
"emperror.dev/errors"
)
// ErrorMatcher checks if an error matches a certain condition.
type ErrorMatcher interface {
// MatchError checks if err matches a certain condition.
MatchError(err error) bool
}
// ErrorMatcherFunc turns a plain function into an ErrorMatcher if it's def... | match/match.go | 0.777975 | 0.418281 | match.go | starcoder |
package ast
import (
"github.com/cntzr/remgo/token"
)
type (
Node interface {
TokenLiteral() string
}
// Represents one complete reminder as a one-liner
Statement interface {
Node
statementNode()
}
// List of all reminders in one file or over all files
Reminders struct {
Statements []Statement
}
... | ast/ast.go | 0.553747 | 0.587174 | ast.go | starcoder |
package rest
import (
"sort"
)
// Filter tests if a value fulfills the given logic.
type Filter func(interface{}) bool
// Dict is a container with guaranteed key ordering.
type Dict struct {
Keys []string
Values []interface{}
}
// NewDictWithCap creates a new Dict object with given capacity.
func NewDictWithCa... | dict.go | 0.796807 | 0.433802 | dict.go | starcoder |
package main
import (
"fmt"
"time"
)
// Return difference between two times in a printable format
func getTimeDiffString(a, b time.Time) (timeDiff string) {
year, month, day, hour, min, sec := getTimeDiffNumbers(a, b)
// Format the output
timeDiff = ""
if year > 0 {
if year > 1 {
timeDiff += fmt.Sprintf... | timeutils.go | 0.53607 | 0.525612 | timeutils.go | starcoder |
package vector
import (
"github.com/zhangxianweihebei/gostl/utils/iterator"
)
//ArrayIterator is an implementation of RandomAccessIterator
var _ iterator.RandomAccessIterator = (*VectorIterator)(nil)
// VectorIterator represents a vector iterator
type VectorIterator struct {
vec *Vector
position int // the p... | ds/vector/iterator.go | 0.86332 | 0.474692 | iterator.go | starcoder |
package main
import (
"crypto/md5"
"encoding/json"
"fmt"
"strings"
)
func minmax(a, b int) (int, int) {
if a < b {
return a, b
} else {
return b, a
}
}
type Line struct {
X1, Y1, X2, Y2 int
}
type VectorImage struct {
Lines []Line
}
// The interface given
func NewRectangle(width, height int) *VectorIm... | Structural/Adapter/adapter_with_caching.go | 0.669205 | 0.405714 | adapter_with_caching.go | starcoder |
package entity
import (
"fmt"
"math"
"unsafe"
)
// Coord is the of coordinations entity position (x, y, z)
type Coord float32
// Vector3 is type of entity position
type Vector3 struct {
X Coord
Y Coord
Z Coord
}
func (p Vector3) String() string {
return fmt.Sprintf("(%.2f, %.2f, %.2f)", p.X, p.Y, p.Z)
}
// ... | engine/entity/AOI.go | 0.766905 | 0.569494 | AOI.go | starcoder |
package src
import (
"strings"
"strconv"
//"fmt"
)
/** Lists all user-callable functions that return matrices */
var Functions = map[string]bool {
"zeros(" : true,
"id(" : true,
"rref(" : true,
"transpose(" : true,
"inv(" : true,
"col(" : true,
"row(" : true,
"null(": true... | src/Functions.go | 0.538983 | 0.497986 | Functions.go | starcoder |
package gofra
import (
"image/color"
. "github.com/gitchander/gofra/complex"
"github.com/gitchander/gofra/fcolor"
"github.com/gitchander/gofra/math2d"
)
type colorСomputer interface {
colorСompute(x, y int) color.RGBA
Clone() colorСomputer
}
type aliasingСomputer struct {
iterations int
colorTable []fc... | compute.go | 0.704872 | 0.431405 | compute.go | starcoder |
package timeutils
import (
"time"
)
const pATTERN string = "2006-01-02 15:04:05"
/**
return Now time-object within Golang builtin type `time.Time`.
*/
func NowTime() time.Time {
return time.Now()
}
/**
return formatted string from Now time-object within Golang builtin type `time.Time`.
Predefined layouts ANSIC, ... | pkg/timeutils/timeutils.go | 0.905572 | 0.498413 | timeutils.go | starcoder |
package main
import (
"strconv"
"math"
"syscall/js"
)
func main() {
}
type node struct {
data int
// For each node, which node it can most efficiently be reached from.
// If a node can be reached from many nodes, cameFrom will eventually contain the
// most efficient previous step.
previous *node
// For ... | src/examples/wasm/export/wasm.go | 0.521959 | 0.458894 | wasm.go | starcoder |
package clone_graph
import "container/list"
/*
133. 克隆图
https://leetcode-cn.com/problems/clone-graph
给你无向 连通 图中一个结点的引用,请你返回该图的 深拷贝(克隆)。
图中的每个结点都包含它的值 val(int) 和其邻居的列表(list[Node])。
class Node {
public int val;
public List<Node> neighbors;
}
测试用例格式:
简单起见,每个结点的值都和它的索引相同。例如,第一个结点值为 1(val = 1),第二个结点值为 2(val =... | solutions/clone-graph/d.go | 0.53048 | 0.506591 | d.go | starcoder |
package indicators
import (
"container/list"
"errors"
"github.com/jaybutera/gotrade"
"math"
)
// A Highest High Value Bars Indicator (HhvBars), no storage, for use in other indicators
type HhvBarsWithoutStorage struct {
*baseIndicatorWithIntBounds
// private variables
periodHistory *list.List
currentHigh ... | indicators/hhvbars.go | 0.619011 | 0.484563 | hhvbars.go | starcoder |
package match
import "time"
// Condition is used to match a time.
// All fields are optional and can be used in any combination.
// For each field one value of the list has
// to match to find a match for the condition.
type Condition struct {
Year []int
Month []time.Month
Day []int // 1 to 31
Weekday []... | match/next.go | 0.736401 | 0.652449 | next.go | starcoder |
package bin
import (
"bytes"
"encoding/binary"
"io"
"reflect"
"strconv"
"github.com/dyrkin/bin/util"
)
type decoder struct {
buf *bytes.Buffer
}
//Decode struct from byte array
func Decode(payload []byte, response interface{}) {
value := reflect.ValueOf(response)
decoder := &decoder{bytes.NewBuffer(payloa... | decoder.go | 0.535098 | 0.432423 | decoder.go | starcoder |
package plot
import (
"fmt"
"math"
"time"
)
const (
_ = iota
// ConsolidateAverage represents an average consolidation type.
ConsolidateAverage
// ConsolidateLast represents a last value consolidation type.
ConsolidateLast
// ConsolidateMax represents a maximal value consolidation type.
ConsolidateMax
// C... | pkg/plot/func.go | 0.86923 | 0.538073 | func.go | starcoder |
package spin
// Sizing from
// https://github.com/preble/pyprocgame/blob/master/procgame/modes/scoredisplay.py#L104
func singlePlayerPanel(e *ScriptEnv, r Renderer) {
g := r.Graphics()
player := GetPlayerVars(e)
switch {
case player.Score < 1_000_000_000:
g.Font = Font18x12
case player.Score < 10_000_000_000:... | panels.go | 0.688468 | 0.417093 | panels.go | starcoder |
package predicate
import (
"github.com/searKing/golang/go/error/exception"
"github.com/searKing/golang/go/util/class"
"github.com/searKing/golang/go/util/object"
)
/**
* Represents a predicate (boolean-valued function) of one argument.
*/
type Predicater interface {
/**
* Evaluates this predicate on the give... | go/util/function/predicate/predicate.go | 0.890157 | 0.500244 | predicate.go | starcoder |
package main
type Version string
// From rpmio/rpmvercmp.c
// https://github.com/rpm-software-management/rpm/blob/master/rpmio/rpmvercmp.c
/* compare alpha and numeric segments of two versions */
/* return 1: a is newer than b */
/* 0: a and b are the same version */
/* -1: b is newer than a */
func (a ... | web/rpmvercmp.go | 0.713032 | 0.400749 | rpmvercmp.go | starcoder |
package db
import (
"reflect"
"time"
"github.com/upper/db/v4/internal/adapter"
)
// Comparison represents a relationship between values.
type Comparison struct {
*adapter.Comparison
}
// Gte is a comparison that means: is greater than or equal to value.
func Gte(value interface{}) *Comparison {
return &Compar... | comparison.go | 0.840979 | 0.502441 | comparison.go | starcoder |
package main
import (
"fmt"
"github.com/gtfierro/xboswave/ingester/types"
xbospb "github.com/gtfierro/xboswave/proto"
"strings"
)
var lookup = map[string]func(msg xbospb.XBOS) float64{
"uptime": func(msg xbospb.XBOS) float64 {
return float64(msg.HamiltonData.H3C.Uptime)
},
"acc_x": func(msg xbospb.XBOS) floa... | ingester/plugins/hamilton1.go | 0.544559 | 0.565179 | hamilton1.go | starcoder |
package vesper
import (
"math"
"math/rand"
"strconv"
)
const epsilon = 0.000000001
// Zero is the Vesper 0 value
var Zero = Number(0)
// One is the Vesper 1 value
var One = Number(1)
// MinusOne is the Vesper -1 value
var MinusOne = Number(-1)
// Number - create a Number object for the given value
func Number(... | number.go | 0.716417 | 0.516169 | number.go | starcoder |
package studio
import (
"github.com/chewxy/math32"
)
func (v *Vec3) VectorLength() float32 {
return math32.Sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
}
func (v *Vec3) VectorNormalize() float32 {
length := v.VectorLength()
if length > 0.0 {
ilength := 1 / length
v[0] *= ilength
v[1] *= ilength
v[2] *= ileng... | studio/vecutil.go | 0.605682 | 0.526404 | vecutil.go | starcoder |
package timezone
import "regexp"
// TimezoneInfo is the data for parsing timezone from a string.
type TimezoneInfo struct {
RegexPatterns []string
AlternativePatterns map[*regexp.Regexp]string
Timezones map[string]int
}
// These timezone list are taken fromseveral sources:
// - http://stackoverflo... | internal/timezone/timezones.go | 0.656438 | 0.601301 | timezones.go | starcoder |
package plot
import (
"errors"
"fmt"
"reflect"
"sort"
"github.com/ShawnROGrady/benchparse"
"github.com/ShawnROGrady/benchplot/plot/plotter"
)
// The available plot types.
const (
ScatterType = "scatter"
AvgLineType = "avg_line"
)
type plotOptions struct {
groupBy []string
plotTypes []string
filterE... | plot/benchmark.go | 0.627837 | 0.430506 | benchmark.go | starcoder |
package faker
import (
"fmt"
"golang.org/x/exp/rand"
)
type nameFaker struct {
formatsFemale, formatsMale *weightedEntries
firstNameFemale, firstNameMale *weightedEntries
lastName *weightedEntries
prefixFemale, prefixMale *weightedEntries
suffixFemale, suffixMale *weight... | pkg/workload/faker/name.go | 0.560493 | 0.477432 | name.go | starcoder |
package main
import (
"fmt"
"math/cmplx"
)
func main() {
fmt.Println(quartic([]float64{7, 0, 0, 0, 5}))
fmt.Println(quartic([]float64{7, 50, 49, 6, 5}))
fmt.Println(quartic([]float64{10, 4, 0, 0, 0}))
fmt.Println(quartic([]float64{2, 4, 6, 8, 10}))
fmt.Println(quartic([]float64{-6, -4, 190, 45, 19}))
}
func ... | math/quartic-equation.go | 0.589835 | 0.413004 | quartic-equation.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.825871 | 0.597256 | game_mode.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.