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 models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// CrossTenantAccessPolicyConfigurationPartner
type CrossTenantAccessPolicyConfigurationPartner struct {
// Stores additional data not described in the OpenAP... | models/cross_tenant_access_policy_configuration_partner.go | 0.661486 | 0.435601 | cross_tenant_access_policy_configuration_partner.go | starcoder |
package engine
import (
"fmt"
"github.com/ajeetdsouza/tracy/pkg/config"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/mat"
)
const (
wPoint = 1.0
wVector = 0.0
)
type Tuple struct {
data mat.Vector
}
func NewTuple(x, y, z, w float64) Tuple {
return Tuple{mat.NewVecDense(4, []float64{x, y, z, w})}
}
fun... | pkg/engine/tuple.go | 0.788339 | 0.564219 | tuple.go | starcoder |
package websocket
import (
"math/rand"
)
func (c *Chain) RandMove(playerColor string) (int, int) {
validSquares := make([][2]int, 0)
for y, v := range c.Squares {
for x, color := range v.Color {
if color == "" || color == playerColor {
validSquares = append(validSquares, [2]int{x, y})
}
}
}
sq := v... | websocket/bot.go | 0.525856 | 0.446434 | bot.go | starcoder |
package raytracer
import (
"fmt"
"gonum.org/v1/gonum/spatial/r3"
"math"
"reflect"
)
type hitRecord struct {
t float64
p r3.Vec
normal r3.Vec
shape Shape
material Material
}
type Shape interface {
// rotation vector is in degrees
Rotate(rv r3.Vec)
Scale(c float64)
Translate(tv r3.Vec)
... | raytracer/shape.go | 0.838911 | 0.55652 | shape.go | starcoder |
package game
import (
"math"
"sort"
)
// NewEngine initializes a new physics engine
func NewEngine(width, height int, circles []*Circle, capsules []*Capsule, rectangles []*collisionRect) *Engine {
e := &Engine{
minArea: 99999999,
steps: 10,
inverseSteps: 1 / 10,
selectedCapsule: capsu... | game/physics.go | 0.710528 | 0.474814 | physics.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_adaboost
#include <capi/adaboost.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type AdaboostOptionalParam struct {
InputModel *adaBoostModel
Iterations int
Labels *mat.Dense
Test *mat.Dense
Tolera... | adaboost.go | 0.756717 | 0.464234 | adaboost.go | starcoder |
package optimization
import "fmt"
type (
Grid struct {
NumX int `json:"num_x"`
NumY int `json:"num_y"`
NumZ int `json:"num_z"`
MinX float64 `json:"min_x"`
MinY float64 `json:"min_y"`
MinZ float64 `json:"min_z"`
SizX float64 `json:"siz_x"`
SizY float64 `json:"siz_y"`
SizZ float64 `json:"siz_z"`
... | optimization/grid.go | 0.85814 | 0.484258 | grid.go | starcoder |
package main
import (
"fmt"
"log"
"math/rand"
"time"
ui "github.com/gizak/termui"
"github.com/gizak/termui/widgets"
)
const (
// Number of agents in the market
numOfAgents = 10
// Initial amount of money that each agent owns
initialWealth = 100.0
// How many trades to simulate
rounds = 10000
// If the p... | rich.go | 0.674158 | 0.480113 | rich.go | starcoder |
package main
import (
"fmt"
"log"
"math"
"os"
"github.com/millere/nonlinear"
)
func main() {
maxIterations := 10000
useBisection(maxIterations)
useChord(maxIterations)
useNewton(maxIterations)
useSecant(maxIterations)
useShamanskii(maxIterations, 3)
}
// fns is a slice containing each function, its deriv... | project/main.go | 0.511473 | 0.407274 | main.go | starcoder |
package math
import "github.com/g3n/engine/math32"
type Line2 struct {
A *math32.Vector2
B *math32.Vector2
}
func NewLine2(a, b *math32.Vector2) *Line2 {
return &Line2{
A: a,
B: b,
}
}
func (l *Line2) Intersects(other *Line2) (bool, *math32.Vector2) {
a1 := l.B.Y - l.A.Y
b1 := l.A.X - l.B.X
c1 := a1*l.A.... | math/line.go | 0.848031 | 0.607925 | line.go | starcoder |
package il
import (
"fmt"
)
// Builder is used for building function bodies in a programmatic way.
type Builder struct {
strings *StringTable
body []uint32
labels map[string]uint32
fixups map[string][]uint32
}
// NewBuilder creates a new Builder instance. It uses the given StringTable when it needs to
// ... | mixer/pkg/il/builder.go | 0.675229 | 0.41401 | builder.go | starcoder |
package characterdisplay
// Controller is an interface that describes the basic functionality of a character
// display controller.
type Controller interface {
DisplayOff() error // turns the display off
DisplayOn() error // turns the display on
CursorOff() error // sets the curso... | interface/display/characterdisplay/characterdisplay.go | 0.721253 | 0.4184 | characterdisplay.go | starcoder |
package probe
import (
"aoc2021/pkg/io"
"aoc2021/pkg/numbers"
"strconv"
"strings"
)
type Probe struct {
Position numbers.Vector2
Velocity numbers.Vector2
}
type TargetArea struct {
Start numbers.Vector2
End numbers.Vector2
}
type ProbeData struct {
Target TargetArea
}
func ReadProbeData(file string) Pro... | pkg/probe/probe.go | 0.584508 | 0.420183 | probe.go | starcoder |
package cp
import "math"
type PolyLine struct {
Verts []Vector
}
type PolyLineSet struct {
Lines []*PolyLine
}
func Next(i, count int) int {
return (i + 1) % count
}
func Sharpness(a, b, c Vector) float64 {
return a.Sub(b).Normalize().Dot(c.Sub(b).Normalize())
}
func (pl *PolyLine) Push(v Vector) *PolyLine {
... | polyline.go | 0.735167 | 0.607343 | polyline.go | starcoder |
package accounting
import (
"encoding/json"
"time"
)
// InvoiceReadResponse The invoice data stored in HubSpot
type InvoiceReadResponse struct {
// The invoice number. Note that this is _not_ the ID of the invoice, but the number that the billed customer will see.
ExternalInvoiceNumber *string `json:"externalInv... | generated/accounting/model_invoice_read_response.go | 0.752922 | 0.440289 | model_invoice_read_response.go | starcoder |
package utility
import (
"fmt"
"math/big"
)
type (
// EllipticCurve represents the parameters of a short Weierstrass equation elliptic
// curve.
EllipticCurve struct {
A *big.Int
B *big.Int
P *big.Int
G EllipticCurvePoint
N *big.Int
H *big.Int
ma ModularArithmetic
}
)
// NewEllipticCurve c... | utility/elliptic_curve.go | 0.750095 | 0.664506 | elliptic_curve.go | starcoder |
package librato
// Aggregate provides a means for aggregating metrics on the client side, and pushing the
// the calculated value to librato.
type Aggregate struct {
// Each metric has a name that is unique to its class of metrics e.g. a gauge name must be unique among gauges. The name
// identifies a metric in subs... | metric.go | 0.863751 | 0.550426 | metric.go | starcoder |
package coldata
import (
"fmt"
"github.com/cockroachdb/apd"
"github.com/cockroachdb/cockroach/pkg/col/coltypes"
)
// column is an interface that represents a raw array of a Go native type.
type column interface{}
// SliceArgs represents the arguments passed in to Vec.Append and Nulls.set.
type SliceArgs struct ... | pkg/col/coldata/vec.go | 0.633637 | 0.531696 | vec.go | starcoder |
package crypto11
import (
"crypto/elliptic"
"math/big"
)
var p256k1 p256k1Curve
type p256k1Curve struct {
*elliptic.CurveParams
}
func P256K1() elliptic.Curve {
p256k1.CurveParams = &elliptic.CurveParams{Name: "P-256K1"}
p256k1.P, _ = new(big.Int).SetString("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF... | 256k1.go | 0.602529 | 0.548371 | 256k1.go | starcoder |
package sqlite
import (
"github.com/go-vela/server/database/sqlite/dml"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
"github.com/sirupsen/logrus"
)
// GetBuildStepCount gets a count of all steps by build ID from the database.
func (c *client) GetBuildStepCount(b *library.Build) (int64... | database/sqlite/step_count.go | 0.542136 | 0.418519 | step_count.go | starcoder |
package ir
// Constant is the interface implemented by constant values (e.g. numbers,
// strings, but also code chunks).
type Constant interface {
ProcessConstant(p ConstantProcessor)
}
// A ConstantProcessor is able to process all the different types of constant
// using the various ProcessXXX methods.
type Constan... | ir/code.go | 0.797281 | 0.609379 | code.go | starcoder |
package eval
import (
"golang.org/x/xerrors"
"github.com/mmcloughlin/ec3/arith/ir"
"github.com/mmcloughlin/ec3/internal/errutil"
)
// Value is a value stored in a register.
type Value interface {
// Bits returns the number of bits required to represent the value.
Bits() uint
}
// Processor is an implementation... | arith/eval/eval.go | 0.649912 | 0.462837 | eval.go | starcoder |
package xls
import (
"math"
"time"
)
const mjd0 float64 = 2400000.5
const mjdDJ2000 float64 = 51544.5
func shiftJulianToNoon(julianDays, julianFraction float64) (float64, float64) {
switch {
case -0.5 < julianFraction && julianFraction < 0.5:
julianFraction += 0.5
case julianFraction >= 0.5:
julianDays += 1... | date.go | 0.69035 | 0.506408 | date.go | starcoder |
package image3d
import (
"errors"
"fmt"
_ "image/jpeg"
"path/filepath"
"strings"
"unsafe"
gl "github.com/adrianderstroff/pbr/pkg/core/gl"
"github.com/adrianderstroff/pbr/pkg/view/image/image2d"
)
// Image3D stores the dimensions, data format and it's pixel data.
// It can be used to manipulate single pixels ... | pkg/view/image/image3d/image3d.go | 0.761095 | 0.466299 | image3d.go | starcoder |
// Package operators provides all operators used by WebAssembly bytecode,
// together with their parameter and return type(s).
package operators
import (
"fmt"
"github.com/go-interpreter/wagon/wasm"
)
var (
ops [256]Op // an array of Op values mapped by wasm opcodes, used by New().
noReturn = wasm.ValueTyp... | wasm/operators/op.go | 0.772531 | 0.435841 | op.go | starcoder |
package plaid
import (
"encoding/json"
)
// TransactionStreamAmount Object with data pertaining to an amount on the transaction stream.
type TransactionStreamAmount struct {
// represents the numerical value of an amount.
Amount *float32 `json:"amount,omitempty"`
// The ISO-4217 currency code of the amount. Alwa... | plaid/model_transaction_stream_amount.go | 0.859752 | 0.566918 | model_transaction_stream_amount.go | starcoder |
package executor
import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"meerkat/internal/storage"
"meerkat/internal/storage/vector"
"meerkat/internal/util/sliceutil"
"strings"
)
func selectStringOpFn(op ComparisonOperation) func(x []byte, y string) bool {
var v func(x []byte, y string) bool
switch op ... | internal/executor/full_scan_operator.go | 0.560012 | 0.607023 | full_scan_operator.go | starcoder |
package matchers
import (
"fmt"
"reflect"
"github.com/ptcar2009/gomega/format"
"github.com/ptcar2009/gomega/matchers/support/goraph/bipartitegraph"
)
type ConsistOfMatcher struct {
Elements []interface{}
missingElements []interface{}
extraElements []interface{}
}
func (matcher *ConsistOfMatcher) Ma... | matchers/consist_of.go | 0.67694 | 0.446434 | consist_of.go | starcoder |
package engine
import (
"unicode"
)
// utils.go contains various utility functions used throughout the engine.
var CharToPieceType map[rune]uint8 = map[rune]uint8{
'N': Knight,
'B': Bishop,
'R': Rook,
'Q': Queen,
'K': King,
}
// Convert a string board coordinate to its position
// number.
func CoordinateToPos... | engine/utils.go | 0.687945 | 0.429669 | utils.go | starcoder |
package literalcircuit
import (
"github.com/xyproto/bits"
"bytes"
"fmt"
"io/ioutil"
"strings"
)
// Circuit is a collection of components (truth tables that act as functions, such as "xor"),
// a collection of connections between components (gate table expressions)
// and the name of the main list of gate table ... | circuit.go | 0.629547 | 0.451568 | circuit.go | starcoder |
package processor
import (
"database/sql"
"errors"
"fmt"
"strings"
"sync"
"time"
"github.com/Jeffail/benthos/v3/internal/bloblang/field"
"github.com/Jeffail/benthos/v3/internal/bloblang/mapping"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/internal/interop"
"github.com/Jeffa... | lib/processor/sql.go | 0.719285 | 0.435241 | sql.go | starcoder |
package flightdb
import(
"fmt"
"regexp"
"strconv"
)
/* Callsigns, as used in ADS-B broadcasts
1. Many airlines use the ICAO flight number: SWA3848
2. Many private aircraft use their registration: N839AL
3. Some (private ?) aircraft use just their equipment type:
4. Annoyingly, some airlines use a bare flight numb... | callsign.go | 0.539469 | 0.400632 | callsign.go | starcoder |
package ent
import (
"fmt"
"strings"
"time"
"github.com/empiricaly/recruitment/internal/ent/run"
"github.com/empiricaly/recruitment/internal/ent/step"
"github.com/empiricaly/recruitment/internal/ent/steprun"
"github.com/facebook/ent/dialect/sql"
)
// StepRun is the model entity for the StepRun schema.
type S... | internal/ent/steprun.go | 0.600071 | 0.407186 | steprun.go | starcoder |
package geocube
//go:generate enumer -json -sql -type Resampling -trimprefix Resampling
import (
"fmt"
"regexp"
pb "github.com/airbusgeo/geocube/internal/pb"
"github.com/airbusgeo/godal"
"github.com/google/uuid"
)
// Resampling defines how the raster is resampled when its size has to be changed
type Resampling... | internal/geocube/variable.go | 0.666388 | 0.460532 | variable.go | starcoder |
package plaid
import (
"encoding/json"
)
// NumbersACH Identifying information for transferring money to or from a US account via ACH or wire transfer.
type NumbersACH struct {
// The Plaid account ID associated with the account numbers
AccountId string `json:"account_id"`
// The ACH account number for the accou... | plaid/model_numbers_ach.go | 0.755276 | 0.426979 | model_numbers_ach.go | starcoder |
package sql
import (
"database/sql"
"database/sql/driver"
"fmt"
"reflect"
"strings"
)
// ColumnScanner is the interface that wraps the
// four sql.Rows methods used for scanning.
type ColumnScanner interface {
Next() bool
Scan(...interface{}) error
Columns() ([]string, error)
Err() error
}
// ScanOne scans... | dialect/sql/scan.go | 0.684897 | 0.464537 | scan.go | starcoder |
package cassgowary
import (
"fmt"
)
type Term struct {
Variable *Variable
Coefficient float64
}
type Terms []*Term
func NewTerm(v *Variable, coefficient float64) *Term {
return &Term{
Variable: v,
Coefficient: coefficient,
}
}
func NewTermFrom(variable *Variable) *Term {
return NewTerm(variable, 1.0... | term.go | 0.8119 | 0.444384 | term.go | starcoder |
package schema
const ModelSchema = `{
"$id": "docs/spec/metricsets/metricset.json",
"type": "object",
"description": "Data captured by an agent representing an event occurring in a monitored service",
"allOf": [
{ "$id": "doc/spec/timestamp_epoch.json",
"title": "Timestamp Epoch",
... | model/metricset/generated/schema/metricset.go | 0.780286 | 0.562417 | metricset.go | starcoder |
package s11n
import (
"strconv"
"strings"
"gopkg.in/yaml.v3"
)
// MatchOne returns the yaml node that matches the provided path.
// If zero or more than one node matches the provided path,
// MatchOne will return nil
func MatchOne(node *yaml.Node, path string) *yaml.Node {
results := make([]*yaml.Node, 0)
for n... | internal/s11n/match.go | 0.761627 | 0.443239 | match.go | starcoder |
package stripe
import "encoding/json"
// Retrieves the promotion code with the given ID. In order to retrieve a promotion code by the customer-facing code use [list](https://stripe.com/docs/api/promotion_codes/list) with the desired code.
type PromotionCodeParams struct {
Params `form:"*"`
// Whether the promotion... | promotioncode.go | 0.852168 | 0.477006 | promotioncode.go | starcoder |
package types
import (
"errors"
"fmt"
"hash"
"github.com/spaolacci/murmur3"
)
// MalType - the root type of all mal values
type MalType interface{}
// Counted - collections that have finite, known size
type Counted interface {
Count() int
}
// Seqable - collections that can produce a traversing sequence, or a... | types/types.go | 0.607663 | 0.432782 | types.go | starcoder |
package common
import (
"fmt"
"math"
)
// This is an improved version of Viterbi map matching, where we handle sparse traces by
// applying multiple transitions based on the distance between observations. For example,
// if two consecutive samples are k*VITERBI2_GRANULARITY apart, then we will apply (k-1)
// tra... | fbastani-solution/common/viterbi2.go | 0.734881 | 0.693674 | viterbi2.go | starcoder |
package engine
import (
"softchess/internal/softchess.types"
)
// Tests found in board_test.go
// boardEvaluator calculates the board value
type boardEvaluator struct {
board *Board
}
// newBoardEvaluator creates a new boardEvaluator for the board
func newBoardEvaluator(board *Board) *boardEvaluator {
b := new(b... | internal/softchess.engine/boardEvaluator.go | 0.642881 | 0.434341 | boardEvaluator.go | starcoder |
package num
import (
"math"
"strconv"
"strings"
)
// Int is the default value used in Sets and Matrices in this package
type Int int64
func init() {
// populate atoi map for Abc func
for i, v := range abc {
atoi[v] = Int(i + 1)
}
}
// String returns n as a base 10 string and satisfies the stringer interface... | num.go | 0.798619 | 0.409398 | num.go | starcoder |
package main
import (
"fmt"
"strconv"
"github.com/grmpflh27/aoc_2019/aoc2019_shared"
)
type Coord struct {
X int
Y int
}
type Move struct {
from Coord
to Coord
direction string
}
func (m Move) distance() int {
return Abs(m.to.Y-m.from.Y) + Abs(m.to.X-m.from.X)
}
func parseMoves(strMoves []str... | day_3/day_3.go | 0.610686 | 0.418875 | day_3.go | starcoder |
package ubiquity
// In this file, we include chain ranking functions based on security and performance
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rsa"
"crypto/x509"
"time"
"github.com/cloudflare/cfssl/helpers"
)
// Compute the priority of different hash algorithm based on security
// SHA2 > SHA1 >> MD =... | ubiquity/performance.go | 0.731059 | 0.467453 | performance.go | starcoder |
package v2
/*
All hard-coded default values for configurable aspects of objects in our API should go here.
However, hard-coded values that are not (yet) configurable in the API can live with the code.
These values are materialized into the object before processing begins.
This prevents defaults from being scattered t... | pkg/apis/planetscale/v2/defaults.go | 0.622459 | 0.503235 | defaults.go | starcoder |
package gohm
const LUA_SAVE string = `
-- This script receives four parameters, all encoded with
-- MessagePack. The decoded values are used for saving a model
-- instance in Redis, creating or updating a hash as needed and
-- updating zero or more sets (indices) and zero or more hashes
-- (unique indices).
--
-- # mo... | lua_save.go | 0.674801 | 0.588741 | lua_save.go | starcoder |
package environment
import (
)
func makeTerrainField(size int) TerrainField {
logNormal := getLogNormalConverter(0.0, 0.5, 10000)
field := TerrainField{
SolidityCurrent: zeroSquare(size),
SolidityConstant: applyGridDistribution(randomSquare(size), logNormal),
SolidityAmplitude: applyGridDistribution(randomSqu... | environment/initialization.go | 0.702122 | 0.729014 | initialization.go | starcoder |
package ui
import (
"math"
"wireworld/resources"
"wireworld/sim"
"wireworld/util"
"github.com/go-gl/gl/v3.3-core/gl"
)
const (
ZoomMin = 1
ZoomMax = 30
ZoomDefault = 15
)
// Canvas facilitates panning and zooming and tracks mouse input.
type Canvas struct {
mousePosition [2]int
mouseDelta [2]i... | ui/canvas.go | 0.672439 | 0.424949 | canvas.go | starcoder |
package main
import (
"github.com/gen2brain/raylib-go/raylib"
)
func main() {
screenWidth := int32(800)
screenHeight := int32(450)
rl.InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo animation")
logoPositionX := screenWidth/2 - 128
logoPositionY := screenHeight/2 - 128
framesCoun... | examples/shapes/logo_raylib_anim/main.go | 0.507812 | 0.450964 | main.go | starcoder |
package main
import (
"fmt"
"math"
"github.com/ByteArena/box2d"
"github.com/wdevore/Ranger-Go-IGE/api"
"github.com/wdevore/Ranger-Go-IGE/engine/geometry"
"github.com/wdevore/Ranger-Go-IGE/engine/maths"
"github.com/wdevore/Ranger-Go-IGE/engine/rendering/color"
"github.com/wdevore/Ranger-Go-IGE/extras/shapes"
)... | examples/complex/physics/complex/c4_lava/tracking_component.go | 0.831006 | 0.404243 | tracking_component.go | starcoder |
package matrix
import "runtime"
func (A *DenseMatrix) Plus(B MatrixRO) (Matrix, error) {
C := A.Copy()
err := C.Add(B)
return C, err
}
func (A *DenseMatrix) PlusDense(B *DenseMatrix) (*DenseMatrix, error) {
C := A.Copy()
err := C.AddDense(B)
return C, err
}
func (A *DenseMatrix) Minus(B MatrixRO) (Matrix, err... | dense_arithmetic.go | 0.666714 | 0.439447 | dense_arithmetic.go | starcoder |
package r2
import "math"
// Vec is a 2D vector.
type Vec struct {
X, Y float64
}
// Add returns the vector sum of p and q.
func Add(p, q Vec) Vec {
return Vec{
X: p.X + q.X,
Y: p.Y + q.Y,
}
}
// Sub returns the vector sum of p and -q.
func Sub(p, q Vec) Vec {
return Vec{
X: p.X - q.X,
Y: p.Y - q.Y,
}
... | spatial/r2/vector.go | 0.930868 | 0.777638 | vector.go | starcoder |
package types
import (
"fmt"
sdk "github.com/ci123chain/ci123chain/pkg/abci/types"
)
type Minter struct {
Inflation sdk.Dec `json:"inflation"` //current annual inflation rate
AnnualProvisions sdk.Dec `json:"annual_provisions"` //current annual expected provisions
}
func NewMinter(inflation... | pkg/mint/types/minter.go | 0.761804 | 0.410225 | minter.go | starcoder |
package main
import "strings"
/**
* Get the type from a documentation command line
* @param {string} [line] The comment line to parse
* @returns {string,string}
*/
func GetType(line string) (string, string) {
array := Split(line, " ")
Type := ""
for _, word := range array {
if StartsWith(word, "{") && EndsWi... | util.go | 0.768125 | 0.4081 | util.go | starcoder |
package cfxaddress
import (
"github.com/pkg/errors"
)
/*
Base32-encode address:
To create the payload, first, concatenate the version-byte with addr to get a 21-byte array. Then, encode it left-to-right, mapping each 5-bit sequence to the corresponding ASCII character (see alphabet below). Pad to the right with zero... | vendor/github.com/Conflux-Chain/go-conflux-sdk/types/cfxaddress/body.go | 0.628065 | 0.483709 | body.go | starcoder |
// Package datatypes/dictionary provides an easy dictionary (key => value) homogeneous
// struct management, making the iteration of a unique-key lists more powerful,
// simple and clean, accepting primitives types and complex user structs as well.
// This part of package contains the core behaviour
package dictiona... | dictionary/dictionary.go | 0.81637 | 0.535281 | dictionary.go | starcoder |
Package smart provides details about a particular disk device which includes both
basic details such as vendor, model, serial, etc as well as smart details such as
Raw_Read_Error_Rate, Temperature_Celsius, Spin_Up_Time, etc by parsing various disk
pages such as inquiry page, ata command set page ,etc using various SCS... | pkg/smart/doc.go | 0.572842 | 0.525856 | doc.go | starcoder |
package kit
import (
"github.com/SirMetathyst/zinc"
)
// Velocity2Key ...
const Velocity2Key uint = 2475506976
// Velocity2Data ...
type Velocity2Data struct {
X float32
Y float32
}
// Velocity2Component ...
type Velocity2Component struct {
ctx zinc.CTX
data map[zinc.EntityID]Velocity2Data
}
// NewVelocity2... | kit/zinc_Velocity2.go | 0.621081 | 0.485661 | zinc_Velocity2.go | starcoder |
package lsdp
// DistanceMeasurer provides measurement of the distance between 2 strings
type DistanceMeasurer interface {
Distance(string, string) float64
}
// Lsd returns standard Levenshtein distance
func Lsd(a, b string) int {
wd := &Weights{1, 1, 1}
return int(wd.Distance(a, b))
}
// Weights represents cost p... | lsd.go | 0.887844 | 0.666944 | lsd.go | starcoder |
package pazu
import (
"fmt"
"strconv"
"unicode"
)
type List struct {
Elements []interface{} // Elements may be Atoms or Lists
}
type Atom struct {
Value interface{}
}
type Symbol string
// Parse takes an s-expression of string tokens and returns an abstract syntax tree. It returns
// a single item which may b... | pkg/pazu/parser.go | 0.555918 | 0.467453 | parser.go | starcoder |
package heap
type
// A HeapInt is an effient data structure to find the minimum element in a collection
HeapInt interface {
Peek() (int, bool)
Pop() (int, bool)
Push(int)
}
type
// A HeapInt8 is an effient data structure to find the minimum element in a collection
HeapInt8 interface {
Peek() (int8, bool)
Pop()... | heap/reified_heap.go | 0.575707 | 0.512754 | reified_heap.go | starcoder |
package blockchain
const wrapperABI = `[
{
"constant": true,
"inputs": [
{
"name": "x",
"type": "bytes14"
},
{
"name": "byteInd",
"type": "uint256"
}
],
"name": "getInt8Fr... | blockchain/wrapper_abi.go | 0.622574 | 0.444143 | wrapper_abi.go | starcoder |
package gohome
import (
"github.com/PucklaMotzer09/mathgl/mgl32"
"github.com/PucklaMotzer09/tmx"
"image/color"
)
type sprite2DConfiguration struct {
TextureName string
Flip uint8
Region TextureRegion
}
// A tmx map as a RenderObject
type TiledMap struct {
Sprite2D
*tmx.Map
layers []Texture
}
/... | src/gohome/tiledmap.go | 0.627723 | 0.403978 | tiledmap.go | starcoder |
package roaring
import (
"bytes"
"io"
"strconv"
)
// RoaringBitmap represents a compressed bitmap where you can add integers.
type RoaringBitmap struct {
highlowcontainer roaringArray
}
// Write out a serialized version of this bitmap to stream
func (b *RoaringBitmap) WriteTo(stream io.Writer) (int, error) {
re... | roaring.go | 0.806281 | 0.406332 | roaring.go | starcoder |
package ofbx
import "github.com/oakmound/oak/v2/alg/floatgeom"
func resolveEnumProperty(object Obj, name string, defaultVal int) int {
element := resolveProperty(object, name)
if element == nil {
return defaultVal
}
x := element.getProperty(4)
if x == nil {
return defaultVal
}
return int(x.value.toInt32()... | misc.go | 0.527803 | 0.493164 | misc.go | starcoder |
package ent
import (
"fmt"
"strings"
"entgo.io/ent/dialect/sql"
"github.com/vorteil/direktiv/pkg/secrets/ent/namespacesecret"
)
// NamespaceSecret is the model entity for the NamespaceSecret schema.
type NamespaceSecret struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Ns holds th... | pkg/secrets/ent/namespacesecret.go | 0.661267 | 0.403684 | namespacesecret.go | starcoder |
package stalecucumber
/**
Opcode: BINBYTES8 (0x8e)
Push a Python bytes object.
There are two arguments: the first is an 8-byte unsigned int giving
the number of bytes in the string, and the second is that many bytes,
which are taken literally as the string content.
**
Stack before: []
Stack after: [bytes... | protocol_4.go | 0.709925 | 0.436322 | protocol_4.go | starcoder |
package dynago
import (
"encoding/json"
"fmt"
"reflect"
"strconv"
"time"
)
/*
BinarySet stores a set of binary blobs in dynamo.
While implemented as a list in Go, DynamoDB does not preserve ordering on set
types and so may come back in a different order on retrieval. Use dynago.List
if ordering is important.
*/... | types.go | 0.700075 | 0.432423 | types.go | starcoder |
package binding
import (
"fmt"
"reflect"
"github.com/phlashdev/sherlock/codeanalysis/syntax"
)
var (
binaryOperators []boundBinaryOperator = []boundBinaryOperator{
*newBoundBinaryOperator(syntax.PlusToken, Addition, reflect.TypeOf(0)),
*newBoundBinaryOperator(syntax.MinusToken, Subtraction, reflect.TypeOf(0)... | codeanalysis/binding/boundbinaryoperator.go | 0.650911 | 0.500671 | boundbinaryoperator.go | starcoder |
package minecraft
import (
"fmt"
math2 "github.com/itay2805/mcserver/math"
"log"
"math"
)
type Position struct {
X, Y, Z int
}
func (p Position) String() string {
return fmt.Sprintf("Position{X: %d, Y: %d, Z: %d}", p.X, p.Y, p.Z)
}
func (p Position) ToPoint() math2.Point {
return math2.NewPoint(float64(p.X),... | minecraft/types.go | 0.74382 | 0.526404 | types.go | starcoder |
package pool
import (
"time"
"github.com/ubclaunchpad/cumulus/blockchain"
"github.com/ubclaunchpad/cumulus/common/util"
"github.com/ubclaunchpad/cumulus/consensus"
"github.com/ubclaunchpad/cumulus/miner"
)
// PooledTransaction is a Transaction with a timestamp.
type PooledTransaction struct {
Transaction *bloc... | pool/pool.go | 0.758421 | 0.406597 | pool.go | starcoder |
// Copyright 2015, <NAME>, see LICENSE for details.
// Copyright 2019, Minio, Inc.
package reedsolomon
//go:noescape
func _galMulAVX512Parallel82(in, out [][]byte, matrix *[matrixSize82]byte, addTo bool)
//go:noescape
func _galMulAVX512Parallel84(in, out [][]byte, matrix *[matrixSize84]byte, addTo bool)
const (
d... | vendor/github.com/klauspost/reedsolomon/galoisAvx512_amd64.go | 0.533154 | 0.462837 | galoisAvx512_amd64.go | starcoder |
package examples
import (
"io"
"math/rand"
"os"
"github.com/go-echarts/go-echarts/v2/charts"
"github.com/go-echarts/go-echarts/v2/components"
"github.com/go-echarts/go-echarts/v2/opts"
)
var (
baseMapData = []opts.MapData{
{Name: "北京", Value: float64(rand.Intn(150))},
{Name: "上海", Value: float64(rand.Intn... | examples/map.go | 0.582491 | 0.456955 | map.go | starcoder |
package query
import (
"fmt"
"github.com/vmware/purser/pkg/controller/dgraph/models"
"github.com/vmware/purser/pkg/controller/utils"
)
var secondsFromFirstOfCurrentMonth = getSecondsSinceMonthStart
func getSecondsSinceMonthStart() string {
return fmt.Sprintf("%f", utils.GetSecondsSince(utils.GetCurrentMonthStar... | pkg/controller/dgraph/models/query/helpers.go | 0.688992 | 0.514705 | helpers.go | starcoder |
package dtw
import (
"math"
)
// Ends holds the ends of a DTW path piece
type Ends struct {
End0, End1 int
}
// CumCostMatrix represents the accumulated cost matrix needed to compute DTW distance.
type CumCostMatrix struct {
s1, s2 [][]float64
values []float64
space PointSpace
wi... | dtw/cost.go | 0.699357 | 0.456046 | cost.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"strconv"
"strings"
)
func readInput(fname string) string {
data, err := ioutil.ReadFile(fname)
if err != nil {
panic("Cannot read input data.")
}
s := string(data)
return strings.TrimRight(s, "\n")
}
/*
Represent the most recent `preambleLength` numbers as a vertic... | day09/main.go | 0.539954 | 0.514522 | main.go | starcoder |
package duplist
import (
"time"
)
// TimeString is a modified skiplist implementation allowing duplicate
// time keys to exist inside the same list. Elements with duplicate keys are
// adjacent inside TimeString, with a later insert placed left of earlier
// ones.
// Elements with different keys are sorted in ascend... | datastructure/duplist/timestring.go | 0.674158 | 0.403861 | timestring.go | starcoder |
package sim
import (
"time"
)
// A Strategy is an interface which triggers reinvestments based on some
// criteria held in its internal state. It gets the current date to evaluate
// passed along with a Portfolio to trigger rebalancing if the criteria are
// met.
type Strategy interface {
tick(time.Time, Portfolio)... | sim/strategy.go | 0.814496 | 0.57332 | strategy.go | starcoder |
package gotree
import "errors"
// GeneralNode defines a tree node for a general purpose tree.
type GeneralNode struct {
value Element
children []*GeneralNode
parent *GeneralNode
}
// NewGeneralNode returns a new general tree node with the given value
// and the given list of child nodes, if any.
func NewGene... | general.go | 0.835484 | 0.53607 | general.go | starcoder |
package serialization
import (
"time"
cjl "github.com/cjlapao/common-go/duration"
)
// ISODuration represents an ISO 8601 duration
type ISODuration struct {
duration cjl.Duration
}
// GetYears returns the number of years.
func (i ISODuration) GetYears() int {
return i.duration.Years
}
// GetWeeks returns the n... | abstractions/go/serialization/iso_duration.go | 0.875121 | 0.462655 | iso_duration.go | starcoder |
package stat64
import (
"bytes"
"encoding/binary"
"math"
)
// size is the size of a Summary in bytes
const size = 32
// The is structured as four float64 values
// * count of observations
// * sum of observations
// * running mean of observations
// * sum of squares of differences from the current mean
var z... | internal/summary/stat64/stats.go | 0.915672 | 0.753126 | stats.go | starcoder |
package cmd
import (
"fmt"
"regexp"
"strconv"
"github.com/jaredbancroft/aoc2020/pkg/helpers"
"github.com/jaredbancroft/aoc2020/pkg/luggage"
"github.com/spf13/cobra"
)
// day7Cmd represents the day7 command
var day7Cmd = &cobra.Command{
Use: "day7",
Short: "Advent of Code 2020 - Day 7: Handy Haversacks",
L... | cmd/day7.go | 0.651577 | 0.488283 | day7.go | starcoder |
package xmss
// Expands an n-byte array into a len*n byte array using the `prf` function
func expandSeed(params *Params, inseed []byte) (expanded []byte) {
expanded = make([]byte, params.wotsSignLen)
ctr := make([]byte, 32)
var idx int
for i := 0; i < int(params.wlen); i++ {
ctr = toByte(i, 32)
idx = i * para... | wots.go | 0.796846 | 0.427636 | wots.go | starcoder |
// Package mathutil implements some functions for math calculation.
package mathutil
import (
"fmt"
"math"
"strconv"
"strings"
"github.com/duke-git/lancet/v2/lancetconstraints"
)
// Exponent calculate x^n
func Exponent(x, n int64) int64 {
if n == 0 {
return 1
}
t := Exponent(x, n/2)
if n%2 == 1 {
ret... | mathutil/mathutil.go | 0.682997 | 0.427695 | mathutil.go | starcoder |
package code
import "fmt"
// instSet is a map of an opcode and a binary opcode.
type instSet map[string]byte
// contains reports whether mneum is contained in instSet.
func (is instSet) isValid(mneum string) bool {
_, found := is[mneum]
return found
}
var (
// destInstSet is a map of dest mneumonics and its bina... | assembler/code/code.go | 0.68595 | 0.564639 | code.go | starcoder |
package dellstoragecenter
import (
"strconv"
"strings"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
)
type (
// Dellstoragecenter Defines the interface for connecting to a Dell Storage Center
Dellstoragecenter struct {
IPAddress string `toml:"ip_address"`
Po... | plugins/inputs/dellstoragecenter/dellstoragecenter.go | 0.619126 | 0.445168 | dellstoragecenter.go | starcoder |
package neat
import (
"errors"
"sort"
"github.com/klokare/evo"
)
// Known errors
var (
ErrNoParents = errors.New("NEAT crosser requires at least 1 parent")
ErrTooManyParents = errors.New("NEAT crosser does not support more than 2 parents")
)
// Crosser combines 1 or more parents to create an offspring gen... | neat/crosser.go | 0.506103 | 0.466056 | crosser.go | starcoder |
package smf_context
type UEPathGraph struct {
SUPI string
Graph []*UEPathNode
}
type UEPathNode struct {
UPFName string
Parent string
Neighbors map[string]*UEPathNode
IsBranchingPoint bool
EndPointOfEachChild map[string]*UEPathEndPoint
}
type UEPathEndPoint struct {
End... | src/smf/smf_context/ue_path.go | 0.523177 | 0.449695 | ue_path.go | starcoder |
package nonogen
import (
"errors"
"fmt"
"image"
"image/color"
"image/jpeg"
"os"
"github.com/nfnt/resize"
)
func drawLine(x1, x2, y int, img image.RGBA, color color.Color) {
for ; x1 < x2; x1++ {
img.Set(x1, y, color)
}
}
func drawVerticalLine(y1, y2, x int, img image.RGBA, color color.Color) {
for ; y1 ... | draw.go | 0.502197 | 0.452173 | draw.go | starcoder |
package core
import (
"unsafe"
)
// PrimitiveType is a raster primitive type.
type PrimitiveType uint8
// Supported primitive types
const (
PrimitiveTypeTriangles PrimitiveType = iota
PrimitiveTypePoints
PrimitiveTypeLines
)
// Mesh is an interface which wraps handling of geometry.
type Mesh interface {
SetPri... | core/mesh.go | 0.77081 | 0.44342 | mesh.go | starcoder |
package histogram
const (
// Label holds the string label denoting the histogram type in the database.
Label = "histogram"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldTime holds the string denoting the time field in the database.
FieldTime = "time"
// FieldCount ho... | ent/histogram/histogram.go | 0.606615 | 0.430327 | histogram.go | starcoder |
package russian
var (
centuryNumberCase = [3]string{"век", "века", "веков"}
yearNumberCase = [3]string{"год", "года", "лет"}
monthNumberCase = [3]string{"месяц", "месяца", "месяцев"}
weekNumberCase = [3]string{"неделя", "недели", "недель"}
dayNumberCase = [3]string{"день", "дня", "... | russian/time.go | 0.688573 | 0.643581 | time.go | starcoder |
package arbitrage
import (
"fmt"
"math"
"time"
"gotrading/core"
"gotrading/networking"
)
type Simulation struct {
hits []*core.Hit
Report Report
}
func (sim *Simulation) Init(hits []*core.Hit) {
sim.hits = make([]*core.Hit, len(hits))
for i, h := range hits {
copy := *h
sim.hits[i] = ©
}
sim.Re... | strategies/arbitrage/simulation.go | 0.526586 | 0.437343 | simulation.go | starcoder |
package horizon
import (
"fmt"
"math"
"github.com/golang/geo/s2"
geojson "github.com/paulmach/go.geojson"
)
// calcProjection Returns projection on line and fraction for point
/*
line - s2.Polyline
point - s2.Point
projected - projection of point on line
fraction - number in [0;1], describes how far project... | utils.go | 0.802981 | 0.49109 | utils.go | starcoder |
package data
import (
"math"
"time"
"github.com/chewxy/math32"
)
func getCurrentTime() uint64 {
return uint64(time.Now().Unix())
}
// CalculateAverage calculates average of two arrays divided by n
func CalculateAverage(avg []float32, p []float32, n float32) []float32 {
if n == 0 {
return p
}
if len(avg) < ... | data/util.go | 0.569374 | 0.547706 | util.go | starcoder |
package relationship
// Type is a type of relationship
type Type struct {
Name string
Descriptors []string
InverseName string
Disallows []string
}
// AllTypes returns all relationship types
func AllTypes() []Type {
types := []Type{
{
Name: "parent",
InverseName: "child",
Disallows: [... | pkg/relationship/types.go | 0.517083 | 0.450299 | types.go | starcoder |
package model
import (
"encoding/json"
"fmt"
"regexp"
"github.com/kosctelecom/horus/log"
)
// IndexedMeasure is a group of tabular metrics indexed by the first one.
type IndexedMeasure struct {
// ID is the measure db id.
ID int `db:"id"`
// Name is the name of the indexed measure.
Name string `db:"name"`
... | model/indexed_measure.go | 0.778102 | 0.403567 | indexed_measure.go | starcoder |
package test
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/xabinapal/gopve/pkg/types"
"github.com/xabinapal/gopve/pkg/types/errors"
)
func HelperCreatePropertiesMap(props types.Properties) types.Properties {
obj := make(types.Properties, len(pr... | test/properties.go | 0.622 | 0.476153 | properties.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.