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 core
import (
"fmt"
"github.com/philandstuff/dhall-golang/v5/term"
)
type context map[string][]Value
func (ctx context) extend(name string, t Value) context {
newctx := context{}
for k, v := range ctx {
newctx[k] = v
}
newctx[name] = append(newctx[name], t)
return newctx
}
func (ctx context) fresh... | core/typecheck.go | 0.527317 | 0.457682 | typecheck.go | starcoder |
package dom
import (
"image/color"
"log"
"github.com/google/gojiraw/graphics"
)
const (
VERTEX_NON = iota // Draw the default vertex handle.
VERTEX_HOVER // Draw the hover vertex handle.
VERTEX_PRESS // Draw the mouse down vertex handle
NUM_VERTEX_STATES
)
const (
QUAD_ELEMENT_DX = 45.
QUA... | content/dom/quad_element.go | 0.524395 | 0.402451 | quad_element.go | starcoder |
package gr
import (
"bufio"
"fmt"
"io"
"strconv"
"strings"
"github.com/ortiye/molsolvent/pkg/util"
)
// readCfgFirst reads the first configuration. It reads the number of atoms, the
// columns and performs the usual calculations like in readCfg.
func (g *GR) readCfgFirst(r *bufio.Reader) (box [3]float64, xyz X... | pkg/gr/read.go | 0.626238 | 0.449513 | read.go | starcoder |
package container
import (
"reflect"
)
// invoke will call the given function and return its returned value.
// It only works for functions that return a single value.
func invoke(function interface{}) interface{} {
return reflect.ValueOf(function).Call(arguments(function))[0].Interface()
}
// binding keeps a bind... | container.go | 0.779951 | 0.435061 | container.go | starcoder |
package shape
import (
"encoding/json"
"log"
"github.com/gmlewis/lottie2flare/lottie/properties"
)
const (
// TransformType represents a lottie transform.
TransformType Type = "tr"
)
// Transform represents a lottie shape/transform.
type Transform interface {
InitialOpacity() float64
// InitialRotation retu... | lottie/shape/transform.go | 0.839372 | 0.441733 | transform.go | starcoder |
package tin
type QuadEdge struct {
pool *Pool
qnext *QuadEdge
qprev *QuadEdge
next *QuadEdge
data [2]float64
lface *DelaunayTriangle
index int
}
type edgeID uint32
const (
Nil = 0xFFFFFFFF
canonical edgeID = 0xFFFFFFFC
quad edgeID = 0x00000003
)
func (e *QuadEdge) Init() {
e1 := New(... | edge.go | 0.599251 | 0.418637 | edge.go | starcoder |
package tailsamplingprocessor
import (
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
"go.opentelemetry.io/collector/internal/collector/telemetry"
"go.opentelemetry.io/collector/obsreport"
)
// Variables related to metrics specific to tail sampling.
var (
tagPolicyKey, _ = ta... | processor/samplingprocessor/tailsamplingprocessor/metrics.go | 0.69035 | 0.489686 | metrics.go | starcoder |
package input
import (
"github.com/Jeffail/benthos/v3/internal/codec"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/input/reader"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
)
func init() {
Cons... | lib/input/azure_blob_storage_config.go | 0.814164 | 0.646725 | azure_blob_storage_config.go | starcoder |
package routing
import (
"strings"
)
// routeTrie is defined to hide away the traverse method in the trie data structure
// defined below.
type routeTrie interface {
add(route *Route)
search(path string) ([]*Route, map[string]string)
}
// trie is a simple trie data structure that allows for multiple routes to be ... | routing/trie.go | 0.673299 | 0.519704 | trie.go | starcoder |
package animation
import (
"github.com/g3n/engine/core"
"github.com/g3n/engine/geometry"
"github.com/g3n/engine/math32"
)
// A Channel associates an animation parameter channel to an interpolation sampler
type Channel struct {
keyframes math32.ArrayF32 // Input keys (usually time)
values ... | animation/channel.go | 0.761272 | 0.480783 | channel.go | starcoder |
package gorethink
import (
p "github.com/dancannon/gorethink/ql2"
)
// Now returns a time object representing the current time in UTC
func Now(args ...interface{}) Term {
return constructRootTerm("Now", p.Term_NOW, args, map[string]interface{}{})
}
// Time creates a time object for a specific time
func Time(args .... | Godeps/_workspace/src/github.com/dancannon/gorethink/query_time.go | 0.84634 | 0.506225 | query_time.go | starcoder |
package gfx
import (
"image/draw"
"math"
)
// Block has a position, size and color.
type Block struct {
Pos Vec3
Size Vec3
Color BlockColor
}
// NewBlock creates a new Block.
func NewBlock(pos, size Vec3, ic BlockColor) Block {
return Block{Pos: pos, Size: size, Color: ic}
}
// Box creates a box for the B... | block.go | 0.814274 | 0.496948 | block.go | starcoder |
package plan
import (
"encoding/json"
"fmt"
"sort"
"github.com/alibaba/polardbx-operator/pkg/operator/v1/xstore/change/driver/model"
)
type StepType string
// Valid plan node types. The order of the raw values is
// the order of the node types.
const (
StepTypeSnapshot StepType = "Snapshot"
StepTypeBumpGen S... | pkg/operator/v1/xstore/change/driver/plan/plan.go | 0.589716 | 0.446796 | plan.go | starcoder |
package gohome
const (
SHAPE_2D_SHADER_NAME string = "Shape2D"
)
// A 2D shape as a RenderObject
type Shape2D struct {
NilRenderObject
// The name of the shape
Name string
shapeInterface Shape2DInterface
// The transform of the shape
Transform *TransformableObject2D
// Wether the shape is vis... | src/gohome/shape2d.go | 0.809878 | 0.585634 | shape2d.go | starcoder |
package tls
import (
"crypto/tls"
"crypto/x509"
"errors"
"io/ioutil"
)
//------------------------------------------------------------------------------
// Documentation is a markdown description of how and why to use TLS settings.
const Documentation = `### TLS
Custom TLS settings can be used to override system... | lib/util/tls/type.go | 0.691914 | 0.514522 | type.go | starcoder |
package component
import (
"github.com/gotracker/voice"
"github.com/gotracker/voice/oscillator"
"github.com/gotracker/voice/period"
)
// FreqModulator is a frequency (pitch) modulator
type FreqModulator struct {
period period.Period
delta period.Delta
autoVibratoEnabled bool
autoVibrat... | component/modulator_freq.go | 0.820037 | 0.609669 | modulator_freq.go | starcoder |
package qr
// Zero-knowledge proof of quadratic residousity (implemented for historical reasons)
import (
"math/big"
"fmt"
"github.com/emmyzkp/crypto/common"
"github.com/emmyzkp/crypto/schnorr"
)
// ProveQR demonstrates how the prover can prove that y1^2 is QR.
func ProveQR(y1 *big.Int, group *schnorr.Group) b... | qr/qr.go | 0.771069 | 0.412648 | qr.go | starcoder |
package petstore
import (
"bytes"
"encoding/json"
)
// ReadOnlyFirst struct for ReadOnlyFirst
type ReadOnlyFirst struct {
Bar *string `json:"bar,omitempty"`
Baz *string `json:"baz,omitempty"`
}
// NewReadOnlyFirst instantiates a new ReadOnlyFirst object
// This constructor will assign default values to propertie... | samples/openapi3/client/petstore/go-experimental/go-petstore/model_read_only_first.go | 0.792223 | 0.408601 | model_read_only_first.go | starcoder |
package ui
const (
txtAboutProject = `Juggle accounts with Kitri
MADE FOR NON-ACCOUNTANTS
Kitri is an accounting calculator complementing spreadsheets
TRIVIALLY EASY BOOKKEEPING
Kitri bridges the gap between spreadsheets and bookkeeping software
Kitri streamlines the part that is tricky in Microsoft Excel, Libre... | ui/text.go | 0.651687 | 0.544135 | text.go | starcoder |
package payload
import (
"github.com/pkg/errors"
"github.com/ywangd/gobufrkit/bufr"
"fmt"
)
const refNotSet = -1
// Bitmap wraps the information about a bitmap, i.e. its bits etc.
type Bitmap struct {
// start and stop (exclusive) indices for the bitmap nodes (031031)
Index0 int
Index1 int
}
... | deserialize/payload/bitmap.go | 0.633183 | 0.421611 | bitmap.go | starcoder |
package heap
import (
"fmt"
"math/bits"
)
// A Heap is a binary tree together with the maximum heap property.
// That is, each parent item is greater than its children.
type Heap struct {
less Lesser
values []interface{}
size int
}
// Lesser defines the less-than comparison between two values.
type Lesser f... | heap.go | 0.831485 | 0.476214 | heap.go | starcoder |
package fp448
import (
"errors"
"circl/internal/conv"
)
// Size in bytes of an element.
const Size = 56
// Elt is a prime field element.
type Elt [Size]byte
func (e Elt) String() string { return conv.BytesLe2Hex(e[:]) }
// p is the prime modulus 2^448-2^224-1.
var p = Elt{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0... | src/circl/math/fp448/fp.go | 0.719975 | 0.467028 | fp.go | starcoder |
package graph
import "fmt"
// MemoryBackendNode a memory backend node
type MemoryBackendNode struct {
*Node
edges map[Identifier]*MemoryBackendEdge
}
// MemoryBackendEdge a memory backend edge
type MemoryBackendEdge struct {
*Edge
}
// MemoryBackend describes the memory backend
type MemoryBackend struct {
Backe... | graffiti/graph/memory.go | 0.728265 | 0.413832 | memory.go | starcoder |
package function
import (
"fmt"
"math"
"strings"
"time"
"gopkg.in/src-d/go-errors.v1"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/expression"
)
// TimeDiff subtracts the second argument from the first expressed as a time value.
type TimeDiff struct {
expression.BinaryEx... | sql/expression/function/timediff.go | 0.768038 | 0.537406 | timediff.go | starcoder |
package audio
import "math"
var (
// RootA or concert A is the reference frequency for A4.
// Modify this package variable if you need to change it to 435 (classical) or
// 415 (baroque). Methods refering to this root A note will use this variable.
RootA = 440.0
)
// AvgInt averages the int values passed
func Av... | audio.go | 0.707101 | 0.435121 | audio.go | starcoder |
package batchingchannels
import (
"context"
"github.com/askiada/external-sort/vector"
"golang.org/x/sync/errgroup"
"golang.org/x/sync/semaphore"
)
// BatchingChannel implements the Channel interface, with the change that instead of producing individual elements
// on Out(), it batches together the entire interna... | file/batchingchannels/batching_channel.go | 0.737158 | 0.429728 | batching_channel.go | starcoder |
package parquet
import (
"context"
"errors"
"fmt"
"os"
"github.com/xitongsys/parquet-go-source/buffer"
"github.com/xitongsys/parquet-go/parquet"
"github.com/xitongsys/parquet-go/reader"
"github.com/xitongsys/parquet-go/writer"
"github.com/benthosdev/benthos/v4/public/service"
)
func parquetProcessorConfig(... | internal/impl/parquet/processor.go | 0.551091 | 0.712495 | processor.go | starcoder |
package unit
// Area represents a SI unit of area (in square meters, m²)
type Area Unit
// ...
const (
// SI
SquareYoctometer = SquareMeter * 1e-48
SquareZeptometer = SquareMeter * 1e-42
SquareAttometer = SquareMeter * 1e-36
SquareFemtometer = SquareMeter * 1e-30
SquarePicometer = Squ... | area.go | 0.902116 | 0.447098 | area.go | starcoder |
package value
import (
"fmt"
"github.com/chewxy/hm"
"github.com/pkg/errors"
"gorgonia.org/tensor"
)
// TypeOf returns the Type of the value
func TypeOf(v Value) hm.Type {
switch t := v.(type) {
case tensor.Tensor:
dt, dim := tensorInfo(t)
return makeTensorType(dim, dt)
case Scalar:
return t.Dtype()
cas... | vendor/gorgonia.org/gorgonia/value/values_utils.go | 0.725843 | 0.52616 | values_utils.go | starcoder |
package tree
import (
"fmt"
. "github.com/Jcowwell/go-algorithm-club/Utils"
"golang.org/x/exp/constraints"
)
// Binary Search Tree's Node
type BinarySearchTreeNode[T constraints.Ordered] struct {
value T
left *BinarySearchTreeNode[T]
right *BinarySearchTreeNode[T]
parent *BinarySearchTreeNode[T]
}
// Con... | BinarySearchTree/binary_search_tree.go | 0.725551 | 0.540681 | binary_search_tree.go | starcoder |
package main
import "sort"
/*
Given an arrays of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
you can return the answer in any order.
Example 1:
Inpu... | leetcode/1.two_sum.go | 0.666497 | 0.547041 | 1.two_sum.go | starcoder |
package matrix
import (
"math"
)
// LUPDecompose does LUP decomposition of matrix
// https://en.wikipedia.org/wiki/LU_decomposition
/* INPUT: t - array of pointers to rows of a square matrix having dimension N
* Tol - small tolerance number to detect failure when the matrix is near degenerate
* OUTPUT: New ... | matrix/LUDecomposition.go | 0.695752 | 0.65044 | LUDecomposition.go | starcoder |
package slotutil
import (
"time"
"github.com/prysmaticlabs/prysm/shared/timeutils"
)
// The Ticker interface defines a type which can expose a
// receive-only channel firing slot events.
type Ticker interface {
C() <-chan uint64
Done()
}
// SlotTicker is a special ticker for the beacon chain block.
// The chann... | .docker/Prysm/prysm-spike/shared/slotutil/slotticker.go | 0.69035 | 0.419053 | slotticker.go | starcoder |
package feeestimator
import (
"fmt"
"github.com/incognitochain/incognito-chain/common"
"math/big"
"github.com/incognitochain/coin-service/pdexv3/feeestimator/jsonresult"
)
func EstimateFeeInSellToken(
sellAmount uint64, sellToken string, tradePath []string, pdexState jsonresult.PdexState,
) (uint64, error) {
i... | pdexv3/feeestimator/estimator.go | 0.6137 | 0.419648 | estimator.go | starcoder |
package flatbuffers
import (
"math"
)
type (
// A SOffsetT stores a signed offset into arbitrary data.
SOffsetT int32
// A UOffsetT stores an unsigned offset into vector data.
UOffsetT uint32
// A VOffsetT stores an unsigned offset in a VTable.
VOffsetT uint16
)
const (
// VtableMetadataFields is the count o... | go/encode.go | 0.742795 | 0.487551 | encode.go | starcoder |
package maybe
import (
"errors"
"math"
"math/bits"
)
// HyperLogLog is data structure for estimating cardinality with a accuracy of ` 1 - 1.04 / sqrt(m)` with
// m defined as `2^b`, the reference is from this paper: http://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf
// This being said the accuracy of the da... | hll.go | 0.734501 | 0.503784 | hll.go | starcoder |
package assert
import (
"fmt"
"math"
"reflect"
"golang.org/x/exp/constraints"
)
// Positive asserts that the value is positive.
func Positive[T constraints.Signed | constraints.Float](a T) error {
if a < 0 {
return fmt.Errorf("%v is not positive", a)
}
return nil
}
// Nagative asserts that the value is neg... | test/assert/integer.go | 0.767908 | 0.641914 | integer.go | starcoder |
package schema
// PerforceSchemaJSON is the content of the file "perforce.schema.json".
const PerforceSchemaJSON = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "perforce.schema.json#",
"title": "PerforceConnection",
"description": "Configuration for a connection to Perforce Server.",
"all... | schema/perforce_stringdata.go | 0.764804 | 0.429848 | perforce_stringdata.go | starcoder |
package delaunator
import (
"fmt"
"math"
)
type triangulation struct {
coords []float64
triangles []uint
halfEdges []int
hull []int
}
type point struct {
x float64
y float64
}
type Point2d interface {
X() float64
Y() float64
}
func (p point) X() float64 {
return ... | pkg/triangulation.go | 0.602412 | 0.607634 | triangulation.go | starcoder |
package lcd
// Bounding box indices, representing the corners of the box (top/bottom left/right).
const (
TL = iota
TR = iota
BR = iota
BL = iota
)
// BBox represents a bounding box, with the indices above representing the corners.
type BBox [4]Point
// Create a new bounding box representing one segment of a 7 ... | bbox.go | 0.8575 | 0.708918 | bbox.go | starcoder |
package rolling
import (
"math"
"sort"
"sync"
)
// Count returns the number of elements in a window.
func Count(w Window) float64 {
result := 0
for _, bucket := range w {
result += len(bucket)
}
return float64(result)
}
// Sum the values within the window.
func Sum(w Window) float64 {
var result = 0.0
for... | reduce.go | 0.775902 | 0.441553 | reduce.go | starcoder |
package geogfn
import (
"github.com/cockroachdb/cockroach/pkg/geo"
"github.com/golang/geo/s1"
"github.com/golang/geo/s2"
)
// wgs84SphereRadiusMeters is the radius if WGS84 was a sphere.
const wgs84SphereRadiusMeters = 6371008.7714150598325213222
// Distance returns the distance between geographies a and b on a ... | pkg/geo/geogfn/distance.go | 0.856332 | 0.61581 | distance.go | starcoder |
package plaid
import (
"encoding/json"
"time"
)
// SignalEvaluateCoreAttributes The core attributes object contains additional data that can be used to assess the ACH return risk. Examples of data include: `days_since_first_plaid_connection`: The number of days since the first time the Item was connected to an ap... | plaid/model_signal_evaluate_core_attributes.go | 0.815122 | 0.755569 | model_signal_evaluate_core_attributes.go | starcoder |
package ls
// Composer interface represents term composition algorithm. During
// layer composition, any term metadata that implements Composer
// interface will be composed using the customized implementation. If
// the term does not implement the Composer interface, Setcomposition
// will be used
type Composer inte... | pkg/ls/semcomposition.go | 0.731059 | 0.498047 | semcomposition.go | starcoder |
package objects
type VxlanInstance struct {
baseObj
Vni uint32 `SNAPROUTE: "KEY", CATEGORY:"Tunnel", ACCESS:"w", MULTIPLICITY:"*", DESCRIPTION: VXLAN Network Id, MIN: "1" , MAX: "16777215"`
AdminState string `DESCRIPTION: Administrative state of VXLAN layer, UP will allow for traffic to be proc... | objects/vxlandObjects.go | 0.620737 | 0.428233 | vxlandObjects.go | starcoder |
package discovery
import "fmt"
type Vacuum struct {
// A list of MQTT topics subscribed to receive availability (online/offline) updates. Must not be used together with `availability_topic`
// Default: <no value>
Availability []Availability `json:"availability,omitempty"`
// When `availability` is configured, t... | vacuum.go | 0.830594 | 0.408513 | vacuum.go | starcoder |
package ta
import (
// "fmt"
)
// Mean gets the mean value for an array of float64 values
func Mean(values []float64) float64 {
var total float64=0
for _,element := range values {
total += element
}
return total / float64(len(values))
}
// Sma produces the Simple Moving Average for the
// supplied array of ... | ta/ma.go | 0.735167 | 0.576691 | ma.go | starcoder |
package sese
import (
"encoding/xml"
"github.com/fgrid/iso20022"
)
type Document00800107 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.008.001.07 Document"`
Message *ReversalOfTransferInConfirmationV07 `xml:"RvslOfTrfInConf"`
}
func (d *Document00800107) AddMessage() *ReversalOfTransferInC... | sese/ReversalOfTransferInConfirmationV07.go | 0.79732 | 0.424114 | ReversalOfTransferInConfirmationV07.go | starcoder |
package dyno
import (
"context"
ddb "github.com/aws/aws-sdk-go-v2/service/dynamodb"
"sync"
)
// DisableKinesisStreamingDestination executes DisableKinesisStreamingDestination operation and returns a DisableKinesisStreamingDestination operation
func (s *Session) DisableKinesisStreamingDestination(input *ddb.Disable... | op_DisableKinesisStreamingDestination.go | 0.685529 | 0.446736 | op_DisableKinesisStreamingDestination.go | starcoder |
package mat
import (
"encoding/binary"
"encoding/gob"
"errors"
"fmt"
"math"
)
func init() {
gob.Register(&Dense[float32]{})
gob.Register(&Dense[float64]{})
}
const (
binaryDenseFloat32 byte = iota
binaryDenseFloat64
)
// MarshalBinary marshals a Dense matrix into binary form.
func (d Dense[T]) MarshalBina... | mat/dense_marshaling.go | 0.687315 | 0.440229 | dense_marshaling.go | starcoder |
package neuralnet
import ()
// Implementation of a github.com/alonsovidales/go_ml ml.DataSet
type DataSet struct {
NN *NeuralNet
Examples Matrix
Answers Matrix
}
// Implementation of the ml.DataSet interface for NeuralNet
// Returns the cost and gradients for the current thetas configuration
func (ds Data... | ml_dataset.go | 0.797202 | 0.608681 | ml_dataset.go | starcoder |
package anns
import (
"bytes"
crand "crypto/rand"
"encoding/gob"
"errors"
"math"
"math/big"
"math/rand"
"github.com/sachaservan/vec"
"github.com/ncw/gmp"
)
// Hash is an abstract hash function
type Hash interface {
Digest(*vec.Vec) *gmp.Int
StringDigest(*vec.Vec) string
}
// UniversalHash is a universal... | anns/hashes.go | 0.810516 | 0.466116 | hashes.go | starcoder |
package cast
import (
"fmt"
"strconv"
"time"
)
// TryToBool casts an empty interface to a bool.
func TryToBool(i interface{}) (b bool, err error) {
switch v := i.(type) {
case nil:
case bool:
b = v
case *bool:
b = *v
case string:
b, err = strconv.ParseBool(v)
case *string:
b, err = strconv.ParseBool(... | util/cast/try.go | 0.603231 | 0.527195 | try.go | starcoder |
package sema
import (
"fmt"
"github.com/rhysd/gocaml/ast"
"github.com/rhysd/gocaml/common"
. "github.com/rhysd/gocaml/types"
"github.com/rhysd/locerr"
)
// InferredTypes is a dictonary from an AST nodes to inferred types.
type InferredTypes map[ast.Expr]Type
// Type schemes for generic types
type schemes map[Ty... | sema/infer.go | 0.68458 | 0.537466 | infer.go | starcoder |
package assert
import (
"regexp"
"strings"
)
type String struct {
logFacade *logFacade
actual string
}
func (a *String) IsEqualTo(expected string) *String {
return a.isTrue(a.actual == expected,
"Expected <%s>, but was <%s>.", expected, a.actual)
}
func (a *String) IsNotEqualTo(unexpected string) *String ... | vendor/github.com/assertgo/assert/string.go | 0.787278 | 0.561816 | string.go | starcoder |
package continuous
import (
"github.com/jtejido/ggsl/specfunc"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Benktander type II distribution (Benktander-Weibull Distribution)
// https://en.wikipedia.org/wiki/Benktander_type_II_distribution
type BenktanderType2 struct {
baseCo... | dist/continuous/benktander_type_2.go | 0.743541 | 0.49292 | benktander_type_2.go | starcoder |
package datastruct
import (
"fmt"
"strings"
)
// SinglyLinkedList is a singly linked list implementation using generics. This type is not safe for concurrent use
// and thus needs to be guarded using a mutex.
// This empty value of this struct is valid and can be used.
type SinglyLinkedList[V comparable] struct {
... | datastruct/singly_linked_list.go | 0.717111 | 0.559952 | singly_linked_list.go | starcoder |
package optional
import (
"errors"
"github.com/searKing/golib/util/object"
)
var empty = &Optional{}
var (
ErrorNoValuePresent = errors.New("No value present")
)
// Optional is a container object which may or may not contain a non-{@code null} value.
// If a value is present, {@code isPresent()} returns {@code tr... | util/optional/optional.go | 0.926736 | 0.458106 | optional.go | starcoder |
package knapsack
import (
"fmt"
)
// Loot represents an object we can add to the bag. A loot has a Weight and a Value.
// Weight must be strictly positive; Weight > 0.
// Value must be positive; Value >= 0.
// In a knapsack problem, we want to select the Loot so that they maximize the total Value.
type Loot struct {... | pkg/knapsack/knapsack.go | 0.710929 | 0.466846 | knapsack.go | starcoder |
package timeseries
import (
"sort"
"time"
)
//FloatSeries represents timepoints with floating point values
type FloatSeries struct {
Data []FloatPoint `json:"data"`
sorted bool
}
//FloatPoint represents a floatingpoint at a specific time
type FloatPoint struct {
Date time.Time `json:"date"`
Val float64 `j... | timeseries/timeseries.go | 0.822759 | 0.641549 | timeseries.go | starcoder |
package ard
import (
"fmt"
"io"
"strings"
"gopkg.in/yaml.v3"
)
func FindYamlNode(node *yaml.Node, path ...PathElement) *yaml.Node {
if len(path) == 0 {
return node
}
switch node.Kind {
case yaml.AliasNode:
return FindYamlNode(node.Alias, path...)
case yaml.DocumentNode:
for _, childNode := range nod... | ard/yaml.go | 0.500977 | 0.420778 | yaml.go | starcoder |
package eaopt
import (
"fmt"
"math"
)
// A Metric returns the distance between two genomes.
type Metric func(a, b Individual) float64
// A DistanceMemoizer computes and stores Metric calculations.
type DistanceMemoizer struct {
Metric Metric
Distances map[string]map[string]float64
nCalculations int /... | distance.go | 0.737442 | 0.627809 | distance.go | starcoder |
package save
import (
"fmt"
"math"
)
// BitStorage implement the compacted data array used in chunk storage.
// https://wiki.vg/Chunk_Format
// This implement the format since Minecraft 1.16
type BitStorage struct {
data []uint64
mask uint64
bits, size int
valuesPerLong int
}
// NewBitStorage create a new ... | save/bitstorage.go | 0.612657 | 0.449997 | bitstorage.go | starcoder |
package result
// Result represents a result that can either be okay, or an error
type Result[T any] struct {
Ok T
Err error
}
// IsOk returns whether the result was a success
func (r Result[T]) IsOk() bool {
return r.Err == nil
}
// IsErr returns whether the result was an error
func (r Result[T]) IsErr() bool {... | result/result.go | 0.825871 | 0.549459 | result.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// OnPremisesProvisioningError
type OnPremisesProvisioningError struct {
// Store... | models/on_premises_provisioning_error.go | 0.644113 | 0.404037 | on_premises_provisioning_error.go | starcoder |
package markets
import (
"fmt"
"strconv"
"time"
"github.com/aleibovici/cryptopump/exchange"
"github.com/aleibovici/cryptopump/functions"
"github.com/aleibovici/cryptopump/logger"
"github.com/aleibovici/cryptopump/types"
"github.com/sdcoffey/big"
"github.com/sdcoffey/techan"
)
// Data struct host temporal m... | markets/markets.go | 0.584034 | 0.421314 | markets.go | starcoder |
package ff
import (
"io"
"github.com/cloudflare/circl/internal/conv"
)
// FpSize is the length in bytes of an Fp element.
const FpSize = 48
// fpMont represents an element in the Montgomery domain (little-endian).
type fpMont = [FpSize / 8]uint64
// fpRaw represents an element in the integers domain (little-endi... | ecc/bls12381/ff/fp.go | 0.767646 | 0.406744 | fp.go | starcoder |
package matrix
import "fmt"
type RMatrix struct {
cols [][]float64
m, n int
}
func MakeRealMatrix(m, n int) *RMatrix {
A := RMatrix{
cols: make([][]float64, m),
m: m,
n: n,
}
for i := 0; i < m; i++ {
A.cols[i] = make([]float64, n)
}
return &A
}
func (Ap *RMatrix) Shape() (m, n int) {
return ... | pkg/matrix/real.go | 0.591251 | 0.477067 | real.go | starcoder |
package parse
import (
"strings"
"github.com/omniskop/vitrum/vit"
)
type propertyValueType int
const (
valueTypeComponent propertyValueType = iota
valueTypeList
valueTypeExpression
)
// a propertyValue is either a component definition, a list of more componentValues or a JavaScript expression
type propertyVal... | vit/parse/parseExpression.go | 0.61555 | 0.420183 | parseExpression.go | starcoder |
package exec
import (
"errors"
"github.com/peter-mount/calculator/context"
"math"
"math/cmplx"
)
var (
unsupportedMathType = errors.New( "Unsupported number type" )
)
// RealComplex1 invokes a function based on the value type.
// If a is numeric then rf will be used.
// If a is complex then cf will be used... | exec/math.go | 0.877372 | 0.424352 | math.go | starcoder |
package main
const immMapTmpl = `
var _ immutable.Immutable = new({{.Name}})
var _ = new({{.Name}}).__tmpl
func {{Export "New"}}{{Capitalise .Name}}(inits ...func(m *{{.Name}})) *{{.Name}} {
res := {{Export "New"}}{{Capitalise .Name}}Cap(0)
if len(inits) == 0 {
return res
}
return res.WithMutable(func (m *{{.... | immutable/cmd/immutableGen/tmplImmMap.go | 0.619932 | 0.518363 | tmplImmMap.go | starcoder |
package brush
import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/world"
"math/rand"
"time"
)
// Perform performs the world edit action passed in a specific shape, in the world that is passed. Perform
// will only ever edit blocks found within the shape passed.
// Perform re... | brush/perform.go | 0.81899 | 0.545225 | perform.go | starcoder |
package obj
import (
"github.com/deadsy/sdfx/sdf"
"github.com/ivanpointer/pterosphera/render"
)
// TrackballSensorMount holds the parameters for the trackball sensor mount.
type TrackballSensorMount struct {
// ScrewDist defines the distance between the screw holes (center).
ScrewDist float64
// ScrewRTop is th... | go_sdx/obj/trackball_sensor.go | 0.705481 | 0.492249 | trackball_sensor.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// SimulationEvent
type SimulationEvent struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for ... | models/simulation_event.go | 0.597373 | 0.553807 | simulation_event.go | starcoder |
package treap
import (
"fmt"
"math"
"math/rand"
"reflect"
"time"
)
// Tree contains a reference to the root of the tree
type Tree struct {
Root *Node
rnd *rand.Rand
}
// Randomized priorities are in the range of [0 - 2^31)
const maxPriority = math.MaxInt32
// NewTree returns an empty treap Tree
func NewTree... | treap/treap.go | 0.672869 | 0.51879 | treap.go | starcoder |
package cursors
import "github.com/influxdata/influxql"
// FieldType represents the primitive field data types available in tsm.
type FieldType int
const (
Float FieldType = iota // means the data type is a float
Integer // means the data type is an integer
Unsigned // mea... | tsdb/cursors/schema.go | 0.784319 | 0.619817 | schema.go | starcoder |
package tfidf
import (
"log"
"math"
"github.com/kiteco/kiteco/kite-golib/text"
)
// TermCounter defines the functions that a termcounter must implement.
type TermCounter interface {
Weight(w string) float64
}
// IDFCounter keeps track on the number of docs that contain a certain word in a corpus.
// IDFCounter ... | kite-golib/tfidf/termcounter.go | 0.713232 | 0.468122 | termcounter.go | starcoder |
package datastructure
import "fmt"
// A BST is a binaray tree in symmetric order
// A binary tree is
// - either empty
// - two disjoinct binary tree (left and right)
// Symmetric order: each node as a key and every node's key is:
// - larger than all keys in its left subtree
// - smaller than all keys in its right s... | datastructure/binary_search_tree.go | 0.606032 | 0.506347 | binary_search_tree.go | starcoder |
MAix Go Bezel
https://www.sipeed.com
https://wiki.sipeed.com/en/maix/board/go.html
https://www.seeedstudio.com/Sipeed-MAix-GO-Suit-for-RISC-V-AI-IoT-p-2874.html
*/
//-----------------------------------------------------------------------------
package main
import (
"log"
"github.com/deadsy/sdfx/obj"
"github.co... | examples/maixgo/main.go | 0.562657 | 0.449091 | main.go | starcoder |
package advanced
import (
"encoding/binary"
"math"
)
// MarshalBinary encode the target EncodingMatrixParameters on a slice of bytes.
func (mParams *EncodingMatrixLiteral) MarshalBinary() (data []byte, err error) {
data = make([]byte, 8)
data[0] = uint8(mParams.LinearTransformType)
data[1] = uint8(mParams.LevelS... | ckks/advanced/marshaler.go | 0.617051 | 0.416441 | marshaler.go | starcoder |
package sparsemat
import (
"encoding/json"
"fmt"
"sort"
"strings"
"github.com/olekukonko/tablewriter"
)
type CSRMatrix struct {
rows, cols int
data [][]int
}
type csrMatrix struct {
Rows, Cols int
Data [][]int
}
func (mat *CSRMatrix) MarshalJSON() ([]byte, error) {
return json.Marshal(csrMatr... | csrmat.go | 0.734024 | 0.541348 | csrmat.go | starcoder |
package deepcopy
import (
"errors"
"fmt"
"reflect"
)
// Copy returns a deepcopy of the specified object.
// Unexported fields of a struct are ignored and will not be copied.
// The types unsafe.Pointer and uintptr are not supported and they will cause a panic.
// A channel will point to original channel.
// Error ... | deepcopy.go | 0.567697 | 0.459743 | deepcopy.go | starcoder |
package util
import (
"fmt"
"strconv"
"strings"
iex "github.com/jonwho/go-iex"
"golang.org/x/text/language"
"golang.org/x/text/message"
)
func FormatQuote(quote *iex.Quote) string {
stringOrder := []string{
"Symbol",
"Company Name",
"Current",
"High",
"Low",
"Open",
"Close",
"Change % (1 day)"... | util/formatter.go | 0.524882 | 0.539226 | formatter.go | starcoder |
package cnns
import (
"fmt"
"math/rand"
"github.com/LdDl/cnns/tensor"
"github.com/pkg/errors"
"gonum.org/v1/gonum/mat"
)
// ConvLayer Convolutional layer structure
// Oj - O{j}, activated output from previous layer for j-th neuron (in other words: previous summation input)
// Ok - O{k}, activated output from cu... | convolutional_layer.go | 0.712532 | 0.46642 | convolutional_layer.go | starcoder |
package Maximize_Capital
import (
"container/heap"
)
/*
Given a set of investment projects with their respective profits, we need to find the most profitable projects.
We are given an initial capital and are allowed to invest only in a fixed number of projects. Our goal is to choose projects that give us the maximum... | Pattern09 - Two Heaps/Maximize_Capital/solution.go | 0.822937 | 0.78403 | solution.go | starcoder |
package vm
import (
"sort"
"github.com/vsariola/sointu"
)
// FeatureSet defines what opcodes / parameters are included in the compiled virtual machine
// It is used by the compiler to decide how to encode opcodes
type FeatureSet interface {
Opcode(unitType string) (int, bool)
TransformCount(unitType string) int
... | vm/featureset.go | 0.624523 | 0.442576 | featureset.go | starcoder |
package etw
import (
"bytes"
"encoding/binary"
)
// InType indicates the type of data contained in the ETW event.
type InType byte
// Various InType definitions for TraceLogging. These must match the definitions
// found in TraceLoggingProvider.h in the Windows SDK.
const (
InTypeNull InType = iota
InTypeUnicode... | vendor/github.com/Microsoft/go-winio/internal/etw/eventmetadata.go | 0.546738 | 0.565719 | eventmetadata.go | starcoder |
package holidaylist
import (
"errors"
"math"
"time"
)
// Holiday holds all information about the day of the holiday
type Holiday struct {
Name string `json:"name"`
Year int `json:"year"`
Month time.Month `json:"month"`
Day int `json:"day"`
Time time.Time `json:"date"`
Calc Calculate
... | holidaylist.go | 0.762159 | 0.507385 | holidaylist.go | starcoder |
package flow
import (
"github.com/golang/glog"
)
// a workflow defines the start and ends and some channels and timers to step through
// the tasks themselves know which other task to call
// a workflow is created and run for each thread of a flow launcher
type Workflow struct {
Name string
Start ... | workflow/flow/workflow.go | 0.535098 | 0.522263 | workflow.go | starcoder |
package tile
import (
"encoding/binary"
"fmt"
"hash/maphash"
"math"
)
// HashTiler is used for tile coding.
type HashTiler struct {
numTilings int
seed *maphash.Seed
}
// InvalidNumTilingsError is returned
type InvalidNumTilingsError struct {
NumTilings int
Reason string
}
func (err InvalidNumTili... | hashTiler.go | 0.750004 | 0.483466 | hashTiler.go | starcoder |
package fake
var ShipmentCreate string
var ShipmentBuy string
func init() {
ShipmentCreate = `
{
"id": "shp_vN9h7XLn",
"object": "Shipment",
"mode": "test",
"to_address": {
"id": "adr_zMlCRtmt",
"object": "Address",
"name": "Dr. <NAME>",
"company": null,
"street1": "179 N Harbor... | fake/shipmentFake.go | 0.516352 | 0.487917 | shipmentFake.go | starcoder |
package ipldfree
import (
"fmt"
ipld "github.com/ipld/go-ipld-prime"
)
var (
_ ipld.Node = &Node{}
)
/*
Node is an implementatin of `ipld.Node` that can contain any content.
This implementation is extremely simple; it is general-purpose,
but not optimized for any particular purpose.
The "zero" value of thi... | vendor/github.com/ipld/go-ipld-prime/impl/free/freeNode.go | 0.699357 | 0.40392 | freeNode.go | starcoder |
package mathgl
import (
"math"
)
type Quatd struct {
W float64
V Vec3d
}
func QuatIdentd() Quatd {
return Quatd{1., Vec3d{0, 0, 0}}
}
func QuatRotated(angle float64, axis Vec3d) Quatd {
angle = (float64(math.Pi) * angle) / 180.0
c, s := float64(math.Cos(float64(angle/2))), float64(math.Sin(float64(angle/2)))... | quatd.go | 0.829596 | 0.719716 | quatd.go | starcoder |
package ACO
import (
"math"
"math/rand"
)
// Solve ATSP returns optimal cost and solution to the ATSP specified by matrix graph.
// The solution is heavily dependent on specified values for alfa, beta, rho, q & m.
func SolveAS(graph [][]float64, alfa float64, beta float64, rho float64, q float64, m int, iterations ... | AS.go | 0.740456 | 0.413536 | AS.go | starcoder |
package delaunay
import (
"fmt"
"math"
)
// Triangulation represents a delaunay triangulation.
type Triangulation struct {
Root *Triangle
}
// NewTriangulation creates a new triangulation object.
// Given points should to be randomly sorted for optimum efficicency of triangle tree.
func NewTriangula... | delaunay/triangulation.go | 0.684791 | 0.474022 | triangulation.go | starcoder |
package rpg2dtest
import (
"github.com/ghthor/filu/rpg2d"
"github.com/ghthor/filu/rpg2d/entity"
"github.com/ghthor/gospec"
)
type (
worldState rpg2d.WorldState
worldStateDiff rpg2d.WorldStateDiff
)
type (
terrainMapState rpg2d.TerrainMapState
terrainMapStateSlices []rpg2d.TerrainMapStateSlice
)
fun... | rpg2d/rpg2dtest/state.go | 0.621311 | 0.482917 | state.go | starcoder |
// copied from https://github.com/worldiety/ioutil/
package bundle
import (
"io"
"math"
)
// byteSeeker is an implementation for an in-memory io.WriteSeeker and io.ReadSeeker
type byteSeeker struct {
buf []byte
pos int
}
// Read returns EOF if no bytes can be read anymore.
func (b *byteSeeker) Read(p []byte) (... | byteseeker.go | 0.622 | 0.495239 | byteseeker.go | starcoder |
package svg
import (
"encoding/xml"
"strconv"
"strings"
)
// TransformList is a slice of SVG transformations,
// that marshals into a list of transformation specifications
// to be used in the transform attribute of group containers
type TransformList []Transform
func (tl *TransformList) append(t Transform) *Tran... | transform.go | 0.80784 | 0.447702 | transform.go | starcoder |
package datapb
import (
"fmt"
"reflect"
)
// ToData converts reflect.Value to a datapb.Data
func ToData(v reflect.Value) (*Data, error) {
if !v.IsValid() {
return &Data{Kind: &Data_UndefValue{}}, nil
}
switch v.Kind() {
case reflect.Bool:
return &Data{Kind: &Data_BooleanValue{v.Bool()}}, nil
case reflect.... | datapb/reflect.go | 0.571527 | 0.547706 | reflect.go | starcoder |
package main
import "fmt"
func (gr *Graph) Mst() (mst []Edge) {
var edgeToAdd, groupID uint64
mst = []Edge{}
// Using union-find algorithm to detect cycles
sort.Sort(byWeight(gr.RawEdges))
vertexByGroup := make(map[uint64][]uint64)
vertexGroups := make(map[uint64]uint64)
connect := make([]uint64, 2)
lastUsedG... | Greedy-Algorithms/minimum-spanning-tree.go | 0.660063 | 0.448124 | minimum-spanning-tree.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.