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 format
import (
"fmt"
"math"
"strings"
)
// Format converts currency to a string with correct symbol and precision.
func Format(currencyCode string, value float64) (string, error) {
strFormat := getDefaultFormat(value < 0)
return FormatAs(currencyCode, value, strFormat)
}
func getDefaultFormat(isNegativ... | format/format.go | 0.68658 | 0.577853 | format.go | starcoder |
package zstd
import (
"bytes"
"errors"
"io"
)
// HeaderMaxSize is the maximum size of a Frame and Block Header.
// If less is sent to Header.Decode it *may* still contain enough information.
const HeaderMaxSize = 14 + 3
// Header contains information about the first frame and block within that.
type Header struc... | vendor/github.com/klauspost/compress/zstd/decodeheader.go | 0.639961 | 0.433082 | decodeheader.go | starcoder |
package bo
import (
"math"
)
// Exploration is the strategy to use for exploring the Gaussian process.
type Exploration interface {
Estimate(gp *GP, minimize bool, x []float64) (float64, error)
}
// UCB implements upper confidence bound exploration.
type UCB struct {
Kappa float64
}
// Estimate implements Explor... | exploration.go | 0.768125 | 0.59408 | exploration.go | starcoder |
package value_render
// used for ES indexing template
import (
"encoding/json"
"errors"
"reflect"
"regexp"
"strings"
"time"
"github.com/golang/glog"
)
func dateFormat(t interface{}, format string, location *time.Location) (string, error) {
if t1, ok := t.(time.Time); ok {
return t1.In(location).Format(for... | value_render/index_render.go | 0.50708 | 0.446434 | index_render.go | starcoder |
package hdrcolour
import (
"encoding/json"
"fmt"
"image/color"
"github.com/DexterLB/traytor/maths"
)
// Colour is a representation of a float32 RGB colour
type Colour struct {
R, G, B float32
}
// String returns the string representation of the colour in the form of {r, g, b}
func (c *Colour) String() string {... | hdrcolour/colours.go | 0.908148 | 0.544378 | colours.go | starcoder |
package mysql
import (
"fmt"
"strconv"
"strings"
"ariga.io/atlas/sql/internal/sqlx"
"ariga.io/atlas/sql/schema"
)
// FormatType converts schema type to its column form in the database.
// An error is returned if the type cannot be recognized.
func FormatType(t schema.Type) (string, error) {
var f string
swit... | sql/mysql/convert.go | 0.55929 | 0.474327 | convert.go | starcoder |
package regexwriter
import "regexp"
// RegexAction is a combination of a regular expression and a function
type RegexAction struct {
// Search expression
regex *regexp.Regexp
// Action to take on matched/non-matched bytes
action func([][]byte)
}
// IsMatch returns whether the regular expresion is a m... | regexwriter.go | 0.688992 | 0.448849 | regexwriter.go | starcoder |
package binarytree
type Node struct {
value int
parent *Node
left *Node
right *Node
}
func NewNode(i int) *Node {
return &Node{value: i}
}
func (n *Node) Compare(m *Node) int {
if n.value < m.value {
return -1
} else if n.value > m.value {
return 1
} else {
return 0
}
}
func (n *Node) Value() int... | go/binarytree/bst.go | 0.578091 | 0.400222 | bst.go | starcoder |
package iso20022
// Provides further details specific to the individual transaction(s) included in the message.
type CreditTransferTransaction9 struct {
// Unique identification, as assigned by a sending party, to unambiguously identify the credit instruction within the message.
CreditIdentification *Max35Text `xml... | CreditTransferTransaction9.go | 0.814607 | 0.473475 | CreditTransferTransaction9.go | starcoder |
package internal
import (
"math"
"math/big"
"reflect"
"github.com/tada/catch"
"github.com/tada/dgo/dgo"
)
type (
// bf type anonymizes the big.Float to avoid collisions between a Float attribute and the Float() function while
// the bigFloatVal still inherits all functions from big.Float since the actual fiel... | internal/bigfloat.go | 0.721645 | 0.580293 | bigfloat.go | starcoder |
package iso20022
// Set of elements used to provide the total sum of entries per bank transaction code.
type TotalsPerBankTransactionCode4 struct {
// Number of individual entries for the bank transaction code.
NumberOfEntries *Max15NumericText `xml:"NbOfNtries,omitempty"`
// Total of all individual entries inclu... | TotalsPerBankTransactionCode4.go | 0.777469 | 0.468365 | TotalsPerBankTransactionCode4.go | starcoder |
package digraph
// DepthFirstWalk performs a depth-first traversal of the nodes
// that can be reached from the initial input set. The callback is
// invoked for each visited node, and may return false to prevent
// vising any children of the current node
func DepthFirstWalk(node Node, cb func(n Node) bool) {
frontie... | vendor/github.com/hashicorp/terraform/digraph/util.go | 0.828384 | 0.560012 | util.go | starcoder |
package testsuites
import (
"errors"
"fmt"
"mnimidamonbackend/domain/repository"
"testing"
)
// Logging the unimplemented test suites.
var unimplemented = "Unimplemented Tests"
// For testing common repository procedures. For more consistency and easier code consistency.
type CommonRepositoryTestSuiteInterface i... | testsuites/common_repository_suite.go | 0.535827 | 0.421909 | common_repository_suite.go | starcoder |
package transaction
import (
"github.com/neophora/neo2go/pkg/interop/attribute"
"github.com/neophora/neo2go/pkg/interop/input"
"github.com/neophora/neo2go/pkg/interop/output"
"github.com/neophora/neo2go/pkg/interop/witness"
)
// Transaction represents a NEO transaction, it's an opaque data structure
// that can b... | pkg/interop/transaction/transaction.go | 0.800731 | 0.425009 | transaction.go | starcoder |
package iso20022
// Set of elements used to provide information on the corrective interbank transaction, to which the resolution message refers.
type CorrectiveInterbankTransaction1 struct {
// Set of elements used to provide corrective information for the group header of the message under investigation.
GroupHeade... | CorrectiveInterbankTransaction1.go | 0.830732 | 0.608914 | CorrectiveInterbankTransaction1.go | starcoder |
package test_persistence
import (
dataV1 "github.com/expproletariy/pip-timers-service/data/version1"
persist "github.com/expproletariy/pip-timers-service/persistence"
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
type TimersPersistenceF... | test/persistence/TimersMemoryPersistenceFuxture.go | 0.552057 | 0.547646 | TimersMemoryPersistenceFuxture.go | starcoder |
package flagsfiller
import (
"flag"
"fmt"
"os"
"reflect"
"strconv"
"strings"
"time"
)
var (
durationType = reflect.TypeOf(time.Duration(0))
stringSliceType = reflect.TypeOf([]string{})
stringToStringMapType = reflect.TypeOf(map[string]string{})
)
// FlagSetFiller is used to map the fields of... | flagset.go | 0.589126 | 0.411525 | flagset.go | starcoder |
package gofakeit
import "strings"
// HackerPhrase will return a random hacker sentence
func HackerPhrase() string {
words := strings.Split(Generate(getRandValue([]string{"hacker", "phrase"})), " ")
words[0] = strings.Title(words[0])
return strings.Join(words, " ")
}
// HackerAbbreviation will return a random hack... | hacker.go | 0.696887 | 0.417568 | hacker.go | starcoder |
package fuzzy
import (
"unicode"
"unicode/utf8"
)
var noop = func(r rune) rune { return r }
// Match returns true if source matches target using a fuzzy-searching
// algorithm. Note that it doesn't implement Levenshtein distance (see
// RankMatch instead), but rather a simplified version where there's no
// approx... | vendor/github.com/renstrom/fuzzysearch/fuzzy/fuzzy.go | 0.776284 | 0.449816 | fuzzy.go | starcoder |
package examples
import (
"honnef.co/go/js/xhr"
"myitcv.io/highlightjs"
"github.com/lijianying10/react"
"github.com/lijianying10/react/examples/immtodoapp"
"github.com/lijianying10/react/jsx"
)
// ImmExamplesDef is the definition of the ImmExamples component
type ImmExamplesDef struct {
react.ComponentDef
}
//... | examples/imm_examples.go | 0.616243 | 0.471223 | imm_examples.go | starcoder |
package iso20022
// Limit of amounts for the customer.
type ATMTransactionAmounts2 struct {
// Currency of the limits, if different from the requested amount.
Currency *ActiveCurrencyCode `xml:"Ccy,omitempty"`
// Maximum amount allowed in the authorised currency if the withdrawal was not approved.
MaximumAuthori... | ATMTransactionAmounts2.go | 0.851598 | 0.421314 | ATMTransactionAmounts2.go | starcoder |
package quicktime
import "bytes"
import "encoding/binary"
import "errors"
import "math"
type stscEntry struct {
FirstChunk int32
SamplesPerChunk int32
SampleID int32
}
// A STSCAtom stores a table of samples per chunk
type STSCAtom struct {
Atom *Atom
Entries []stscEntry
}
// ParseSTSC converts ... | stsc_atom.go | 0.589126 | 0.431524 | stsc_atom.go | starcoder |
package statsd
import (
"context"
"math"
"sort"
"strconv"
"time"
"github.com/hligit/gostatsd"
"github.com/hligit/gostatsd/pkg/stats"
)
// percentStruct is a cache of percentile names to avoid creating them for each timer.
type percentStruct struct {
count string
mean string
sum string
su... | pkg/statsd/aggregator.go | 0.64512 | 0.412471 | aggregator.go | starcoder |
package basic
import "github.com/airmap/tegola"
// ClonePoint will return a basic.Point for given tegola.Point.
func ClonePoint(pt tegola.Point) Point {
return Point{pt.X(), pt.Y()}
}
// ClonePoint will return a basic.Point3 for given tegola.Point3.
func ClonePoint3(pt tegola.Point3) Point3 {
return Point3{pt.X(),... | basic/clone.go | 0.746971 | 0.717519 | clone.go | starcoder |
<tutorial>
Performance benchmark example of using 51Degrees Hash Trie device detection.
The example shows how to:
<ol>
<li>Instantiate the 51Degrees device detection provider.
<p><pre class="prettyprint lang-go">
var provider = FiftyOneDegreesTrieV3.NewProvider(dataFile)
</pre></p>
<li>Open an input file with a list o... | PerfHashTrie.go | 0.547706 | 0.64072 | PerfHashTrie.go | starcoder |
package graph
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// UploadSession
type UploadSession struct {
// Stores additional data not describ... | models/microsoft/graph/upload_session.go | 0.642769 | 0.411643 | upload_session.go | starcoder |
package amsclient
import (
"encoding/json"
)
// ClusterMetricsNodes struct for ClusterMetricsNodes
type ClusterMetricsNodes struct {
Compute *float64 `json:"compute,omitempty"`
Infra *float64 `json:"infra,omitempty"`
Master *float64 `json:"master,omitempty"`
Total *float64 `json:"total,omitempty"`
}
// Ne... | pkg/api/ams/amsclient/model_cluster_metrics_nodes.go | 0.789274 | 0.447823 | model_cluster_metrics_nodes.go | starcoder |
package metrics
import (
// "fmt"
"math"
"github.com/gcla/sklearn/base"
"gonum.org/v1/gonum/mat"
)
type float = float64
type constVector = base.MatConst
// R2Score """R^2 (coefficient of determination) regression score function.
// Best possible score is 1.0 and it can be negative (because the
// model can be... | metrics/regression.go | 0.814238 | 0.587499 | regression.go | starcoder |
package raygui
import (
rl "github.com/gen2brain/raylib-go/raylib"
)
// GUI controls states
type ControlState int
const (
Disabled ControlState = iota
// Normal is the default state for rendering GUI elements.
Normal
// Focused indicates the mouse is hovering over the GUI element.
Focused
// Pressed indicate... | raygui/raygui.go | 0.665737 | 0.497192 | raygui.go | starcoder |
package option
type Optional[T any] struct {
value T
hasValue bool
}
func Some[T any](value T) Optional[T] {
return Optional[T]{value: value, hasValue: true}
}
func None[T any]() Optional[T] {
return Optional[T]{hasValue: false}
}
func FromValueOrFalse[T any](value T, ok bool) Optional[T] {
if ok {
return... | monads/option/option.go | 0.838382 | 0.464173 | option.go | starcoder |
package is
import "reflect"
// Check if obj is of a specified type
func isType(obj interface{}, check reflect.Kind) bool {
return reflect.TypeOf(obj).Kind() == check
}
// Check if obj is of struct type
func isStructType(obj interface{}, check string) bool {
value := reflect.ValueOf(obj).Type().String()
if len(va... | is.go | 0.737253 | 0.422088 | is.go | starcoder |
package barneshut
import (
"fmt"
"math"
"sort"
)
type MaxRepulsiveForce struct {
AccX, AccY, X, Y float64
Norm float64 // direction and norm
Idx int // body index where repulsive vector is max
}
func (r *Run) ComputeMaxRepulsiveForce() {
r.maxRepulsiveForce.Norm = 0.0
// parse b... | barnes-hut/barnes-hut-stats.go | 0.725551 | 0.405213 | barnes-hut-stats.go | starcoder |
package binary
import "github.com/google/gapid/core/math/u32"
// BitStream provides methods for reading and writing bits to a slice of bytes.
// Bits are packed in a least-significant-bit to most-significant-bit order.
type BitStream struct {
Data []byte // The byte slice containing the bits
ReadPos uint32 //... | core/data/binary/bitstream.go | 0.718693 | 0.648731 | bitstream.go | starcoder |
package main
/**
Golang implementation of https://github.com/skipperkongen/jts-algorithm-pack/blob/master/src/org/geodelivery/jap/concavehull/SnapHull.java
which is a Java port of st_concavehull from Postgis 2.0
*/
import (
"github.com/furstenheim/SimpleRTree"
"github.com/furstenheim/go-convex-hull-2d"
"github.com... | polygon-map/concave_hull.go | 0.851413 | 0.434221 | concave_hull.go | starcoder |
package omnik
import (
"encoding/hex"
"strconv"
"time"
)
// InverterMsg provides an easy way to turn an omnik message into actual values.
type InverterMsg struct {
Data []byte
}
// Sample is an inverter sample DTO.
type Sample struct {
Timestamp string
Date string
Time string
Temperature float32
En... | invertermsg.go | 0.679498 | 0.46557 | invertermsg.go | starcoder |
// +build reach
package cover
import (
"io"
. "github.com/tsavola/reach/internal"
)
func Location() {
Cover()
}
func Cond(conditions ...bool) {
Cover(conditions...)
}
func Bool(x bool) bool {
Cover(!x, x)
return x
}
func Min(x, min int) int {
Cover(x == min, x > min)
return x
}
func MinInt8(x, min int8... | cover/cover.go | 0.560974 | 0.591074 | cover.go | starcoder |
package parser
import (
"fmt"
"github.com/di-wu/parser/op"
"reflect"
"strings"
)
// InitError is an error that occurs on instantiating new structures.
type InitError struct {
// The error message. This should provide an intuitive message or advice on
// how to solve this error.
Message string
}
func (e *InitE... | errors.go | 0.677047 | 0.445349 | errors.go | starcoder |
package topojson
import (
"math"
"github.com/paulmach/orb"
)
type quantize struct {
Transform *Transform
dx, dy, kx, ky float64
}
func newQuantize(dx, dy, kx, ky float64) *quantize {
return &quantize{
dx: dx,
dy: dy,
kx: kx,
ky: ky,
Transform: &Transform{
Scale: [2]float64{1 / kx, 1 / ky},
... | encoding/topojson/quantize.go | 0.698535 | 0.595022 | quantize.go | starcoder |
package pgtypes
import "github.com/apaxa-go/helper/mathh"
//replacer:ignore
//go:generate go run $GOPATH/src/github.com/apaxa-go/generator/replacer/main.go -- $GOFILE
// SetInt8 sets z to x and returns z.
func (z *Numeric) SetInt8(x int8) *Numeric {
if x == 0 {
return z.SetZero()
}
if x < 0 {
z.sign = numeri... | numeric-ints.go | 0.655667 | 0.42471 | numeric-ints.go | starcoder |
package tensor
import (
"reflect"
"github.com/pkg/errors"
"gonum.org/v1/gonum/blas"
"gonum.org/v1/gonum/mat"
)
// Trace returns the trace of a matrix (i.e. the sum of the diagonal elements). If the Tensor provided is not a matrix, it will return an error
func (e StdEng) Trace(t Tensor) (retVal interface{}, err ... | edge/vendor/gorgonia.org/tensor/defaultengine_linalg.go | 0.625667 | 0.406214 | defaultengine_linalg.go | starcoder |
package evaluator
import "errors"
var (
// ErrNotFound means the unknow string within the expression cannot be Get from neither functions or params
ErrNotFound = errors.New("neither function not variable found")
// ErrInvalidResult means the invalid result type expected with the real output
ErrInvalidResult = err... | evaluator.go | 0.73678 | 0.480966 | evaluator.go | starcoder |
package tree
type node struct {
value int
left *node
right *node
}
func newNode(value int) *node {
return &node{value, nil, nil}
}
type UnbalancedBinarySearchTree struct {
root *node
}
func (t *UnbalancedBinarySearchTree) Add(newValue int) {
if t.root == nil {
t.root = newNode(newValue)
return
}
addTo... | tree/UnbalancedBinarySearchTree.go | 0.815453 | 0.463323 | UnbalancedBinarySearchTree.go | starcoder |
package pbparser
import (
"errors"
"fmt"
"strings"
)
// DataTypeCategory is an enumeration which represents the possible kinds
// of field datatypes in message, oneof and extend declaration constructs.
type DataTypeCategory int
const (
ScalarDataTypeCategory DataTypeCategory = iota
MapDataTypeCategory
NamedDat... | datatype.go | 0.759225 | 0.606673 | datatype.go | starcoder |
package lafzi
import (
"math"
"sort"
)
// Database is the core of Lafzi. Used to store the position of tokens within the submitted documents.
type Database struct {
storage dataStorage
}
// Document is the Arabic document that will be indexed.
type Document struct {
ID int64
ArabicText string
}
type do... | lafzi.go | 0.635788 | 0.405096 | lafzi.go | starcoder |
package mortgage
import (
"fmt"
"math"
"strconv"
"time"
"github.com/keep94/toolbox/date_util"
)
// Term represents a single term within an amortization schedule.
type Term struct {
Date time.Time
Payment int64
Interest int64
Balance int64
}
// Principal returns the principal paid during this term
fun... | mortgage.go | 0.824179 | 0.527134 | mortgage.go | starcoder |
package main
import (
"github.com/go-gl/glfw/v3.2/glfw"
)
const (
// The "camera speed" is an arbitrary value that controls how much the
// camera moves in response to an input event.
cameraSpeed = 0.05
)
// WASD keys control camera rotation.
func (c *camera) handleRotation(window *glfw.Window, program uint32) {... | input.go | 0.685213 | 0.421909 | input.go | starcoder |
package schematic
import (
"fmt"
"github.com/df-mc/dragonfly/dragonfly/block"
"github.com/df-mc/dragonfly/dragonfly/world"
"github.com/df-mc/dragonfly/dragonfly/world/chunk"
"reflect"
)
// schematic implements the structure of a Schematic, providing methods to read from it.
type schematic struct {
Data map... | structure.go | 0.808521 | 0.410077 | structure.go | starcoder |
package base62_go
import (
"fmt"
"math"
"math/big"
"strconv"
"strings"
)
const base = 62
type Encoding struct {
encode string
padding int
}
// NewEncoding returns a new Encoding defined by the given alphabet
func NewEncoding(encoder string) *Encoding {
return &Encoding{
encode: encoder,
}
}
// EncodeBy... | encoding.go | 0.832509 | 0.413951 | encoding.go | starcoder |
package ent
import (
"fmt"
"strings"
"entgo.io/ent/dialect/sql"
"github.com/masseelch/elk/internal/integration/pets/ent/pet"
"github.com/masseelch/elk/internal/integration/pets/ent/toy"
)
// Toy is the model entity for the Toy schema.
type Toy struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,om... | internal/integration/pets/ent/toy.go | 0.656218 | 0.415788 | toy.go | starcoder |
package blur
import (
"image"
"image/color"
"math"
"os"
"github.com/Nyarum/img/utils"
)
type Style float64
const (
// Ignore edges, may leave them semi-transparent
IGNORE Style = iota
// Clamp edges, may leave them looking unblurred
CLAMP
// Wrap edges, may change colour of edges
WRAP
)
func abs(num int... | blur/blur.go | 0.839405 | 0.443902 | blur.go | starcoder |
package conf
// StringVar defines a string flag and environment variable with specified name, default value, and usage string.
// The argument p points to a string variable in which to store the value of the flag and/or environment variable.
func (c *Configurator) StringVar(p *string, name string, value string, usage ... | value_string.go | 0.837852 | 0.658568 | value_string.go | starcoder |
package keeper
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/incentive/types"
)
// AccumulateSwapRewards calculates new rewards to distribute this block and updates the global indexes to reflect this.
// The provided rewardPeriod must be valid to avoid panics in calculating... | x/incentive/keeper/rewards_swap.go | 0.791096 | 0.467453 | rewards_swap.go | starcoder |
package steps
import (
"bytes"
"github.com/bitflow-stream/go-bitflow/bitflow"
"github.com/bitflow-stream/go-bitflow/script/reg"
)
type ExpressionProcessor struct {
bitflow.NoopProcessor
Filter bool
checker bitflow.HeaderChecker
expressions []*Expression
}
func RegisterExpression(b reg.ProcessorRegistry)... | steps/expression_processor.go | 0.72952 | 0.605857 | expression_processor.go | starcoder |
package kafkazk
import (
"math"
"sort"
)
// DegreeDistribution counts broker to broker relationships.
type DegreeDistribution struct {
// Relationships is a an adjacency list
// where an edge between brokers is defined as
// a common occupancy in at least one replica set.
// For instance, given the replica set ... | kafkazk/stats.go | 0.827201 | 0.474753 | stats.go | starcoder |
package main
import (
"fmt"
"sort"
)
// https://gist.github.com/inky/3188870
var Notes = []string{"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"}
// Scales as steps from the previous note
var Scales = map[string][]int{
"Major (Ionian)": {2, 2, 1, 2, 2, 2, 1},
"Dorian Mode": ... | music.go | 0.529993 | 0.575409 | music.go | starcoder |
package main
import (
"fmt"
"image/color"
"github.com/hajimehoshi/ebiten/v2"
)
var (
// Zoom controls the zoom amount
Zoom = 8
// WindowWidth is the width of the window
WindowWidth = 500
// WindowHeight is the height of the window
WindowHeight = 500
// BoxWidth is the width of the underlying array of par... | sandbox.go | 0.524151 | 0.402451 | sandbox.go | starcoder |
package test_persistence
import (
"testing"
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
data1 "github.com/pip-templates/pip-templates-microservice-go/data/version1"
persist "github.com/pip-templates/pip-templates-microservice-go/persistence"
"github.com/stretchr/testify/assert"
)
type Beac... | test/persistence/BeaconsPersistenceFixture.go | 0.655115 | 0.606673 | BeaconsPersistenceFixture.go | starcoder |
func uniquePathsWithObstaclesMemo(obstacleGrid [][]int) int {
numR, numC := len(obstacleGrid), len(obstacleGrid[0])
if obstacleGrid[0][0] == 1 { return 0 }
memo := make([][]int, numR)
for row := range memo {
memo[row] = make([]int, numC)
}
var dfs func(int, int) int
dfs = func(cellR... | unique-paths-ii/unique-paths-ii.go | 0.612657 | 0.435481 | unique-paths-ii.go | starcoder |
package coltypes
import (
"strings"
"github.com/lib/pq/oid"
"github.com/znbasedb/znbase/pkg/sql/pgwire/pgcode"
"github.com/znbasedb/znbase/pkg/sql/pgwire/pgerror"
"github.com/znbasedb/znbase/pkg/sql/sem/types"
)
var (
// Bool is an immutable T instance.
Bool = &TBool{VisBool}
// Boolean is same as Bool
Boo... | pkg/sql/coltypes/aliases.go | 0.538983 | 0.411732 | aliases.go | starcoder |
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
type Point struct {
x, y int
}
func newPoint(arr []int) (Point, error) {
if len(arr) != 2 {
return Point{}, fmt.Errorf("invalid input: %v", arr)
}
return Point{arr[0], arr[1]}, nil
}
func (p1 Point) Equal(p2 Point) bool {
return p1.x ... | 2021/day05/solution.go | 0.506591 | 0.415254 | solution.go | starcoder |
package mcpiapi
import (
"fmt"
"strconv"
)
// World has methods for manipulating the Minecraft world.
type World object
// Checkpoint provides access to the checkpoint object for this world.
func (obj World) Checkpoint() Checkpoint {
return Checkpoint(obj)
}
// GetBlock returns the block type at the given coordi... | world.go | 0.807157 | 0.49048 | world.go | starcoder |
package graphblas
import (
"context"
"log"
"github.com/rossmerr/graphblas/constraints"
)
// DenseMatrix a dense matrix
type DenseMatrix[T constraints.Number] struct {
c int // number of rows in the sparse matrix
r int // number of columns in the sparse matrix
data [][]T
}
// NewDenseMatrix returns a De... | denseMatrix.go | 0.845688 | 0.686753 | denseMatrix.go | starcoder |
package field
type Type uint32
const (
TypeAny Type = 1 << iota // any
TypeArray // array
TypeNil // nil
TypeString // string
TypeBool // bool
TypeInt // int
TypeInt8 ... | field/type.go | 0.530236 | 0.50653 | type.go | starcoder |
package tetra3d
import (
"strconv"
"strings"
"github.com/kvartborg/vector"
)
// NodeType represents a Node's type. Node types are categorized, and can be said to extend or "be of" more general types.
// For example, a BoundingSphere has a type of NodeTypeBoundingSphere. That type can also be said to be NodeTypeBo... | node.go | 0.812049 | 0.663676 | node.go | starcoder |
package terminus
import (
"github.com/gdamore/tcell"
)
// IEntity is the interface through which custom
// implementations of Entity can be created
type IEntity interface {
Init()
Update(delta float64)
Draw()
SetScene(scene *Scene)
GetEntity() *Entity
}
// Entity represents a simple entity to be rendered
// to... | entity.go | 0.873943 | 0.435661 | entity.go | starcoder |
package main
import "math"
type Point []float64
/**
* Struct que define um grupo de pontos
* groups: slice representando o conjunto de grupos. Cada grupo é representado por uma slice de inteiros positivos que são os ids dos pontos mapesdos em points. O primeiro ponto de cada grupo é o lider do grupo.
* points: ma... | LP_TRABALHO_1_Rafael_Belmock_Pedruzzi/point.go | 0.510985 | 0.462352 | point.go | starcoder |
package goptimization
import (
"fmt"
"math"
"github.com/pkg/errors"
"gonum.org/v1/gonum/mat"
)
// Simplex Solve a linear problem wihtout strict inequality constraints.
// Input follows standard form:
// Maximize z = Σ(1<=j<=n) c_j*x_j
// Constraints:
// 1<=i<=m, Σ(1<=j<=n) a_i_j*x_j <= b_i
// 1<=j<=n x_j >= 0
/... | simplex.go | 0.643441 | 0.472562 | simplex.go | starcoder |
package iso8583
import (
"fmt"
"reflect"
"github.com/moov-io/iso8583/field"
)
type Message struct {
fields map[int]field.Field
spec *MessageSpec
data interface{}
fieldsMap map[int]struct{}
bitmap *field.Bitmap
}
func NewMessage(spec *MessageSpec) *Message {
fields := spec.CreateMessageField... | message.go | 0.650134 | 0.403978 | message.go | starcoder |
package nft
import (
"fmt"
"github.com/iov-one/weave"
"github.com/iov-one/weave/errors"
)
const UnlimitedCount = -1
type ApprovalMeta []Approval
type Approvals map[Action]ApprovalMeta
func (m ActionApprovals) Clone() ActionApprovals {
return m
}
func (m Approval) Clone() Approval {
return m
}
func (m Approv... | x/nft/approvals.go | 0.519765 | 0.427516 | approvals.go | starcoder |
package pipeline
import (
"errors"
"fmt"
)
type (
// Pipeline holds and runs intermediate actions, called "steps".
Pipeline struct {
steps []Step
context Context
beforeHooks []Listener
finalizer ResultHandler
options options
}
// Result is the object that is returned after each step an... | pipeline.go | 0.706494 | 0.438605 | pipeline.go | starcoder |
package main
import (
"errors"
"math/bits"
"sort"
"github.com/golang-collections/collections/queue"
"github.com/golang-collections/go-datastructures/bitarray"
"github.com/hillbig/rsdic"
)
func prevPowerOf2(n uint) int {
var u uint = 0
for n > 0 {
n >>= 1
u++
}
return 1 << (u - 1)
}
func nextPowerOf2(n... | k2tree.go | 0.636127 | 0.478529 | k2tree.go | starcoder |
package slice
// NewSliceSliceInt creates slice length n
func NewSliceSliceInt(n, m int) SliceSliceInt {
newSlice := make([]SliceInt, n)
for i := range newSlice {
newSlice[i] = NewSliceInt(m)
}
return newSlice
}
// Copy makes a new independent copy of slice
func (slice SliceSliceInt) Copy() SliceSliceInt {
ne... | datastructures/slice/gen-slice-2d.go | 0.777891 | 0.496277 | gen-slice-2d.go | starcoder |
package tcp
// Header represent a TCP packet, Due performance impact, don't use this type and its methods.
type Header struct {
// Indicate source port number of TCP packet as stream identifier
SourcePort uint16
// Indicate destination port of TCP packet as protocol identifier
DestinationPort uint16
// Represen... | tcp/header.go | 0.689619 | 0.410727 | header.go | starcoder |
package spf
import (
"strings"
"unicode/utf8"
)
// lexer represents lexing structure
type lexer struct {
start int
pos int
prev int
length int
input string
}
// lex reads SPF record and returns list of Tokens along with
// their modifiers and values. Parser should parse the Tokens and execute
// releva... | lexer.go | 0.562177 | 0.411347 | lexer.go | starcoder |
package tree
type Tree struct {
Root *TreeNode
}
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func NewTreeNode() *TreeNode {
return &TreeNode{}
}
func (t *Tree) Insert(val int) {
// Tree is empty
if t.Root == nil {
t.Root = &TreeNode{Val: val}
} else { // Insrt the element to the exi... | tree/tree.go | 0.664976 | 0.478224 | tree.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": {},
"l... | app/docs/docs.go | 0.588889 | 0.404919 | docs.go | starcoder |
package logx
import (
"fmt"
"os"
)
// Multi is a type of Log that is an alias for an array where each Log function will affect
// each Log instance in the array.
type Multi []Log
// Add appends the specified Log 'l' the Stack array.
func (m *Multi) Add(l Log) {
if l == nil {
return
}
*m = append(*m, l)
}
//... | v2/multiple.go | 0.584153 | 0.433022 | multiple.go | starcoder |
package timeutil
import (
"fmt"
"strings"
"time"
)
type periodicStart struct {
dayOfWeek int
hourOfDay int
minuteOfHour int
secondOfMinute int
}
// Periodic keeps track of a repeating period of time
type Periodic struct {
start *periodicStart
duration time.Duration
}
// Period is a span of ... | vendor/github.com/coreos/locksmith/pkg/timeutil/periodic.go | 0.772831 | 0.447098 | periodic.go | starcoder |
package meta
import (
"github.com/puppetlabs/wash/cmd/internal/find/parser/predicate"
)
/*
If metadata predicates are constructed on metadata values, then metadata
schema predicates are constructed on metadata schemas. Thus, one would expect
that metadata schema predicate parsing is symmetric with metadata predicate... | cmd/internal/find/primary/meta/schemaPredicate.go | 0.77081 | 0.508666 | schemaPredicate.go | starcoder |
package container
/**
* @Date: 2020/6/26 16:56
* @Description: 红黑树实现
红黑树的特性:
(1)每个节点或者是黑色,或者是红色。
(2)根节点是黑色。
(3)每个叶子节点(NIL)是黑色。 [注意:这里叶子节点,是指为空(NIL)的叶子节点!]
(4)如果一个节点是红色的,则它的子节点必须是黑色的。
(5)从一个节点到该节点的子孙节点的所有路径上包含相同数目的黑节点。
参考:
https://zh.wikipedia.org/wiki/%E7%BA%A2%E9%BB%91%E6%A0%91
https://www.cnblogs.com/skywang1234... | src/gostd/container/rbtree.go | 0.575111 | 0.544135 | rbtree.go | starcoder |
package network
import (
"encoding/json"
"fmt"
"testing"
"github.com/ingrammicro/cio/api/types"
"github.com/ingrammicro/cio/utils"
"github.com/stretchr/testify/assert"
)
// ListCertificatesMocked test mocked function
func ListCertificatesMocked(
t *testing.T,
loadBalancerID string,
certificatesIn []*types.... | api/network/certificates_api_mocked.go | 0.675765 | 0.425963 | certificates_api_mocked.go | starcoder |
package c80machine
import (
"github.com/reiver/go-frame256x288"
"github.com/reiver/go-palette2048"
"github.com/reiver/go-spritesheet8x8x256"
"github.com/reiver/go-spritesheet32x32x256"
"github.com/reiver/go-text32x36"
)
// Type represents a fantasy virtual machine.
type Type struct {
memory [memoryByteSize]uint... | machine/type.go | 0.79162 | 0.425068 | type.go | starcoder |
package views
import (
"github.com/pkg/errors"
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/iou/states"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state"
"github.com/hyperledger-labs/fabric-sma... | integration/fabric/iou/views/lender.go | 0.715225 | 0.482612 | lender.go | starcoder |
package tensor
import (
"github.com/pkg/errors"
"gorgonia.org/tensor/internal/storage"
)
func (e StdEng) Transpose(a Tensor, expStrides []int) error {
if !a.IsNativelyAccessible() {
return errors.Errorf("Cannot Transpose() on non-natively accessible tensor")
}
if dt, ok := a.(DenseTensor); ok {
e.denseTrans... | vendor/gorgonia.org/tensor/defaultengine_matop_transpose.go | 0.522933 | 0.429429 | defaultengine_matop_transpose.go | starcoder |
package parser
import (
"fmt"
"regexp"
"strconv"
c "opensource.go.fig.lu/oops2core/internal/common"
)
type armRegisters c.ARMRegisters
var crashRegexp = regexp.MustCompile(`(?sm)` +
` pc : \[<([[:xdigit:]]+)>\].*?` + // 1
` lr : \[<([[:xdigit:]]+)>\].*?` +
` psr: ([[:xdigit:]]+).*?` +
` sp : ([[:xdigit:]]+)... | internal/parser/parser.go | 0.557364 | 0.562958 | parser.go | starcoder |
package imagekit
import (
"bytes"
"fmt"
"image"
"image/gif"
"image/jpeg"
"image/png"
"github.com/disintegration/imaging"
)
// GetThumbnail creates an image in the given size, trying to encode it to the given max bytes
func GetThumbnail(imageBytes []byte, width, height int, maxBytes int) ([]byte, string, error... | imagekit/images.go | 0.693369 | 0.535098 | images.go | starcoder |
package chess
type Piece rune
const (
BlackRook Piece = '♜'
WhiteRook Piece = '♖'
BlackKnight Piece = '♞'
WhiteKnight Piece = '♘'
BlackKing Piece = '♚'
WhiteKing Piece = '♔'
BlackQueen Piece = '♛'
WhiteQueen Piece = '♕'
BlackBishop Piece = '♝'
WhiteBishop Piece = '♗'
BlackPawn Piece = '♟'
Whi... | chess/chess.go | 0.69987 | 0.428712 | chess.go | starcoder |
package longpalsubseq
import (
"fmt"
)
// I wish to avoid converting our integers to float64, just for the sake of using math.Max.
// Instead, let's create a simple helper function to return the max of two integers.
func max(x, y int) int {
if x > y {
return x
} else {
return y
}
}
func printLongestPalindrom... | longpalsubseq/longpalsubseq.go | 0.756627 | 0.65368 | longpalsubseq.go | starcoder |
package recursion
/*
# https://leetcode.com/explore/learn/card/recursion-ii/507/beyond-recursion/3006/
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as shown on a cit... | recursion/skyline.go | 0.72487 | 0.800068 | skyline.go | starcoder |
package label
import (
"bytes"
"fmt"
"sort"
"unicode/utf8"
"github.com/golang/protobuf/proto"
dto "github.com/prometheus/client_model/go"
"github.com/TyeMcQueen/go-lager"
"google.golang.org/api/monitoring/v3"
)
// A label.Set tracks the possible label names and seen label values for a
// metric.
type Set st... | mon2prom/label/label.go | 0.708515 | 0.472623 | label.go | starcoder |
package latlong
import (
"bytes"
"fmt"
"math"
"strconv"
"github.com/golang/geo/s1"
)
// Angle is Angle with precision.
type Angle struct {
radian s1.Angle
radianprec s1.Angle
}
// NewAngle is constructor for Angle
func NewAngle(degree, degreeprec float64) (a Angle) {
a.radian = s1.Angle(degree) * s1.Deg... | Angle.go | 0.815122 | 0.403244 | Angle.go | starcoder |
package dataset
import (
"github.com/clambin/simplejson/v3/query"
"time"
)
// Dataset is a convenience data structure to construct a SimpleJSON table response. Use this when you're adding
// data for a range of (possibly out of order) timestamps.
type Dataset struct {
data [][]float64
timestamps *Indexer[ti... | dataset/dataset.go | 0.826747 | 0.760139 | dataset.go | starcoder |
package numberz
import (
"github.com/modfin/henry/compare"
"github.com/modfin/henry/slicez"
"math"
"sort"
)
// Min returns the minimum of the number supplied
func Min[N compare.Number](a ...N) N {
return slicez.Min(a...)
}
// Max returns the maximum of the number supplied
func Max[N compare.Number](a ...N) N {
... | exp/numberz/numbers.go | 0.896523 | 0.72645 | numbers.go | starcoder |
package value
import (
"fmt"
"github.com/chewxy/hm"
"github.com/pkg/errors"
"gorgonia.org/tensor"
)
// DualValue ...
type DualValue struct {
Value
D Value // the derivative wrt to each input
}
// SetDeriv ...
func (dv *DualValue) SetDeriv(d Value) error {
if t, ok := d.(tensor.Tensor); ok && t.IsScalar() {
... | internal/value/dual.go | 0.584627 | 0.403391 | dual.go | starcoder |
package interval
import "time"
// Interval presentat time interval [From, To).
type Interval struct {
From time.Time
To time.Time
}
// Offset offsets time interval with the given years, months and days.
func (tv Interval) Offset(years, months, days int) Interval {
tv.From = tv.From.AddDate(years, months, days)... | interval.go | 0.913416 | 0.705316 | interval.go | starcoder |
package types
import (
"context"
"sync"
"github.com/dolthub/dolt/go/store/atomicerr"
"github.com/dolthub/dolt/go/store/d"
"github.com/dolthub/dolt/go/store/util/functions"
)
type DiffChangeType uint8
const (
DiffChangeAdded DiffChangeType = iota
DiffChangeRemoved
DiffChangeModified
)
type ValueChanged st... | go/store/types/ordered_sequences_diff.go | 0.565539 | 0.429848 | ordered_sequences_diff.go | starcoder |
package model
import (
"container/list"
)
// IndexOfEdge returns the index (starting at 0) of the edge in the array. If the edge is not in the array, -1 will be returned.
func IndexOfEdge(edges []CircuitEdge, edge CircuitEdge) int {
for index, e := range edges {
if e.Equals(edge) {
return index
}
}
return ... | model/utilsedge.go | 0.818773 | 0.783036 | utilsedge.go | starcoder |
package ring
import (
"fmt"
"math/bits"
"github.com/ldsec/lattigo/v2/utils"
)
// IsPrime applies a Miller-Rabin test on the given uint64 variable, returning true if the input is probably prime, and false otherwise.
func IsPrime(num uint64) bool {
if num < 2 {
return false
}
for _, smallPrime := range small... | ring/primes.go | 0.738103 | 0.42179 | primes.go | starcoder |
package main
import (
"math"
"math/rand"
"time"
)
type Boid struct {
position Vector2D
velocity Vector2D
id int
}
func createBoid(bid int) {
b := Boid{
position: Vector2D{x: rand.Float64() * screenWidth1, y: rand.Float64() * screenHeight1},
velocity: Vector2D{x: (rand.Float64() * 2) - 1.0, y: (rand.Float6... | boids/boid.go | 0.702224 | 0.493653 | boid.go | starcoder |
package iterator
import (
. "github.com/Wei-N-Ning/gotypes/pkg/option"
)
func parMapImpl[T, R any](iter Iterator[T], f func(x T) R) <-chan Option[R] {
ch := make(chan Option[R], 1024)
outIter := Map(iter, func(x T) Iterator[R] {
return OnceWith(func() R { return f(x) })
})
go func() {
defer close(ch)
outIt... | pkg/iterator/parmap.go | 0.639061 | 0.433022 | parmap.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.