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 mocks
import (
common "github.com/incognitochain/incognito-chain/common"
incdb "github.com/incognitochain/incognito-chain/incdb"
incognitokey "github.com/incognitochain/incognito-chain/incognitokey"
mock "github.com/stretchr/testify/mock"
multiview "github.com/incognitochain/incognito-chain/multiview"... | consensus_v2/blsbft/mocks/Chain.go | 0.751375 | 0.432183 | Chain.go | starcoder |
package fs
// EntryID is the ID of a file system entry.
type EntryID interface {
// ID gets the actual integer value of the EntryID.
ID() int
// Kind distinguishes between a document and a folder's IDs.
Kind() EntryKind
}
// EntryKind determines the type of entry.
type EntryKind byte
const (
// DocumentKind si... | fs/entries.go | 0.634204 | 0.451992 | entries.go | starcoder |
package p256
import (
"math/big"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
)
type MyBitCurve struct {
secp256k1.BitCurve
}
// Add returns the sum of (x1,y1) and (x2,y2)
func (BitCurve *MyBitCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int) {
z := new(big.Int).SetInt64(1)
return BitCurve.affineF... | crypto/p256/mycurve.go | 0.787359 | 0.512754 | mycurve.go | starcoder |
package mapping
import (
"bytes"
"errors"
"fmt"
"math"
"github.com/DataDog/sketches-go/ddsketch/pb/sketchpb"
)
// An IndexMapping that is memory-optimal, that is to say that given a targeted relative accuracy, it
// requires the least number of indices to cover a given range of values. This is done by logarith... | vendor/github.com/DataDog/sketches-go/ddsketch/mapping/logarithmic_mapping.go | 0.84869 | 0.429848 | logarithmic_mapping.go | starcoder |
package arangodb
import (
"context"
"github.com/arangodb/go-driver/v2/arangodb/shared"
"github.com/arangodb/go-driver/v2/connection"
)
type CollectionDocumentCreate interface {
// CreateDocument creates a single document in the collection.
// The document data is loaded from the given document, the document m... | v2/arangodb/collection_documents_create.go | 0.73412 | 0.412471 | collection_documents_create.go | starcoder |
package ui
import (
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
"pool-boy/core"
"strconv"
"strings"
"time"
)
type EventTable struct {
tview.TableContentReadOnly
events *[]core.PoolEvent
}
// GetCell Return the cell at the given position or nil if there is no cell. The
//row and column arguments sta... | ui/table.go | 0.593491 | 0.425247 | table.go | starcoder |
package basic
import "strings"
// PMap2Test applies the function(1st argument) on each item of the list and returns new list
func PMap2Test() string {
return `
func TestPmap<FTYPE>2(t *testing.T) {
// Test : square the list
var v1 <TYPE> = 1
var v2 <TYPE> = 2
var v3 <TYPE> = 3
var v4 <TYPE> = 4
var v9 <TYPE> =... | internal/template/basic/pmapptrtest.go | 0.766381 | 0.566558 | pmapptrtest.go | starcoder |
package resolvers
import (
"fantom-api-graphql/internal/repository"
"fmt"
"math/big"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
)
// UniswapPair represents a pair of tokens in Uniswap protocol.
type UniswapPair struct {
repo repository.Repository
P... | internal/graphql/resolvers/uniswap.go | 0.739611 | 0.451145 | uniswap.go | starcoder |
package math3
type Matrix3 struct {
Elements []float64
}
func NewMatrix3() *Matrix3 {
return &Matrix3{
[]float64{
1, 0, 0,
0, 1, 0,
0, 0, 1,
},
}
}
func (m *Matrix3) Set(n11, n12, n13, n21, n22, n23, n31, n32, n33 float64) *Matrix3 {
te := m.Elements
te[0], te[1], te[2] = n11, n21, n31
te[3], ... | math3/matrix3.go | 0.677154 | 0.605886 | matrix3.go | starcoder |
package dense
import (
"encoding/json"
"errors"
"io"
"math"
"github.com/mitsuse/matrix-go/internal/rewriters"
"github.com/mitsuse/matrix-go/internal/types"
"github.com/mitsuse/matrix-go/internal/validates"
)
type Matrix struct {
initialized bool
base *types.Shape
view *types.Shape
offset ... | dense/dense.go | 0.692642 | 0.432663 | dense.go | starcoder |
package schema
type Chassis 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 member. [RO]
Name string `json:"Name... | cmd/pemgr-server/schema/chassis.go | 0.738103 | 0.48499 | chassis.go | starcoder |
package imgutil
import (
"image"
"image/draw"
"github.com/diamondburned/imgutil/circle"
"github.com/disintegration/imaging"
)
type Processor func(image.Image) *image.NRGBA
// Resize uses MaxSize to calculate and resize the image accordingly.
func Resize(maxW, maxH int) Processor {
return func(img image.Image) ... | processor.go | 0.724383 | 0.419529 | processor.go | starcoder |
package resolv
import (
"math"
"sort"
"github.com/kvartborg/vector"
)
// Object represents an object that can be spread across one or more Cells in a Space. An Object is essentially an AABB (Axis-Aligned Bounding Box) Rectangle.
type Object struct {
Shape Shape // A shape for more specific col... | object.go | 0.894973 | 0.559651 | object.go | starcoder |
package rtime
import (
"strings"
"time"
)
// A Duration represents the elapsed time between two instants as an int64 nanosecond count.
// The representation limits the largest representable duration to approximately 290 years.
type Duration time.Duration
// Hours returns the duration as a floating point number of ... | duration.go | 0.720368 | 0.555254 | duration.go | starcoder |
package group
import (
"crypto"
"io"
h2c "github.com/armfazh/h2c-go-ref"
r255 "github.com/bwesterb/go-ristretto"
)
var (
Ristretto255 Group = ristrettoGroup{}
)
type ristrettoGroup struct {
}
func (g ristrettoGroup) String() string {
return "ristretto255"
}
type ristrettoElement struct {
p r255.Point
}
t... | group/ristretto255.go | 0.653238 | 0.419886 | ristretto255.go | starcoder |
package curve1174
import (
"encoding/binary"
"fmt"
"math/big"
"math/bits"
)
//P3 is 4th (highest) digit (base 2^64) of P=2^251-9
const P3 uint64 = 0x07ffffffffffffff
//P2 is 3rd digit (base 2^64) of P=2^251-9
const P2 uint64 = 0xffffffffffffffff
//P1 is 2nd digit (base 2^64) of P=2^251-9
const P1 uint64 = 0xfff... | field.go | 0.761893 | 0.420064 | field.go | starcoder |
package fp
// MapIntInt64 takes two inputs -
// 1. Function 2. List. Then It returns a new list after applying the function on each item of the list
func MapIntInt64(f func(int) int64, list []int) []int64 {
if f == nil {
return []int64{}
}
newList := make([]int64, len(list))
for i, v := range list {
newList[i]... | fp/mapio.go | 0.793706 | 0.424651 | mapio.go | starcoder |
package operations
import (
"math"
"github.com/bilegochir/proj/core"
)
func init() {
core.RegisterConvertLPToXY("sterea",
"Oblique Stereographic Alternative",
"asd",
NewSterea,
)
}
// Sterea implements core.IOperation and core.ConvertLPToXY
// Lam0, Phi0 float64 /* central meridian, parallel */
type S... | operations/Sterea.go | 0.717606 | 0.433382 | Sterea.go | starcoder |
package estack
import(
"image/color"
"math"
)
// A Luminance is a value representing the physical luminance on the image sensor, across
// a very wide range of values (e.g. kinda HDR)
type Luminance struct {
R,G,B float64
}
// Given the exposure info, map the color into a physical luminance. The bool indicates
//... | pkg/estack/luminance.go | 0.82379 | 0.4881 | luminance.go | starcoder |
// Package dataflow provides data flow analyses that can be performed on a
// previously constructed control flow graph, including a reaching definitions
// analysis and a live variables analysis for local variables.
package dataflow
// This file contains functions common to all data flow analyses, as well as
// one ... | analysis/dataflow/dataflow.go | 0.663669 | 0.478285 | dataflow.go | starcoder |
package settings
import (
"fmt"
"strconv"
"github.com/valyala/fastjson/fastfloat"
"github.com/bytehouse-cloud/driver-go/errors"
)
func SettingToValue(key string, value interface{}) (interface{}, error) {
defVal, ok := Default[key]
if !ok {
return nil, errors.ErrorfWithCaller("query settings not found: %v", ... | driver/lib/settings/utils.go | 0.513181 | 0.546617 | utils.go | starcoder |
package stdlib
import (
"fmt"
"strings"
)
// Date translates QIF date to a string with the date formatted as yyyy/mm/dd.
// The QIF date is a string which looks like
// digit digit? slash (space | digit) digit tic digit digit
// It is is formatted as mm/dd'yy. The month can be one or two digits
// (eg, January i... | stdlib/stdlib.go | 0.698741 | 0.533458 | stdlib.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"strings"
"strconv"
"math"
)
type Action struct {
code string
value int
}
func move(operations []Action) {
currentPositionX := 0
currentPositionY := 0
directionX := 1
directionY := 0
for _, operation := range operations {
... | day12-go/day12.go | 0.670932 | 0.453141 | day12.go | starcoder |
package geometry
import (
"math"
"github.com/tab58/v1/spatial/pkg/numeric"
"gonum.org/v1/gonum/blas"
"gonum.org/v1/gonum/blas/blas64"
)
// Vector2DReader is a read-only interface for a 2D vector.
type Vector2DReader interface {
GetX() float64
GetY() float64
GetComponents() (float64, float64)
Length() (float... | pkg/geometry/vector2d.go | 0.885613 | 0.650315 | vector2d.go | starcoder |
package ff
import (
"io"
"github.com/cloudflare/circl/internal/conv"
)
// ScalarSize is the length in bytes of a Scalar.
const ScalarSize = 32
// scMont represents an element in the Montgomery domain (little-endian).
type scMont = [ScalarSize / 8]uint64
// scRaw represents a scalar in the integers domain (little... | ecc/bls12381/ff/scalar.go | 0.725357 | 0.477128 | scalar.go | starcoder |
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// absdiff example using a function argument rather than attaching an
// Abs method to a structure containing base types.
package main
import (
"fmt"
"math... | test/typeparam/absdiff3.go | 0.860999 | 0.4831 | absdiff3.go | starcoder |
package buffers
import (
"fmt"
"github.com/bloeys/nmage/asserts"
"github.com/go-gl/gl/v4.1-core/gl"
)
//Element represents an element that makes up a buffer (e.g. Vec3 at an offset of 12 bytes)
type Element struct {
Offset int
ElementType
}
//ElementType is the type of an element thats makes up a buffer (e.g. ... | buffers/element.go | 0.783699 | 0.753058 | element.go | starcoder |
package out
import (
"math"
"github.com/cpmech/gosl/chk"
"github.com/cpmech/gosl/gm"
"github.com/cpmech/gosl/la"
"github.com/cpmech/gosl/utl"
)
const DIST_TOL = 1e-6 // tolerance to compare distances or proximity between points
// PlaneData holds data for handling planes described by {u,v}-coordinates
type Pl... | out/topology.go | 0.64969 | 0.50061 | topology.go | starcoder |
// Pointers serve only 1 purpose: sharing.
// Pointers share values across the program boundaries.
// There are several types of program boundaries. The most common one is between function calls.
// We can also have a boundary between Goroutines which we will discuss later.
// When this program starts up, the runtime... | go/language/pointer.go | 0.656548 | 0.641268 | pointer.go | starcoder |
package memory
import (
"errors"
"log"
"github.com/knd/kndchain/pkg/listing"
"github.com/knd/kndchain/pkg/mining"
)
// ErrAddNilBlock is used when no mined block is given to add
var ErrAddNilBlock = errors.New("Mined block is not given to add")
// MemStorage keeps blockchain in memory
type MemStorage struct {
... | pkg/storage/memory/repository.go | 0.718496 | 0.434521 | repository.go | starcoder |
package goertzel
import "math"
// Helper class to hold previous two results.
type Vn struct {
_1 float64
_2 float64
}
// Goertzel Filter data
type Filter struct {
// The frequency of the filter
f float64
// The sampling frequency
fs float64
// The Goertzel coefficient, calculate from frequencies
koef float6... | go/src/goertzel/goertzel.go | 0.849472 | 0.577495 | goertzel.go | starcoder |
package main
import (
"math"
"math/rand"
"time"
)
// Boid is the structure of each boid (bird-android). It has a position vector, a velocity vector and an id.
type Boid struct {
position Vector2D
velocity Vector2D
id int
}
func (b *Boid) calcAcceleration() Vector2D { // find the enclosing window (the vie... | boid.go | 0.658198 | 0.72611 | boid.go | starcoder |
package fndocs
var FnShort = `Transform and validate packages using containerized functions.`
var FnLong = `
The ` + "`" + `fn` + "`" + ` command group contains subcommands for transforming and validating ` + "`" + `kpt` + "`" + ` packages
using containerized functions.
`
var DocShort = `Display the documentation for... | internal/docs/generated/fndocs/docs.go | 0.797517 | 0.487612 | docs.go | starcoder |
package fastly
import (
"fmt"
"sort"
)
const (
// SnippetTypeInit sets the type to init
SnippetTypeInit SnippetType = "init"
// SnippetTypeRecv sets the type to recv
SnippetTypeRecv SnippetType = "recv"
// SnippetTypeHit sets the type to hit
SnippetTypeHit SnippetType = "hit"
// SnippetTypeMiss sets the t... | fastly/vcl_snippets.go | 0.653127 | 0.561095 | vcl_snippets.go | starcoder |
package merkle
import (
"math"
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
"github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing"
"github.com/kaspanet/kaspad/domain/consensus/utils/hashes"
)
// nextPowerOfTwo returns the next highest power of two from a given number if
// it is ... | domain/consensus/utils/merkle/merkle.go | 0.810441 | 0.439086 | merkle.go | starcoder |
package integration
import (
"errors"
"time"
"github.com/fresh8/go-cache/cacher"
)
func RunSuite(cache cacher.Cacher) error {
expectedData := []byte("initial value")
missCount := 0
regen := func() ([]byte, error) {
missCount = missCount + 1
return expectedData, nil
}
if missCount != 0 {
return errors... | integration/common.go | 0.59972 | 0.410343 | common.go | starcoder |
package runner
import (
"github.com/pganalyze/collector/state"
"github.com/pganalyze/collector/util"
)
func diffState(logger *util.Logger, prevState state.PersistedState, newState state.PersistedState, collectedIntervalSecs uint32) (diffState state.DiffState) {
diffState.StatementStats = diffStatements(newState.St... | runner/diff.go | 0.532911 | 0.538316 | diff.go | starcoder |
package deps_parser
/*
Package deps_parser provides tools for parsing and updating DEPS files.
Doing this outside of depot tools proper is arguably a bad idea; we're doing it
for the following reasons:
1. Using depot tools requires adding a Python installation to the Docker image,
which accounts for ~200MB of spa... | go/depot_tools/deps_parser/deps_parser.go | 0.649134 | 0.456652 | deps_parser.go | starcoder |
package analysis
import (
"fmt"
"strings"
"github.com/google/gapid/core/math/interval"
"github.com/google/gapid/core/math/u64"
"github.com/google/gapid/gapil/semantic"
)
// Value interface compliance checks.
var (
_ = Value(&UintValue{})
_ = SetRelational(&UintValue{})
)
// newUintRange returns a new UintVa... | gapil/analysis/uint_value.go | 0.861013 | 0.456168 | uint_value.go | starcoder |
package main
import (
"errors"
"fmt"
"log"
"math"
)
type testCase struct {
a [][]float64
b []float64
x []float64
}
var tc = testCase{
// common RC example. Result x computed with rational arithmetic then
// converted to float64, and so should be about as close to correct as
/... | lang/Go/gaussian-elimination-1.go | 0.527073 | 0.438064 | gaussian-elimination-1.go | starcoder |
package iso20022
// Specifies prices.
type CorporateActionPrice1 struct {
// 1. Price at which security will be purchased/sold if warrant is exercised, either as an actual amount or a percentage.
// 2. Price at which a bond is converted to underlying security either as an actual amount or a percentage.
// 3. Strik... | CorporateActionPrice1.go | 0.79162 | 0.451931 | CorporateActionPrice1.go | starcoder |
package ast
import (
"fmt"
"reflect"
"regexp"
"strings"
)
// Node represents any node in the AST.
type Node interface {
AddChild(node Node)
}
// Position returns the position of the node in the original file. If the
// position cannot be determined an empty string is returned.
func Position(node Node) string {
... | ast/ast.go | 0.586523 | 0.514949 | ast.go | starcoder |
package pb
import (
"fmt"
ostorage "github.com/influxdata/influxdb/services/storage"
"github.com/EMCECS/influx/query/ast"
"github.com/EMCECS/influx/query/semantic"
"github.com/pkg/errors"
)
func ToStoragePredicate(f *semantic.FunctionExpression) (*ostorage.Predicate, error) {
if len(f.Params) != 1 {
return n... | query/functions/storage/pb/predicate.go | 0.586286 | 0.45423 | predicate.go | starcoder |
package testdata
// ListCapturesResponse example
const ListCapturesResponse = `{
"_embedded": {
"captures": [
{
"resource": "capture",
"id": "cpt_4qqhO89gsT",
"mode": "live",
"amount": {
"value": "1027.99",
... | testdata/captures.go | 0.740831 | 0.419053 | captures.go | starcoder |
package geotiff
import (
"encoding/binary"
"math"
)
//DataView allow to easily read data
type DataView []byte
//Uint8 read and return a uint8 from the underlying data starting at the given offset
func (d DataView) Uint8(offset uint, littleEndian bool) uint8 {
return uint8(d[offset])
}
//Int8 read and return a in... | pkg/geotiff/dataview.go | 0.810291 | 0.709925 | dataview.go | starcoder |
package security
import (
"errors"
)
// SignatureType represents the type of a signature.
type SignatureType uint64
// The various possible values of SignatureType.
const (
DigestSha256Type SignatureType = 0
SignatureSha256WithRsaType SignatureType = 1
SignatureSha256WithEcdsaType SignatureType = 3... | ndn/security/signature.go | 0.688573 | 0.448547 | signature.go | starcoder |
// Package dataproc shows how you can use the Cloud Dataproc Client library to manage
// Cloud Dataproc clusters. In this example, we'll show how to instantiate an inline
// workflow template.
package dataproc
// [START dataproc_instantiate_inline_workflow_template]
import (
"context"
"fmt"
"io"
dataproc "cloud.... | dataproc/instantiate_inline_workflow_template.go | 0.687 | 0.53279 | instantiate_inline_workflow_template.go | starcoder |
package via6522
import (
"fmt"
"strconv"
"unicode"
)
const (
viaOrb = 0x0
viaIrb = 0x0
viaOra = 0x1
viaIra = 0x1
viaDdrb = 0x2
viaDdra = 0x3
// bit-offset into PCR for port A & B
viaPcrOffsetA = 0
viaPcrOffsetB = 4
)
/**
* Memory interface implementation.
*/
// The internal state of the 6522 VIA con... | via6522/via6522.go | 0.572245 | 0.412294 | via6522.go | starcoder |
package audio
import "github.com/moshenahmias/gopherboy/memory"
// AddrNR30 is the NR30 register address
const AddrNR30 uint16 = 0xFF1A
// AddrNR31 is the NR31 register address
const AddrNR31 uint16 = 0xFF1B
// AddrNR32 is the NR32 register address
const AddrNR32 uint16 = 0xFF1C
// AddrNR33 is the NR33 register ad... | audio/wave.go | 0.708011 | 0.505005 | wave.go | starcoder |
package mockgres
// Behavior configures how a mock postgresql function should behave.
type Behavior func(b *MockBehaviors)
// MockBehaviors determines how all of Mocker's mock postgresql functions should behave.
type MockBehaviors struct {
RowCount func(string) (int, error)
}
// New creates a Mocker configured with... | golang/07-mocking/postgresql/mockgres/mockgres.go | 0.855142 | 0.4165 | mockgres.go | starcoder |
package strmatcher
import (
"regexp"
)
// Matcher is the interface to determine a string matches a pattern.
type Matcher interface {
// Match returns true if the given string matches a predefined pattern.
Match(string) bool
}
// Type is the type of the matcher.
type Type byte
const (
// Full is the type of matc... | common/strmatcher/strmatcher.go | 0.78345 | 0.512144 | strmatcher.go | starcoder |
package dizi
// Fingering describes the finger positions that produce a note.
type Fingering struct {
// The note this fingering produces in simple notation (often used in
// Chinese sheet music.)
SimpleNotation string
// Fingers are the finger positions needed to produce the note. Leftmost
// being closest to t... | pkg/dizi/dizi.go | 0.670824 | 0.623864 | dizi.go | starcoder |
package d2
import (
"strconv"
"strings"
"github.com/adamcolton/geom/angle"
"github.com/adamcolton/geom/calc/cmpr"
"github.com/adamcolton/geom/geomerr"
)
/*
| a b c | | x |
| d e f | * | y | = | ax+by+c dx+ey+f gx+hy+i|
| g h i | | 1 |
Because of the array syntax, (x,y) get flipped either in the layout or ... | d2/t.go | 0.726426 | 0.566139 | t.go | starcoder |
package gdsp
// Filtic creates the initial condition vector for the filter function. x (optional)
// and y contain the last input and output from the filter function. a and b are
// the filter coefficients.
func Filtic(b Vector, a Vector, y Vector, x Vector) Vector {
na := len(a)
nb := len(b)
m := MaxI(na, nb) - 1
... | filtic.go | 0.661923 | 0.787441 | filtic.go | starcoder |
package day12
import (
"math"
"strconv"
)
const (
north = 0
east = 1
south = 2
west = 3
)
// Solution implements the day 12 solution
type Solution struct{}
// PartOne answers part 1 of the day 12 puzzle
func (s *Solution) PartOne(input *[]string) (int, error) {
ship := getShip()
for _, instruction := rang... | 2020/pkg/day12/solution.go | 0.778565 | 0.475666 | solution.go | starcoder |
package iso20022
// Specifies rates of a corporate action.
type CorporateActionRate16 struct {
// Annual rate of a financial instrument.
Interest *RateAndAmountFormat14Choice `xml:"Intrst,omitempty"`
// Percentage of securities the offeror/issuer will purchase or redeem under the terms of the event. This can be a... | CorporateActionRate16.go | 0.823151 | 0.525978 | CorporateActionRate16.go | starcoder |
package models
import (
"strconv"
"strings"
"github.com/hjkelly/zbbapi/common"
)
// -----------------------------------------------------------------------------
// Plan types: Used to plan for your typical/expected month.
// -----------------------------------------------------------------------------
// Plan h... | models/plan.go | 0.67405 | 0.401394 | plan.go | starcoder |
package aoc
import (
"fmt"
"strconv"
)
// MappingFunc represents a function used to determine which character Print should use for a given integer in the grid.
type MappingFunc func(int) string
// Grid represents a two dimensional array of integers.
type Grid struct {
// Mapper is a MappingFunc used by Print to c... | grid.go | 0.837852 | 0.55447 | grid.go | starcoder |
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
/**
Write a program which allows the user to create a set of animals and to get information about those animals.
Each animal has a name and can be either a cow, bird, or snake. With each command, the user can either create a new
animal of one of the three types... | src/animal2.go | 0.52342 | 0.410638 | animal2.go | starcoder |
package main
// defaultLicensesJSON are the most commonly used licenses for DOI registrations.
// The content is used to check the licenses in new DOI registrations and warn
// about discrepancies between used license URL, name and license content.
const defaultLicensesJSON = `[
{
"URL": "http://www.apache.org/lice... | cmd/gindoid/licenses.go | 0.555194 | 0.433562 | licenses.go | starcoder |
package indicators
import (
"github.com/dellosaneil/stocktracking-backend/model"
"github.com/dellosaneil/stocktracking-backend/util"
)
func SimpleMovingAverage(prices []float64, period int) []float64 {
var movingAverage []float64
var slicedArray = prices[0:period]
var average = movingAverageCalculation(slicedArr... | indicators/MovingAverage.go | 0.655997 | 0.508971 | MovingAverage.go | starcoder |
package cfg
import (
"context"
"fmt"
"golang.org/x/exp/constraints"
"go.uber.org/multierr"
)
type Validateable interface {
Validate(context.Context) error
}
// A Validator checks whether or not a given value is considered valid.
type Validator[T any] interface {
// Validate returns an error if the value of i... | validators.go | 0.816113 | 0.470493 | validators.go | starcoder |
package time
import (
"time"
)
// UnixNano is used to indicate that an int64 stores a unix timestamp at
// nanosecond resolution.
type UnixNano int64
// ToTime returns a time.ToTime from a UnixNano.
func (u UnixNano) ToTime() time.Time {
return time.Unix(0, int64(u))
}
// ToUnixNano returns a UnixNano from a tim... | src/x/time/unix_nano.go | 0.909753 | 0.401717 | unix_nano.go | starcoder |
package avatarme
import (
"code.google.com/p/draw2d/draw2d"
"image"
"image/color"
"image/draw"
)
type Shape struct {
vertices []image.Point
}
func newShape(verts []image.Point) Shape {
return Shape{
vertices: verts,
}
}
var (
v0 = image.Point{0, 0}
v10 = image.Point{0, 2}
v20 = image.Point{0, 4}
v6 =... | shapes.go | 0.598547 | 0.493348 | shapes.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
"strconv"
)
// Int4RangeArrayFromIntArray2Slice returns a driver.Valuer that produces a PostgreSQL int4range[] from the given Go [][2]int.
func Int4RangeArrayFromIntArray2Slice(val [][2]int) driver.Valuer {
return int4RangeArrayFromIntArray2Slice{val: va... | pgsql/int4rangearr.go | 0.8156 | 0.599983 | int4rangearr.go | starcoder |
package linkedlisttrie
import (
"strings"
)
/* LINKED LIST IMPLEMENTAITON */
// A Trie is a kind of search tree, an ordered data structure that stores a dynamic set or associative array
// using a string key, where the position in the trie denotes the value of the key
// A PhraseTrie is an implementation of a Trie... | linkedlisttrie/phrase_trie.go | 0.695752 | 0.512998 | phrase_trie.go | starcoder |
package smarttile
import "math"
// Common density values
const (
DensityLow = 1.0
DensityMedium = 10.0
DensityHigh = 100.0
// Default density when none specified
DefaultDensity = DensityLow
)
const (
densityReferenceBlockSize = 100
)
// TilingInput is the input given to the Tile operation
type TilingInp... | tile.go | 0.819207 | 0.603435 | tile.go | starcoder |
package robot
import (
"errors"
)
const (
NORTH = "NORTH"
SOUTH = "SOUTH"
EAST = "EAST"
WEST = "WEST"
)
type Position struct {
X int
Y int
Direction string
}
type Table struct {
Width int
Height int
}
type Robot struct {
Position Position
Table Table
}
func New(pos Position, t Table) *Robo... | robot/robot.go | 0.710729 | 0.427217 | robot.go | starcoder |
package newtime
import (
"fmt"
"strings"
"time"
)
type Time struct {
Time time.Time
Local *time.Location
Is_zero bool
Error error
}
func NewTime() (t *Time) {
t = new(Time)
t.Time = time.Now().Local()
t.Local = t.Time.Location()
return t
}
func (t *Time) Format(format string) string {
if t.Is_zer... | time.go | 0.700485 | 0.430028 | time.go | starcoder |
package address
/**
* This interface provides factory methods that allow an application to create
* Address objects, URI's, SipURI's and TelURL's from a particular
* implementation of this specification. This class is a singleton and can be
* retrieved from the {@link SipFactory#createAddressFactory()}.
*/
type A... | sip/address/AddressFactory.go | 0.88952 | 0.441733 | AddressFactory.go | starcoder |
package kmeans
import (
"math"
"math/rand"
)
// Observation: Data Abstraction for an N-dimensional
// observation
type Observation []float64
// Abstracts the Observation with a cluster number
// Update and computeation becomes more efficient
type ClusteredObservation struct {
ClusterNumber int
Observation
}
// ... | kmeans/kmeans.go | 0.661923 | 0.781581 | kmeans.go | starcoder |
package images3
const (
// Euclidean similarity parameters.
// Cutoff value for color distance.
colorDiff = 50
// Cutoff coefficient for Euclidean distance (squared).
euclCoeff = 0.2
// Coefficient of sensitivity for Cb/Cr channels vs Y.
chanCoeff = 2
// Euclidean distance threshold (squared) for Y-channel.
... | similarity.go | 0.893835 | 0.642671 | similarity.go | starcoder |
// Package sunrise computes sunrises and sunsets using wikipedia article
// http://en.wikipedia.org/wiki/Sunrise_equation. Testing at my
// latitude and longitude in California shows that computed sunrises and
// sunsets can vary by as much as 2 minutes from those that NOAA reports
// at http://www.esrl.noaa.gov/gmd/g... | sunrise.go | 0.865906 | 0.703454 | sunrise.go | starcoder |
package forGraphBLASGo
import (
"github.com/intel/forGoParallel/pipeline"
)
type diagonalMatrix[T any] struct {
nrows, ncols int
v *vectorReference[T]
k int
}
func newDiagonalMatrix[T any](nrows, ncols int, v *vectorReference[T], k int) functionalMatrix[T] {
return diagonalMatrix[T]{
nro... | functional_MatrixDiagonal.go | 0.523664 | 0.530054 | functional_MatrixDiagonal.go | starcoder |
package main
import (
"fmt"
"time"
)
func main() {
//Puzzle Input
moonLocations := []xyz{xyz{13, 9, 5}, xyz{8, 14, -2}, xyz{-5, 4, 11}, xyz{2, -6, 1}}
//Print the result
fmt.Println(calculateRepeatSteps(moonLocations))
}
func abs(x int) int {
if x < 0 {
return -x
}
return x
}
func max(a, b int64) int64 {... | 2019/d12-p2/main.go | 0.503906 | 0.491761 | main.go | starcoder |
package model
// Bundle. Parse the certificate chain as a single file after linking the server certificate to its issuers certificate within the file.<br>Default value: NO<br>Possible values = YES, NO.
// Cert. Name of and, optionally, path to the X509 certificate file that is used to form the certificate-key pair.... | model/sslcertkey.go | 0.654564 | 0.474509 | sslcertkey.go | starcoder |
package description
import (
"github.com/pkg/errors"
"github.com/uncharted-distil/distil-compute/model"
"github.com/uncharted-distil/distil-compute/pipeline"
)
// CreateGeneralClusteringPipeline creates a pipeline that will cluster tabular data.
func CreateGeneralClusteringPipeline(name string, description string... | primitive/compute/description/cluster.go | 0.632389 | 0.558508 | cluster.go | starcoder |
package procmatch
import (
"fmt"
"strings"
"unicode"
)
// signatureGraph holds the catalog as a graph to be able to quickly find an integration for a given command line (split by word)
// - Nodes either represent an integration, or an intermediary state that may lead to another, more specific integration
// - Edge... | pkg/procmatch/graph.go | 0.707607 | 0.562297 | graph.go | starcoder |
package main
import "fmt"
/**
题目:https://leetcode-cn.com/problems/trapping-rain-water/
接雨水
给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。
输入:height = [0,1,0,2,1,0,1,3,2,1,2,1]
输出:6
解释:上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。
提示:
n == height.length
1 <= n <= 2 * 104
0 <= height[i]... | datastruct/MonotoneStack/leetcodeQuestion/trap/trap.go | 0.601594 | 0.502502 | trap.go | starcoder |
package gopie
import (
"fmt"
"math"
)
type pie struct {
Slices *[]slice
Circle *circle
Background *circle
}
func newPie(chart PieChart, pieRect rectangle, uid string) pie {
if len(chart.Values) == 0 {
return emptyPie(chart, pieRect, uid)
}
if len(chart.Values) == 1 {
return uncutPie(chart, pieRe... | pie.go | 0.771843 | 0.415314 | pie.go | starcoder |
package graph
// Vertex ...
type Vertex interface{}
// Edge ...
type Edge interface {
Vertices() (u, v Vertex)
}
// DirectedEdge ...
type DirectedEdge interface {
Edge
Source() Vertex
Target() Vertex
}
// LabeledEdge ...
type LabeledEdge interface {
Edge
Label() string
}
// WeightedEdge ...
type WeightedEdge... | graph/graph.go | 0.841011 | 0.449574 | graph.go | starcoder |
package lookup
import (
"fmt"
"github.com/dolthub/dolt/go/libraries/doltcore/table/typed/noms"
"github.com/dolthub/dolt/go/store/types"
)
// Range represents the contiguous set of values that a lookup operation covers.
type Range struct {
LowerBound Cut
UpperBound Cut
}
// OpenRange returns a range representi... | go/libraries/doltcore/sqle/lookup/range.go | 0.846831 | 0.428473 | range.go | starcoder |
package advent2021
import (
"fmt"
"github.com/marjamis/advent-of-code/pkg/helpers"
)
// OctopusEnergyMap is the 2d positioning of all dumbo octopuses
type OctopusEnergyMap [][]int
// Coordinates is a row/col position on a 2D matrix
type Coordinates struct {
row int
col int
}
var flashedThisStep = []Coordinates... | internal/pkg/advent2021/day11.go | 0.683208 | 0.408808 | day11.go | starcoder |
package message
// BulkMessage usually contains a single recipient per message
// and is generally used to send the same content to many recipients,
// optionally customizing the message via the use of MergeData.
type BulkMessage struct {
//The message subject.
Subject string
// Plain text portion of the message ... | injectionapi/message/bulkmessage.go | 0.72662 | 0.429728 | bulkmessage.go | starcoder |
package leetcode0912
import (
"math/rand"
"sort"
)
// Ints is int array
type Ints []int
func (n Ints) Len() int {
return len(n)
}
func (n Ints) Less(i, j int) bool {
return n[i] < n[j]
}
func (n Ints) Swap(i, j int) {
n[i], n[j] = n[j], n[i]
}
// Solution 0: Standard Sort (implements Solution 1-4)
// Time: O... | l0912_sort_an_array/sort_an_array.go | 0.669745 | 0.487734 | sort_an_array.go | starcoder |
package wgpu
type AdapterType uint32
const (
AdapterType_DiscreteGPU AdapterType = 0
AdapterType_IntegratedGPU AdapterType = 1
AdapterType_CPU AdapterType = 2
AdapterType_Unknown AdapterType = 3
)
func (v AdapterType) String() string {
switch v {
case AdapterType_DiscreteGPU:
return "Discr... | wgpu/enums.go | 0.522202 | 0.412412 | enums.go | starcoder |
package word
import "regexp"
type replacer struct {
regex *regexp.Regexp
repl string
}
func (r *replacer) replace(str string) string {
return r.regex.ReplaceAllString(str, r.repl)
}
// A list of replacer{ applied in sequenc }.
// The resulting string is split on whitespace.
// (Adapted from splitta, which adap... | word_tokenize.go | 0.600305 | 0.423518 | word_tokenize.go | starcoder |
package colorful
import "math"
// http://en.wikipedia.org/wiki/CIELUV#XYZ_.E2.86.92_CIELUV_and_CIELUV_.E2.86.92_XYZ_conversions
// For L*u*v*, we need to L*u*v*<->XYZ<->RGB and the first one is device dependent.
func XYZToLuv(x, y, z float64) (l, a, b float64) {
// Use D65 white as reference point by default.
// h... | colorful/cs_luv.go | 0.821152 | 0.536495 | cs_luv.go | starcoder |
package advent2019
import (
"bufio"
"io"
"math"
"sort"
"strconv"
"strings"
"github.com/willmadison/advent"
)
type path struct {
stepCountsByPoint map[advent.Point]int
steps []advent.Point
}
func (p path) stepsTo(point advent.Point) int {
return p.stepCountsByPoint[point]
}
func (p path) inter... | advent2019/wires.go | 0.728072 | 0.472197 | wires.go | starcoder |
package internal
import (
"regexp"
"strings"
"github.com/lyraproj/dgo/util"
"github.com/lyraproj/dgo/dgo"
)
type (
// regexpType represents an regexp type without constraints
regexpType int
exactRegexpType regexp.Regexp
regexpVal regexp.Regexp
)
// DefaultRegexpType is the unconstrained Regexp type
const... | internal/regexp.go | 0.566618 | 0.410106 | regexp.go | starcoder |
package router
import (
"encoding/binary"
"sort"
"github.com/v2fly/v2ray-core/v4/common/net"
)
type ipv6 struct {
a uint64
b uint64
}
type GeoIPMatcher struct {
countryCode string
reverseMatch bool
ip4 []uint32
prefix4 []uint8
ip6 []ipv6
prefix6 []uint8
}
func normalize4(ip... | app/router/condition_geoip.go | 0.648578 | 0.408218 | condition_geoip.go | starcoder |
package field
import (
"fmt"
"reflect"
"strings"
)
// A Type represents a field type.
type Type uint8
// List of field types.
const (
TypeInvalid Type = iota
TypeBool
TypeTime
TypeJSON
TypeUUID
TypeBytes
TypeEnum
TypeString
TypeInt8
TypeInt16
TypeInt32
TypeInt
TypeInt64
TypeUint8
TypeUint16
TypeU... | schema/field/type.go | 0.726426 | 0.434041 | type.go | starcoder |
package commands
import (
"github.com/pkg/errors"
"strconv"
"strings"
"github.com/cirocosta/asciinema-edit/cast"
"github.com/cirocosta/asciinema-edit/commands/transformer"
"github.com/cirocosta/asciinema-edit/editor"
"gopkg.in/urfave/cli.v1"
)
var Quantize = cli.Command{
Name: "quantize",
Usage: `Updates th... | commands/quantize.go | 0.740831 | 0.463444 | quantize.go | starcoder |
package filter
import (
"bytes"
"fmt"
"sort"
"strconv"
"unicode"
"github.com/AdRoll/baker"
)
const expandListhelp = `
This filter splits a field using a configured separator and writes the resulting values to other fields of the same
record. The mapping between the extracted values and the destination fields ... | filter/expand_list.go | 0.824885 | 0.417746 | expand_list.go | starcoder |
package phy
import (
"image"
"math"
"github.com/fogleman/gg"
"github.com/jakecoffman/cp"
)
const (
LineWidth = 2
)
type DrawOption struct {
Width, Height int
Flags uint
Outline cp.FColor
Constraint cp.FColor
CollisionPoint cp.FColor
Data interface{}
}
type Drawer struct {
... | app/phy/draw.go | 0.757256 | 0.413536 | draw.go | starcoder |
package glad
import (
"github.com/go-gl/gl/v4.5-core/gl"
)
// VertexArrayObject stores data relative to some vertices stored in VBOs
// VertexArrayObject contain information on data location and layout in memory
// VertexArrayObject represents the vertex attribute state
// In the core profile, at least one VAO is ma... | vao.go | 0.688573 | 0.679724 | vao.go | starcoder |
package kapacitor
import (
"fmt"
"time"
"github.com/influxdata/kapacitor/edge"
"github.com/influxdata/kapacitor/models"
"github.com/influxdata/kapacitor/pipeline"
"github.com/influxdata/kapacitor/tick/ast"
"github.com/influxdata/kapacitor/tick/stateful"
)
type CombineNode struct {
node
c *pipeline.CombineNo... | combine.go | 0.594787 | 0.432063 | combine.go | starcoder |
package iso20022
// Tax related to an investment fund order.
type Tax15 struct {
// Type of tax applied.
Type *TaxType13Code `xml:"Tp"`
// Type of tax applied.
ExtendedType *Extended350Code `xml:"XtndedTp"`
// Amount of money resulting from the calculation of the tax.
Amount *ActiveOrHistoricCurrencyAnd13Deci... | Tax15.go | 0.783409 | 0.505981 | Tax15.go | starcoder |
package grid
import (
"github.com/johnfercher/taleslab/pkg/taleslab/taleslabdomain/taleslabconsts"
"github.com/johnfercher/taleslab/pkg/taleslab/taleslabdomain/taleslabentities"
"math"
"math/rand"
"time"
)
func TerrainGenerator(x, y int, xFrequency, yFrequency, gain float64, minHeight int, forceBaseLand bool) []... | pkg/grid/mountain.go | 0.721939 | 0.578537 | mountain.go | starcoder |
package common
import (
"crypto/sha256"
"fmt"
"github.com/annchain/OG/common/math"
"math/big"
"math/rand"
"reflect"
"bytes"
"strings"
"github.com/annchain/OG/common/hexutil"
)
//go:generate msgp
// Length of hash in bytes.
const (
HashLength = 32
)
var (
hashT = reflect.TypeOf(Hash{})
)
type Padding ... | common/hash.go | 0.658088 | 0.425546 | hash.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.