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 unit
import (
"errors"
"math/big"
"strings"
)
var (
// precision required for big.Float.
// Use SetPrecision to change the value.
precision uint = 1024
)
// Unit store value in Wei unit.
// Wei should be always big.Int.
type Unit struct {
Value *big.Int
}
// String return value of Unit in string form... | unit.go | 0.81648 | 0.418222 | unit.go | starcoder |
package parser
import (
"bufio"
"io"
"regexp"
"strconv"
"strings"
)
// Result represents a test result.
type Result int
// Test result constants
const (
PASS Result = iota
FAIL
SKIP
)
// Report is a collection of package tests.
type Report struct {
Packages []Package
}
// Package contains the test results... | parser/parser.go | 0.582966 | 0.425546 | parser.go | starcoder |
package ag
import (
mat "github.com/nlpodyssey/spago/pkg/mat32"
"github.com/nlpodyssey/spago/pkg/mat32/rand"
"github.com/nlpodyssey/spago/pkg/ml/ag/fn"
)
/*
* Top-level convenience functions
*/
var globalGraph = NewGraph(Rand(rand.NewLockedRand(42)))
// GetGlobalGraph returns the global graph.
// Although tec... | pkg/ml/ag/global.go | 0.805403 | 0.416025 | global.go | starcoder |
package iso20022
// Breakdown of cash movements into a fund as a result of investment funds transactions, eg, subscriptions or switch-in.
type FundCashInBreakdown3 struct {
// Amount of cash flow in, expressed as an amount of money.
Amount *ActiveOrHistoricCurrencyAndAmount `xml:"Amt,omitempty"`
// Amount of the ... | FundCashInBreakdown3.go | 0.812123 | 0.453746 | FundCashInBreakdown3.go | starcoder |
package rgb8
// Conversion of different RGB colorspaces with their native illuminators (reference whites) to CIE XYZ scaled to [0, 1e9] and back.
// RGB values MUST BE LINEAR and in the nominal range [0, 2^8].
// XYZ values are usually in [0, 1e9] but may be slightly outside this interval.
// Ref.: [24]
// AdobeT... | i8/rgb8/wrappers.go | 0.877483 | 0.418756 | wrappers.go | starcoder |
// Commands similar to git, go tools and other modern CLI tools
// inspired by go, go-Commander, gh and subcommand
package cobra
import (
"fmt"
"io"
"reflect"
"strconv"
"strings"
"text/template"
)
var initializers []func()
// automatic prefix matching can be a dangerous thing to automatically enable in CLI t... | Godeps/_workspace/src/github.com/spf13/cobra/cobra.go | 0.662032 | 0.493958 | cobra.go | starcoder |
package main
import "fmt"
var helpDoc = `Usage: hvclient [options]
HVClient is a command-line interface to the GlobalSign Atlas Certificate
Management API (HVCA).
Access to HVCA requires an account. At the time of account setup, GlobalSign
will provide a mutual TLS certificate, an API key, and an API secret which ... | cmd/hvclient/help.go | 0.775775 | 0.418994 | help.go | starcoder |
package llrb
import "fmt"
type KeyT int64
const (
maxkey = KeyT(0x7fffffffffffffff)
minkey = -maxkey - 1
)
type node struct {
key KeyT
parent, left, right *node
black bool
}
type Tree struct {
root *node
}
func (t *Tree) Insert(k KeyT) {
t.root = insert(t.root, k)
t.root.pare... | Lecture 10- Red-black trees/src/llrb/llrb.go | 0.592784 | 0.454835 | llrb.go | starcoder |
package cryptypes
import (
"database/sql/driver"
"time"
)
// EncryptedTime supports encrypting Time data
type EncryptedTime struct {
Field
Raw time.Time
}
// Scan converts the value from the DB into a usable EncryptedTime value
func (s *EncryptedTime) Scan(value interface{}) error {
return decrypt(value.([]byte... | cryptypes/type_time.go | 0.816662 | 0.592667 | type_time.go | starcoder |
// Copyright 2016 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
// Package bip44 基于 BIP32 的系统,赋予树状结构中的各层特殊的意义。让同一个 seed 可以支援多币种、多帐户等。
package bip44
import (
bip32 "github.com/bnchain/bnchain/wallet/bipwallet/go-bip32"
bip39 "github.com/bnchain... | vendor/github.com/33cn/chain33/wallet/bipwallet/go-bip44/bip44.go | 0.542379 | 0.452475 | bip44.go | starcoder |
// Package bytes2 provides alternate implementations of functionality similar
// to go's bytes package.
package bytes2
import (
"fmt"
"io"
"unicode/utf8"
"github.com/xwb1989/sqlparser/dependency/hack"
)
// ChunkedWriter has the same interface as bytes.Buffer's write functions.
// It additionally provides a Rese... | vendor/github.com/xwb1989/sqlparser/dependency/bytes2/chunked_writer.go | 0.642545 | 0.419172 | chunked_writer.go | starcoder |
package puzzle
import (
"fmt"
"strings"
)
// LineWidth the number of cells in each row, column and cube
const LineWidth = 9
const cubeWidth = LineWidth / 3
// Puzzle Representation of a Sudoku puzzle
type Puzzle [LineWidth][LineWidth]Square
// GetRow returns a given row
func (p Puzzle) GetRow(i int) Set {
return... | cmd/go-sudoku/puzzle/puzzle.go | 0.7696 | 0.588121 | puzzle.go | starcoder |
package geosegmentize
import (
"github.com/cockroachdb/errors"
"github.com/twpayne/go-geom"
)
// MaxPoints is the maximum number of points segmentize is allowed to generate.
const MaxPoints = 16336
// SegmentizeGeom returns a modified geom.T having no segment longer
// than the given maximum segment length.
// se... | pkg/geo/geosegmentize/geosegmentize.go | 0.717111 | 0.626224 | geosegmentize.go | starcoder |
package network
import (
"math"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/graph"
)
// HubAuthority is a Hyperlink-Induced Topic Search hub-authority score pair.
type HubAuthority struct {
Hub float64
Authority float64
}
// HITS returns the Hyperlink-Induced Topic Search hub-authority scores for
//... | graph/network/hits.go | 0.712832 | 0.492859 | hits.go | starcoder |
package matrix
import (
"bytes"
"fmt"
"math"
"math/rand"
)
type Vector []float64
// ToMatrix wraps a 1-by-n matrix around the underlying data of a
// vector.
func (v Vector) ToMatrix(dim ...int) *Matrix {
if len(dim) == 0 {
return NewMatrix(1, len(v), v)
} else {
return NewMatrix(dim[0], len(v)/dim[0], v)
... | goml/matrix/vector.go | 0.716417 | 0.64944 | vector.go | starcoder |
package problem0715
import (
"sort"
)
// RangeModule 记录了跟踪的范围
type RangeModule struct {
ranges []*interval
}
// Constructor 返回新建的 RangeModule
func Constructor() RangeModule {
return RangeModule{ranges: make([]*interval, 0, 2048)}
}
// AddRange 添加追踪的返回
func (r *RangeModule) AddRange(left int, right int) {
it := ... | Algorithms/0715.range-module/range-module.go | 0.583203 | 0.461623 | range-module.go | starcoder |
package workspaceiface
import "github.com/orobix/azureml-go-sdk/workspace"
type WorkspaceAPI interface {
// GetDatastores Return the list of datastore of the AML Workspace provided as argument.
GetDatastores(resourceGroup, workspace string) ([]workspace.Datastore, error)
// GetDatastore Return the datastore with ... | workspace/workspaceiface/interface.go | 0.583678 | 0.469703 | interface.go | starcoder |
package day24
import (
"bufio"
"io"
"strconv"
"strings"
)
type Node struct {
ID int
PortA, PortB int
Edges []*Node
}
// CanConnect returns true if the two given Nodes can connect on either port.
func (n *Node) CanConnect(a *Node) bool {
return n.PortA == a.PortA ||
n.PortA == a.PortB ||
... | go/2017/day24/day24.go | 0.658088 | 0.489626 | day24.go | starcoder |
package paillier
import (
"crypto/rand"
"errors"
"io"
"math/big"
)
var one = big.NewInt(1)
// ErrMessageTooLong is returned when attempting to encrypt a message which is
// too large for the size of the public key.
var ErrMessageTooLong = errors.New("paillier: message too long for Paillier public key size")
// Gene... | chengtay/paillier/paillier.go | 0.742795 | 0.440289 | paillier.go | starcoder |
package util
import (
"math"
"math/rand"
)
/*
* Non-linear interpolations between 0 and 1. Clamping is enforced lest the result not
* be defined outside of [0,1]
*/
// NLerp returns the value of the supplied non-linear function at t. Note t is clamped to [0,1]
func NLerp(t, start, end float64, f NonLinear) floa... | util/nlerp.go | 0.809653 | 0.649328 | nlerp.go | starcoder |
package wire
import (
"BtcoinProject/chaincfg/chainhash"
"bytes"
"io"
"time"
)
//maxblockheaderpayload is the maximum number of bytes a blcok header can be
//version 4 bytes timestamp 4bytes + bit 4bytes + nonce 4bytes + prevblock and
//merkleroot hashes
const MaxBlockHeaderPayload = 16 + (chainhash.HashSize * 2)... | wire/blockheader.go | 0.771499 | 0.418281 | blockheader.go | starcoder |
package build
import (
"math"
"github.com/tang/go/amount"
"github.com/tang/go/network"
"github.com/tang/go/xdr"
)
const (
// MemoTextMaxLength represents the maximum number of bytes a valid memo of
// type "MEMO_TEXT" can be.
MemoTextMaxLength = 28
)
var (
// PublicNetwork is a mutator that configures the t... | build/main.go | 0.797004 | 0.441252 | main.go | starcoder |
package surface
import (
"github.com/jphsd/texture"
"github.com/jphsd/texture/color"
col "image/color"
"math"
"math/rand"
)
// Surface collects the ambient light, lights, a material, and normal map required to describe
// an area. If the normal map is nil then the standard normal is use {0, 0, 1}
type Surface st... | surface/surface.go | 0.730866 | 0.492676 | surface.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": {
... | src/services/shopper_service/pkg/api/docs/docs.go | 0.653127 | 0.401277 | docs.go | starcoder |
package rockredis
import (
"encoding/binary"
"errors"
"math"
)
const signMask uint64 = 0x8000000000000000
func encodeIntToCmpUint(v int64) uint64 {
return uint64(v) ^ signMask
}
func decodeCmpUintToInt(u uint64) int64 {
return int64(u ^ signMask)
}
// EncodeInt appends the encoded value to slice b and return... | rockredis/number.go | 0.892963 | 0.504639 | number.go | starcoder |
package schema
const ModelSchema = `{
"$id": "doc/spec/metadata.json",
"title": "Metadata",
"description": "Metadata concerning the other objects in the stream.",
"type": ["object"],
"properties": {
"service": {
"$id": "doc/spec/service.json",
"title": "Service",
"t... | model/metadata/generated/schema/metadata.go | 0.731922 | 0.529081 | metadata.go | starcoder |
package changes
// Move represents a shuffling of some elements (specified by Offset
// and Count) over to a different spot (specified by Distance, which
// can be negative to indicate a move over to the left).
type Move struct {
Offset, Count, Distance int
}
// Revert reverts the move.
func (m Move) Revert() Chan... | changes/move.go | 0.853027 | 0.574037 | move.go | starcoder |
package digits
import (
"fmt"
"strconv"
"strings"
)
const bubblesBySegment = 15
// ParseDigits returns a 3D array of integers which represents the segments of the first circle
// then the different lines of a segment and finally the points which represents the decimals.
func ParseDigits(number string) [][][]int {... | digits/parser.go | 0.743541 | 0.55652 | parser.go | starcoder |
"Space-Efficient Online Computation of Quantile Summaries" (<NAME> 2001)
http://infolab.stanford.edu/~datar/courses/cs361a/papers/quantiles.pdf
This implementation is backed by a skiplist to make inserting elements into the
summary faster. Querying is still O(n).
*/
package gk
// Stream is a quantile summary
type... | gk.go | 0.858659 | 0.512632 | gk.go | starcoder |
package knn
import (
"errors"
"fmt"
"github.com/gonum/matrix"
"github.com/sjwhitworth/golearn/base"
"github.com/sjwhitworth/golearn/kdtree"
"github.com/sjwhitworth/golearn/metrics/pairwise"
"github.com/sjwhitworth/golearn/utilities"
"gonum.org/v1/gonum/mat"
)
// A KNNClassifier consists of a data matrix, ass... | knn/knn.go | 0.714628 | 0.408011 | knn.go | starcoder |
package criteria
// Expression is used to express conditions for selecting an entity
type Expression interface {
// Accept calls the visitor callback of the appropriate type
Accept(visitor ExpressionVisitor) interface{}
// SetAnnotation puts the given annotation on the expression
SetAnnotation(key string, value in... | criteria/criteria.go | 0.906855 | 0.453322 | criteria.go | starcoder |
package transform
import (
"errors"
"github.com/dolthub/go-mysql-server/sql"
)
// Expr applies a transformation function to the given expression
// tree from the bottom up. Each callback [f] returns a TreeIdentity
// that is aggregated into a final output indicating whether the
// expression tree was changed.
fun... | sql/transform/expr.go | 0.763043 | 0.482734 | expr.go | starcoder |
package bigquery
import (
"errors"
"fmt"
"golang.org/x/net/context"
)
// A pageFetcher returns a page of rows, starting from the row specified by token.
type pageFetcher interface {
fetch(ctx context.Context, s service, token string) (*readDataResult, error)
}
// Iterator provides access to the result of a Big... | vendor/cloud.google.com/go/bigquery/iterator.go | 0.701815 | 0.429848 | iterator.go | starcoder |
package cmd
const addFlagsStr = `-n
--dry-run
Don’t actually add the file(s), just show if they exist and/or will be ignored.
-v
--verbose
Be verbose.
-f
--force
Allow adding otherwise ignored files.
-i
--interactive
Add modified contents in the working tree interactively to the index. Optional path arguments may b... | cmd/flags_man_pages.go | 0.683631 | 0.568655 | flags_man_pages.go | starcoder |
package data
import (
"fmt"
"time"
)
// Condition defines parameters to look for in a point or a schedule.
type Condition struct {
// general parameters
ID string
Description string
ConditionType string
MinTimeActive float64
Active bool
// used with point value rules
NodeID stri... | data/rule.go | 0.726814 | 0.475484 | rule.go | starcoder |
package roman_kachanovsky
type Node struct{
left *Node
right *Node
value int
}
type Tree struct{
root *Node
size int
}
func (tree *Tree) Size() int {
return tree.size
}
func (tree *Tree) Root() *Node {
return tree.root
}
// Constructor
func NewTree() *Tree {
tree := new(Tree)
tree.size = 0
return tree
}
... | Binary_Search_Tree/Go/roman_kachanovsky/binary_search_tree.go | 0.742982 | 0.490724 | binary_search_tree.go | starcoder |
package matrix
import (
"github.com/pingcap/tidb-dashboard/pkg/keyvisual/decorator"
)
// Axis stores consecutive buckets. Each bucket has StartKey, EndKey, and some statistics. The EndKey of each bucket is
// the StartKey of its next bucket. The actual data structure is stored in columns. Therefore satisfies:
// le... | pkg/keyvisual/matrix/axis.go | 0.786787 | 0.49231 | axis.go | starcoder |
package relations
import (
"bytes"
"io"
"sort"
"github.com/oleiade/lane"
"github.com/s2gatev/hcache"
)
// pair is used in the construction of the subsequential transducer.
// It contains a transducer state and the symbols that remain to be
// added to the output.
type pair struct {
state *tState
remaining... | regular_relation.go | 0.733833 | 0.426859 | regular_relation.go | starcoder |
package pinata
import (
"bytes"
"fmt"
"strings"
)
// Stick offers methods of hitting the Pinata and extracting its goodness.
type Stick interface {
// Error returns the first error encountered or nil if all operations so far
// were successful.
Error() error
// ClearError clears the error and returns it. If t... | pinata.go | 0.628179 | 0.539893 | pinata.go | starcoder |
package fp
import ()
// MapString make a map from the current slice to a new slice using the function
func MapString(f func(string, int) string, input []string) (output []string) {
output = make([]string, 0)
for idx, data := range input {
output = append(output, f(data, idx))
}
return
}
// MapInt make a map f... | functional/map.go | 0.808974 | 0.44559 | map.go | starcoder |
package sprite
const Font_a = `
X
X X
XXX
X X
X X`
const Font_b = `
XX
X X
XX
X X
XX`
const Font_c = `
XX
X
X
X
XX`
const Font_d = `
XX
X X
X X
X X
XXX`
const Font_e = `
XXX
X
XX
X
XXX`
const Font_f = `
XXX
X
XX
X
X`
const Font_g = `
XX
X
X
X X
XXX`
const Font_h = `
X X
X X
XXX
X X
X X`
const Font_i = `
XX... | font_paku.go | 0.706798 | 0.442757 | font_paku.go | starcoder |
package shp
import (
"github.com/everystreet/go-geojson/v2"
"github.com/golang/geo/r2"
)
// ShapeType represents a shape type in the shp file.
type ShapeType uint
// Valid shape types. All shapes in a single shp file must be of the same type.
const (
// Null shapes are allowed in any shp file, regardless of the t... | shp/shape.go | 0.796015 | 0.701138 | shape.go | starcoder |
package sampler
import (
"time"
metrics "github.com/rcrowley/go-metrics"
)
type (
// DurationSampler is the sampler for sampling duration.
DurationSampler struct {
sample metrics.Sample
}
)
func nanoToMilli(f float64) float64 {
return f / 1000000
}
// NewDurationSampler creates a DurationSampler.
func NewD... | pkg/util/sampler/sampler.go | 0.881347 | 0.483648 | sampler.go | starcoder |
package help
var HelpMessages = map[string]Help{
"help": Help{
Name: "/help",
ShortDesc: "command help",
Synopsis: map[string]string{
"": "show this help",
"<command>": "show help for <command> (without the `/`)",
},
Overview: "Give help on an internal command",
Description: "Find ... | help/builtins.go | 0.614741 | 0.437824 | builtins.go | starcoder |
package array
/*
# Minimum Window Substring
# https://leetcode.com/explore/interview/card/top-interview-questions-hard/116/array-and-strings/838/
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
Example:
Input: S = "ADOBECODEBANC", T = "AB... | interview/hard/array/string.go | 0.850748 | 0.4953 | string.go | starcoder |
// Package pipeline implements a processing pipeline with multiple steps.
package pipeline
import (
"errors"
"fmt"
. "github.com/abitofhelp/go-helpers/string"
. "github.com/abitofhelp/go-helpers/time"
"strings"
"sync"
"time"
)
// Type Status indicates the current state of the pipeline.
type Status int
// Con... | pipeline/pipeline.go | 0.832305 | 0.508971 | pipeline.go | starcoder |
package types
import (
"sync"
"github.com/attic-labs/noms/go/chunks"
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/hash"
"github.com/attic-labs/noms/go/util/sizecache"
)
// ValueReader is an interface that knows how to read Noms Values, e.g. datas/Database. Required to avoid import cycle bet... | go/types/value_store.go | 0.649467 | 0.537406 | value_store.go | starcoder |
package statictimeseries
import (
"fmt"
"sort"
"time"
"github.com/grokify/gotilla/sort/sortutil"
"github.com/grokify/gotilla/time/month"
"github.com/grokify/gotilla/time/timeutil"
"github.com/grokify/gotilla/type/maputil"
"github.com/pkg/errors"
)
type DataSeries struct {
SeriesName string
ItemMap map[s... | data/statictimeseries/data_series.go | 0.564339 | 0.453322 | data_series.go | starcoder |
package agozon
var LocaleJPMap = map[string]LocaleSearchIndex{
"All": LocaleJP.All, "Apparel": LocaleJP.Apparel, "Appliances": LocaleJP.Appliances, "Automotive": LocaleJP.Automotive, "Baby": LocaleJP.Baby,
"Beauty": LocaleJP.Beauty, "Blended": LocaleJP.Blended, "Books": LocaleJP.Books, "Classical": LocaleJP.Classica... | LocaleJP.go | 0.525125 | 0.420243 | LocaleJP.go | starcoder |
package engine
import (
"fmt"
"math"
"gonum.org/v1/gonum/mat"
)
type Transform struct {
data mat.Matrix
}
func NewTransform() Transform {
return Transform{
mat.NewDense(4, 4, []float64{
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
}),
}
}
func (transform Transform) Transpose() Transform {
... | pkg/engine/transform.go | 0.624523 | 0.616647 | transform.go | starcoder |
package levy
import (
"math"
"fmt"
)
// Fast, accurate algorithm for numerical simulation of Levy stable stochastic processes
// <NAME>. 1994
type Levy struct {}
func NewLevy() *Levy {
return new(Levy)
}
// Stochastic variable
func (levy Levy) Vf(alpha float64) (float64, error) {
var vf, x, y float64
... | levy/levy.go | 0.730866 | 0.54577 | levy.go | starcoder |
package iso20022
// Amount of money due to a party as compensation for a service.
type Commission10 struct {
// Service for which the commission is asked or paid.
Type *CommissionType6Code `xml:"Tp,omitempty"`
// Service for which the commission is asked or paid.
ExtendedType *Extended350Code `xml:"XtndedTp,omit... | Commission10.go | 0.736306 | 0.427098 | Commission10.go | starcoder |
package executor
import (
"unsafe"
jsoniter "github.com/json-iterator/go"
)
// OrderedMapItem is a key-value pair for an item in an OrderedMap.
type OrderedMapItem struct {
Key string
Value interface{}
}
// OrderedMap represents a map that maintains the order of its key-value pairs. It's more or less
// just ... | graphql/executor/ordered_map.go | 0.731826 | 0.431644 | ordered_map.go | starcoder |
package types
import (
"bytes"
"fmt"
"regexp"
"sort"
"strings"
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/hash"
)
var EmptyStructType = MakeStructType("", []string{}, []*Type{})
var EmptyStruct = Struct{ValueSlice{}, EmptyStructType, &hash.Hash{}}
type StructData map[string]Value
type... | go/types/struct.go | 0.595963 | 0.431225 | struct.go | starcoder |
package schema
import (
"errors"
"strconv"
)
type Thermal struct {
// The type of a resource. [RO]
OdataType string `json:"@odata.type"`
// The identifier that uniquely identifies the Resource within
// the collection of similar Resources. [RO]
Id string `json:"Id"`
// The name of the Resource or array memb... | cmd/pemgr-server/schema/chassis-thermal.go | 0.735926 | 0.463019 | chassis-thermal.go | starcoder |
package doctor
import (
"fmt"
"github.com/pkg/errors"
"github.com/lieut-data/go-moneywell/api"
"github.com/lieut-data/go-moneywell/api/money"
)
const (
// ProblemNotFullySplit identifies a split transaction whose bucketed children do not sum
// to the transaction amount. This leads to an imbalance that doesn'... | internal/doctor/problems.go | 0.64969 | 0.440469 | problems.go | starcoder |
package iso20022
// Parameters applied to the settlement of a security transfer.
type DeliverInformation16 struct {
// Party that delivers (transferor) securities to the receiving agent (transferee).
Transferor *PartyIdentification70Choice `xml:"Trfr,omitempty"`
// Account from which the securities are to be deli... | DeliverInformation16.go | 0.773131 | 0.46478 | DeliverInformation16.go | starcoder |
package db
import (
"00-newapp-template/pkg/acme"
)
// SimpleDB is two arrays holding Gophers and Things
type SimpleDB struct {
gg []acme.Gopher
tt []acme.Thing
}
// NewSimpleDB provides the most basic 'mock' data possible for Gophers and Things
func NewSimpleDB() (s SimpleDB) {
s.gg = []acme.Gopher{
{ID: "1",... | 00-newapp-template/pkg/server/db/db.go | 0.526586 | 0.424591 | db.go | starcoder |
package tools
import (
"math"
"strings"
)
// CalculateAge to year
func CalculateAge(age float64, unit string) float64 {
calAge := age
if unit != "year" {
switch unit {
case "month":
calAge = age / 12
case "week":
calAge = age / 52
case "day":
calAge = age / 365
}
}
return math.Ceil(calAge*10... | tools/calculate.go | 0.727685 | 0.644225 | calculate.go | starcoder |
package pinapi
import (
"encoding/json"
)
// SpecialsFixturesContestant struct for SpecialsFixturesContestant
type SpecialsFixturesContestant struct {
// Contestant Id.
Id *int64 `json:"id,omitempty"`
// Name of the contestant.
Name *string `json:"name,omitempty"`
// Rotation Number.
RotNum *int `json:"rotNum,... | pinapi/model_specials_fixtures_contestant.go | 0.755907 | 0.50653 | model_specials_fixtures_contestant.go | starcoder |
package raytracer
import (
"math"
)
// Vector definition.
type Vector [4]float64
func sameSideTest(v1, v2 Vector, shifting float64) bool {
return dot(v1, v2)-shifting > -DIFF
}
func subVector(v1, v2 Vector) Vector {
return Vector{
v1[0] - v2[0],
v1[1] - v2[1],
v1[2] - v2[2],
1,
}
}
func psubVector(v1, ... | raytracer/vector.go | 0.762247 | 0.678813 | vector.go | starcoder |
package tree
import (
"errors"
)
// Tree is the structure of tree
type Tree struct {
roots []*Node
Style *Style
lastIndent int
lastNodes []*Node
}
// GetRoots return the root node list of certain node
func (t *Tree) GetRoots() ([]*Node, error) {
if len(t.roots) == 0 {
return nil, errors.New("No root nodes ... | tree.go | 0.634543 | 0.402333 | tree.go | starcoder |
package api
import (
"fmt"
)
type RuleKey string
/*
A Rule defines a mapping from a list of Methods and Matches to an AllConstraints
struct. A Rule applies to a request if one of the Methods and all of the Matches
apply.
If a Rule applies, the constraints inferred from the Matches should be merged
with each o... | vendor/github.com/turbinelabs/api/rule.go | 0.814901 | 0.550184 | rule.go | starcoder |
package controller
import (
"strings"
)
func GetScadaOEMHeader() (headerResult []string, fieldResult []string) {
oldHeader := `AI intern ActivPower
AI intern WindSpeed
AI intern NacellePos
AI intern WindDirection
AI intern PitchAngle1
AI intern PitchAngle2
AI intern PitchAngle3
C intern SpeedGenerator
C intern Spee... | web/controller/databrowserHeaderList.go | 0.709724 | 0.401277 | databrowserHeaderList.go | starcoder |
package impl
import (
"fmt"
"reflect"
"strings"
sqldb "github.com/domonda/go-sqldb"
)
// Update table rows(s) with values using the where statement with passed in args starting at $1.
func Update(conn sqldb.Connection, table string, values sqldb.Values, where, argFmt string, args []interface{}) error {
if len(v... | impl/update.go | 0.655777 | 0.444022 | update.go | starcoder |
package conf
// Uint32Var defines a uint32 flag and environment variable with specified name, default value, and usage string.
// The argument p points to a uint32 variable in which to store the value of the flag and/or environment variable.
func (c *Configurator) Uint32Var(p *uint32, name string, value uint32, usage ... | value_uint32.go | 0.761893 | 0.647979 | value_uint32.go | starcoder |
package tensor
import (
"fmt"
"math"
"reflect"
)
type Tensor struct {
number interface{}
value reflect.Value
dtype reflect.Type
shape []int
name string
errors RaiseError{}
}
func NewTensor(a interface{}) *Tensor {
val := reflect.ValueOf(a)
var shape []int
typ := val.Type()
for typ.Kind() == reflect... | tensor/tensor.go | 0.680135 | 0.498901 | tensor.go | starcoder |
package bytealg
const (
// Index can search any valid length of string.
MaxLen = int(-1) >> 31
MaxBruteForce = MaxLen
)
// Compare two byte slices.
// Returns -1 if the first differing byte is lower in a, or 1 if the first differing byte is greater in b.
// If the byte slices are equal, returns 0.
// If th... | src/internal/bytealg/bytealg.go | 0.812123 | 0.518973 | bytealg.go | starcoder |
package gorgonia
import (
"fmt"
"hash"
"sort"
"github.com/chewxy/hm"
"github.com/pkg/errors"
"gorgonia.org/tensor"
)
type sparsemaxOp struct {
axis int
}
func newSparsemaxOp(axes ...int) *sparsemaxOp {
axis := -1
if len(axes) > 0 {
axis = axes[0]
}
sparsemaxop := &sparsemaxOp{
axis: axis,
}
retur... | op_sparsemax.go | 0.730674 | 0.537709 | op_sparsemax.go | starcoder |
package timeseries
import (
"errors"
"fmt"
"math"
"time"
)
var (
EmptyTimeSeriesErr = errors.New("no records in timeseries")
)
// Record represents a point in the timeseries, currently holds only a float
// value
type Record struct {
Timestamp int64
Value float64
}
// TimeSeries represents a time series... | timeseries/timeseries.go | 0.696784 | 0.457016 | timeseries.go | starcoder |
package blur
import (
"errors"
"github.com/Ernyoke/Imger/convolution"
"github.com/Ernyoke/Imger/padding"
"image"
"math"
)
// BoxGray applies average blur to a grayscale image. The amount of bluring effect depends on the kernel size, where
// both width and height can be specified. The anchor point specifies a po... | blur/blur.go | 0.914539 | 0.726668 | blur.go | starcoder |
package forGraphBLASGo
import "github.com/intel/forGoParallel/pipeline"
type vectorSelect[D, Ds any] struct {
op IndexUnaryOp[bool, D, Ds]
u *vectorReference[D]
value Ds
}
func newVectorSelect[D, Ds any](op IndexUnaryOp[bool, D, Ds], u *vectorReference[D], value Ds) computeVectorT[D] {
return vectorSelect... | functional_Vector_ComputedSelect.go | 0.642545 | 0.632687 | functional_Vector_ComputedSelect.go | starcoder |
package transform
type WHT32 struct {
fScale uint
iScale uint
data []int
}
// For perfect reconstruction, forward results are scaled by 16*sqrt(2) unless
// the parameter is set to false (scaled by sqrt(2), in which case rounding
// may introduce errors)
func NewWHT32(scale bool) (*WHT32, error) {
this := new(W... | go/src/kanzi/transform/WHT32.go | 0.654232 | 0.459379 | WHT32.go | starcoder |
package rando
import (
"errors"
"math/rand"
"time"
)
// Random provides convenient utility funcs for generating random data
type Random struct {
rand *rand.Rand
}
// NewRandom returns a new Random seeded with the current UTC time converted to nanoseconds.
func NewRandom() *Random {
return NewSeededRandom(time.N... | rando.go | 0.779322 | 0.445047 | rando.go | starcoder |
package recsplit
import (
"encoding/binary"
"fmt"
"math"
"math/bits"
"github.com/ledgerwatch/erigon-lib/etl"
"github.com/spaolacci/murmur3"
)
const RecSplitLogPrefix = "recsplit"
const MaxLeafSize = 24
/** <NAME>'s (http://zimbry.blogspot.com/2011/09/better-bit-mixing-improving-on.html)
* 13th variant of th... | recsplit/recsplit.go | 0.755727 | 0.440229 | recsplit.go | starcoder |
// Package inject provides a simple dependency injector.
package inject
import (
"errors"
"reflect"
)
type Injector struct {
instances map[reflect.Type]reflect.Value
factories map[reflect.Type]reflect.Value
}
func NewInjector() *Injector {
return &Injector{
make(map[reflect.Type]reflect.Value),
make(map[re... | pkg/inject/inject.go | 0.707101 | 0.417509 | inject.go | starcoder |
package io
import (
"fmt"
"reflect"
)
type AnySet struct {
orderedElems interface{}
mappedElems interface{}
}
func NewAnySet(iElems interface{}) (as *AnySet, err error) {
/*
Generic Set
Input should be a slice of any hashable type
*/
refValue := reflect.ValueOf(iElems)
if !(refValue.Kind() == reflect.S... | utils/io/generics.go | 0.657538 | 0.439026 | generics.go | starcoder |
package draw
import (
"fmt"
"math"
"strings"
"unicode/utf8"
"github.com/nsf/termbox-go"
)
// Bordered game window area size.
const gameBoyWidth, gameBoyHeight = 96, 24
// Margins inside the bordered game window.
const marginX, marginY = 3, 1
// Draw is a general function for drawing to the terminal.
// The te... | pkg/client/draw/draw_lib.go | 0.788543 | 0.452173 | draw_lib.go | starcoder |
package clock
type VectorClock map[string]uint64
// Compare determines the relationship between two vector clocks.
// a may be less than b, equal to b, greater than b, or there may be no comparison.
func (a VectorClock) Compare(b VectorClock) CompareResult {
// Determine if the scalars are all pairwise equal, less t... | pkg/clock/vector.go | 0.84338 | 0.612831 | vector.go | starcoder |
package goanda
// Supporting OANDA docs - http://developer.oanda.com/rest-live-v20/instrument-ep/
import (
"errors"
"strconv"
"time"
)
// GranularityFromDuration tries to find a granularity for the given duration
func GranularityFromDuration(d time.Duration) (Granularity, error) {
if _, ok := candlestickGranular... | instrument.go | 0.727492 | 0.467393 | instrument.go | starcoder |
package ggol
import (
"sync"
)
// "T" in the Game interface represents the type of unit, it's defined by you.
type Game[T any] interface {
// ResetUnits all units with initial unit.
ResetUnits()
// Generate next units, the way you generate next units will be depending on the NextUnitGenerator function
// you pas... | ggol.go | 0.708717 | 0.541227 | ggol.go | starcoder |
package gpsabl
import (
"time"
)
// Copyright 2019 by <EMAIL>. All
// rights reserved. Use of this source code is governed
// by a BSD-style license that can be found in the
// LICENSE file.
// TrackSummary - the struct to store track statistic data
type TrackSummary struct {
Distance float64
Horizontal... | src/tobi.backfrak.de/internal/gpsabl/Track.go | 0.896382 | 0.525125 | Track.go | starcoder |
Package binding defines interfaces for protocol bindings.
NOTE: Most applications that emit or consume events should use the ../client
package, which provides a simpler API to the underlying binding.
The interfaces in this package provide extra encoding and protocol information
to allow efficient forwarding and end-... | vendor/github.com/cloudevents/sdk-go/v2/binding/doc.go | 0.865622 | 0.577078 | doc.go | starcoder |
package circularqueue
import "errors"
const (
initSize = 32
)
// ErrEmptyQueue tells you a CircularQueue is empty.
var ErrEmptyQueue = errors.New("CircularQueue is empty")
// CircularQueue allocate new memory when necessary.
type CircularQueue struct {
buffer []interface{}
readableIndex int
writableIndex... | circularqueue.go | 0.686685 | 0.425009 | circularqueue.go | starcoder |
package bufio
import (
"bytes"
"io"
)
// LimitedReader implements a limited io.WriterTo.
type LimitedReader struct {
*Reader
N int64
}
// Read reads data into p.
// It returns the number of bytes read into p.
// The bytes are taken from at most one Read on the underlying Reader,
// hence n may be less than len(p... | bufio/reader.go | 0.622 | 0.430088 | reader.go | starcoder |
package wspr
import (
"context"
"errors"
"fmt"
"log"
"strings"
"time"
)
// Send transmits the given transmission using the given functions to activate the transmitter and to transmit the symbol.
func Send(ctx context.Context, activateTransmitter func(bool), transmitSymbol func(Symbol), transmission Transmission... | wspr/wspr.go | 0.618896 | 0.403214 | wspr.go | starcoder |
package main
import (
"math"
)
type Rnd interface {
Float64() float64
}
/***********************
* Vec3
************************/
// Vec3 defines a vector in 3D space
type Vec3 struct {
X, Y, Z float64
}
// Scale scales the vector by the value (return a new vector)
func (v Vec3) Scale(t float64) Vec3 {
return... | model.go | 0.854627 | 0.615839 | model.go | starcoder |
package binary
import (
"fmt"
"image/color"
"reflect"
"github.com/flywave/gltf"
)
// MakeSliceBuffer returns the slice type associated with c and t and with the given element count.
// If the buffer is an slice which type matches with the expected by the acr then it will
// be used as backing slice.
func MakeSli... | binary/slice.go | 0.643665 | 0.435781 | slice.go | starcoder |
package tokens
import (
"fmt"
"strings"
"github.com/pulumi/pulumi/pkg/util/contract"
)
// tokenBuffer is a parseable token buffer that simply carries a position.
type tokenBuffer struct {
Tok Type
Pos int
}
func newTokenBuffer(tok Type) *tokenBuffer {
return &tokenBuffer{
Tok: tok,
Pos: 0,
}
}
func (b ... | pkg/tokens/decors.go | 0.763131 | 0.476214 | decors.go | starcoder |
package solutions
type graphNode struct {
parentNode *graphNode
word string
}
type void struct{}
var member void
var possibleStates = []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
func findLadders(startWord str... | solutions/126.go | 0.736021 | 0.481941 | 126.go | starcoder |
package object
import (
"github.com/gopherd/three/core"
"github.com/gopherd/three/driver/renderer"
"github.com/gopherd/three/geometry"
)
type CameraType int
const (
PerspectiveCameraType CameraType = iota
OrthographicCameraType
)
// Camera represents a camera object
type Camera interface {
Object
CameraType... | object/camera.go | 0.601125 | 0.506652 | camera.go | starcoder |
package key
import (
"fmt"
pb "github.com/youtube/vitess/go/vt/proto/topodata"
)
// This file contains the functions to convert topo data to and from proto3
// KeyspaceIdTypeToProto translates a KeyspaceIdType to proto, or panics
func KeyspaceIdTypeToProto(k KeyspaceIdType) pb.KeyspaceIdType {
switch k {
case ... | go/vt/key/proto3.go | 0.578329 | 0.409988 | proto3.go | starcoder |
package learnML
import (
"../matrix"
"../rand"
"math"
)
type SupervisedLearner interface {
// Returns the name of this learner
Name() string
// Train this learner
Train(features, labels *matrix.Matrix, paras ...float64)
// Partially train using a single pattern
TrainIncremental(feat, lab matrix.Vector)
/... | goml/learnML/supervised.go | 0.630116 | 0.634076 | supervised.go | starcoder |
package randomness
import (
"crypto/rand"
"hash"
"math/big"
)
// GenerateSecureRandom receives the number of desired randomness bytes and returns a slice of that size from Crypto.Rand
func GenerateSecureRandom(keySize int) ([]byte, error) {
k := make([]byte, keySize)
_, err := rand.Read(k)
if err != nil {
... | randomness/csprng.go | 0.860428 | 0.45641 | csprng.go | starcoder |
package query
import (
"connectordb/datastream"
"errors"
)
//Operator is an interface describing the functions that are needed for query. The standard operator implements these,
// but for import sake and for simplified mocking, only the necessary interface is shown here
type Operator interface {
GetStreamIndexRan... | src/connectordb/query/query.go | 0.761538 | 0.464962 | query.go | starcoder |
package network
import (
"bytes"
"fmt"
"github.com/rqme/neat"
)
type Neuron struct {
neat.NeuronType
neat.ActivationType
X, Y float64 // Hint at where neuron might be positioned in a 2D representation
}
type Neurons []Neuron
type Synapse struct {
Source, Target int // Indexes of source and target neurons
W... | network/classic.go | 0.676727 | 0.461502 | classic.go | starcoder |
package table
import (
"github.com/shopspring/decimal"
)
// CellType is the type of a table cell.
type CellType int
// Table is a matrix of table cells.
type Table struct {
columns []int
rows []*Row
}
// New creates a new table with column groups.
func New(groups ...int) *Table {
var columns []int
for grou... | lib/table/table.go | 0.783202 | 0.409339 | table.go | starcoder |
package timecode
import (
"fmt"
"time"
)
// Range is a pair of decimal seconds defining a time interval
// starting at Range[0] and ending at Range[1]
type Range [2]float64
// Canon returns the range in proper order, where r[0] <= r[1]
func (r Range) Canon() Range {
if r[0] > r[1] {
r[0], r[1] = r[1], r[0]
}
... | vendor/github.com/cbsinteractive/pkg/timecode/range.go | 0.69285 | 0.492981 | range.go | starcoder |
package text
import (
"bytes"
)
//--------------------------------------------------------------------------------------------------
/*
OTransform - A representation of a transformation relating to a leaps document. This can either be a
text addition, a text deletion, or both.
*/
type OTransform struct {
Position ... | src/github.com/jeffail/leaps/lib/text/transforms.go | 0.746971 | 0.577317 | transforms.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// WorkbookChartAxes
type WorkbookChartAxes struct {
Entity
// Represents the category axis in a chart. Read-only.
categoryAxis *WorkbookChartAxis;
... | models/microsoft/graph/workbook_chart_axes.go | 0.706393 | 0.412826 | workbook_chart_axes.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.