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 light
import (
"time"
"github.com/kasworld/h4o/_examples/app"
"github.com/kasworld/h4o/eventtype"
"github.com/kasworld/h4o/geometry"
"github.com/kasworld/h4o/graphic"
"github.com/kasworld/h4o/material"
"github.com/kasworld/h4o/math32"
"github.com/kasworld/h4o/util/helper"
"math"
"github.com/kaswor... | _examples/demos/light/point.go | 0.596903 | 0.458955 | point.go | starcoder |
package heatmap
import (
"fmt"
"image"
"image/color"
"image/png"
"math"
"os"
"entityDetection/detection/centroid"
)
// Heatmap stores a heatmap image with its maximum point count
type Heatmap struct {
maxCount int
heatmapImage *image.RGBA
}
// NewHeatmap generates new Heatmap instance.
// Don't compute... | detection/heatmap/heatmap.go | 0.855248 | 0.610076 | heatmap.go | starcoder |
package filter
import (
"github.com/sonirico/container/types"
"github.com/sonirico/container/utils"
)
// SliceWithInPlaceMutation filters the given array by applying in-place state mutation, which mutates
// the underlying array. Accepts a flag to indicate whether to copy the result array as the result to
// preven... | filter/slices.go | 0.765944 | 0.563738 | slices.go | starcoder |
package timeutil
import (
"time"
)
// IsGreaterThan compares two times and returns true if the left
// time is greater than the right time.
func IsGreaterThan(timeLeft time.Time, timeRight time.Time, orEqual bool) bool {
if timeLeft.After(timeRight) {
return true
} else if orEqual && timeLeft.Equal(timeRight) {
... | time/timeutil/compare.go | 0.850562 | 0.556882 | compare.go | starcoder |
package msxsdk
import (
"encoding/json"
)
// SiteLocation struct for SiteLocation
type SiteLocation struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
AdditionalProperties map[string]interface{}
}
type _SiteLocation SiteLocation
// NewSiteLocation instantiates a new SiteLocation o... | model_site_location.go | 0.797241 | 0.421254 | model_site_location.go | starcoder |
// Package meter storage metering
package meter
import (
"fmt"
"math"
"strconv"
"strings"
)
// Storage unit constants.
const (
Byte = 1
KByte = Byte << 10
MByte = KByte << 10
GByte = MByte << 10
TByte = GByte << 10
PByte = TByte << 10
EByte = PByte << 10
)
// ByteSize byte size
type ByteSize uint64
// ... | meter.go | 0.676513 | 0.473718 | meter.go | starcoder |
package nodeset
import (
"fmt"
"github.com/insolar/insolar/network/consensus/gcpv2/api/member"
"github.com/insolar/insolar/network/consensus/gcpv2/phasebundle/stats"
)
type ConsensusStat uint8
const (
ConsensusStatUnknown ConsensusStat = iota
ConsensusStatTrusted
ConsensusStatDoubted
ConsensusStatMissingTh... | network/consensus/gcpv2/phasebundle/nodeset/consensus_stats.go | 0.511717 | 0.439507 | consensus_stats.go | starcoder |
package common
import (
"fmt"
"math/big"
"math/rand"
"reflect"
"strconv"
)
// -------------------------
// package Consts, Vars
// Lengths of hashes and addresses in bytes.
const (
HashLength = 32
)
// ------------------
// package Functions
// BytesToHash sets b to hash.
// If b is larger than len(h), b wil... | common/hash.go | 0.733165 | 0.412767 | hash.go | starcoder |
package flowmon
import (
"fmt"
"reflect"
)
// FlowAggregate is a list of flows aggregated by a set of keys
type FlowAggregate struct {
Keys []string
Flows []*FlowInfo
TotalBytes DecUint64
TotalPackets DecUint64
LastTimeReceived DecUint64
FirstTimeReceived DecUint64
FirstTimeFlowStart DecUint64
LastT... | pkg/flowmon/aggregate.go | 0.671686 | 0.484624 | aggregate.go | starcoder |
package v1beta1
/*
For imports, we'll need the controller-runtime
[`conversion`](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/conversion)
package, plus the API version for our hub type (v1beta2), and finally some of the
standard packages.
*/
import (
"sigs.k8s.io/controller-runtime/pkg/conversion"
observab... | api/v1beta1/multiclusterobservability_conversion.go | 0.721547 | 0.429728 | multiclusterobservability_conversion.go | starcoder |
package indexers
import (
"bytes"
"encoding/binary"
"io"
"math"
"github.com/utreexo/utreexod/chaincfg/chainhash"
"github.com/utreexo/utreexod/wire"
)
// proofStatsSize has 19 elements that are each 8 bytes big.
const proofStatsSize int = 8 * 19
// proofStats are the relevant proof statistics to check how big... | blockchain/indexers/utreexoproofstats.go | 0.588889 | 0.509093 | utreexoproofstats.go | starcoder |
package main
import (
"fmt"
"math"
)
// symmetric and lower use a packed representation that stores only
// the lower triangle.
type symmetric struct {
order int
ele []float64
}
type lower struct {
order int
ele []float64
}
// symmetric.print prints a square matrix from the packed repre... | lang/Go/cholesky-decomposition-1.go | 0.729038 | 0.442155 | cholesky-decomposition-1.go | starcoder |
package encoding
import (
"fmt"
"reflect"
"strings"
)
func stringifyType(t reflect.Type) reflect.Type {
switch t.Kind() {
case reflect.Map:
return reflect.MapOf(stringType, interfaceType)
case reflect.Slice:
return reflect.SliceOf(interfaceType)
case reflect.Struct:
return stringifyStructType(t)
case re... | cfn/encoding/stringify.go | 0.525612 | 0.430686 | stringify.go | starcoder |
package common
import (
"fmt"
"github.com/mikeyhu/glipso/interfaces"
)
// SYM is a symbol, beginning with a : and normally used as keys within maps
type SYM string
// IsType for SYM
func (s SYM) IsType() {}
// IsValue for SYM
func (s SYM) IsValue() {}
// String for SYM
func (s SYM) String() string {
return stri... | common/symbol.go | 0.690246 | 0.466116 | symbol.go | starcoder |
package encryption
import (
"strings"
"strconv"
"crypto/aes"
"crypto/cipher"
"math/rand"
"encoding/hex"
)
// ----- Encrypts a string for usage with node using AES encryption
func Encrypt(key, text string) (string) {
// Convert the text to encrpyt into a byte array and then pad the array to... | go-encryption.go | 0.722037 | 0.426322 | go-encryption.go | starcoder |
package dprec
import "fmt"
func NewQuat(w, x, y, z float64) Quat {
return Quat{
W: w,
X: x,
Y: y,
Z: z,
}
}
func IdentityQuat() Quat {
return Quat{
W: 1.0,
X: 0.0,
Y: 0.0,
Z: 0.0,
}
}
func RotationQuat(angle Angle, direction Vec3) Quat {
cs := Cos(angle / 2.0)
sn := Sin(angle / 2.0)
normalize... | dprec/quat.go | 0.827515 | 0.758242 | quat.go | starcoder |
package ent
import (
"fmt"
"strings"
"entgo.io/ent/dialect/sql"
"github.com/Yiling-J/carrier/examples/ent_recipe/ent/ingredient"
)
// Ingredient is the model entity for the Ingredient schema.
type Ingredient struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Name holds the value of... | examples/ent_recipe/ent/ingredient.go | 0.632843 | 0.443118 | ingredient.go | starcoder |
package rand
// Code ported to Go from: https://github.com/SRombauts/SimplexNoise
// Copyright (c) 2014-2018 <NAME> (<EMAIL>)
// Distributed under the MIT License (MIT) (See accompanying file licenses/SimplexNoise.txt)
import (
"github.com/maxfish/go-libs/pkg/fmath"
)
/**
* 1D Perlin simplex noise
* @param[in] x ... | pkg/rand/perlin.go | 0.860633 | 0.44071 | perlin.go | starcoder |
package refconv
import (
"fmt"
"math"
"reflect"
"strconv"
"github.com/cstockton/go-conv/internal/refutil"
)
func (c Conv) convStrToUint64(v string) (uint64, error) {
if parsed, err := strconv.ParseUint(v, 10, 0); err == nil {
return parsed, nil
}
if parsed, err := strconv.ParseFloat(v, 64); err == nil {
... | vendor/github.com/cstockton/go-conv/internal/refconv/uint.go | 0.795062 | 0.436682 | uint.go | starcoder |
package idx
import (
"github.com/Fantom-foundation/go-lachesis/common/bigendian"
)
type (
// Epoch numeration.
Epoch uint32
// Event numeration.
Event uint32
// Txn numeration.
Txn uint32
// Block numeration.
Block uint64
// Lamport numeration.
Lamport uint32
// Frame numeration.
Frame uint32
// P... | inter/idx/index.go | 0.724968 | 0.55652 | index.go | starcoder |
package x32
import (
"fmt"
)
// normalisationFunc is a transfer function for converting fx param values.
type normalisationFunc func(float32) float32
// paramInfo represents a VST fx parameter.
type paramInfo struct {
// x32AddrFormat is a format string for the X32 address suffix.
x32AddrFormat string
// normToX... | plugs.go | 0.526343 | 0.571109 | plugs.go | starcoder |
package simulation
import (
"bytes"
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/daodiseomoney/core/x/treasury/types"
)
// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's
// Value to the c... | x/treasury/simulation/decoder.go | 0.632616 | 0.400105 | decoder.go | starcoder |
package app
// These are usage (help) texts shown when the app is started without the required arguments.
// Note: Using an indentation of two spaces as it provides a nice "look" in the console.
var (
InitUsage = `Write an empty template for a configuration file in TOML format.
The empty configuration file is a ... | app/usage.go | 0.749087 | 0.616099 | usage.go | starcoder |
package filter
import (
"errors"
"fmt"
"image"
"image/color"
"github.com/fairhive-labs/go-pixelart/internal/colorutils"
)
const (
Min int = 3
)
var (
errNilMatrix = errors.New("kernel matrix cannot be nil")
errEmptyMatrix = errors.New("kernel matrix cannot be empty")
errKernelSize =... | internal/filter/convolution.go | 0.533154 | 0.401219 | convolution.go | starcoder |
package generic
import (
"net/url"
"reflect"
"strconv"
"strings"
"time"
)
// asBool converts a specified value to boolean value.
func asBool(x interface{}) (result bool, isValid ValidFlag, err error) {
switch t := x.(type) {
case nil:
return result, false, nil
case int, int8, int16, int32, int64:
result =... | convert.go | 0.687105 | 0.452354 | convert.go | starcoder |
package function
import (
"errors"
kanzi "github.com/flanglet/kanzi-go"
)
const (
_TRANSFORM_SKIP_MASK = 0xFF
)
// ByteTransformSequence encapsulates a sequence of transforms or functions in a function
type ByteTransformSequence struct {
transforms []kanzi.ByteTransform // transforms or functions
skipFlags by... | function/ByteTransformSequence.go | 0.83152 | 0.677899 | ByteTransformSequence.go | starcoder |
package phy
import (
"fmt"
"math"
"github.com/Tnze/go-mc/bot/path"
"github.com/Tnze/go-mc/bot/world"
"github.com/Tnze/go-mc/bot/world/entity/player"
"github.com/Tnze/go-mc/data/block/shape"
)
const (
playerWidth = 0.6
playerHeight = 1.8
resetVel = 0.003
maxYawChange = 11
maxPitchChange = 7
stepH... | bot/phy/phy.go | 0.63477 | 0.441071 | phy.go | starcoder |
package actionlint
// ExprNode is a node of expression syntax tree. To know the syntax, see
// https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
type ExprNode interface {
// Token returns the first token of the node. This method is useful to get position of this node.
Toke... | expr_ast.go | 0.885074 | 0.63409 | expr_ast.go | starcoder |
package termui
import "strings"
/* Table is like:
┌Awesome Table ────────────────────────────────────────────────┐
│ Col0 | Col1 | Col2 | Col3 | Col4 | Col5 | Col6 |
│──────────────────────────────────────────────────────────────│
│ Some Item #1 | AAA | 123 | CCCCC | EEEEE | GGGGG | IIIII |
│─────... | table.go | 0.711331 | 0.488893 | table.go | starcoder |
package validator
import (
"fmt"
"math/big"
"sort"
"strings"
"github.com/hyperledger/burrow/crypto"
)
var big0 = big.NewInt(0)
// A Validator multiset - can be used to capture the global state of validators or as an accumulator each block
type Set struct {
powers map[crypto.Address]*big.Int
publicKeys ma... | acm/validator/set.go | 0.811415 | 0.474875 | set.go | starcoder |
package internal
import (
"math"
)
// Check if coordinate is within [0, size-1], and if not, reflect out of bounds coordinates back into the value range
func reflect(size, x int) int {
if(x < 0) {
return -x - 1;
}
if(x >= size) {
return 2*size - x - 1;
}
return ... | internal/usm.go | 0.755457 | 0.653707 | usm.go | starcoder |
package gl_utils
import (
"github.com/go-gl/mathgl/mgl32"
"math"
)
// Camera2D a Camera based on an orthogonal projection
type Camera2D struct {
x float32
y float32
width float32
halfWidth float32
height float32
halfHeight float32
zo... | gl_utils/camera_2d.go | 0.888487 | 0.574514 | camera_2d.go | starcoder |
package output
import (
"context"
"os"
"time"
"github.com/Jeffail/benthos/v3/internal/codec"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/internal/shutdown"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/o... | lib/output/stdout.go | 0.700485 | 0.496704 | stdout.go | starcoder |
package helper
import (
"fmt"
"log"
"github.com/wesovilabs/orion/internal/errors"
"github.com/zclconf/go-cty/cty"
)
// IsSlice returns true if value is a slice.
func IsSlice(value cty.Value) bool {
return value.Type().IsListType() || value.Type().IsTupleType() || value.Type().IsCollectionType()
}
// ToStrictSt... | helper/types.go | 0.689096 | 0.432243 | types.go | starcoder |
package csg
import (
"fmt"
"io"
"math"
"math/rand"
)
// F64Epsilon is the epsilon utilized for AlmostEqual
var F64Epsilon float64
func init() {
// Calculate the epsilon
F64Epsilon = math.Nextafter(1, 2) - 1
}
// Vector representation of a vector point in 3 dimensional space
type Vector struct {
X float64
Y ... | csg/vector.go | 0.878353 | 0.681406 | vector.go | starcoder |
package unixtime
// (unix)time.Time Borrowed largely from https://github.com/pieterclaerhout/example-json-unixtimestamp
// Differences include:
// - Additional forwarded methods
// Note:
// Duration is not included in/does not come from the above mentioned package
import (
"math"
"strconv"
"time"
)
// Time defin... | unixtime.go | 0.860911 | 0.40642 | unixtime.go | starcoder |
package logic
// Operand is the template for operands.
type Operand interface {
Evaluate(ctx interface{}) (bool, error)
}
// Operator is the template for operators.
type Operator struct {
operands []Operand
}
// AndOperator is the implementation of the boolean AND operators.
type AndOperator struct {
Operator
}
... | logic/logic.go | 0.781997 | 0.532668 | logic.go | starcoder |
package statusmodule
import (
"time"
"github.com/bwmarrin/discordgo"
bot "github.com/erikmcclure/sweetiebot/sweetiebot"
)
// StatusModule manages the status message
type StatusModule struct {
lastchange time.Time
}
// New StatusModule
func New() *StatusModule {
return &StatusModule{}
}
// Name of the module
f... | statusmodule/StatusModule.go | 0.639961 | 0.428951 | StatusModule.go | starcoder |
package murmur2
import "hash"
type murmur2 struct {
data []byte
cached *uint32
}
// New32 creates a murmur 2 based hash.Hash32 implementation.
func New32() hash.Hash32 {
return &murmur2{
data: make([]byte, 0),
}
}
// Write a slice of data to the hasher.
func (mur *murmur2) Write(p []byte) (n int, err error)... | lib/util/hash/murmur2/murmur2.go | 0.703549 | 0.455865 | murmur2.go | starcoder |
package lo25519
// edBlacklist is a list of elements of the ed25519 curve that have low order.
// The list was copied from https://github.com/jedisct1/libsodium/blob/141288535127c22162944e12fcadb8bc269671cc/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c
var edBlacklist = [7][32]byte{
/* 0 (order 4) */
{0x0... | internal/lo25519/ed25519.go | 0.547706 | 0.460532 | ed25519.go | starcoder |
package photoshop
import "fmt"
// Point represents a point on the screen
type Point struct {
// X is the x-coordinate
X float64
// Y is the y-coordinate
Y float64
}
// Size represents a width and height size
type Size struct {
// Width is the rectangle width
Width float64
// Height is the rectangle height
He... | structural-patterns/composite/photoshop/photoshop.go | 0.854733 | 0.460895 | photoshop.go | starcoder |
// Package usesgenerics defines an Analyzer that checks for usage of generic
// features added in Go 1.18.
package usesgenerics
import (
"go/ast"
"go/types"
"reflect"
"strings"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
"golang.org/x... | go/analysis/passes/usesgenerics/usesgenerics.go | 0.710226 | 0.469155 | usesgenerics.go | starcoder |
package analysis
// Possibility is an enumerator of possibilites.
type Possibility int
const (
// True represents a logical certanty or true.
True Possibility = iota
// Maybe represents the possibility of true or false.
Maybe
// False represents a logical certanty of false.
False
// Impossible represents a... | gapil/analysis/possibility.go | 0.722331 | 0.458046 | possibility.go | starcoder |
package split
import (
"fmt"
"math"
"strings"
)
// A Complex represents a split-complex number.
type Complex struct {
re, im float64
}
// Real returns the real part of z, a float64 value.
func (z *Complex) Real() float64 {
return z.re
}
// Imag returns the imaginary part of z, a float64 value.
func (z *Comple... | complex.go | 0.893245 | 0.610221 | complex.go | starcoder |
package xlog
import (
"fmt"
"github.com/globalsign/mgo/bson"
"strings"
"time"
)
var (
// TimeOfDayLayouts supported time layouts in time-of-day
TimeOfDayLayouts = []string{
"15:04",
"1504",
"15:04:05",
"150405",
}
// StorageSizeSuffixes storage size suffixes
StorageSizeSuffixes = []struct {
S stri... | utils.go | 0.582135 | 0.40698 | utils.go | starcoder |
package btree
import (
"container/list"
"fmt"
)
// BinaryTree represents a binary search tree.
type BinaryTree struct {
root *Node
}
// NewBinaryTree creates a new binary tree.
func NewBinaryTree() *BinaryTree {
return &BinaryTree{}
}
// Sum returns the sum of all tree nodes.
func (t *BinaryTree) Sum() int {
i... | btree/tree.go | 0.754734 | 0.427337 | tree.go | starcoder |
package utils
type NodeColor byte
const (
Red NodeColor = 0
Black = 1
DoubleBlack = 2
)
type Direction byte
const (
LEFT Direction = 0
RIGHT = 1
NODIR = 2
)
var nilNodeSingle = new(NilNode)
type TreeNodeInterface interface {
IsNilNode() bool
IsNotNilN... | utils/rbtree.go | 0.679923 | 0.425128 | rbtree.go | starcoder |
// Package interpolation implements various algorithms to fill in missing values in a Series or DataFrame.
package interpolation
import (
"context"
"github.com/padchin/dataframe-go"
)
// FillDirection is used to set the direction that nil values are filled.
type FillDirection uint8
func (opt FillDirection) has(x... | forecast/interpolation/interpolate.go | 0.849176 | 0.657085 | interpolate.go | starcoder |
package predictor
import (
"encoding/gob"
"fmt"
"log"
"os"
"github.com/pkg/errors"
G "gorgonia.org/gorgonia"
"gorgonia.org/tensor"
)
type convnet struct {
g *G.ExprGraph
w0, w1, w2, w3, w4 *G.Node // weights, the number at the back indicates which layer it's used for
d0, d1, d2, d3 flo... | predictor/convnet.go | 0.651466 | 0.495972 | convnet.go | starcoder |
package fauxgl
type Triangle struct {
V1, V2, V3 Vertex
}
func NewTriangle(v1, v2, v3 Vertex) *Triangle {
t := Triangle{v1, v2, v3}
t.FixNormals()
return &t
}
func NewTriangleForPoints(p1, p2, p3 Vector) *Triangle {
v1 := Vertex{Position: p1}
v2 := Vertex{Position: p2}
v3 := Vertex{Position: p3}
return NewTr... | triangle.go | 0.616936 | 0.766665 | triangle.go | starcoder |
package internal
import (
"errors"
"fmt"
"math"
)
// Replacement mode for out of bounds values when projecting images
type HistoNormMode int
const (
HNMNone = iota // Do not normalize histogram
HNMLocScale // Normalize histogram by matching location and scale of the reference frame. Good for stacking li... | internal/postprocess.go | 0.505371 | 0.408395 | postprocess.go | starcoder |
package vector
import (
"errors"
"math"
"strconv"
)
const (
INVALID_DIMENSION = "Invalid dimension"
DIVISION_BY_ZERO = "Divison by zero not allowed"
INDEX_OUT_OF_BOUND = "Index out of bound"
)
type Vector struct {
dimension int
coordinates []float64
}
func New() Vector {
return Vector{1, []float64{0}}... | vector/vector.go | 0.713831 | 0.510252 | vector.go | starcoder |
package uxid
import (
cryptorand "crypto/rand"
"io"
"time"
)
const CrockfordEncoding string = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
func Generate(prefix string, size string) (id_str string, err error) {
time_string := EncodeTime(time.Now().UTC())
rand_string := EncodeRand(size)
if "" == prefix {
return time_st... | uxid.go | 0.671147 | 0.546133 | uxid.go | starcoder |
import "github.com/kaitai-io/kaitai_struct_go_runtime/kaitai"
/**
* BCD (Binary Coded Decimals) is a common way to encode integer
* numbers in a way that makes human-readable output somewhat
* simpler. In this encoding scheme, every decimal digit is encoded as
* either a single byte (8 bits), or a nibble (half o... | bcd/src/go/bcd.go | 0.620392 | 0.400984 | bcd.go | starcoder |
package flume
const errorsSchema = `
{
"type": [
"string"
]
}
`
const eventSchema = `
{
"type": "record",
"name": "AvroFlumeEvent",
"fields": [
{
"name": "headers",
"type": {
"type": "map",
"values": "string"
}
},
{
"name": "body",
"type": "bytes... | flume/schemas.go | 0.7478 | 0.452354 | schemas.go | starcoder |
package dft
import (
"math"
"github.com/emer/etable/etensor"
"gonum.org/v1/gonum/dsp/fourier"
)
// Dft struct holds the variables for doing a fourier transform
type Params struct {
CompLogPow bool `def:"true" desc:"compute the log of the power and save that to a separate table -- generaly more useful for vis... | dft/dft.go | 0.543106 | 0.46223 | dft.go | starcoder |
package machine
// digitalOceanDescriptions enumerates DigitalOcean instance offerings.
var digitalOceanDescriptions = []Description{
{Size: "512mb", CPU: 1, RAM: .5, Disk: "20", Region: "ams1", Price: 0.00744},
{Size: "512mb", CPU: 1, RAM: .5, Disk: "20", Region: "ams2", Price: 0.00744},
{Size: "512mb", CPU: 1, RA... | cluster/machine/digitalOceanConstants.go | 0.52829 | 0.467028 | digitalOceanConstants.go | starcoder |
package tplink
import "math"
// Basic Instructions
type aliasValue struct {
errorCode
Value string `json:"alias"`
}
type delayTime struct {
errorCode
Delay int `json:"delay"`
}
type deviceIdValue struct {
errorCode
Value string `json:"deviceId"`
}
type errorCode struct {
ErrorCode int `json:"err_code,omite... | pkg/tplink/types.go | 0.662032 | 0.517571 | types.go | starcoder |
package ace
import (
"github.com/gopherjs/gopherjs/js"
)
// Range is a wrapper for the Ace Range type.
type Range struct {
*js.Object
}
// NewRange returns a newly created Range object.
func NewRange(startRow, startColumn, endRow, endColumn int) Range {
return Range{js.Global.Get("Range").New(startRow, startColum... | range.go | 0.91068 | 0.564519 | range.go | starcoder |
package color
import (
"image/color"
"github.com/goplus/interp"
)
func init() {
interp.RegisterPackage("image/color", extMap, typList)
}
var extMap = map[string]interface{}{
"(image/color.Alpha).RGBA": (color.Alpha).RGBA,
"(image/color.Alpha16).RGBA": (color.Alpha16).RGBA,
"(image/color.CMYK).RGBA": ... | pkg/image/color/export.go | 0.513181 | 0.588653 | export.go | starcoder |
package cluster
const (
single_linkage = iota
complete_linkage
average_linkage
mcquitty_linkage
median_linkage
centroid_linkage
ward_linkage
)
type HClusters struct {
// Data points [m x n]
X Matrix
// Distance metric
Metric Metri... | ML/hclust_sl.go | 0.790692 | 0.518729 | hclust_sl.go | starcoder |
package inverter
import (
"fmt"
"time"
)
//WattHour type
type WattHour float64
//KWh type
type KWh float64
//ErrorCode type
type ErrorCode int64
//DailyStatistics of an Inverter with error code
type DailyStatistics struct {
DailyProduction WattHour
YearlyProduction WattHour
TotalProduction WattHour
ErrorCo... | inverter/inverter.go | 0.617859 | 0.467575 | inverter.go | starcoder |
package svg
import (
"fmt"
"strconv"
"strings"
"unicode"
)
// PathCommand is a representation of an SVG path command. It contains the
// operator symbol and the command's parameters.
type PathCommand struct {
Symbol string
Params []float64
}
// IsAbsolute returns true is the SVG path command is absolute.
func ... | path.go | 0.738669 | 0.420481 | path.go | starcoder |
package continuous
import (
"github.com/jtejido/linear"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Laplace distribution
// https://en.wikipedia.org/wiki/Laplace_distribution
type Laplace struct {
location, scale float64 // μ, b
src rand.Source
natural ... | dist/continuous/laplace.go | 0.81593 | 0.460835 | laplace.go | starcoder |
package ligo
// Get a copy of a Seq.
// Only the seq structure is copied, the elements of the resulting
// seq are the same as the corresponding elements of the given seq.
func CopySeq(seq Seq) Seq {
if seq == nil {
return nil
} else if seq.Rest() == nil {
return cons(seq.First(), nil)
}
return cons(seq.First... | ligo_simple_fns.go | 0.727589 | 0.578805 | ligo_simple_fns.go | starcoder |
package openapi
import (
"encoding/json"
)
// RecipientName The name of the recipient to whom the card will be shipped
type RecipientName struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
MiddleName *string `json:"middle_name,omitempty"`
}
// NewRecipientName instantiates a new Re... | synctera/model_recipient_name.go | 0.684791 | 0.475484 | model_recipient_name.go | starcoder |
package astrewrite
import (
"fmt"
"go/ast"
)
// WalkFunc describes a function to be called for each node during a Walk. The
// returned node can be used to rewrite the AST. Walking stops if the returned
// bool is false.
type WalkFunc func(ast.Node) (ast.Node, bool)
// Walk traverses an AST in depth-first order: I... | vendor/github.com/fatih/astrewrite/astrewrite.go | 0.505371 | 0.665057 | astrewrite.go | starcoder |
package go_ehlers_indicators
import (
"fmt"
"math"
)
const (
M = iota
F
)
// MAMA from this paper: https://www.mesasoftware.com/papers/MAMA.pdf
func MAMAFAMA(vals []float64, fastLimit, slowLimit float64, which int) []float64 {
smooth := make([]float64, len(vals))
period := make([]float64, len(vals))
detrender... | mama.go | 0.577495 | 0.562657 | mama.go | starcoder |
package rango
func Cube(object *Object, material Material, side float64) {
var triangles = make([]Triangle, 0)
var halfSide float64 = side * 0.5
min := V(-halfSide, -halfSide, -halfSide)
max := V(halfSide, halfSide, halfSide)
var v0 Vector = Vector{}
var v1 Vector = Vector{}
var v2 Vector = Vector{}
/* fr... | rango/cube.go | 0.514644 | 0.437643 | cube.go | starcoder |
package imaging
import (
"image"
"image/color"
"github.com/disintegration/imaging"
)
type rawImg interface {
Set(x, y int, c color.Color)
Opaque() bool
}
func isFullyTransparent(c color.Color) bool {
// TODO: This can be optimized by checking the color type and
// only extract the needed alpha value.
_, _,... | app/imaging/utils.go | 0.508544 | 0.483892 | utils.go | starcoder |
package stringsx
// Create a new Set that contains the given values.
func NewSet(values ...string) Set {
s := Set{}
for _, value := range values {
s[value] = struct{}{}
}
return s
}
// Set is unique a collection of strings. The internal order is not guaranteed.
type Set map[string]struct{}
// Len returns the s... | stringsx/set.go | 0.87849 | 0.504272 | set.go | starcoder |
package go_kd_segment_tree
type TreeNode interface {
Search(p Point) []interface{}
Insert(seg *Segment) error
SearchRect(rect Rect) []interface{}
Dumps(prefix string) string
}
func NewNode(segments []*Segment,
tree *Tree,
level int,
) TreeNode {
if len(segments) == 0 {
return nil
}
if len(segments) <= tre... | node.go | 0.655115 | 0.460228 | node.go | starcoder |
package types
import (
"time"
)
//------------------------------------------------------------------------------
// Metadata is an interface representing the metadata of a message part within
// a batch.
type Metadata interface {
// Get returns a metadata value if a key exists, otherwise an empty string.
Get(key... | lib/types/message.go | 0.674265 | 0.62561 | message.go | starcoder |
package randomnames
// List of adjectives from https://www.d.umn.edu/~rave0029/research/adjectives1.txt
import (
"math/rand"
"sync"
)
func init() {
adjSize = len(Adjectives)
}
// RandomAdjective returns a pseudo-random adjective from the list
func RandomAdjective() string {
return Adjectives[rand.Intn(adjSize)]... | adjectives.go | 0.55435 | 0.55911 | adjectives.go | starcoder |
package proto
const (
BackendSwagger = `{
"swagger": "2.0",
"info": {
"title": "backend.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/v1/schema/{id}": {
... | proto/swagger.pb.go | 0.843638 | 0.402157 | swagger.pb.go | starcoder |
package internal
import (
"fmt"
"strconv"
)
// SeniorAge is the minimum age from which a Passenger is considered a senior to the BusCompany.
const SeniorAge = 65
// Passenger represents a bus passenger, uniquely identified by their SSN.
type Passenger struct {
SSN string
SeatNumber uint8
Destinat... | bus-service/internal/passenger.go | 0.702428 | 0.508361 | passenger.go | starcoder |
package collision
import (
"github.com/teomat/mater/aabb"
"github.com/teomat/mater/transform"
"github.com/teomat/mater/vect"
"log"
"math"
)
type PolygonAxis struct {
// The axis normal.
N vect.Vect
D float64
}
type PolygonShape struct {
// The raw vertices of the polygon. Do not touch!
// Use polygon.SetVe... | collision/polygonShape.go | 0.857231 | 0.599749 | polygonShape.go | starcoder |
// Package counterpairpair is an example using go-frp and two counterpairs.
package counterpairpair
import (
"math/rand"
"github.com/gmlewis/go-frp/v2/examples/inception/counterpair"
h "github.com/gmlewis/go-frp/v2/html"
)
const max = 100
// MODEL
type Model struct {
first counterpair.Model
last counterpair... | examples/inception/counterpairpair/counterpairpair.go | 0.702836 | 0.432782 | counterpairpair.go | starcoder |
package utils
//Represents a version vector
type VersionVector struct {
Val map[DCId]int64
}
// Create a new version vector
func NewVersionVector() *VersionVector {
return NewVersionVectorVV( nil)
}
// Create a new version vector that is a copy of the given version vector
func NewVersionVectorVV( otherVv *VersionV... | src/rockscrdtdb/utils/version_vector.go | 0.73307 | 0.421254 | version_vector.go | starcoder |
package gomultifast
import "sort"
// used as node id number, used to count nodes
var nodeID = 0
// edge indicating the next node
type edge struct {
alpha rune // Edge alpha. An alpha is a text character in the trie
next *node // Target node of the edge
}
// A pattern to be stored in the trie
type pattern struct... | ac_node.go | 0.739799 | 0.518485 | ac_node.go | starcoder |
package square
// An item variation (i.e., product) in the Catalog object model. Each item may have a maximum of 250 item variations.
type CatalogItemVariation struct {
// The ID of the `CatalogItem` associated with this item variation.
ItemId string `json:"item_id,omitempty"`
// The item variation's name. This is ... | square/model_catalog_item_variation.go | 0.850065 | 0.488527 | model_catalog_item_variation.go | starcoder |
package neat
import (
"context"
"fmt"
"github.com/pkg/errors"
"github.com/spf13/cast"
"github.com/yaricom/goNEAT/v2/neat/math"
"gopkg.in/yaml.v3"
"io"
"io/ioutil"
"strconv"
"strings"
)
// GenomeCompatibilityMethod defines the method to calculate genomes compatibility
type GenomeCompatibilityMethod string
c... | neat/neat.go | 0.730866 | 0.411761 | neat.go | starcoder |
package graph
import "sort"
type NodeID int
// Node represents a node in a graph with access to its
// incident edges. If its in a directed graph, it also has access
// to its incoming/outgoing edges. It can also store a value.
type Node interface {
// GetID returns the node's unique identifier.
GetID() NodeID
/... | graph/node.go | 0.741206 | 0.595346 | node.go | starcoder |
package game
import (
"fmt"
"math"
"math/rand"
)
type Ball struct {
Pos [2]float64
Velocity [2]float64
radius float64
}
func NewBall() Ball {
b := Ball{Pos: [2]float64{0, 0}}
angle := rand.Float64()*90.0 - 45.0
if rand.Float32() < 0.5 {
angle += 180
}
angle = angle * math.Pi / 180
intialSpeed :=... | game/ball.go | 0.519765 | 0.561515 | ball.go | starcoder |
package confusionmatrix
import (
"math"
"fmt"
)
type ConfusionMatrix struct {
TruePositives int
FalsePositives int
TrueNegatives int
FalseNegatives int
}
func (cm *ConfusionMatrix) Update(actual, predicted bool) {
if actual {
if predicted {
cm.TruePositives += 1
} e... | confusionmatrix.go | 0.834946 | 0.461199 | confusionmatrix.go | starcoder |
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/sundaytycoon/buttons-api/internal/storage/servicedb/ent/user"
)
// User is the model entity for the User schema.
type User struct {
config `json:"-"`
// ID of the ent.
ID string `json:"id,omitempty"`
// CreatedAt holds the v... | internal/storage/servicedb/ent/user.go | 0.52074 | 0.408277 | user.go | starcoder |
package getenv
import (
"fmt"
"os"
"reflect"
"sort"
"strconv"
"strings"
)
func isDigit(b byte) bool {
return '0' <= b && b <= '9'
}
func isUpper(b byte) bool {
return 'A' <= b && b <= 'Z'
}
func isLower(b byte) bool {
return 'a' <= b && b <= 'z'
}
func isAlpha(b byte) bool {
return isUpper(b) || isLower(... | getenv/getenv.go | 0.5769 | 0.415788 | getenv.go | starcoder |
package day03
import (
"math"
"strconv"
"strings"
)
type Point struct {
x int
y int
}
func origin() Point {
return Point{0, 0}
}
type GridVal [2]int
type Grid map[Point]GridVal
func grid_key(x int, y int) Point {
return Point{x, y}
}
func abs(a int) int {
if a < 0 {
return -a
}
return a
}
func update... | day03/day03.go | 0.717012 | 0.441312 | day03.go | starcoder |
package cflow
import (
"fmt"
)
// Event model interface
type Evt interface{
Vars() []Var // Return the list of needed variables.
Weight() float64 // Define the weight (from available variables).
}
// TreeVar groups the branch name and a value
// of the proper type, as needed by rtree.ReadVar.
type Var struct ... | cflow/cflow.go | 0.590189 | 0.425784 | cflow.go | starcoder |
package design
import (
"fmt"
"io"
"time"
"github.com/gregoryv/draw"
"github.com/gregoryv/draw/shape"
"github.com/gregoryv/draw/types/date"
)
// NewGanttChart returns a GanttChart spanning days from the given
// date. Panics if date cannot be resolved.
func NewGanttChart(from date.String, days int) *GanttChart... | design/ganttchart.go | 0.660282 | 0.424352 | ganttchart.go | starcoder |
package main
import (
"fmt"
"log"
"os"
)
type Cypher struct {
rowIndex int
colIndex int
char rune
}
func cyphers() []Cypher {
return []Cypher{
{rowIndex: 1, colIndex: 1, char: 'B'},
{rowIndex: 1, colIndex: 2, char: 'G'},
{rowIndex: 1, colIndex: 3, char: 'W'},
{rowIndex: 1, colIndex: 4, char: 'K'},... | cmd/bifid/main.go | 0.550607 | 0.402128 | main.go | starcoder |
package vector
import "math"
// Vector represents a mathematical n-dimensional vector
type Vector []float64
// Equal compares a and b elementwise under a precision eps.
func (a Vector) Equal(b Vector, eps float64) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if math.Abs(a[i]-b[i]) > eps {
... | vector.go | 0.900964 | 0.765987 | vector.go | starcoder |
package main
/*
题目:解码异或后的数组
未知 整数数组 arr 由 n 个非负整数组成。
经编码后变为长度为 n - 1 的另一个整数数组 encoded ,其中 encoded[i] = arr[i] XOR arr[i + 1] 。例如,arr = [1,0,2,1] 经编码后得到 encoded = [1,2,3] 。
给你编码后的数组 encoded 和原数组 arr 的第一个元素 first(arr[0])。
请解码返回原数组 arr 。可以证明答案存在并且是唯一的。
提示:
2 <= n <= 10^4
encoded.length == n - 1
0 <= encoded[i] <= 10... | internal/leetcode/1720.decode-xored-array/main.go | 0.513181 | 0.428233 | main.go | starcoder |
package rendering
import (
"image/color"
"math"
"github.com/veandco/go-sdl2/sdl"
"github.com/wdevore/RangerGo/api"
"github.com/wdevore/RangerGo/engine/geometry"
"github.com/wdevore/RangerGo/engine/maths"
)
type renderState struct {
clearColor color.RGBA
drawColor color.RGBA
current api.IAffineTransform
}
... | engine/rendering/render_context.go | 0.702326 | 0.416263 | render_context.go | starcoder |
package lib
import (
"errors"
"fmt"
"time"
"github.com/dcaiafa/nitro"
)
type Time struct {
time time.Time
}
var _ /* implements */ nitro.Indexable = Time{}
func NewTime(t time.Time) Time {
return Time{time: t}
}
func (t Time) String() string { return t.time.String() }
func (t Time) Type() string { return ... | lib/time.go | 0.607663 | 0.478407 | time.go | starcoder |
package utils
import (
"time"
"px.dev/pixie/src/shared/services/jwtpb"
)
// ClaimType represents the type of claims we allow in our system.
type ClaimType int
const (
// UnknownClaimType is an unknown type.
UnknownClaimType ClaimType = iota
// UserClaimType is a claim for a user.
UserClaimType
// ServiceClai... | src/shared/services/utils/claims.go | 0.548674 | 0.467271 | claims.go | starcoder |
package validator
import (
"fmt"
"net"
"unicode/utf8"
)
// BetweenString is
func BetweenString(v string, left int64, right int64) bool {
return DigitsBetweenInt64(int64(utf8.RuneCountInString(v)), left, right)
}
// InString check if string str is a member of the set of strings params
func InString(str string, pa... | validator_string.go | 0.651466 | 0.404302 | validator_string.go | starcoder |
package primitive
import (
"fmt"
"strings"
"math"
"github.com/fogleman/gg"
"github.com/golang/freetype/raster"
)
type Line struct {
Worker *Worker
X1, Y1 float64
X2, Y2 float64
tX1, tY1 float64
tX2, tY2 float64
Width float64
}
func NewRandomLine(worker *Worker) *Line {
... | primitive/line.go | 0.654122 | 0.572902 | line.go | starcoder |
package caser
import (
"strings"
)
func Convert(v string, f, t CaseType) string {
var splitFn func(string) []string
var mapFn func(string) string
var joinFn func([]string) string
var o string
switch f {
case CaseType_Camel:
splitFn = splitOnCapitalOrNumber
case CaseType_Pascal:
splitFn = splitOnCapitalOr... | convert.go | 0.511717 | 0.407923 | convert.go | starcoder |
package rel
import (
"fmt"
"sort"
"strings"
"github.com/arr-ai/frozen"
)
// Names represents a set of names.
type Names frozen.Set
// EmptyNames is the empty set of names.
var EmptyNames = Names(frozen.Set{})
// NewNames returns a new set of names with the given names.
func NewNames(names ...string) Names {
s... | rel/names.go | 0.838548 | 0.432243 | names.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.