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 seq
import (
"github.com/fogfish/golem/generic"
)
// AnyT is Seq data type build of `generic.T` elements.
// It is a type alias of `[]generic.T`
type AnyT []generic.T
// Contain tests if sequence contains an element
func (seq AnyT) Contain(e generic.T) bool {
return seq.Exists(func(x generic.T) bool { ret... | seq/seq.go | 0.807157 | 0.446676 | seq.go | starcoder |
package strassen
import (
"context"
"log"
"github.com/rossmerr/graphblas"
"github.com/rossmerr/graphblas/constraints"
)
// Multiply multiplies a matrix by another matrix using the Strassen algorithm
func Multiply[T constraints.Number](ctx context.Context, a, b graphblas.Matrix[T]) graphblas.Matrix[T] {
return ... | math/strassen/strassen.go | 0.750461 | 0.695079 | strassen.go | starcoder |
package objects
import "strconv"
//User structure for the user
type User struct {
X, Y, Z int64
C chan string
Name string
SentTimeUpdate int
}
//ToString Function to convert the user to a string object
func (u *User) ToString() string {
return strconv.FormatInt(u.X, 10) + ", " + st... | lib/objects/user.go | 0.573201 | 0.706026 | user.go | starcoder |
package cw
import (
"context"
"strings"
"time"
"unicode"
)
// WPMToSeconds returns the duration of a dit in seconds with the given speed in WpM.
func WPMToSeconds(wpm int) float64 {
return (float64(60) / float64(50*wpm))
}
// BPMToSeconds returns the duration of a dit in seconds with the given speed in BpM.
fun... | cw/cw.go | 0.736874 | 0.639609 | cw.go | starcoder |
package migrate
import (
"reflect"
"strconv"
"strings"
"time"
"github.com/google/uuid"
"github.com/neuronlabs/neuron/errors"
"github.com/neuronlabs/neuron/mapping"
)
var (
/** Character types */
// FChar is the 'char' field type.
FChar = &ParameterDataType{SQLName: "char", DataType: DataType{Name: "char"}... | repository/postgres/migrate/types.go | 0.516839 | 0.498779 | types.go | starcoder |
package bls12381
type pair struct {
g1 *PointG1
g2 *PointG2
}
func newPair(g1 *PointG1, g2 *PointG2) pair {
return pair{g1, g2}
}
// Engine is BLS12-381 elliptic curve pairing engine
type Engine struct {
G1 *G1
G2 *G2
fp12 *fp12
fp2 *fp2
pairingEngineTemp
pairs []pair
}
// NewEngine creates new pairin... | pairing.go | 0.615319 | 0.569254 | pairing.go | starcoder |
package rest
type RestClient interface {
// Makes a GET request to the shift api at "/staged".
// Returns result as array of mappings of strings to interfaces
// where each map in the array represents a migration, and each
// migration contains keys and values describing all of the fields
// of a migration.
Stag... | runner/pkg/rest/rest_api.go | 0.641085 | 0.455259 | rest_api.go | starcoder |
package builder
import (
"path"
"github.com/gravitational/gravity/lib/storage"
)
// DependencyForServer looks up a dependency in the list of sub-phases of the given phase
// that references the specified server and returns a reference to it.
// If no server has been found, it returns the reference to the phase its... | lib/update/internal/builder/builder.go | 0.808635 | 0.407333 | builder.go | starcoder |
package avaclient
// PositionDto struct for PositionDto
type PositionDto struct {
// Elements GUID identifier.
Id string `json:"id"`
// This is used to store the GAEB XML Id within this IElement. This data is not used for any calculations or evaluations but only for GAEB serialization and deserialization.
GaebXmlI... | model_position_dto.go | 0.819352 | 0.400955 | model_position_dto.go | starcoder |
package types
import (
"strconv"
)
// Vector3int16 is a three-dimensional Euclidean vector with 16-bit integer
// precision.
type Vector3int16 struct {
X, Y, Z int16
}
// NewVector3int16 returns a vector initialized with the given components.
func NewVector3int16(x, y, z int) Vector3int16 {
return Vector3int16{X:... | Vector3int16.go | 0.921087 | 0.616388 | Vector3int16.go | starcoder |
package vmath
import (
"fmt"
"math"
"github.com/maja42/vmath/mathi"
)
type Vec4i [4]int
func (v Vec4i) String() string {
return fmt.Sprintf("Vec4i[%d x %d x %d x %d]", v[0], v[1], v[2], v[3])
}
// Format the vector to a string.
func (v Vec4i) Format(format string) string {
return fmt.Sprintf(format, v[0], v[1... | vec4i.go | 0.906547 | 0.636664 | vec4i.go | starcoder |
package box2d
import (
"fmt"
"math"
)
/// Weld joint definition. You need to specify local anchor points
/// where they are attached and the relative body angle. The position
/// of the anchor points is important for computing the reaction torque.
type B2WeldJointDef struct {
B2JointDef
/// The local anchor poin... | DynamicsB2JointWeld.go | 0.886574 | 0.746347 | DynamicsB2JointWeld.go | starcoder |
package main
import (
"fmt"
"gopkg.in/yaml.v2"
)
// Dataset is a wrapper around a configuration for a dataset export
type Dataset struct {
Directory string `yaml:"directory"`
ZipFileName string `yaml:"zipFileName"`
PrimaryKeyFileName string `yaml:"pkFileName"`
NumberOfEntities uint16 ... | model.go | 0.667581 | 0.417331 | model.go | starcoder |
package main
import (
"fmt"
"image/color"
"math"
"math/rand"
"os"
"runtime"
"time"
"github.com/veandco/go-sdl2/sdl"
"github.com/xyproto/pf"
"github.com/xyproto/pixelpusher"
"github.com/xyproto/sdl2utils"
)
const (
// Size of "worldspace pixels", measured in "screenspace pixels"
pixelscale = 4
// The r... | cmd/strobe/main.go | 0.674694 | 0.493714 | main.go | starcoder |
package models
// There are a few methods of PatternPhase we can implement uniformly, and that we also
// would want access to to implement the unique logic for a given phase. We can embed
// this type in our specific implementations in order to gain access to these methods.
type phaseCoreAuto struct {
ticker *PriceT... | models/phaseAutoCore.go | 0.841077 | 0.544075 | phaseAutoCore.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// WorkbookSortField
type WorkbookSortField struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used ... | models/workbook_sort_field.go | 0.72594 | 0.600569 | workbook_sort_field.go | starcoder |
package binding
import (
"fmt"
"reflect"
"runtime"
)
// isStructPtr returns true if the value given is a
// pointer to a struct
func isStructPtr(value interface{}) bool {
return reflect.ValueOf(value).Kind() == reflect.Ptr &&
reflect.ValueOf(value).Elem().Kind() == reflect.Struct
}
// isFunction returns true i... | v2/internal/binding/reflect.go | 0.598077 | 0.416975 | reflect.go | starcoder |
package tart
// On Balance Volume (OBV) measures buying and selling
// pressure as a cumulative indicator, adding volume on
// up days and subtracting it on down days. OBV was
// developed by <NAME> and introduced in his 1963
// book Granville's New Key to Stock Market Profits.
// It was one of the first indicators to... | obv.go | 0.640186 | 0.53777 | obv.go | starcoder |
package channeld
import (
"errors"
"fmt"
"math"
"channeld.clewcat.com/channeld/pkg/channeldpb"
"channeld.clewcat.com/channeld/pkg/common"
"go.uber.org/zap"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/anypb"
)
type SpatialController interface {
// No... | pkg/channeld/spatial.go | 0.6508 | 0.40486 | spatial.go | starcoder |
package canvas
// Object represents an object that can be drawn on the canvas.
type Object interface {
// Stroke draws an outline of the Object.
Stroke(Point)
// Fill fills the area of the canvas represented by the Object.
Fill(Point)
// Set various styles having to do with drawing lines. For more
// informat... | object.go | 0.864882 | 0.573141 | object.go | starcoder |
package entropy
import (
"errors"
"kanzi"
)
const (
BINARY_ENTROPY_TOP = uint64(0x00FFFFFFFFFFFFFF)
MASK_24_56 = uint64(0x00FFFFFFFF000000)
MASK_0_24 = uint64(0x0000000000FFFFFF)
MASK_0_32 = uint64(0x00000000FFFFFFFF)
)
type Predictor interface {
// Update the probability model
Upda... | go/src/kanzi/entropy/BinaryEntropyCodec.go | 0.804137 | 0.40204 | BinaryEntropyCodec.go | starcoder |
package models
import (
"errors"
)
// Provides operations to call the validateComplianceScript method.
type DataType int
const (
// None data type.
NONE_DATATYPE DataType = iota
// Boolean data type.
BOOLEAN_DATATYPE
// Int64 data type.
INT64_DATATYPE
// Double data type.
DOUBLE_DAT... | models/data_type.go | 0.661048 | 0.422207 | data_type.go | starcoder |
package parse
import (
"encoding/json"
"flag"
"fmt"
"reflect"
"strconv"
"strings"
"time"
)
// Parser is an interface that allows the contents of a flag.Getter to be set.
type Parser interface {
flag.Getter
SetValue(interface{})
}
// BoolValue bool Value type
type BoolValue bool
// Set sets bool value from ... | vendor/github.com/containous/flaeg/parse/parse.go | 0.805288 | 0.499756 | parse.go | starcoder |
package main
import (
"bufio"
"fmt"
"io"
"math/bits"
"os"
)
// State is a game state bitboard encoding the entire game state. No
// methods actually modify the State, rather return an updated State.
type State uint64
// Mask efficiently validate moves, mostly behaving like a State. No
// methods actually modify... | misc/bsquare.go | 0.684159 | 0.437163 | bsquare.go | starcoder |
package go_kd_segment_tree
import (
"errors"
"fmt"
mapset "github.com/deckarep/golang-set"
"sort"
)
type ConjunctionNode struct {
TreeNode
Tree *Tree
DimName interface{}
Level int
DecreasePercent float64
segments []*Segment
dimNode map[interface{}]ConjunctionDimNode
}
func (node *Con... | node_conjunction.go | 0.551574 | 0.507873 | node_conjunction.go | starcoder |
package main
import (
"log"
"time"
"github.com/ikester/gpio"
)
const redIndex int = 0
const greenIndex int = 1
const blueIndex int = 2
const brightnessIndex int = 3
// default raw brightness. Not to be used user-side
const defaultBrightnessInt int = 10
//upper and lower bounds for user specified brightness
con... | led.go | 0.743541 | 0.471041 | led.go | starcoder |
package sql
import (
"fmt"
"github.com/sheenobu/cm.go"
)
// ValueColumn is a value column that contains metadata about the database column
type ValueColumn struct {
name string
ctype string
null bool
fns map[string]func() interface{}
}
// Column returns a column object given the name and type
func Column(... | sql/column.go | 0.569374 | 0.4133 | column.go | starcoder |
package main
import (
"math"
"math/rand"
. "github.com/jakecoffman/cp"
"github.com/jakecoffman/cp/examples"
)
const (
COLLISION_TYPE_STICKY = 1
STICK_SENSOR_THICKNESS = 2.5
)
func PostStepAddJoint(space *Space, key, _ interface{}) {
space.AddConstraint(key.(*Constraint))
}
func StickyPreSolve(arb *Arbiter,... | examples/sticky/sticky.go | 0.682891 | 0.423398 | sticky.go | starcoder |
package texture
import (
"log"
"time"
"github.com/kasworld/h4o/_examples/app"
"github.com/kasworld/h4o/geometry"
"github.com/kasworld/h4o/graphic"
"github.com/kasworld/h4o/light"
"github.com/kasworld/h4o/material"
"github.com/kasworld/h4o/math32"
"github.com/kasworld/h4o/texture"
"github.com/kasworld/h4o/ut... | _examples/demos/texture/cylinder.go | 0.51562 | 0.41052 | cylinder.go | starcoder |
package protocol
const size int = 16
type ColorModel struct {
Color [3]uint8
Hold uint8
}
type LedMatrixModel struct {
Matrix [size][size]ColorModel
}
func (l *LedMatrixModel) ConvertMatrixToFrame() (FrameModelOutput, FrameModelOutput) {
var frame FrameModelOutput
var frame2 FrameModelOutput
frame.FrameNumb... | GOLANG/protocol_paillettes/protocol/LedMatrixModel.go | 0.515376 | 0.635548 | LedMatrixModel.go | starcoder |
package interest
import (
"github.com/strongo/decimal"
"time"
"fmt"
)
type Credit interface {
Formula() Formula
RatePeriod() RatePeriodInDays
RatePercent() decimal.Decimal64p2
MinimumPeriod() int
GracePeriod() int
}
type Deal interface {
Credit
Time() time.Time
LentAmount() decimal.Decimal64p2
}
type dea... | interfaces.go | 0.705785 | 0.434281 | interfaces.go | starcoder |
package fy
import "github.com/MaxSlyugrov/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE d MMMM y", Long: "d MMMM y", Medium: "d MMM y", Short: "dd-MM-yy"},
Time: cldr.CalendarDateFormat{Full: "HH:mm:ss zzzz", Long: "HH:mm:ss z", Medium: "HH:m... | resources/locales/fy/calendar.go | 0.516352 | 0.425009 | calendar.go | starcoder |
package cal
import (
"fmt"
"time"
)
// Canadian holidays
// Source: https://en.wikipedia.org/wiki/Public_holidays_in_Canada
// Other source with conflicting data: https://www.timeanddate.com/holidays/canada/
// Wikipedia was chosen over timeanddate, an actual Canadian should go over the data.
var (
// National hol... | v2/holiday_defs_ca.go | 0.53607 | 0.547101 | holiday_defs_ca.go | starcoder |
package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
)
// Grid for cellular automata, mazes, etc.
type Grid [][]byte
// Coordinate is a position on a Grid, i.e., grid[y][x]
type Coordinate struct {
y int
x int
}
// Returns the value at a map coordinate, or the zero byte if out of bounds
func (g Grid) Ge... | 2020/20/a.go | 0.669745 | 0.403126 | a.go | starcoder |
package schema
const PayloadSchema = `{
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "docs/spec/metrics/payload.json",
"title": "Metrics payload",
"description": "Metrics for correlation with other APM data",
"type": "object",
"properties": {
"metrics": {
"t... | model/metric/generated/schema/payload.go | 0.82386 | 0.536191 | payload.go | starcoder |
package task
import (
"fmt"
"path"
"github.com/pkg/errors"
"github.com/uncharted-distil/distil-compute/model"
"github.com/uncharted-distil/distil-compute/primitive/compute"
"github.com/uncharted-distil/distil-compute/primitive/compute/description"
"github.com/uncharted-distil/distil-compute/primitive/compute... | api/task/geocoding.go | 0.696991 | 0.420064 | geocoding.go | starcoder |
package transformer
import "gopkg.in/bblfsh/sdk.v2/uast/nodes"
func MapEach(vr string, m Mapping) Mapping {
src, dst := m.Mapping()
return Map(Each(vr, src), Each(vr, dst))
}
// ArrayOp is a subset of operations that operates on an arrays with a pre-defined size. See Arr.
type ArrayOp interface {
Op
arr(st *Stat... | vendor/gopkg.in/bblfsh/sdk.v2/uast/transformer/arrays.go | 0.797399 | 0.628122 | arrays.go | starcoder |
package simplex
import (
"math"
)
// Skewing and unskewing factors for 2, 3, and 4 dimensions
var (
f2 float64 = 0.5 * (math.Sqrt(3.0) - 1.0)
g2 float64 = (3.0 - math.Sqrt(3.0)) / 6.0
f3 float64 = 1.0 / 3.0
g3 float64 = 1.0 / 6.0
F4 float64 = (math.Sqrt(5.0) - 1.0) / 4.0
G4 float64 = (5.0 - math.Sqrt(5.0)) / 2... | util/noise/simplex/simplex.go | 0.723016 | 0.63202 | simplex.go | starcoder |
package linkedlist
import (
"errors"
"fmt"
col "github.com/raunakjodhawat/gorithims/src/dataStructure/collection"
"reflect"
)
// Node holds the value/data and a pointer to next and previous value
type Node struct {
Val interface{}
Next *Node
Prev *Node
}
// List type, stores the head and tail. It represents ... | src/dataStructure/collection/linkedList/linkedList.go | 0.746693 | 0.4081 | linkedList.go | starcoder |
package main
import (
"github.com/srabraham/advent-of-code-2019/internal/seanmath"
"io/ioutil"
"log"
"math"
"sort"
"strings"
)
func f(err error) {
if err != nil {
log.Fatal(err)
}
}
type GridPos struct {
x int
y int
}
type Grid struct {
vals map[GridPos]string
maxX int
maxY int
}
func (g Grid) ValAt... | cmd/day10/day10.go | 0.631253 | 0.462837 | day10.go | starcoder |
package curves
import (
math2 "github.com/wieku/danser-go/bmath"
"github.com/wieku/danser-go/bmath"
"math"
)
type Catmull struct {
points []math2.Vector2d
ApproxLength float64
}
func NewCatmull(points []math2.Vector2d) Catmull {
if len(points) != 4 {
panic("4 points are needed to create centripetal ca... | bmath/curves/catmull.go | 0.777046 | 0.621311 | catmull.go | starcoder |
package conditions
import (
"strings"
"time"
)
// Binary string operators
var stringComparisons = map[string]func(string, string) bool{
"equals": func(a, b string) bool { return a == b },
"equalsFoldCase": strings.EqualFold,
"notEquals": func(a, b string) bool { return a != b },
"beginsWith": s... | credential/presentation/conditions/operations.go | 0.826922 | 0.509398 | operations.go | starcoder |
// Renders a textured spinning cube using GLFW 3 and OpenGL 4.1 core forward-compatible profile.
// VS Code, left hand column: Green lines are new lines (since last commit), blue lines are changed from last commit,
// and red arrows mean deletion since last commit.
package main
import (
_ "image/png"
"github.com/... | cmd/Basics/07-Box2D/main.go | 0.735926 | 0.486088 | main.go | starcoder |
package rules
var (
kingMoveOffsets = []square{
{file: -1, rank: 1}, {file: 0, rank: 1}, {file: 1, rank: 1},
{file: -1, rank: 0} /*****************/, {file: 1, rank: 0},
{file: -1, rank: -1}, {file: 0, rank: -1}, {file: 1, rank: -1},
}
knightMoveOffsets = []square{
{file: -1, rank: 2}, {file: -1, rank: -2}... | rules/pieces_offsets.go | 0.525856 | 0.611556 | pieces_offsets.go | starcoder |
package privacy
import (
"errors"
"math/big"
"github.com/incognitochain/incognito-chain/common"
)
// SchnorrPublicKey represents Schnorr Publickey
// PK = G^SK + H^R
type SchnorrPublicKey struct {
publicKey *EllipticPoint
g, h *EllipticPoint
}
func (schnorrPubKey SchnorrPublicKey) GetPublicKey() *Elliptic... | privacy/schnorr.go | 0.766992 | 0.405596 | schnorr.go | starcoder |
A full reptend prime in base b is a prime such that b is a primitive root modulo p. In this case 10
is the base.
A number m is a primitive root modulo n, if the multiplicative order of the number m modulo n is
equal to phi(n). (totient function) (Primitive roots modulo n)
Phi(p) = p - 1. Therefore the order of 1... | Problems/euler026.go | 0.666171 | 0.552298 | euler026.go | starcoder |
package brotli
/* Copyright 2013 Google Inc. All Rights Reserved.
Distributed under MIT license.
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
/* Functions to estimate the bit cost of Huffman trees. */
func shannonEntropy(population []uint32, size uint, total *uint) float64 {
v... | vendor/github.com/andybalholm/brotli/bit_cost.go | 0.684053 | 0.475423 | bit_cost.go | starcoder |
package p273
import "bytes"
/**
Convert a non-negative integer to its english words representation.
Given input is guaranteed to be less than 2^31 - 1.
123 -> "One Hundred Twenty Three"
12345 -> "Twelve Thousand Three Hundred Forty Five"
1234567 -> "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Se... | algorithms/p273/273.go | 0.614163 | 0.439266 | 273.go | starcoder |
package ast
// Hierarchy provides helper methods to access a children's parent node and
// some node's children nodes.
type Hierarchy struct {
root Node
visitor NodeVisitor
parents map[Node]Node
children map[Node][]Node
}
func (h *Hierarchy) Root() Node {
return h.root
}
// Parent finds the parent node of... | pkg/ast/hierarchy.go | 0.738858 | 0.535402 | hierarchy.go | starcoder |
package fault
import (
"errors"
"math/rand"
"net/http"
"sync"
)
const (
// defaultRandSeed is used when a random seed is not set explicitly.
defaultRandSeed = 1
)
var (
// ErrNilInjector when a nil Injector is passed.
ErrNilInjector = errors.New("injector cannot be nil")
// ErrInvalidPercent when a percent ... | fault.go | 0.684897 | 0.410697 | fault.go | starcoder |
package orbit
import (
"math"
"github.com/dayaftereh/discover/server/mathf"
)
// https://github.com/jordanstephens/kepler.js
type Orbit struct {
r *mathf.Vec3 // position
v *mathf.Vec3 // velocity
mu float64 // mu = G*M
CentralBodyRadius float64
}
func NewOr... | server/mathf/orbit/orbit.go | 0.868269 | 0.569673 | orbit.go | starcoder |
package runner
import (
"errors"
"fmt"
"os"
"sort"
"strings"
"testing"
"text/tabwriter"
)
// NewRegistry returns a pointer to a new TestRegistry
func NewRegistry() *TestRegistry {
return &TestRegistry{
tests: make(map[string]Test),
TestSuites: make(map[string]TestSuite),
}
}
//NewTestSuite returns... | test/runner/runner.go | 0.732687 | 0.449755 | runner.go | starcoder |
package merkletree2
import "fmt"
// ValueConstructor is an interface for constructing values, so that typed
// values can be pulled out of the Merkle Tree. All Values must have the same
// type, howerver multiple types can be encoded by having this type implement
// the codec.Selfer interface.
type ValueConstructor i... | go/merkletree2/config.go | 0.711531 | 0.51068 | config.go | starcoder |
package GoTrees
import "strconv"
// bTreeNode is a container for the array of nodes used in b tree nodes
type bTreeNode struct {
nodes []*keyValue
length int
children []*bTreeNode
numChildren int
}
func newbTreeNode(alloc int) bTreeNode {
return bTreeNode{nodes: make([]*keyValue, alloc), length: 0... | BTreeNode.go | 0.584864 | 0.42662 | BTreeNode.go | starcoder |
Package etag is used to calculate the hash value of the file.
The algorithm is based on the qetag of Qi Niuyun.
Qetag address is
https://github.com/qiniu/qetag
This package extends two export functions based on Qetag,
named GetEtagByString, GetEtagByBytes
And re-implemented GetEtagByPath
*/
package goetag
import ... | etag.go | 0.718594 | 0.442757 | etag.go | starcoder |
package engine
import (
"bytes"
"github.com/wesrobin/battlesnakes/model"
"log"
"math"
)
func getCoordAfterMove(coord model.Coord, move model.Move) model.Coord {
switch move {
case model.Up:
return model.Coord{X: coord.X, Y: coord.Y + 1}
case model.Down:
return model.Coord{X: coord.X, Y: coord.Y - 1}
case ... | engine/util.go | 0.615435 | 0.494812 | util.go | starcoder |
package tables
import (
"github.com/sudachen/go-tables/internal"
"github.com/sudachen/go-tables/util"
"reflect"
)
type Column struct {
column reflect.Value
na util.Bits
}
func Col(a interface{}) *Column {
v := reflect.ValueOf(a)
if v.Kind() != reflect.Slice {
panic("anly slice is allowed as an argument"... | tables/column.go | 0.71721 | 0.413004 | column.go | starcoder |
package consensus
import (
"context"
"fmt"
"github.com/filecoin-project/go-filecoin/internal/pkg/block"
"github.com/filecoin-project/go-filecoin/internal/pkg/clock"
)
// BlockValidator defines an interface used to validate a blocks syntax and
// semantics.
type BlockValidator interface {
BlockSemanticValidator
... | internal/pkg/consensus/block_validation.go | 0.736969 | 0.417153 | block_validation.go | starcoder |
package heisenberg
import (
"fmt"
"math"
"math/cmplx"
)
// Dense64 is an algebriac matrix
type Dense64 struct {
R, C int
Matrix []complex64
}
func (a Dense64) String() string {
output := ""
for i := 0; i < a.R; i++ {
for j := 0; j < a.C; j++ {
output += fmt.Sprintf("%f ", a.Matrix[i*a.C+j])
}
outp... | dense.go | 0.741487 | 0.535463 | dense.go | starcoder |
package v1alpha1
// DataTransferConfigListerExpansion allows custom methods to be added to
// DataTransferConfigLister.
type DataTransferConfigListerExpansion interface{}
// DataTransferConfigNamespaceListerExpansion allows custom methods to be added to
// DataTransferConfigNamespaceLister.
type DataTransferConfigNa... | client/listers/bigquery/v1alpha1/expansion_generated.go | 0.556159 | 0.538073 | expansion_generated.go | starcoder |
// package shp implements shape structures/routines
package shp
import (
"github.com/cpmech/gosl/chk"
"github.com/cpmech/gosl/gm"
"github.com/cpmech/gosl/io"
"github.com/cpmech/gosl/la"
"github.com/cpmech/gosl/utl"
)
// constants
const MINDET = 1.0e-14 // minimum determinant allowed for dxdR
// ShpFunc is the ... | shp/shp.go | 0.588298 | 0.458106 | shp.go | starcoder |
package probe
import (
"fmt"
"reflect"
"regexp"
"strconv"
"strings"
"github.com/litmuschaos/litmus-go/pkg/log"
)
//Model contains operands and operator for the comparison operations
// a and b attribute belongs to operands and operator attribute belongs to operator
type Model struct {
a interface{}
b ... | pkg/probe/comparator.go | 0.650134 | 0.509764 | comparator.go | starcoder |
package maths
import (
"fmt"
"math"
"github.com/wdevore/Ranger-Go-IGE/api"
)
type vector struct {
x, y float32
}
// NewVector constructs a new IVector
func NewVector() api.IVector {
o := new(vector)
return o
}
// NewVectorUsing constructs a new IVector using components
func NewVectorUsing(x, y float32) api.I... | engine/maths/vector.go | 0.851459 | 0.519704 | vector.go | starcoder |
package pg
import (
"github.com/lib/pq/oid"
)
// RowDescriptionMessageType identifies RowDescriptionMessage message.
const RowDescriptionMessageType = 'T'
// RowDescriptionMessage represents a message sent by a backend to describe query result fields.
type RowDescriptionMessage struct {
// List of fields to be ret... | pkg/pg/row_description_message.go | 0.763396 | 0.422803 | row_description_message.go | starcoder |
package models
import (
"math"
)
type Vector struct {
data [3]float64
}
func NewEmptyVector() *Vector {
return &Vector{
[3]float64{0, 0, 0},
}
}
func NewVectorFromArray(data [3]float64) *Vector {
return &Vector{data}
}
func NewVector(x, y, z float64) *Vector {
return &Vector{
[3]float64{x, y, z},
}
}
f... | models/vector.go | 0.757884 | 0.757593 | vector.go | starcoder |
// Package dbf implements a database of f(t,{x}) functions (e.g. time-space functions). The
// functions in this package are accompanied by derivatives w.r.t t and gradients w.r.t {x}. For
// instance: g(t,{x}) = df/dt, h(t,{x}) = dg/dt, and grad = df/d{x}
package dbf
import (
"os"
"github.com/cpmech/gosl/chk"
"g... | fun/dbf/dbfunctions.go | 0.726037 | 0.563498 | dbfunctions.go | starcoder |
package sbvector
// BitVectorBuilderData holds bit vector data to build.
type BitVectorBuilderData struct {
vec *BitVectorData
}
// SuccinctBitVectorBuilder is interface of succinct bit vector builder.
type SuccinctBitVectorBuilder interface {
Set(i uint64, val bool)
Get(i uint64) (bool, error)
PushBack(b bool)
... | sbvector_builder.go | 0.847653 | 0.571139 | sbvector_builder.go | starcoder |
package lango
const jsonList = `
{
"aa": {
"code": "aa",
"name": [
"Afar"
],
"native": [
"Afaraf"
]
},
"ab": {
"code": "ab",
"name": [
"Abkhaz"
],
"native": [
"аҧсуа бызшәа",
"аҧсшәа"
]
},
"ae": {
"code": "ae",
"name": [
"Ave... | list.go | 0.514644 | 0.461684 | list.go | starcoder |
package blockchain
import (
"encoding/json"
"fmt"
)
// Data is an interface used to standardize methods for any type of Block data
type Data interface {
GetData() Data
ToString() string
}
// =========== Transaction ===========
// Transaction is a type of Data
type Transaction struct {
From string `json:"f... | src/blockchain/data.go | 0.554953 | 0.419232 | data.go | starcoder |
package rtc
import "math"
// Triangle returns a new TriangleT.
func Triangle(p1, p2, p3 Tuple) *TriangleT {
e1 := p2.Sub(p1)
e2 := p3.Sub(p1)
normal := e2.Cross(e1).Normalize()
bounds := Bounds()
bounds.UpdateBounds(p1)
bounds.UpdateBounds(p2)
bounds.UpdateBounds(p3)
return &TriangleT{
Shape: Shape{Trans... | rtc/triangle.go | 0.915748 | 0.606469 | triangle.go | starcoder |
package test
import (
"fmt"
"reflect"
gomegaFormat "github.com/onsi/gomega/format"
gomegaMatchers "github.com/onsi/gomega/matchers"
gomegaTypes "github.com/onsi/gomega/types"
)
func MatchArray(elements ...interface{}) gomegaTypes.GomegaMatcher {
return &MatchArrayMatcher{
Elements: elements,
}
}
type Match... | test/array.go | 0.676834 | 0.44077 | array.go | starcoder |
package bitset
// Dense is a standard bitset, represented as a sequence of bits. See Sparse in
// this package for a more memory-efficient storage scheme for sparse bitsets.
type Dense struct {
sets []Set64
}
// NewDense creates a set capable of representing values in the range
// [0, capacity), at least. The Cap me... | dense.go | 0.774924 | 0.475605 | dense.go | starcoder |
package mat
import (
"bufio"
"fmt"
"io"
"math"
"os"
"strconv"
"strings"
"github.com/pkg/errors"
)
// Vector is a list of float numbers.
type Vector []float64
// SparseVector is a map with index is a key and value is a value at that index.
type SparseVector map[int]float64
// SparseMatrix is a list of spars... | mat/mat.go | 0.600657 | 0.555435 | mat.go | starcoder |
package consensus
import (
"github.com/axiom-org/axiom/util"
)
// The nomination state for the Stellar Consensus Protocol.
// See page 21 of:
// https://www.stellar.org/papers/stellar-consensus-protocol.pdf
type NominationState struct {
// The values we have voted to nominate
X []SlotValue
// The values we have ... | consensus/nomination_state.go | 0.73659 | 0.531696 | nomination_state.go | starcoder |
package trix
// NodeList represents a list of pointers to nodes
type NodeList []*Node
// ConvertValues applies the conversion function to each of the NodeList's
// nodes that match specified keys, and replaces its value with the one
// returned.
func (nodes NodeList) ConvertValues(conv func(*Node) Value, keys ...stri... | nodelist.go | 0.824744 | 0.680122 | nodelist.go | starcoder |
package geom
import "math"
// PointEmptyCoordHex is the hex representation of a NaN that represents
// an empty coord in a shape.
const PointEmptyCoordHex = 0x7FF8000000000000
// PointEmptyCoord is the NaN float64 representation of the empty coordinate.
func PointEmptyCoord() float64 {
return math.Float64... | point.go | 0.859384 | 0.502808 | point.go | starcoder |
package aduket
import (
"encoding/json"
"encoding/xml"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func (r RequestRecorder) AssertStringBodyEqual(t *testing.T, expectedBody string) bool {
return assert.Equal(t, expectedBody, string(r.Data))
}
func (r RequestRecorder) AssertJSONBodyEqual(t *te... | assert.go | 0.758868 | 0.604428 | assert.go | starcoder |
package constraint
import (
"fmt"
"reflect"
"github.com/jt0/gomer/flect"
"github.com/jt0/gomer/gomerr"
)
// Length determines whether the value's length is either between (inclusively) two provided values (a min and max) or a
// single value (internally: min = max). This tests for min <= len(value) <= max. The v... | constraint/length.go | 0.744006 | 0.57681 | length.go | starcoder |
package problem9
import (
"math"
)
/**
* Special Pythagorean triplet
*
* https://projecteuler.net/problem=9
* A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
* a^2 + b^2 = c^2
* For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
* There exists exactly one Pythagorean triplet for whic... | problem-9/answer.go | 0.773559 | 0.431584 | answer.go | starcoder |
package plot
import (
"math"
"sort"
)
// Violin implements violin plot using cubic-pulse for kernel function.
type Violin struct {
Style
Label string
Side float64
Kernel Length
Normalized bool
Data []float64 // sorted
}
// NewViolin creates a new violin element using the specified values.
fu... | violin.go | 0.66356 | 0.519217 | violin.go | starcoder |
package address
type country struct {
ID string
Name string
DefaultLanguage string
PostCodePrefix string
PostCodeRegex postCodeRegex
Format string
LatinizedFormat string
AdministrativeAreaNameType FieldName
LocalityNameType FieldName
DependentLocalityNameType FieldName
PostCodeNam... | data.go | 0.51562 | 0.407805 | data.go | starcoder |
package tuple
import (
"fmt"
"golang.org/x/exp/constraints"
)
// T4 is a tuple type holding 4 generic values.
type T4[Ty1, Ty2, Ty3, Ty4 any] struct {
V1 Ty1
V2 Ty2
V3 Ty3
V4 Ty4
}
// Len returns the number of values held by the tuple.
func (t T4[Ty1, Ty2, Ty3, Ty4]) Len() int {
return 4
}
// Values returns ... | tuple4.go | 0.801081 | 0.496826 | tuple4.go | starcoder |
package v1
import (
"encoding/json"
)
// IPAssignmentInput struct for IPAssignmentInput
type IPAssignmentInput struct {
Address string `json:"address"`
Manageable *bool `json:"manageable,omitempty"`
Customdata *map[string]interface{} `json:"customdata,omitempty"`
}
// NewIPAssignmentInput instantiates a new IPA... | v1/model_ip_assignment_input.go | 0.708414 | 0.400603 | model_ip_assignment_input.go | starcoder |
package binutils
// Utility functions to translate native types into bytes sequence and vise versa.
import (
"encoding/binary"
"fmt"
)
// AllocateBytes creates a byte slice of required size.
func AllocateBytes(size int) []byte {
return make([]byte, size)
}
// Uint8 translates next byte from buffer into uint8 valu... | utils.go | 0.840488 | 0.494751 | utils.go | starcoder |
package threshold
import (
"context"
"time"
"github.com/geo-data/nicer/sample"
)
type (
// Threshold combines a Sampler with a threshold value and arbitrary name.
// It can then poll the Sampler and compare metrics against the threshold,
// triggering alerts when a threshold is crossed.
Threshold struct {
N... | threshold/threshold.go | 0.778776 | 0.464719 | threshold.go | starcoder |
package screen
import (
"image/color"
"github.com/go-vgo/robotgo"
"github.com/haroflow/go-macros/automation"
)
func Commands() []automation.Command {
moduleName := "screen"
return []automation.Command{
{
ModuleName: moduleName,
MethodName: "capture",
Parameters: "",
Description: "Captures and ... | automation/screen/screen.go | 0.720762 | 0.583915 | screen.go | starcoder |
package midi
import (
"encoding/binary"
"io"
"github.com/pkg/errors"
)
const (
SingleTrack uint16 = iota
Syncronous
Asyncronous
)
type Encoder struct {
// we need a write seeker because we will update the size at the end
// and need to back to the beginning of the file.
w io.WriteSeeker
/*
Format des... | encoder.go | 0.646906 | 0.428831 | encoder.go | starcoder |
package pt
import "math"
func NewSDFMesh(sdf SDF, box Box, step float64) *Mesh {
min := box.Min
size := box.Size()
nx := int(math.Ceil(size.X / step))
ny := int(math.Ceil(size.Y / step))
nz := int(math.Ceil(size.Z / step))
sx := size.X / float64(nx)
sy := size.Y / float64(ny)
sz := size.Z / float64(nz)
var t... | pt/mc.go | 0.52683 | 0.565899 | mc.go | starcoder |
package block
import (
"encoding/json"
"fmt"
"sort"
"github.com/filecoin-project/go-filecoin/internal/pkg/encoding"
"github.com/ipfs/go-cid"
"github.com/pkg/errors"
"github.com/polydawn/refmt/obj/atlas"
)
func init() {
// A TipSetKey serializes as a sorted array of CIDs.
// Deserialization will sort the CID... | internal/pkg/block/tipset_key.go | 0.698844 | 0.411939 | tipset_key.go | starcoder |
package window
import (
"math"
)
// Apply applies the window windowFunction to x.
func Apply(x []float64, windowFunction func(int) []float64) {
for i, w := range windowFunction(len(x)) {
x[i] *= w
}
}
// Rectangular returns an L-point rectangular window (all values are 1).
func Rectangular(L int) []float64 {
r... | window/window.go | 0.813164 | 0.412057 | window.go | starcoder |
package stats
import (
"fmt"
"time"
"github.com/status-im/simulation/propagation"
)
// Stats represents stats data for given simulation log.
type Stats struct {
NodeHits map[int]int
NodeCoverage Coverage
LinkCoverage Coverage
NodeHistogram *Histogram
LinkHistogram *Histog... | stats/stats.go | 0.659515 | 0.599427 | stats.go | starcoder |
package condition
import (
"fmt"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
)
//------------------------------------------------------------------------------
func init() {
Constructors[TypeAnd] = TypeSpec{
constructor: NewAnd... | lib/condition/and.go | 0.639849 | 0.615781 | and.go | starcoder |
package ahrs
import (
"log"
"math"
"fmt"
"github.com/skelterjohn/go.matrix"
)
type Kalman1State struct {
State
f *matrix.DenseMatrix
z *Measurement
y *matrix.DenseMatrix
h *matrix.DenseMatrix
ss *matrix.DenseMatrix
kk *matrix.DenseMatrix
}
// Initialize the state at the start of the... | ahrs/ahrs_kalman1.go | 0.705785 | 0.678021 | ahrs_kalman1.go | starcoder |
package judge
import (
"fmt"
"math"
"github.com/didi/nightingale/src/dataobj"
)
type Function interface {
Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)
}
type MaxFunction struct {
Function
Limit int
Operator string
RightValue float64
}
func (f MaxFunction) Comput... | src/modules/judge/judge/func.go | 0.548915 | 0.441974 | func.go | starcoder |
package main
import (
"fmt"
"math"
"github.com/golang-collections/go-datastructures/queue"
)
type Node struct {
value int
left, right *Node
}
type Tree struct {
root *Node
}
func LevelOrderBinaryTree(arr []int) *Tree {
tree := new(Tree)
tree.root = levelOrderBinaryTree(arr, 0, len(arr))
return tree
... | corpus/hermant.data-structure-algo/BinaryTree/Tree.go | 0.645008 | 0.418816 | Tree.go | starcoder |
package nn
import "github.com/MaxSlyugrov/cldr"
var currencies = []cldr.Currency{
{Currency: "ADP", DisplayName: "andorransk peseta", Symbol: ""},
{Currency: "AED", DisplayName: "UAE dirham", Symbol: ""},
{Currency: "AFA", DisplayName: "afghani (1927–2002)", Symbol: ""},
{Currency: "AFN", DisplayName: "afghani", ... | resources/locales/nn/currency.go | 0.609059 | 0.405007 | currency.go | starcoder |
package main
import (
"math"
"math/rand"
. "github.com/jakecoffman/cp"
"github.com/jakecoffman/cp/examples"
)
const (
bevel = 1.0
)
func main() {
space := NewSpace()
space.Iterations = 10
offset := Vector{-320, -240}
for i := 0; i < len(bouncy_terrain_verts)-1; i++ {
a := bouncy_terrain_verts[i]
b := ... | examples/bouncyhexagons/bouncyhexagons.go | 0.602529 | 0.573917 | bouncyhexagons.go | starcoder |
package idx
import (
"github.com/galaxy-digital/lachesis-base/common/bigendian"
)
type (
// Epoch numeration.
Epoch uint32
// Event numeration.
Event uint32
// Block numeration.
Block uint64
// Lamport numeration.
Lamport uint32
// Frame numeration.
Frame uint32
// Pack numeration.
Pack uint32
// ... | inter/idx/index.go | 0.743168 | 0.572544 | index.go | starcoder |
package commands
var EventsShort = `[Alpha] Poll the cluster until all provided resources have become Current and list the status change events.`
var EventsLong = `
[Alpha] Poll the cluster for the state of all the provided resources until either they have all become
Current or the timeout is reached. The output will... | kustomize/internal/commands/status/generateddocs/commands/docs.go | 0.648355 | 0.651012 | docs.go | starcoder |
package query
type JoinType int
const (
// use “iota + 1” to be sure that the enum type is initialized.
JoinTypeBase JoinType = iota + 1
JoinTypeLeft
JoinTypeLeftOuter
JoinTypeRight
JoinTypeRightOuter
JoinTypeInner
JoinTypeFull
JoinTypeFullOuter
JoinTypeNatural
JoinTypeCros... | enum.go | 0.553988 | 0.490846 | enum.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.