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 got
import (
"errors"
"fmt"
"math"
"reflect"
"regexp"
"runtime"
"strings"
"sync/atomic"
"github.com/ysmood/got/lib/utils"
)
// Assertions helpers
type Assertions struct {
Testable
ErrorHandler AssertionError
must bool
desc string
}
// Desc returns a clone with the description for failure ena... | assertions.go | 0.689828 | 0.551091 | assertions.go | starcoder |
package strings
import "sort"
// SortedSlice is a sorted slice of strings without duplicates
type SortedSlice []string
func MakeSortedSlice(slice []string) SortedSlice {
if len(slice) <= 1 {
return SortedSlice(slice)
}
tmp := make([]string, len(slice))
copy(tmp, slice)
sort.Strings(tmp)
sortedSlice := make... | pkg/strings/sortedSlice.go | 0.722723 | 0.465205 | sortedSlice.go | starcoder |
package hash
import (
"fmt"
"hash/fnv"
"reflect"
)
func Calc(subject any) uint64 {
if subject == nil {
return 0
}
value := reflect.ValueOf(subject)
switch value.Kind() {
case reflect.Bool:
return hash(fmt.Sprintf("bool:%v", value.Bool()))
case reflect.Int:
return hash(fmt.Sprintf("int:%d", value.Int()... | internal/hash/hash.go | 0.596786 | 0.441613 | hash.go | starcoder |
package timehelper
import (
"time"
)
// Durations missing in time package.
const (
Tick time.Duration = 100 * time.Nanosecond
Day time.Duration = 24 * time.Hour
Week time.Duration = 7 * Day
// https://en.wikipedia.org/wiki/Tropical_year
TropicalYear time.Duration = time.Duration(365.24219 * float64(Day))
// ... | timehelper/duration.go | 0.891079 | 0.417925 | duration.go | starcoder |
package bip39
import (
"os"
"math"
"bufio"
"errors"
"strings"
"math/big"
"crypto/rand"
"crypto/sha256"
"crypto/sha512"
"golang.org/x/crypto/pbkdf2"
)
/************************** Package variables *****************************/
var (
filename = "words.txt" // this variable is the name of the file with the... | bip39.go | 0.502686 | 0.413418 | bip39.go | starcoder |
package kata
import (
"sort"
"strconv"
"strings"
)
// Statistics
// Values truncated to integers.
type statistics struct {
span, average, median int
}
func calculateStatistics(data []int) statistics {
sort.Ints(data)
dataLen := len(data)
var result statistics
// calculate range
result.span = data[dataLen-1]... | 6_kyu/Statistics_for_an_Athletic_Association.go | 0.644673 | 0.406744 | Statistics_for_an_Athletic_Association.go | starcoder |
package unassert
// ErrorHandler handles an error.
// See unassert_panic & unassert_stderr
type ErrorHandler func(format string, v ...interface{})
// Error promotes an error according to 'unassert_' build tags.
// Formats according to a format specifier.
func Error(format string, v ...interface{}) {
if !enabled {
... | unassert.go | 0.726329 | 0.412175 | unassert.go | starcoder |
package selenium
import (
"fmt"
"strings"
"github.com/pkg/errors"
"github.com/theRealAlpaca/go-selenium/logger"
)
// Asserter is a helper struct to assert the element's text, attributes, etc.
type Asserter struct {
e *Element
}
// Valuer is a helper struct to compare the actual value of an element with the
// ... | element_asserts.go | 0.7478 | 0.528229 | element_asserts.go | starcoder |
package stripe
// Currency is the list of supported currencies.
// For more details see https://support.stripe.com/questions/which-currencies-does-stripe-support.
type Currency string
// List of values that Currency can take.
const (
CurrencyAED Currency = "aed" // United Arab Emirates Dirham
CurrencyAFN Currency =... | currency.go | 0.651022 | 0.446374 | currency.go | starcoder |
package parser
import (
"github.com/facebookresearch/Clinical-Trial-Parser/src/common/col/set"
)
// Element defines the element of the CYK state table.
type Element struct {
leftNonTerminal string
rightNonTerminal string
begin int
split int
end int
}
// NewBinary creates a binary element.
func NewBinary(l... | src/ct/parser/cfg.go | 0.755547 | 0.486392 | cfg.go | starcoder |
package math2d
import "math"
type Matrix3x3 [3 * 3]float64
func (m *Matrix3x3) InitIdendity() {
*m = Matrix3x3{
1, 0, 0,
0, 1, 0,
0, 0, 1,
}
}
func (m *Matrix3x3) InitTranslate(x, y float64) {
*m = Matrix3x3{
1, 0, 0,
0, 1, 0,
x, y, 1,
}
}
func (m *Matrix3x3) InitScale(x, y float64) {
*m = Matrix3... | math2d/matrix_3x3.go | 0.593727 | 0.716122 | matrix_3x3.go | starcoder |
package parse
import (
"fmt"
"runtime"
"strings"
"strconv"
"regexp"
)
// Tree is the representation of a single parsed template.
type Tree struct {
Name string // name of the template represented by the tree.
ParseName string // name of the top-level template during parsing, for... | Godeps/_workspace/src/github.com/byrnedo/typesafe-config/parse/parse.go | 0.82566 | 0.477554 | parse.go | starcoder |
package square
// Stores information about an invoice. You use the Invoices API to create and manage invoices. For more information, see [Manage Invoices Using the Invoices API](/docs/invoices-api/overview).
type Invoice struct {
// The Square-assigned ID of the invoice.
Id string `json:"id,omitempty"`
// The Squar... | square/model_invoice.go | 0.845974 | 0.401482 | model_invoice.go | starcoder |
package utils
// IfString func
// If the `b` parameter is true, then the p1 value will be returned, otherwise the p2 value will be returned.
func IfString(b bool, p1 string, p2 string) string {
if b {
return p1
}
return p2
}
// IfStringPtr func
// If the `b` parameter is true, then the p1 value will be returned... | utils/if.go | 0.70069 | 0.494873 | if.go | starcoder |
package ast
import (
"fmt"
"strings"
"github.com/frankreh/go-clang/clang/typekind"
)
// TypeKey keys a single index int to a kind of type and the
// index into the appropriate slice.
type TypeKey struct {
TypeKind typekind.Kind
TypeId int // Index into relevant TypeMap slices.
}
type Type interface {
Kind()... | ast/typemap.go | 0.693369 | 0.441191 | typemap.go | starcoder |
package moneybear
import (
"strconv"
"strings"
"github.com/pkg/errors"
)
// Money stores the amount and currency.
type Money struct {
amount *Amount
currency *Currency
}
// New creates a new instance of the Money class.
func New(amount int64, currency string) (*Money, error) {
curr, err := getCurrencyByCode... | money.go | 0.823506 | 0.475118 | money.go | starcoder |
package pong
import "math"
import "github.com/lord/lodo/core"
import "fmt"
// angle = 0 is aligned with the X axis.
// angle = PI/2 is aligned with the Y axis.
type ball struct {
x, y, angle, speed float64
speedupHits int
speedupRate float64
speedMax float64
color core.Color
hits int
... | pong/ball.go | 0.542621 | 0.478773 | ball.go | starcoder |
package pow
// Parameters to the siphash block algorithm. Used by Cuckaroo but can be seen
// as a generic way to derive a hash within a block of them.
const sipHashBlockBits uint64 = 6
const sipHashBlockSize uint64 = 1 << sipHashBlockBits
const sipHashBlockMask uint64 = sipHashBlockSize - 1
// SipHashBlock builds a... | core/pow/siphash.go | 0.728941 | 0.53607 | siphash.go | starcoder |
package raytracer
/*
Light related methods
*/
import (
"math"
)
const sunDist = 99999999999.00
const sunRadius = 4999999999.95
func isShortestIntersection(inter *Intersection, sInter *Intersection) bool {
return (sInter.Triangle != nil && sInter.Triangle.id == inter.Triangle.id) || sInter.Dist < DIFF
}
func isFl... | raytracer/direct_lighting.go | 0.869105 | 0.435301 | direct_lighting.go | starcoder |
package main
import (
"fmt"
"math"
"math/rand"
"time"
)
func sin(v float32) float32 { return float32(math.Sin(float64(v))) }
func cos(v float32) float32 { return float32(math.Cos(float64(v))) }
func sqrt(v float32) float32 { return float32(math.Sqrt(float64(v))) }
func atan2(x, y float32) float32 { return floa... | physicscompress2/pos/pos.go | 0.719482 | 0.59464 | pos.go | starcoder |
// This file implements operations in R3, a univariate quotient polynomial
// ring over GF(3) with modulus x^761 + 2*x + 2. It is a port of the public
// domain, C reference implementation.
package r3
import (
"github.com/companyzero/sntrup4591761/r3/mod3"
"github.com/companyzero/sntrup4591761/r3/vector"
)
// swa... | r3/r3.go | 0.774711 | 0.466846 | r3.go | starcoder |
// Package curve25519 implements a prime-order group over Curve25519 with hash-to-curve.
package curve25519
import (
"fmt"
"filippo.io/edwards25519"
"filippo.io/edwards25519/field"
"github.com/bytemare/crypto/group/internal"
)
// Element represents a Curve25519 point. It wraps an Edwards25519 implementation to... | group/curve25519/element.go | 0.921755 | 0.422028 | element.go | starcoder |
package modbus
import (
"fmt"
)
/*
Atomic allows locked access to the server's internal cache of coil, discrete, input, holding, and file values.
implementation in serverCache.go An Atomic instance is created by calling the StartAtomic() function on the Server
Do not Complete an atomic unless you started it. It's n... | server.go | 0.675015 | 0.514522 | server.go | starcoder |
package enc
func (e *Encoder) setByte1Int64(value int64, offset int) int {
e.d[offset] = byte(value)
return offset + 1
}
func (e *Encoder) setByte2Int64(value int64, offset int) int {
e.d[offset+0] = byte(value >> 8)
e.d[offset+1] = byte(value)
return offset + 2
}
func (e *Encoder) setByte4Int64(value int64, of... | msgpack/enc/set.go | 0.75274 | 0.518485 | set.go | starcoder |
package main
import (
"fmt"
"math"
. "github.com/mmcloughlin/avo/build"
. "github.com/mmcloughlin/avo/operand"
. "github.com/mmcloughlin/avo/reg"
)
func main() {
distributeForward(&SortableScalar{reg: GP64, size: 8, mov: MOVQ, cmp: CMPQ})
distributeBackward(&SortableScalar{reg: GP64, size: 8, mov: MOVQ, cmp:... | build/qsort/sort_asm.go | 0.704668 | 0.499023 | sort_asm.go | starcoder |
package feedforward
import (
"errors"
"math/rand"
"sync"
"time"
)
// Represents a multilayer feedforward neural network trained using the online variant of SGD.
type Network struct {
BaseSubject
neurons []int
activations []ActivationFunction
layers []layer
initializer Initializer
stop Stoppi... | network.go | 0.797636 | 0.570571 | network.go | starcoder |
package validation
import (
"goyave.dev/goyave/v4/util/walk"
)
// Errors structure representing errors associated with an element of the validated data.
// The element may represent the root object or the fields of a nested object.
// The key is the name of the field.
type Errors map[string]*FieldErrors
// ArrayErr... | validation/errors.go | 0.78436 | 0.540621 | errors.go | starcoder |
package continuous
import (
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// LogNormal distribution
// https://en.wikipedia.org/wiki/Log-normal_distribution
type LogNormal struct {
location, scale float64 // μ, σ
src rand.Source
}
func NewLogNormal(location, scale f... | dist/continuous/log_normal.go | 0.783906 | 0.529507 | log_normal.go | starcoder |
package gortex
import (
"fmt"
//"log"
)
// Long Short Term Memory cell
type TemporalConvolution struct {
Kernels []*Matrix // keep kernels as set of column vectors for calc speed
Biases *Matrix
Pads []*Matrix // learnable pads !!
KernelSize int
KernelShift int
}
func MakeTemporalConvolution(... | temporal_convolution.go | 0.574395 | 0.434461 | temporal_convolution.go | starcoder |
package gosigl
import (
opengl "github.com/go-gl/gl/v4.1-core/gl"
"math"
)
type VertexBufferObject uint32
type VertexArrayObject uint32
type ElementArrayObject uint32
type VertexObject struct {
Id VertexBufferObject
AttribId [32]VertexArrayObject
attribStride [32]int
numAttributes int
elementArrayBuffer Elemen... | mesh.go | 0.536556 | 0.502625 | mesh.go | starcoder |
package shared
var (
NullableTypeImports = map[string]string{
"bytes": "",
"database/sql/driver": "",
"encoding/json": "",
}
)
const (
NullableTypeTmpl =
`
type NullableType struct {
loaded bool
null bool
value {{.Type}}
}
func (receiver NullableType) Else(value {{.Type}}) Nullable... | drivers/shared/nullable_type_tmpl.go | 0.663233 | 0.410343 | nullable_type_tmpl.go | starcoder |
package solver
import (
"fmt"
"io"
"strconv"
"strings"
)
// Grid represents the Sudoku grid, with 0 representing an empty cell.
type Grid [81]int
// UpdateEvent represents a Grid update event.
type UpdateEvent struct {
Index int
Value int
}
// Print prints a grid to the writer.
func (grid Grid) Print(w io.Wri... | src/solver/grid.go | 0.770033 | 0.405331 | grid.go | starcoder |
package aes
import (
"crypto/cipher"
ccrypto "github.com/crossedbot/common/golang/crypto"
)
// EncryptionParams represents an interface to perform symmetric encryption
type EncryptionParams interface {
// Encrypt encrypts the given plain text and returns its cipher
Encrypt(plain []byte) []byte
// Decrypt decry... | golang/crypto/aes/encyptionparams.go | 0.818229 | 0.450964 | encyptionparams.go | starcoder |
package strobogrammatic_number
func FindStrobogrammatic(n int) []string {
return helper(n, n)
}
func helper(n, m int) []string {
if n == 0 {
return []string{""}
}
if n == 1 {
return []string{"0", "1", "8"}
}
list := helper(n-2, m)
res := make([]string, 0)
for i := 0; i < len(list); i++ {
s := list[i... | golang/strobogrammatic_number2/strobogrammatic_number.go | 0.556641 | 0.417153 | strobogrammatic_number.go | starcoder |
package toy
import (
"github.com/OpenWhiteBox/primitives/encoding"
"github.com/OpenWhiteBox/AES/constructions/saes"
"github.com/OpenWhiteBox/AES/constructions/toy"
)
var powx = [16]byte{0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f}
// backOneRound takes round key... | cryptanalysis/toy/toy.go | 0.753557 | 0.480418 | toy.go | starcoder |
package polyclip
import "reflect"
type Point struct {
X float64
Y float64
}
type Polygon struct {
Points []Point
}
type Node struct {
Poly Polygon
Index int
Point Point
Intersect bool
Dist float64
Next *Node
Prev *Node
IsEntry bool
Friend *Node
Processed bool
}
type In... | polyclip.go | 0.682679 | 0.567218 | polyclip.go | starcoder |
package itau
import (
"fmt"
"strconv"
boleto "github.com/italolelis/go-boleto"
)
const (
bankNumbersSize = 25
maxOurNumberSize = 8
maxDocumentIDSize = 7
maxClientCodeSize = 5
)
// Itau is the itau bank slip implementation
// Source: (http://download.itau.com.br/bankline/cobranca_cnab240.pdf)
type Itau str... | itau/itau.go | 0.521227 | 0.409044 | itau.go | starcoder |
package main
import "log"
// initTrie initializes a new prefix tree - trie.
// state is the number of first state to be created.
// patternNumber is the number of first pattern to be added.
// finalFor is an array, where index is state and value is the number of
// pattern that the state is final for. 0 if none.
// p... | src/match-trie.go | 0.617859 | 0.560313 | match-trie.go | starcoder |
package bravo16
import (
"fmt"
)
// Decode decodes the bravo16 encoded data in ‘src’ into ‘dst’ (as binary), and returns the number of bytes written to ‘dst’.
func Decode(dst []byte, src []byte) (int64, error) {
lenSrc := len(src)
if 1 > lenSrc {
return 0, nil
}
if length := lenSrc; 0 != length % 2 {
return... | decode.go | 0.7011 | 0.565479 | decode.go | starcoder |
package stripe
// A string identifying the type of the source of this line item, either an `invoiceitem` or a `subscription`.
type InvoiceLineType string
// List of values that InvoiceLineType can take
const (
InvoiceLineTypeInvoiceItem InvoiceLineType = "invoiceitem"
InvoiceLineTypeSubscription InvoiceLineType =... | invoicelineitem.go | 0.835785 | 0.47457 | invoicelineitem.go | starcoder |
package image
import (
"errors"
"sort"
"sync"
)
// medianPixel finds the median r, g, b values from the given
// pixel array and creates a new pixel from that median values
func medianPixel(pixels []Pixel) Pixel {
var (
rValues []int
gValues []int
bValues []int
)
for _, pix := range pixels {
rValues = ... | moving_objects.go | 0.727975 | 0.499268 | moving_objects.go | starcoder |
package gohorizon
import (
"encoding/json"
)
// FarmProvisioningStatusInfo Provisioning status data about this automated farm.
type FarmProvisioningStatusInfo struct {
// This represents the state of the current image of this instant clone farms. * READY: This is the state of the current image after successful com... | model_farm_provisioning_status_info.go | 0.738575 | 0.505737 | model_farm_provisioning_status_info.go | starcoder |
// Package meanshift provides mean shift clustering for ℝⁿ data.
package meanshift
import (
"fmt"
"github.com/biogo/cluster/cluster"
)
type pnt []float64
func (p pnt) V() []float64 { return p }
type value struct {
pnt
w float64
cluster int
}
func (v *value) Weight() float64 { return v.w }
func (v *val... | meanshift/meanshift.go | 0.80969 | 0.629945 | meanshift.go | starcoder |
package day22
import (
"fmt"
"github.com/knalli/aoc"
"regexp"
)
type Point struct {
X int
Y int
Z int
}
func (p *Point) ToString() string {
return fmt.Sprintf("%d,%d,%d", p.X, p.Y, p.Z)
}
// Range […[
type Range struct {
Begin int
End int
}
func (r *Range) Each(f func(v int)) {
for v := r.Begin; v < r.... | day22/puzzle.go | 0.703244 | 0.427935 | puzzle.go | starcoder |
package jparse
import (
"encoding/json"
"fmt"
)
// SimpleParse is a parsing function that takes in a simple json and array of values to parse
func SimpleParse(value []string, j string) []string {
var parsedJSON []string
var result map[string]interface{}
json.Unmarshal([]byte(j), &result)
for i := 0; i < len(val... | jparse.go | 0.503174 | 0.430506 | jparse.go | starcoder |
package aoc2020
/*
--- Day 22: Crab Combat ---
It only takes a few hours of sailing the ocean on a raft for boredom to sink in. Fortunately, you brought a small deck of space cards! You'd like to play a game of Combat, and there's even an opponent available: a small crab that climbed aboard your raft before you left.
... | app/aoc2020/aoc2020_22_part1.go | 0.615319 | 0.737395 | aoc2020_22_part1.go | starcoder |
package message
type jiraMessage struct {
issue JiraIssue
Base
}
// JiraIssue requires project and summary to create a real jira issue.
// Other fields depend on permissions given to the specific project, and
// all fields must be legitimate custom fields defined for the project.
// To see whether you have the righ... | message/jira_issue.go | 0.642545 | 0.481576 | jira_issue.go | starcoder |
package gorow
import (
"math"
"github.com/cnkei/gospline"
// "github.com/pa-m/sklearn/interpolate"
"errors"
"github.com/sgreben/piecewiselinear"
)
func reverseslice(in []float64) []float64 {
out := make([]float64, len(in))
for i, value := range in {
out[len(in)-i-1] = value
}
return out
}
func ewmovin... | numerical.go | 0.561215 | 0.400046 | numerical.go | starcoder |
package qdb
/*
#include <qdb/ts.h>
#include <stdlib.h>
*/
import "C"
import (
"math"
"time"
"unsafe"
)
// TsStringPoint : timestamped data
type TsStringPoint struct {
timestamp time.Time
content string
}
// Timestamp : return data point timestamp
func (t TsStringPoint) Timestamp() time.Time {
return t.time... | entry_timeseries_string.go | 0.68784 | 0.425665 | entry_timeseries_string.go | starcoder |
package graph
import "github.com/Tom-Johnston/mamba/sortints"
//SplitEdge modifies the graph G by removing the edge ij (if it is present) and adding a new vertex connected to i and j.
func SplitEdge(g EditableGraph, i, j int) {
//Make j > i
if j == i {
panic("Multiedges are not supported")
}
g.RemoveEdge(i, j)... | graph/transformation.go | 0.68679 | 0.496765 | transformation.go | starcoder |
package facet
import (
"math"
"gonum.org/v1/plot"
)
// A Transformation bundles two functions Trans and Inverse together with
// an appropiate Ticker. The two functions map two intervals.
type Transformation struct {
Name string
Trans func(from, to Interval, x float64) float64
Inverse func(from, to Interva... | trans.go | 0.841858 | 0.623463 | trans.go | starcoder |
package data_structures
import "fmt"
/*
A bracket is considered to be any one of the following characters: (, ), {, }, [, or ].
Two brackets are considered to be a matched pair if the an opening bracket
(i.e., (, [, or {) occurs to the left of a closing bracket (i.e., ), ], or })
of the exact same type. There are th... | data-structures/BalancedBrackets.go | 0.60288 | 0.654798 | BalancedBrackets.go | starcoder |
package generateFiles
func createValidJobJSON(recipe, location string) string {
body := `{
"recipe": "` + recipe + `",
"state": "created",
"files": [{
"alias_name": "CPIH",
"url": "` + location + `"
}]
}`
return body
}
func GetValidPOSTCreateFilterJSON(datasetID, edition, version string) string {
r... | endToEndTests/json.go | 0.675015 | 0.430207 | json.go | starcoder |
package main
func mapSlice[In any, Out any](inputs []In, mapFunc func(input In) Out) []Out {
outputs := make([]Out, len(inputs))
for i, input := range inputs {
outputs[i] = mapFunc(input)
}
return outputs
}
func flatMapSlice[In any, Out any](inputs []In, flatMapFunc func(input In) []Out) []Out {
outputs := mak... | slices.go | 0.61231 | 0.532972 | slices.go | starcoder |
package finance
import (
"context"
"github.com/piquette/finance-go/quote"
"github.com/turbot/steampipe-plugin-sdk/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/plugin"
"github.com/turbot/steampipe-plugin-sdk/plugin/transform"
)
func tableFinanceQuote(ctx context.Context) *plugin.Table {
return &plugin.T... | finance/table_finance_quote.go | 0.671686 | 0.414247 | table_finance_quote.go | starcoder |
package trie
// TernaryTrie represents ternary trie-tree.
type TernaryTrie struct {
root TernaryNode
}
// NewTernaryTrie creates a new ternary trie-tree.
func NewTernaryTrie() *TernaryTrie {
return &TernaryTrie{}
}
// Root returns a root node of ternary trie-tree.
func (t *TernaryTrie) Root() Node {
return &t.roo... | internal/trie/ternary.go | 0.862511 | 0.681015 | ternary.go | starcoder |
package assertion
import (
"bytes"
"fmt"
"reflect"
. "github.com/mataharimall/api-seller/tests/functional/idata"
)
func ShouldBeJSONAndHave(actual interface{}, expected ...interface{}) string {
if len(expected) != 2 {
return "Must have key/value arguments"
}
var b []byte
if v, ok := actual.([]byte); ok {
... | idata/assertion/assertion.go | 0.504883 | 0.424591 | assertion.go | starcoder |
package linear
import (
"math"
)
type RectangularCholeskyDecomposition struct {
root RealMatrix
rank int
}
func NewRectangularCholeskyDecomposition(matrix RealMatrix) (*RectangularCholeskyDecomposition, error) {
return NewRectangularCholeskyDecompositionWithThreshold(matrix, 0)
}
func NewRectangularCholeskyDeco... | rectangular_cholesky_decomposition.go | 0.737347 | 0.501526 | rectangular_cholesky_decomposition.go | starcoder |
package metrics
import (
"fmt"
"time"
"github.com/codahale/hdrhistogram"
"github.com/mailgun/timetools"
)
type Histogram interface {
// Returns latency at quantile with microsecond precision
LatencyAtQuantile(float64) time.Duration
// Records latencies with microsecond precision
RecordLatencies(d time.Durati... | metrics/histogram.go | 0.802013 | 0.584983 | histogram.go | starcoder |
package ArtificialNeuralNetwork
import (
actf "RestaurantChatbot/ArtificialNeuralNetwork/ActivationFunctions"
"RestaurantChatbot/MatrixHelper"
"gonum.org/v1/gonum/mat"
)
type Layer struct {
numNeurons int
weights mat.Matrix
lastOutput mat.Matrix
error mat.Matrix
activat... | RestaurantChatbot/ArtificialNeuralNetwork/Layer.go | 0.831006 | 0.485356 | Layer.go | starcoder |
package slice
import "reflect"
// Insert insert value at index i, it panics if i > len(slice).
// The input slice will be modified.
func InsertGeneric(slice interface{}, i int, value interface{}) interface{} {
return InsertValue(reflect.ValueOf(slice), i, reflect.ValueOf(value))
}
// InsertValue insert value at ind... | insert.go | 0.559771 | 0.573738 | insert.go | starcoder |
package gpkg
import (
"encoding/binary"
"errors"
"fmt"
"math"
)
type envelopeType uint8
// Magic is the magic number encode in the header. It should be 0x4750
var Magic = [2]byte{0x47, 0x50}
const (
EnvelopeTypeNone = envelopeType(0)
EnvelopeTypeXY = envelopeType(1)
EnvelopeTypeXYZ = envelopeType... | provider/gpkg/binary_header.go | 0.667581 | 0.423696 | binary_header.go | starcoder |
package parser
import (
"strconv"
"strings"
"github.com/zzossig/rabbit/ast"
"github.com/zzossig/rabbit/token"
"github.com/zzossig/rabbit/util"
)
func (p *Parser) parseParam() ast.Param {
pr := ast.Param{}
p.nextToken()
pr.EQName = p.parseEQName()
if p.peekTokenIs(token.AS) {
p.nextToken()
pr.TypeDecl... | parser/parser_etc.go | 0.520984 | 0.495911 | parser_etc.go | starcoder |
package latitude
import (
"fmt"
"math"
)
// Latitude stores a numeric coordinate referencing a celestial bodies Y axis.
type Latitude float32
// Absolute returns the numeric value held by the Latitude pointer to an absolute number.
func (latitude *Latitude) Absolute() float32 {
return float32(math.Abs(float64(*la... | latitude/latitude.go | 0.939025 | 0.771499 | latitude.go | starcoder |
package circuit
import (
"crypto/rand"
"fmt"
"math/big"
"github.com/markkurossi/mpc/ot"
"github.com/markkurossi/mpc/p2p"
)
// Player runs the BMR protocol client on the P2P network.
func Player(nw *p2p.Network, circ *Circuit, inputs *big.Int, verbose bool) (
[]*big.Int, error) {
numPlayers := len(nw.Peers) ... | circuit/player.go | 0.500977 | 0.419707 | player.go | starcoder |
package object
import (
"math"
"github.com/jeinfeldt/raytracer/raytracing/util"
"github.com/jeinfeldt/raytracer/raytracing/vector"
)
type (
// Material indicates a certain material which scatters a ray
Material interface {
Scatter(r Ray, record *HitRecord, attenuation *vector.Vector3, scattered *Ray) bool
}
... | raytracing/object/material.go | 0.827236 | 0.631878 | material.go | starcoder |
package gorgonia
import (
"fmt"
"hash"
"hash/fnv"
"time"
tf32 "github.com/chewxy/gorgonia/tensor/f32"
tf64 "github.com/chewxy/gorgonia/tensor/f64"
"github.com/chewxy/gorgonia/tensor/types"
"github.com/leesper/go_rng"
)
/*
This file contains all the Ops related to building a neural network.
Bear in mind th... | op_nn.go | 0.613931 | 0.446072 | op_nn.go | starcoder |
package matrixlib
// IntMatrix is an square integer matrix of the specified dimentions
type IntMatrix struct {
matrix [][]int
Size int
}
// Create creates a square matrix of the specified dimension
func Create(size int) IntMatrix {
result := make([][]int, size)
for i := range result {
result[i] = make([]int, ... | matrixlib/matrixlib.go | 0.862134 | 0.607489 | matrixlib.go | starcoder |
package mandelbrot
import (
"DistributedMandelbrot/misc"
"DistributedMandelbrot/task"
"image/color"
"math"
)
type Mandelbrot struct {
mathLog2 float64
settings Settings
}
func NewMandelbrot(settings Settings) Mandelbrot {
mandelbrot := Mandelbrot{
mathLog2: math.Log(2),
settings: settings,
}
return man... | mandelbrot/mandelbrot.go | 0.665411 | 0.478651 | mandelbrot.go | starcoder |
package gravitree
import (
"fmt"
"math"
)
// OpeningCriteria represents a type of criteria used to decide whether a
// monopole approximation can be used for given tree node.
type OpeningCriteria int
const (
// The PKDGRAV3 opening criteria (Potter, Stadel, & Teyssier 2017; S 3.1).
// This computes R_i for each ... | tree.go | 0.716318 | 0.687741 | tree.go | starcoder |
package mapping
import (
"strings"
"cloud.google.com/go/bigtable"
"github.com/sendinblue/bigtable-access-layer/data"
)
// Mapper is in charge of translating data from Big Table into a human-readable format.
type Mapper struct {
// mapping coming from the JSON file
*Mapping
// those functions are in charge of s... | mapping/mapper.go | 0.608943 | 0.457561 | mapper.go | starcoder |
package stats
import (
"strings"
)
type limitedScope interface {
namespace() string
tags() map[string]string
rootScope() *rootScope
}
type HistogramOption func(*histogramVector)
type Scope interface {
limitedScope
Counter(string) Counter
CounterVector(string, []string) CounterVector
Gauge(string) Gauge
... | vendor/github.com/upfluence/stats/scope.go | 0.522446 | 0.597843 | scope.go | starcoder |
package element
// note: not thourougly tested on moduli != .NoCarry
const FromMont = `
// FromMont converts z in place (i.e. mutates) from Montgomery to regular representation
// sets and returns z = z * 1
func (z *{{.ElementName}}) FromMont() *{{.ElementName}} {
fromMont{{.ElementName}}(z)
return z
}
`
const Con... | internal/templates/element/conv.go | 0.807688 | 0.447098 | conv.go | starcoder |
package color
import (
"image/color"
"math"
)
/*
* Maps a distribution to a series of colors.
*/
type Mapping interface {
Map(counts []uint64) []color.NRGBA
}
/*
* Restricts a value to an interval, so that min <= value <= max.
*/
func clamp(value float64, min float64, max float64) float64 {
/*
* Decide on... | color/color.go | 0.817246 | 0.419232 | color.go | starcoder |
package parser
import (
"errors"
"fmt"
"github.com/hashicorp/go-multierror"
"github.com/gardenbed/emerge/internal/regex/ast"
)
func Parse(in input) (ast.Node, error) {
r := newRegex()
out, ok := r.regex(in)
if !ok {
return nil, errors.New("invalid regular expression")
}
// Check for errors
if r.errors... | internal/regex/parser/regex.go | 0.616705 | 0.418043 | regex.go | starcoder |
package nmea
import (
"fmt"
"github.com/martinlindhe/unit"
)
const (
// TypeMDA type for MDA sentences
TypeMDA = "MDA"
)
// Sentence info:
// 1 Barometric pressure, inches of mercury, to the nearest 0.01 inch
// 2 I = inches of mercury
// 3 Barometric pressure, bars, to the nearest .001 bar
// 4 B =... | mda.go | 0.691393 | 0.609146 | mda.go | starcoder |
package processor
import (
"bytes"
"fmt"
"net/url"
"regexp"
"strconv"
"time"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/types"
"github.com/Jeffail/benthos/lib/util/text"
"github.com/microcosm-cc/bluemonday"
"github.com/opentracing/opentra... | lib/processor/text.go | 0.754734 | 0.669826 | text.go | starcoder |
package parser
import (
"fmt"
"reflect"
"strconv"
"strings"
"time"
"github.com/containous/traefik/v2/pkg/types"
)
type initializer interface {
SetDefaults()
}
// FillerOpts Options for the filler.
type FillerOpts struct {
AllowSliceAsStruct bool
}
// Fill populates the fields of the element using the infor... | pkg/config/parser/element_fill.go | 0.614972 | 0.412885 | element_fill.go | starcoder |
package incclient
import (
"encoding/hex"
"github.com/incognitochain/go-incognito-sdk-v2/key"
"github.com/incognitochain/go-incognito-sdk-v2/rpchandler/jsonresult"
"math/big"
)
// BurnProof represents a proof object submitted to smart contracts for the sake of un-shielding.
type BurnProof struct {
Instruction []... | incclient/bridge_burning_proof.go | 0.613352 | 0.42054 | bridge_burning_proof.go | starcoder |
package dusl
import (
"fmt"
)
// An Ambit represent a region inside some Source, identified by a Start
// (byte-offset) and an end (byte-offset).
type Ambit struct {
Source *Source
Start int
End int
}
// AmbitFromString creates an Ambit representing a given string. Useful for unit testing.
func AmbitFromStri... | ambit.go | 0.861945 | 0.449272 | ambit.go | starcoder |
package rng
import (
"fmt"
"math"
"math/rand"
"sync"
)
// UniformGenerator is a random number generator for uniform distribution.
// The zero value is invalid, use NewUniformGenerator to create a generator
type UniformGenerator struct {
mu *sync.Mutex
rd *rand.Rand
}
// NewUniformGenerator returns a uniform-di... | vendor/github.com/leesper/go_rng/uniform.go | 0.717507 | 0.414366 | uniform.go | starcoder |
package phomath
import "math"
const (
EulerOrderXYZ = iota
EulerOrderYXZ
EulerOrderZXY
EulerOrderZYX
EulerOrderYZX
EulerOrderXZY
numEulerOrders
)
const (
EulerOrderDefault = EulerOrderXYZ
)
func eulerNoop(_ *Euler) {/* do nothing */}
// static check that euler is Vector3Like
var _ Vector3Like = &Euler{}
f... | phomath/euler.go | 0.749912 | 0.480662 | euler.go | starcoder |
package vector
// Add adds two vectors
// Example: Add({1, 2, 0}, {1, 0, 1}) = {2, 0, 1}
func Add(this Vector3, vectors ...Vector3) Vector3 {
result := this.Copy()
for _, vector := range vectors {
result.Add(vector)
}
return result
}
// Sub subs two or more vectors
// Example: Sub({{1, 2, 0}, 1, 0, 1}) = {0, 2,... | raytracing/vector/operations.go | 0.944829 | 0.838878 | operations.go | starcoder |
package dora
import (
"fmt"
"strconv"
"github.com/shadowkrusha/dora/pkg/danger"
)
// The available accessTypes for a dora query
const (
ObjectAccess accessType = iota
ArrayAccess
)
type accessType int
// queryToken represents a single "step" in each query.
// Queries are parsed into a []queryTokens to be used... | pkg/dora/parse.go | 0.729423 | 0.494629 | parse.go | starcoder |
// package hi exposes a few Go functions to be wrapped and used from Python.
package hi
import (
"fmt"
"github.com/go-python/gopy/_examples/cpkg"
)
const (
Version = "0.1" // Version of this package
Universe = 42 // Universe is the fundamental constant of everything
)
var (
Debug = false ... | _examples/hi/hi.go | 0.719975 | 0.517449 | hi.go | starcoder |
package miris
import (
"github.com/mitroadmaps/gomapinfer/common"
)
func SamplePoints(track []Detection) []common.Point {
var points []common.Point
for i := 0; i < len(track) - 1; i++ {
segment := common.Segment{track[i].Bounds().Center(), track[i+1].Bounds().Center()}
points = append(points, segment.Sample(10... | miris/distance.go | 0.678114 | 0.411111 | distance.go | starcoder |
package stack
// Stack is a basic LIFO stack that can hold any value
type Stack struct {
Values []interface{}
}
// NewStack creates a new stack and returns a pointer to it
func NewStack(capacity int) *Stack {
return &Stack{
make([]interface{}, 0, capacity),
}
}
// Push adds a value to the top of the stack.
func... | stack.go | 0.796094 | 0.421135 | stack.go | starcoder |
package jsonw
import (
"bytes"
)
// Buffer writes JSON values to a buffer.
// The zero value for Buffer is an empty buffer ready to use.
type Buffer struct {
b bytes.Buffer
jsonw
}
// Object writes an object (a set of name/value pairs) to the buffer.
// Writes within f will be nested in the object.
// Returns the... | buffer.go | 0.784278 | 0.571199 | buffer.go | starcoder |
package execute
import (
"context"
"github.com/influxdata/flux"
"github.com/influxdata/flux/codes"
"github.com/influxdata/flux/compiler"
"github.com/influxdata/flux/internal/errors"
"github.com/influxdata/flux/semantic"
"github.com/influxdata/flux/values"
)
type dynamicFn struct {
// Configuration attributes... | execute/row_fn.go | 0.696784 | 0.432842 | row_fn.go | starcoder |
package hector
import (
"math/rand"
"math"
"strings"
"strconv"
)
type Vector struct {
data map[int64]float64
}
func NewVector() *Vector {
v := Vector{}
v.data = make(map[int64]float64)
return &v
}
func (v *Vector) ToString() []byte {
sb := StringBuilder{}
for key, value := range v.data {
sb.Int64(key)
... | vector.go | 0.562417 | 0.418875 | vector.go | starcoder |
package clust
import (
"github.com/emer/etable/etable"
"github.com/emer/etable/etensor"
"github.com/emer/etable/simat"
)
// Plot sets the rows of given data table to trace out lines with labels that
// will render cluster plot starting at root node when plotted with a standard plotting package.
// The lines doubl... | clust/plot.go | 0.721841 | 0.592519 | plot.go | starcoder |
package location
import (
"errors"
"fmt"
"math"
)
// This const is used for generating the latitdue and longitude
// only used in newPoint() function
const (
// this number is aprroximate from 1 seconds to meters
meters = 24.384
)
// This one is used for getting the center of the marked location by splitting th... | mapping.go | 0.782912 | 0.560794 | mapping.go | starcoder |
package kalman
// https://www.bzarg.com/p/how-a-kalman-filter-works-in-pictures/
import (
"fmt"
"github.com/konimarti/lti"
"gonum.org/v1/gonum/mat"
)
//Context contains the current state and covariance of the system
type Context struct {
X *mat.VecDense // Current system state
P *mat.Dense // Current covari... | kalman.go | 0.66769 | 0.510619 | kalman.go | starcoder |
package examples
import (
"fmt"
"math/rand"
"sync"
"sync/atomic"
"time"
)
// In the previous example we saw how to manage simple counter state using atomic operations.
// For more complex state we can use a mutex to safely access data across multiple goroutines.
// Mutex func to illustrate mutexes in go.
func M... | examples/mutexes.go | 0.619932 | 0.458349 | mutexes.go | starcoder |
package ElementaryCyclesSearch
import (
"fmt"
"math"
)
/**
* This is a helpclass for the search of all elementary cycles in a graph
* with the algorithm of Johnson. For this it searches for strong connected
* components, using the algorithm of Tarjan. The constructor gets an
* adjacency-list of a graph. Based o... | StrongConnectedComponents.go | 0.79956 | 0.468973 | StrongConnectedComponents.go | starcoder |
package rtc
import "math"
// Sphere creates a unit sphere at the origin.
// It implements the Object interface.
func Sphere() *SphereT {
return &SphereT{Shape{Transform: M4Identity(), Material: GetMaterial()}}
}
// GlassSphere creates a unit glass sphere at the origin.
// It implements the Object interface.
func Gl... | rtc/sphere.go | 0.917284 | 0.553867 | sphere.go | starcoder |
Package goroutinemap implements a data structure for managing go routines
by name. It prevents the creation of new go routines if an existing go routine
with the same name exists.
*/
package goroutinemap
import (
"fmt"
"runtime"
"sync"
"time"
"github.com/golang/glog"
k8sRuntime "k8s.io/kubernetes/pkg/util/runti... | pkg/util/goroutinemap/goroutinemap.go | 0.671147 | 0.447702 | goroutinemap.go | starcoder |
package operator
import (
"fmt"
"strconv"
"strings"
"github.com/waflab/waflab/autogen/utils"
)
const (
byteRangeStringLength = 10
)
/*
This function assume that argument follows the format: <number>, <range>, <number>.
In addition to that, the function assume that the range are non-overlapping. Having an over... | autogen/operator/validation.go | 0.592313 | 0.419648 | validation.go | starcoder |
package ImgMeta
/*
Structure of a JFIF APP0 segment
APP0 segments are used in the old JFIF standard to store information about the picture dimensions and an optional thumbnail.
The format of a JFIF APP0 segment is as follows (note that the size of thumbnail data is 3n, where n = Xthumbnail * Ythumbnail,
and it... | exif/JFIF.go | 0.534855 | 0.567457 | JFIF.go | starcoder |
package test
import (
"bytes"
"fmt"
"strings"
"testing"
"github.com/google/go-cmp/cmp"
)
func checkDiff(t *testing.T, buf bytes.Buffer, expect string, formats ...interface{}) {
expect = fmt.Sprintf(expect, formats...)
if !cmp.Equal(expect, buf.String()) {
t.Fatal(
cmp.Diff(
buf.String(),
expect,
... | test/checks.go | 0.61659 | 0.451871 | checks.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.