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 datastore
import (
"github.com/rivine/rivine/build"
"github.com/rivine/rivine/modules"
"github.com/rivine/rivine/types"
)
// ProcessConsensusChange follows the most recent changes to the consensus set,
// including parsing new blocks and saving data from the transaction.
func (nsm *namespaceManager) Proces... | modules/datastore/update.go | 0.558086 | 0.423816 | update.go | starcoder |
package sanity
import (
"regexp"
"strings"
"github.com/aquilax/truncate"
)
// Rule represents a file sanitization rule, a function that turns (potentially)
// invalid input string into valid output.
type Rule func(in string) (out string)
// Truncate truncates string to the specified length.
func Truncate(length ... | rule.go | 0.721154 | 0.426919 | rule.go | starcoder |
package hllpp
import "sort"
// create a mask of numOnes 1's, shifted left shift bits
func mask(numOnes, shift uint32) uint32 {
return ((1 << numOnes) - 1) << shift
}
func setRegister(data []byte, bitsPerRegister, idx uint32, rho uint8) {
bitIdx := idx * bitsPerRegister
byteOffset := bitIdx / 8
bitOffset := bitI... | dense.go | 0.742328 | 0.448366 | dense.go | starcoder |
package impl
import (
. "github.com/gabz57/goledmatrix/canvas"
"github.com/gabz57/goledmatrix/canvas/effect"
. "github.com/gabz57/goledmatrix/components"
"github.com/gabz57/goledmatrix/components/shapes"
"time"
)
const (
HeartRedWidth = 13
HeartRedHeight = 12
)
type HeartRed struct {
shape *Composite... | components/impl/heartRed.go | 0.789883 | 0.449695 | heartRed.go | starcoder |
package timekit
import (
"time"
)
// YearsRange returns an array of the year integer values between two dates. For example if one date is 2000 and the other is 2002, the output will be [2000,2001,2002].
func YearsRange(start time.Time, end time.Time) []int {
var years []int
// Developers Note:
// We want to leve... | range.go | 0.85564 | 0.75766 | range.go | starcoder |
package vanta
import (
"bytes"
"fmt"
"math"
"math/rand"
"os"
"strconv"
"time"
)
// New returns a new top-level environment in which Klisp programs can be
// evaluated. Because Klisp doesn't have the traditional notion of a "VM",
// initialize a new Environment to evaluate a form.
func New() Environment {
retu... | vanta/env.go | 0.674479 | 0.462837 | env.go | starcoder |
package apitest
import (
"math/rand"
"testing"
"time"
"github.com/romshark/dgraph_graphql_go/api/graph/gqlmod"
"github.com/stretchr/testify/require"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
func randomString(length int, runes []rune) string {
if runes == nil {
runes = []rune("a")
}
b := make([]... | apitest/helpers.go | 0.52683 | 0.498718 | helpers.go | starcoder |
package wavreader
import (
"fmt"
"io"
"math"
)
const (
// The length, in milliseconds, of conversion chunks
msCHUNK = 10
)
// Convert converts a Reader into a new Reader with the specified format, converting the audio signal if necessary
func Convert(r Reader, format StreamFormat) (Reader, error) {
// Fast pat... | lib/wavreader/convert.go | 0.653569 | 0.405802 | convert.go | starcoder |
package tools
import (
"math/rand"
"os"
"time"
)
type (
// Identifier represents a unique identifier
Identifier = string
// State type for game states represented as an 8-bit integer
State = uint8
// AnswerIndex represents the index for an answer as an integer
AnswerIndex = int
// QuestionIndex represent... | backend/tools/tools.go | 0.752195 | 0.458773 | tools.go | starcoder |
package ioutil
import (
"encoding/binary"
"fmt"
"io"
"math"
"strconv"
"unsafe"
)
// A Decoder implements various decoding helpers for Little Endian and Big Endian. It may optimize some
// paths in the future, so that the generic call with byte order may be slower than the direct invocation.
// The implementatio... | decoder.go | 0.712832 | 0.402157 | decoder.go | starcoder |
package main
/* homogenous system of linear equations with coefficients of GF(2) */
import (
"fmt"
)
/* *** Bit *** ************************************************************* */
type Bit int
func (this Bit) Check() {
if this != 0 && this != 1 {
panic(fmt.Sprint("Invalid Value. Should be 0 or 1, but is ", th... | improved-go-version/factorize/linearsystem.go | 0.543833 | 0.436022 | linearsystem.go | starcoder |
package tttoe
import (
"errors"
"strings"
)
var InvalidCoordinate error = errors.New("Coordinate should be in [0, 2] interval.")
var NoneEmptyCell error = errors.New("You're trying to play on a none empty cell.")
type Stage struct {
cells [][]string
}
func NewStage() Stage {
stage := Stage{}
stage.cells = make... | tttoe/stage.go | 0.633297 | 0.415077 | stage.go | starcoder |
package region
import "strings"
// GetCountryBin return the bin for the given country alpha-2 code.
func GetCountryBin(countryCode string) (GeoBin, bool) {
cleaned := strings.ToUpper(countryCode)
bin, exists := countryBins[cleaned]
return bin, exists
}
// GetCountryList returns a list of all country alpha-2 code... | region/country.go | 0.642096 | 0.576065 | country.go | starcoder |
package syntax
import (
"bytes"
"fmt"
"github.com/grailbio/reflow/internal/scanner"
"github.com/grailbio/reflow/types"
"github.com/grailbio/reflow/values"
)
// DeclKind is the type of declaration.
type DeclKind int
const (
// DeclError is an illegal declaration.
DeclError DeclKind = iota
// DeclAssign is a... | syntax/decl.go | 0.560012 | 0.420421 | decl.go | starcoder |
package bitwisebytes
import (
"encoding/binary"
"fmt"
)
//ByteOrder specifies how to convert byte sequences into
// 16-, 32-, or 64-bit unsigned integers.
type ByteOrder interface {
Uint8([]byte) uint8
Uint16([]byte) uint16
Uint24([]byte) uint32
Uint32([]byte) uint32
Uint40([]byte) uint64
Uint48([]byte) uint6... | binaryops.go | 0.545528 | 0.4953 | binaryops.go | starcoder |
package container
import (
"errors"
"fmt"
"reflect"
)
// Edge represents the relationship between two types
type Edge struct {
From reflect.Type
To reflect.Type
hasSpecialInType bool
}
type Edges []*Edge
func (e Edge) Equal(edge Edge) bool {
return e.From == edge.From &&
e.To == edge.To
}
func (e Edges... | pkg/container/graph.go | 0.739234 | 0.553083 | graph.go | starcoder |
package main
import (
"fmt"
"time"
)
// this code allows to change the channel passed in to a go routine during execution
// that can be useful if we need to use a channel with a different size
// since a channel cannot be resized, we create and use another one
// the go routine using the channel updates the channe... | gochannelchange.go | 0.518546 | 0.441191 | gochannelchange.go | starcoder |
package main
import (
"bufio"
"io"
"math"
"sort"
"strconv"
"strings"
)
var _ = declareDay(20, func(part2 bool, inputReader io.Reader) interface{} {
if part2 {
return day20Part2(inputReader)
}
return day20Part1(inputReader)
})
func day20Part1(inputReader io.Reader) interface{} {
scanner := bufio.NewScanne... | day20.go | 0.555194 | 0.416619 | day20.go | starcoder |
package store
import (
`fmt`
`strings`
)
// Print formats for generating named parameters.
const (
namedParamFmt = `:%v`
namedEqualFmt = `%[1]v = :%[1]v`
)
// query contains SQL query components needed for building prepared statements.
type query struct {
Table string
MultiRow bool
Command string
Filters []... | store/query.go | 0.782787 | 0.420302 | query.go | starcoder |
package bsonx
import (
"encoding/binary"
"math"
"time"
"github.com/wimspaargaren/mongo-go-driver/bson/bsontype"
"github.com/wimspaargaren/mongo-go-driver/bson/primitive"
)
// IDoc is the interface implemented by Doc and MDoc. It allows either of these types to be provided
// to the Document function to create ... | x/bsonx/constructor.go | 0.738009 | 0.457743 | constructor.go | starcoder |
package mathutil
import (
"fmt"
"github.com/grokify/mogo/errors/errorsutil"
)
var MaxTries = int32(100000)
// RangeFloat64 creates a range with a fixed set of cells and
// returns the cell for a certain value.
type RangeFloat64 struct {
Min float64
Max float64
Cells int32
iter int32
}
// CellIndexForVal... | math/mathutil/rangefloat64.go | 0.664976 | 0.422445 | rangefloat64.go | starcoder |
package output
import (
"sort"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/cache"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/output/writer"
"github.com/Jeffail/benthos/v3/lib/types"
)
//-----------... | lib/output/cache.go | 0.764804 | 0.649287 | cache.go | starcoder |
package notice
import (
"fmt"
"time"
"github.com/dustin/go-humanize"
"github.com/future-architect/gbilling2slack/report"
"github.com/nlopes/slack"
)
type slackNotifier struct {
slackAPIToken string
slackChannel string
}
func NewSlackNotifier(slackAPIToken, slackChannel string) *slackNotifier {
return &slac... | notice/notice.go | 0.581422 | 0.457137 | notice.go | starcoder |
package object
import (
"github.com/gopherd/three/core"
)
// OrthographicCamera represents an orthographic camera
type OrthographicCamera struct {
cameraImpl
left, right, top, bottom core.Float
}
var _ Camera = (*OrthographicCamera)(nil)
// NewOrthographicCamera creates a OrthographicCamera
func NewOrthographic... | object/camera_orthographic.go | 0.802478 | 0.467575 | camera_orthographic.go | starcoder |
package wasm
import (
"fmt"
"reflect"
)
type InvalidTableIndexError uint32
func (e InvalidTableIndexError) Error() string {
return fmt.Sprintf("wasm: Invalid table to table index space: %d", uint32(e))
}
type InvalidValueTypeInitExprError struct {
Wanted reflect.Kind
Got reflect.Kind
}
func (e InvalidValu... | core/wasm/index.go | 0.664758 | 0.412353 | index.go | starcoder |
package runtime
import (
"encoding/base64"
"fmt"
"strconv"
"strings"
"github.com/catper/protobuf/jsonpb"
"github.com/catper/protobuf/ptypes/duration"
"github.com/catper/protobuf/ptypes/timestamp"
"github.com/catper/protobuf/ptypes/wrappers"
)
// String just returns the given string.
// It is just for compati... | runtime/convert.go | 0.734976 | 0.450964 | convert.go | starcoder |
package sqlutil
import (
"database/sql"
"fmt"
"reflect"
)
// A ScanRow is a container for SQL metadata for a single row.
// The row metadata is used to generate dataframe fields and a slice that can be used with sql.Scan
type ScanRow struct {
Columns []string
Types []reflect.Type
}
// NewScanRow creates a new... | data/sqlutil/scanrow.go | 0.789193 | 0.541954 | scanrow.go | starcoder |
package value
import "strconv"
// Int holds a single int64 value.
type Int struct {
valPtr *int64
}
// NewInt makes a new Int with the given int64 value.
func NewInt(val int64) *Int {
valPtr := new(int64)
*valPtr = val
return &Int{valPtr: valPtr}
}
// NewIntFromPtr makes a new Int with the given pointer to int... | value/int.go | 0.794146 | 0.512815 | int.go | starcoder |
Package plyfile provides functions for reading and writing PLY files. The package uses the C plyfile library, originally developed by Greg Turk and released in February 1994. All Go code is provided under the Apache 2.0 license. Greg Turk's code has a separate license (see lib folder).
Disclaimer
There are probably c... | doc.go | 0.538741 | 0.859546 | doc.go | starcoder |
// Package reflectx contains a set of reflection utilities and well-known types.
package reflectx
import (
"context"
"fmt"
"reflect"
)
// Well-known reflected types. Convenience definitions.
var (
Bool = reflect.TypeOf((*bool)(nil)).Elem()
Int = reflect.TypeOf((*int)(nil)).Elem()
Int8 = reflect.TypeO... | sdks/go/pkg/beam/core/util/reflectx/types.go | 0.760117 | 0.426859 | types.go | starcoder |
package local
import (
"bufio"
"bytes"
"io"
"go.nickng.io/sesstype"
)
// Scanner is a lexical scanner.
type Scanner struct {
r *bufio.Reader
pos sesstype.TokenPos
typevars []struct {
parseTypeVar bool
validTypeVars map[string]bool
}
}
// NewScanner returns a new instance of Scanner.
func N... | local/scanner.go | 0.538255 | 0.502319 | scanner.go | starcoder |
package edges
// finds zero-crossings in Laplacian (bli)
func isCandidateEdge(bli [][]uint8, smoothed [][]float32, col, row int) (result bool) {
result = false
/*
* test for zero-crossings of Laplacian, then make sure that zero-crossing
* sign correspondence principle is satisfied (i.e. a positive z-c must
* h... | detection.go | 0.603932 | 0.505066 | detection.go | starcoder |
package docs
import (
"bytes"
"encoding/json"
"strings"
"text/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {
"url": "htt... | docs/docs.go | 0.557604 | 0.438424 | docs.go | starcoder |
package iso20022
// Information related for the transportation of goods by sea.
type TransportBySea5 struct {
// Identifies the port where the goods are loaded on board the ship.
PortOfLoading *Max35Text `xml:"PortOfLoadng"`
// Identifies the port where the goods are discharged.
PortOfDischarge *Max35Text `xml:"... | TransportBySea5.go | 0.753285 | 0.573201 | TransportBySea5.go | starcoder |
package domain
type MonthSummaryRepository interface {
Store(monthSummary MonthSummary) (MonthSummary, error)
Delete(monthSummary MonthSummary) error
FindMonth(year int, month int) (MonthSummary, error)
}
type MonthSummary struct {
ID string `datastore:"-"`
Year int
Month int
Day1 string `datastore:",noind... | src/domain/monthSummaryDomain.go | 0.532182 | 0.836154 | monthSummaryDomain.go | starcoder |
package chain
import (
"math"
"time"
)
// time.Unix will add `time.unixToInternal` to a unix timestamp in int64 space.
// TimeOfRound will stay below this buffer so that such a conversion does not overflow.
const timeBufferBits = 36
const maxTimeBuffer = int64(1 << timeBufferBits)
// TimeOfRoundErrorValue is the v... | chain/time.go | 0.835718 | 0.418459 | time.go | starcoder |
package merkletree
import (
"bytes"
"errors"
"github.com/dusk-network/dusk-blockchain/pkg/crypto/hash"
)
// Payload is data that can be stored and checked in the Merkletree.
// Types implementing this interface can be items of the Merkletree
type Payload interface {
CalculateHash() ([]byte, error)
}
// Tree str... | pkg/crypto/merkletree/merkletree.go | 0.769946 | 0.532668 | merkletree.go | starcoder |
package server
import (
"encoding/json"
"time"
"github.com/rcrowley/go-metrics"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
)
var logger = logp.NewLogger("statd")
type metric struct {
name string
tags map[string]string
lastSeen time.Time
sampleRate floa... | x-pack/metricbeat/module/statsd/server/registry.go | 0.80871 | 0.437643 | registry.go | starcoder |
package mana
import (
"time"
"github.com/iotaledger/hive.go/identity"
"github.com/iotaledger/goshimmer/packages/ledgerstate"
)
// TxInfo holds information related to the transaction which we are processing for mana calculation.
type TxInfo struct {
// Timestamp is the timestamp of the transaction.
TimeStamp ti... | packages/mana/txinfo.go | 0.707708 | 0.432483 | txinfo.go | starcoder |
package functional
// #cgo CFLAGS: -I ${SRCDIR}/../..
// #cgo LDFLAGS: -L ${SRCDIR}/../../cgotorch -Wl,-rpath ${SRCDIR}/../../cgotorch -lcgotorch
// #cgo LDFLAGS: -L ${SRCDIR}/../../cgotorch/libtorch/lib -Wl,-rpath ${SRCDIR}/../../cgotorch/libtorch/lib -lc10 -ltorch -ltorch_cpu
// #include "cgotorch/cgotorch.h"
import... | nn/functional/functional.go | 0.745861 | 0.400339 | functional.go | starcoder |
package box2d
import (
"fmt"
)
/// Friction joint definition.
type B2FrictionJointDef struct {
B2JointDef
/// The local anchor point relative to bodyA's origin.
LocalAnchorA B2Vec2
/// The local anchor point relative to bodyB's origin.
LocalAnchorB B2Vec2
/// The maximum friction force in N.
MaxForce float... | DynamicsB2JointFriction.go | 0.826397 | 0.659796 | DynamicsB2JointFriction.go | starcoder |
package dense
import (
"bytes"
"encoding/gob"
"github.com/therfoo/therfoo/tensor"
"math/rand"
)
type Dense struct {
activate func(*tensor.Vector) *tensor.Vector
derive func(*tensor.Vector) *tensor.Vector
neuronsCount int
weightsCount int
weights [][]float64
}
func (d *Dense) Activate(x *tenso... | layers/dense/dense.go | 0.629775 | 0.557243 | dense.go | starcoder |
package query
import (
"errors"
"math"
"time"
"github.com/influxdata/influxql"
"github.com/influxdata/platform/models"
)
var (
// ErrQueryInterrupted is an error returned when the query is interrupted.
ErrQueryInterrupted = errors.New("query interrupted")
)
// ZeroTime is the Unix nanosecond timestamp for no... | vendor/github.com/influxdata/platform/query/query.go | 0.757166 | 0.468669 | query.go | starcoder |
package matchers
import "bytes"
// SevenZ matches a 7z archive.
func SevenZ(in []byte, _ uint32) bool {
return bytes.HasPrefix(in, []byte{0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C})
}
// Gzip matched gzip files based on http://www.zlib.org/rfc-gzip.html#header-trailer.
func Gzip(in []byte, _ uint32) bool {
return bytes.H... | internal/matchers/archive.go | 0.640074 | 0.467818 | archive.go | starcoder |
package iso20022
// Specifies the payment terms of the underlying transaction.
type PaymentTerms3 struct {
// Due date specified for the payment terms.
DueDate *ISODate `xml:"DueDt,omitempty"`
// Payment period specified for these payment terms.
PaymentPeriod *PaymentPeriod1 `xml:"PmtPrd,omitempty"`
// Textual... | PaymentTerms3.go | 0.861159 | 0.443721 | PaymentTerms3.go | starcoder |
package layer
import tf "github.com/galeone/tensorflow/tensorflow/go"
type LLeakyReLU struct {
alpha float64
dtype DataType
inputs []Layer
name string
shape tf.Shape
trainable bool
layerWeights []*tf.Tensor
}
func LeakyReLU() *LLeakyReLU {
return &LLeakyReLU{
alpha: ... | layer/LeakyReLU.go | 0.755186 | 0.436202 | LeakyReLU.go | starcoder |
package groph
import "errors"
// Graph is the main type to do queries and stores a vertex to be used as the starting point of any query. At the same
// time it maintains a map of known vertices
type Graph struct {
StartVertex *Vertex
IndexMap map[interface{}]*Vertex
}
// Find returns the vertex with the provide... | graph.go | 0.830732 | 0.64593 | graph.go | starcoder |
package client
// Selectors are used to select a subset of hosts from an inventory
type Selector interface {
isSelector()
}
// HasAllLabels is a selector that selects hosts containing all the labels
type HasAllLabels struct {
Labels []string
}
// HasAnyLabel is a selector that selects hosts containing any of the ... | client/selectors.go | 0.805096 | 0.455138 | selectors.go | starcoder |
package frontend
import (
"github.com/isaacev/Plaid/source"
)
// Scope represents the variable and type environment available at a point in
// a program's AST. This includes type data stored in the type table and
// variable names/type-signatures stored in the variables table. All scopes
// (except the global scope)... | frontend/scope.go | 0.626353 | 0.438605 | scope.go | starcoder |
package trie
func (trie *RuneTrie) find(contents []rune, accu []rune) (string, interface{}) {
if trie.value != nil {
return string(accu), trie.value
}
if len(contents) == 0 {
return "", nil
}
k := contents[0]
tt, ok := trie.children[k]
if !ok {
return "", nil
}
return tt.find(contents[1:], append(accu, ... | app/service/main/antispam/util/trie/rune_trie.go | 0.535827 | 0.438364 | rune_trie.go | starcoder |
package wadlib
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/sha1"
"encoding/binary"
"errors"
"fmt"
)
// WADFile represents a file within a WAD.
// RawData should always be the encrypted data ready to be stored within a WAD.
type WADFile struct {
Record *ContentRecord
RawData []byte
}
// LoadDataSe... | file.go | 0.583678 | 0.483587 | file.go | starcoder |
package transactions
//ToDo: Channels for sending created, deleted, editted transactions
func mockTransactions() []*Transaction {
t1 := &Transaction{ID: 0, Type: TransactionBuy, CoinID: "BTC", CoinAmount: 0.084, DateTime: 1515940982305, PriceUSD: 243.93}
t2 := &Transaction{ID: 1, Type: TransactionBuy, CoinID: "VSX"... | transactions/transactions.go | 0.731442 | 0.506958 | transactions.go | starcoder |
package add
import (
"fmt"
"github.com/knutsonchris/stackilackey/cmd"
)
type host struct {
}
/*
Host will add a new host to the cluster.
Arguments
{host}
A single host name. If the hostname is of the standard form of
basename-rack-rank the default values for the appliance, rack,
and rank parameters are tak... | add/host.go | 0.711631 | 0.42937 | host.go | starcoder |
package cat_pipe
import (
"fmt"
)
// RawByteManipulator takes in byte array (without newline) and returns byte array (without newlines). Return empty array to skip, non-nil err to stop.
// out: The line to be added to the writer. If nil or of length 0, no line will be added.
// err: Error to be thrown, execution wi... | types.go | 0.662578 | 0.421671 | types.go | starcoder |
package transform
type WHT8 struct {
fScale uint
iScale uint
data []int
}
// For perfect reconstruction, forward results are scaled by 8 unless the
// parameter is set to false (in which case rounding may introduce errors)
func NewWHT8(scale bool) (*WHT8, error) {
this := new(WHT8)
this.data = make([]int, 64)
... | go/src/kanzi/transform/WHT8.go | 0.695958 | 0.420481 | WHT8.go | starcoder |
package creds
import (
"fmt"
"github.com/forj-oss/goforjj"
)
// ObjectValue describe the Objects keys value
type Value struct {
value *goforjj.ValueStruct // value.
// If source == `forjj` => real value
// If source == `file` => Path the a file containing the value
// Else => address of the data, with eventual... | creds/value.go | 0.728169 | 0.453141 | value.go | starcoder |
package ride
import (
"github.com/pkg/errors"
)
type estimationScopeV2 struct {
values []scopeValue
stash []scopeValue
functions []*FunctionDeclarationNode
builtin map[string]int
}
func newEstimationScopeV2(values []string, functions map[string]int) *estimationScopeV2 {
initial := make([]scopeValue, l... | pkg/ride/tree_estimatorV2.go | 0.575111 | 0.470007 | tree_estimatorV2.go | starcoder |
package plot
import (
"math"
"strconv"
"gonum.org/v1/plot"
)
type FuncScale struct {
Func func(float64) float64
}
func (s *FuncScale) Normalize(min, max, x float64) float64 {
if s.Func == nil {
panic("s.Func is nil")
}
fMin := s.Func(min)
return (s.Func(x) - fMin) / (s.Func(max) - fMin)
}
func Log10Min3... | plot/plotelements.go | 0.741112 | 0.420719 | plotelements.go | starcoder |
package docs
import (
"bytes"
"encoding/json"
"strings"
"github.com/alecthomas/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{.Description}}",
"title": "{{.Title}}",
"contact": {
... | docs/docs.go | 0.650578 | 0.411939 | docs.go | starcoder |
package util
import (
"fmt"
"testing"
. "golang.org/x/exp/slices"
)
func preFormattedErrorString[T any](expected, got T) string {
return fmt.Sprintf("expected: %+v got: %+v", expected, got)
}
func AssertTrue(value bool, t *testing.T) {
t.Run(fmt.Sprintf("AssertTrue : %v", value), func(t *testing.T) {
if valu... | Utils/assert.go | 0.587115 | 0.675052 | assert.go | starcoder |
package vector
import (
"math"
)
// Vector3 contains 3 components
type Vector3 struct {
x float64
y float64
z float64
}
// NewVector3 creates a new vector with corresponding 3 components
func NewVector3(x float64, y float64, z float64) Vector3 {
return Vector3{
x: x,
y: y,
z: z,
}
}
// Vector3Right is (... | vector3.go | 0.915176 | 0.821223 | vector3.go | starcoder |
package transform
import (
"errors"
"fmt"
)
const (
_BWTS_MAX_BLOCK_SIZE = 1024 * 1024 * 1024 // 1 GB
)
// BWTS Bijective version of the Burrows-Wheeler Transform
// The main advantage over the regular BWT is that there is no need for a primary
// index (hence the bijectivity). BWTS is about 10% slower than BWT.
... | transform/BWTS.go | 0.693058 | 0.41324 | BWTS.go | starcoder |
package base
import (
"errors"
"fmt"
"strconv"
"time"
"unicode"
)
// Duration is identical to time.Duration, except it can implements the
// json.Marshaler interface with time.Duration.String() and
// time.Duration.ParseDuration().
type Duration time.Duration
// String returns a string representing the duration... | duration.go | 0.812979 | 0.406626 | duration.go | starcoder |
package zngnative
import (
"math"
"github.com/brimsec/zq/pkg/nano"
"github.com/brimsec/zq/zng"
)
// CoerceToFloat64 attempts to convert a value to a float64. The
// resulting coerced value is written to out, and true is returned. If
// the value cannot be coerced, then false is returned.
func CoerceToFloat64(in z... | zngnative/coerce.go | 0.751283 | 0.407746 | coerce.go | starcoder |
// hebbplot plots hebbian learning simulation over time
package main
import (
"math/rand"
"strconv"
"github.com/emer/etable/eplot"
"github.com/emer/etable/etable"
"github.com/emer/etable/etensor"
_ "github.com/emer/etable/etview" // include to get gui views
"github.com/goki/gi/gi"
"github.com/goki/gi/gimain"... | examples/hebbplot/hebbplot.go | 0.663342 | 0.4133 | hebbplot.go | starcoder |
package mocks
import (
"github.com/sasalatart/batcoms/domain/locations"
"github.com/sasalatart/batcoms/domain/statistics"
"github.com/sasalatart/batcoms/domain/wikibattles"
)
// WikiBattle returns an instance of wikibattles.Battle that may be used for testing purposes
func WikiBattle() wikibattles.Battle {
return... | mocks/wikibattles.go | 0.535098 | 0.455622 | wikibattles.go | starcoder |
package main
import "fmt"
type Tree struct {
Root *Node
}
type Node struct {
key byte
left *Node
right *Node
}
//Creating a tree
func (t *Tree) Insert(data byte) {
if t.Root == nil {
t.Root = &Node{
key: data,
}
} else {
t.Root.Insert(data)
}
}
// Insert inserts data into the Node
func (n *Node)... | binarysearchtree/main.go | 0.545044 | 0.459743 | main.go | starcoder |
package unix
import (
"fmt"
"github.com/sfomuseum/go-edtf"
"github.com/sfomuseum/go-edtf/parser"
_ "log"
)
// DateSpan is a struct containing Unix timestamps for a range of (two) dates. Dates before 1970-01-01 are represented as negative values.
type DateSpan struct {
// Start is the Unix timestamp for the start... | vendor/github.com/sfomuseum/go-edtf/unix/range.go | 0.792865 | 0.482063 | range.go | starcoder |
package micro
import (
ast "github.com/awalterschulze/gominikanren/sexpr/ast"
"sort"
)
// deriveTuple3SVars returns a function, which returns the input values.
// Since tuples are not first class citizens in Go, this is a way to fake it, because functions that return tuples are first class citizens.
func deriveTup... | micro/derived.gen.go | 0.808559 | 0.401277 | derived.gen.go | starcoder |
package indicator
// Money flow index strategy.
func MoneyFlowIndexStrategy(asset Asset) []Action {
actions := make([]Action, len(asset.Date))
moneyFlowIndex := DefaultMoneyFlowIndex(
asset.High,
asset.Low,
asset.Closing,
asset.Volume)
for i := 0; i < len(actions); i++ {
if moneyFlowIndex[i] >= 80 {
... | volume_strategies.go | 0.607314 | 0.417865 | volume_strategies.go | starcoder |
package tetra3d
import (
"github.com/kvartborg/vector"
)
// Node represents an object that exists in 3D space and can be positioned relative to an origin point.
// By default, this origin point is {0, 0, 0} (or world origin), but Nodes can be parented
// to other Nodes to change this origin (making their movements r... | node.go | 0.894536 | 0.76249 | node.go | starcoder |
package model
//------------------------------------------------------------------------------
// RelationshipState describes the current state of a relationship
type RelationshipState struct {
Relationship string `yaml:"Relationship"` // name of relationship
Dependency string `yaml:"Dependency"` // nam... | src/tsai.eu/solar/model/state.go | 0.845465 | 0.405449 | state.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// ProvisioningStep
type ProvisioningStep struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for... | models/microsoft/graph/provisioning_step.go | 0.643105 | 0.420124 | provisioning_step.go | starcoder |
package neural
import (
"fmt";
"github.com/gonum/matrix/mat64"
)
func NewLayer(name ActivationName, inputs int, outputs int,
weight []float64) *Layer {
layer := new(Layer)
layer.Name = name
layer.ActivationFunction = NewActivationFunction(layer.Name)
layer.DActivationFunction = NewDActivatio... | neural/layer.go | 0.610105 | 0.492737 | layer.go | starcoder |
package mem
import (
"fmt"
"sync"
"time"
)
var c *Cache
// MemData is a struct that holds the data for the memory
type MemData struct {
Key string // key for the data
Value []byte // data to be stored in memory
Expire int64 // unix timestamp, 0 means never expire
Created int64 // unix timestamp, the ... | mem.go | 0.681197 | 0.432123 | mem.go | starcoder |
package main
import (
"math"
)
const gravity = 9.81
type DoublePendulum [2]Pendulum
func getDPCoords(dp DoublePendulum, scale float64) (x1, y1, x2, y2 float64) {
var (
p1 = &(dp[0])
p2 = &(dp[1])
)
var (
r1 = p1.Length * scale
r2 = p2.Length * scale
a1 = p1.Theta
a2 = p2.Theta
)
sin1, cos1 := ... | doublepend/doublepend.go | 0.691289 | 0.529446 | doublepend.go | starcoder |
// Package dataproc shows how you can use the Dataproc Client library to manage
// Dataproc clusters. In this example, we'll show how to submit a Spark job a cluster.
package dataproc
// [START dataproc_submit_job]
import (
"context"
"fmt"
"io"
"io/ioutil"
"log"
"regexp"
dataproc "cloud.google.com/go/dataproc... | dataproc/submit_job.go | 0.700997 | 0.478041 | submit_job.go | starcoder |
package resp
import (
"fmt"
"reflect"
"strconv"
"unsafe"
)
func ConvertFrom(r Reply, i interface{}) error {
val := reflect.ValueOf(i)
return convertFrom(r, val)
}
func convertFrom(r Reply, val reflect.Value) error {
switch val.Kind() {
default:
return fmt.Errorf("Error Data types are not supported '%s'", v... | convert.go | 0.519765 | 0.424173 | convert.go | starcoder |
package triangulate
type Triangle struct {
X1 float32
Y1 float32
X2 float32
Y2 float32
X3 float32
Y3 float32
}
type vec2 struct {
x float32
y float32
}
// Code translated from
// https://github.com/CMU-Graphics/DrawSVG/blob/master/src/triangulation.cpp
// TODO find and implement an algorithm on your own.
fun... | triangulate/triangulate.go | 0.695441 | 0.495667 | triangulate.go | starcoder |
package parser
import (
"fmt"
"io"
"strconv"
"github.com/coyove/nj/bas"
"github.com/coyove/nj/internal"
"github.com/coyove/nj/typ"
)
type Token struct {
Type uint32
Str string
Pos typ.Position
}
func (t *Token) String() string {
return t.Str
}
type Node struct {
bas.Value
NodeType byte
SymLine uint... | parser/node.go | 0.504639 | 0.418519 | node.go | starcoder |
package element
type Datatype interface {
DataDef() DataDef
}
type DataDef int
const (
DataDefChar DataDef = iota
DataDefVarchar2
DataDefNChar
DataDefNVarChar2
DataDefNumber
DataDefFloat
DataDefBinaryFloat
DataDefBinaryDouble
DataDefLong
DataDefLongRaw
DataDefRaw
DataDefDate
DataDefTimestamp
DataDefIn... | ast/element/datatype.go | 0.510741 | 0.541833 | datatype.go | starcoder |
package matrix
import (
"fmt"
"goharvest2/pkg/color"
"goharvest2/pkg/errors"
"strconv"
)
type MetricFloat64 struct {
*AbstractMetric
values []float64
}
func (me *MetricFloat64) Clone(deep bool) Metric {
clone := MetricFloat64{AbstractMetric: me.AbstractMetric.Clone(deep)}
if deep && len(me.values) != 0 {
c... | pkg/matrix/metric_float64.go | 0.531453 | 0.425367 | metric_float64.go | starcoder |
package main
import (
"fmt"
gospec "github.com/AlaxLee/go-spec-util"
"go/types"
)
func main() {
comparableExample01()
comparableExample02()
comparableExample03()
comparableExample04()
comparableExample05()
comparableExample06()
comparableExample07()
comparableExample08()
comparableExample09()
comparableE... | tutorial/03-comparability/comparable.go | 0.674158 | 0.441793 | comparable.go | starcoder |
package main
import (
"image"
"image/color"
"image/jpeg"
"log"
"math"
"os"
"sync"
"time"
tor "github.com/NullHypothesis/zoossh"
cluster "github.com/NullHypothesis/mlgo/cluster"
)
const (
blockLength = 5
)
// numBits maps an 8-bit integer to the numbers of its bits.
var numBits = map[uint]int{
0: 0, 1: ... | uptime.go | 0.609757 | 0.571587 | uptime.go | starcoder |
package ui
/*
Drawing the cross is a somewhat complicated and involved process.
First, we create two rects (vertical and horizontal cross pieces) based on
the size of whatever icons we will be putting on the cross, and our
icon margin/padding padding values.
Then, we create a window that covers the bounds of both re... | ui/cross.go | 0.731922 | 0.552238 | cross.go | starcoder |
package selection
import (
"github.com/higker/go-common/sorting"
)
var (
positiveOrderIntFunc = func(leftNum, rightNum *int) {
if *(leftNum) > *(rightNum) {
*(leftNum), *(rightNum) = *(rightNum), *(leftNum)
}
}
reverseOrderIntFunc = func(leftNum, rightNum *int) {
if *(leftNum) < *(rightNum) {
*(leftN... | sorting/selection/selection.go | 0.512937 | 0.510741 | selection.go | starcoder |
package iso20022
// Breakdown of cash movements into a fund as a result of investment funds transactions, eg, subscriptions or switch-in.
type FundCashInBreakdown1 struct {
// Amount of cash flow in, expressed as an amount of money.
Amount *ActiveOrHistoricCurrencyAndAmount `xml:"Amt,omitempty"`
// Amount of the ... | FundCashInBreakdown1.go | 0.746324 | 0.402803 | FundCashInBreakdown1.go | starcoder |
package level
import (
"encoding/binary"
"github.com/tinogoehlert/goom/utils"
"github.com/tinogoehlert/goom/wad"
)
const (
nodeSize = 28
glNodeSize = 32
)
// BBox describe a rectangle which is the area covered by each of the two child nodes respectively.
// A bounding box consists of four short values (top, ... | level/node.go | 0.707405 | 0.500244 | node.go | starcoder |
package particles
import (
"image/color"
"math/rand"
"github.com/gremour/grue"
)
// GlitterEdge generates particles that glitter
// on the edge of rect.
type GlitterEdge struct {
Rect grue.Rect
Placer Placer
Image string
Color color.Color
InitialSize float64
MaxSize float64
// L... | particles/glitter.go | 0.623148 | 0.486454 | glitter.go | starcoder |
package generators
import (
"fmt"
"image"
"image/color"
"math"
"os"
"../tools"
)
func drawTurningSandCurve(img *image.RGBA64, points []Point, c color.RGBA64, sandCoef int) {
for index, point := range points {
if index+1 == len(points) {
addToTurningSandLine(img, point, points[0], c, sandCoef)
} else {
... | generators/g_turningHazardousShape.go | 0.578924 | 0.409988 | g_turningHazardousShape.go | starcoder |
package day07
import (
"regexp"
"strconv"
)
// BagGraph is the graph that contains
// all bags
type BagGraph map[string]*Bag
// NewGraph creates a new bag graph
func NewGraph() BagGraph {
return make(BagGraph)
}
// AddBag adds a new bag to the system
func (g BagGraph) AddBag(bagID string) *Bag {
b := NewBag(bag... | day07/day7.go | 0.708818 | 0.439026 | day7.go | starcoder |
package bn256
import (
"errors"
"math/big"
)
// GT is an abstract cyclic group. The zero value is suitable for use as the
// output of an operation, but cannot be used as an input.
type GT struct {
p *gfP12
}
// Pair calculates an Optimal Ate pairing.
func Pair(g1 *G1, g2 *G2) *GT {
return >{optimalAte(g2.p, g... | bn256/bn256gt.go | 0.774669 | 0.40486 | bn256gt.go | starcoder |
package fat32
import (
"encoding/binary"
"errors"
"fmt"
)
// dos331BPB is the DOS 3.31 BIOS Parameter Block
type dos331BPB struct {
dos20BPB *dos20BPB // Dos20BPB holds the embedded DOS 2.0 BPB
sectorsPerTrack uint16 // SectorsPerTrack is number of sectors per track. May be unused when LBA-only access ... | pkg/metadata/vendor/github.com/diskfs/go-diskfs/filesystem/fat32/dos331bpb.go | 0.620737 | 0.450541 | dos331bpb.go | starcoder |
package nets
import (
"errors"
"fmt"
"math"
"math/rand"
"time"
"github.com/qvantel/nerd/internal/logger"
"github.com/qvantel/nerd/internal/nets/paramstores"
"github.com/qvantel/nerd/internal/series/pointstores"
)
// MLP holds the neurons and thus serves to keep track of the values through the network during ... | internal/nets/mlp.go | 0.66356 | 0.436862 | mlp.go | starcoder |
package main
func maximum(a, b int) int {
if a > b {
return a
} else {
return b
}
}
func dynamic_matrix(x, y int) [][]int {
var matrix [][]int
for i := 0; i < x; i++ {
var row []int
matrix = append(matrix, row)
for j := 0; j < y; j++ {
matrix[i] = append(matrix[i], 0)
}
}
return matrix
}
fun... | programs/benchmark/knapsack.go | 0.613237 | 0.538559 | knapsack.go | starcoder |
package tree
import (
core "github.com/sunshower-io/anvil/collections"
)
func (t *TreeMap) Remove(key core.Key) core.Value {
i := t.collectGreaterThanOrEqualTo(key)
if i.node != nil {
t.RemoveAll(i)
return i.node.value
}
return nil
}
func (t *TreeMap) RemoveAll(i core.Iterator) {
iter := i.(*treema... | maps/tree/delete.go | 0.654784 | 0.440951 | delete.go | starcoder |
package gcache
// ReacCacher is the interface that is implemented by every read only cache.
type ReadCacher[K comparable, V any] interface {
// Get returns the value for the given key.
// If no such key exists then the zero value is returned and ok is false.
Get(key K) (value V, ok bool)
// Len returns the number ... | basic.go | 0.787114 | 0.430147 | basic.go | starcoder |
package livy
/*
“Should array indices start at 0 or 1?
My compromise of 0.5 was rejected without, I thought, proper consideration.”
— <NAME>
http://exple.tive.org/blarg/2013/10/22/citation-needed/
"So let us let our ordinals start at zero: an element's ordinal (subscript)
equals the number of elements prece... | lib/parse.go | 0.621081 | 0.527438 | parse.go | starcoder |
package fragbag
import (
"fmt"
"strings"
"github.com/TuftsBCB/structure"
)
var _ = StructureLibrary(&structureAtoms{})
// structureAtoms represents a Fragbag structural fragment library.
// Fragbag fragment libraries are fixed both in the number of fragments and in
// the size of each fragment.
type structureAto... | structure.go | 0.799051 | 0.452657 | structure.go | starcoder |
package discovery
import "fmt"
type Light 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, th... | light.go | 0.857738 | 0.487551 | light.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.