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 cuda
import (
"github.com/MathieuMoalic/amumax/data"
"github.com/MathieuMoalic/amumax/util"
)
// multiply: dst[i] = a[i] * b[i]
// a and b must have the same number of components
func Mul(dst, a, b *data.Slice) {
N := dst.Len()
nComp := dst.NComp()
util.Assert(a.Len() == N && a.NComp() == nComp && b.Len(... | cuda/madd.go | 0.616359 | 0.567637 | madd.go | starcoder |
package linkedhashmap
import (
"github.com/lemonyxk/gods/containers"
"github.com/lemonyxk/gods/utils"
)
func assertEnumerableImplementation[T comparable, P any]() {
var _ containers.EnumerableWithKey[T, P] = (*Map[T, P])(nil)
}
// Each calls the given function once for each element, passing that element's key an... | maps/linkedhashmap/enumerable.go | 0.806815 | 0.445952 | enumerable.go | starcoder |
// Package view manages template loading and caching. Data inclusion to the template and execution.
// It features common settings of template name prefix and suffix (defaults to templates/ and .html).
// It holds a set of Common templates, which are automatically included in every new View.
package view
import (
"h... | view.go | 0.683736 | 0.463444 | view.go | starcoder |
package blueprint
import (
"encoding/json"
"fmt"
"testing"
"github.com/ingrammicro/cio/api/types"
"github.com/ingrammicro/cio/utils"
"github.com/stretchr/testify/assert"
)
// TODO exclude from release compile
// ListScriptsMocked test mocked function
func ListScriptsMocked(t *testing.T, scriptsIn []*types.Sc... | api/blueprint/scripts_api_mocked.go | 0.515864 | 0.405861 | scripts_api_mocked.go | starcoder |
package matrix
import (
"errors"
"math"
"github.com/Jacalz/linalg/vector"
)
var (
errorInvalidMultiplication = errors.New("the columns of u must be equal to the rows of v")
errorDifferentSize = errors.New("the matrix sizes are not equal")
errorNotQuadratic = errors.New("the matrix must be quad... | matrix/matrix.go | 0.756717 | 0.544559 | matrix.go | starcoder |
package nvm
// Vector is a vector interface.
type Vector interface {
// IsNaV reports whether `v` is "Not-a-Vector".
IsNaV() bool
// Dim returns the dimension of vector.
Dim() int
// At returns the element at position `i`. At will panic if `i` is out of bounds.
At(i int) float64
// SetAt sets `f` to the ele... | nvm/vector.go | 0.900271 | 0.779909 | vector.go | starcoder |
package metrics
import (
gometrics "github.com/rcrowley/go-metrics"
"sync"
)
type UniformSample struct {
count int64
mutex sync.Mutex
reservoirSize int
values []int64
}
// NewUniformSample constructs a new uniform sample with the given reservoir
// size.
func NewUniformSample(reservoirS... | pkg/metrics/sample.go | 0.797478 | 0.434461 | sample.go | starcoder |
package dsp
import (
"log"
"math"
"sort"
)
// DataSet is a float64 slice with util functions.
type DataSet []float64
// Bounds returns the bounds for the dataset
func (d DataSet) Bounds() (float64, float64) {
maxValue := math.Inf(-1)
minValue := math.Inf(1)
for i := 0; i < len(d); i++ {
if d[i] > maxValue {
... | dataset.go | 0.872102 | 0.674712 | dataset.go | starcoder |
package interpolation
import (
"strings"
"github.com/hashicorp/hil"
"github.com/hashicorp/hil/ast"
)
// interpolationFuncLower converts a string to be all in lowercase
func interpolationFuncLower() ast.Function {
return ast.Function{
ArgTypes: []ast.Type{ast.TypeString},
ReturnType: ast.TypeString,
Varia... | internal/interpolation/strings.go | 0.729905 | 0.401101 | strings.go | starcoder |
package main
import (
"github.com/abates/AdventOfCode/2016/alg"
"github.com/abates/AdventOfCode/2016/util"
)
type WallDetector func(*alg.Coordinate) bool
func MagicDetector(magicNumber int) WallDetector {
return func(coordinate *alg.Coordinate) bool {
value := coordinate.X*coordinate.X + 3*coordinate.X + 2*coor... | 2016/13/util.go | 0.732496 | 0.453383 | util.go | starcoder |
package ad9910
import (
"encoding/binary"
)
// RampLimit mirrors the digital ramp limit register.
type RampLimit [8]byte
// NewRampLimit returns an initialized RampLimit.
func NewRampLimit() RampLimit {
return [8]byte{}
}
// UpperFTW returns the upper frequency tuning word.
func (r *RampLimit) UpperFTW() uint32 {... | register/dds/ad9910/ramp.go | 0.887522 | 0.469459 | ramp.go | starcoder |
package main
/**
在一个 m*n 的棋盘的每一格都放有一个礼物,每个礼物都有一定的价值(价值大于 0)。你可以从棋盘的左上角开始拿格子里的礼物,
并每次向右或者向下移动一格、直到到达棋盘的右下角。给定一个棋盘及其上面的礼物的价值,请计算你最多能拿到多少价值的礼物?
示例 1:
输入:
[
[1,3,1],
[1,5,1],
[4,2,1]
]
输出: 12
解释: 路径 1→3→5→2→1 可以拿到最多价值的礼物
提示:
0 < grid.length <= 200
0 < grid[0].length <= 200
*/
/**
方法1:自身dp
*/
func maxValue(grid [][]i... | lcof/maxValue/maxValue.go | 0.559771 | 0.499817 | maxValue.go | starcoder |
package mssqlclrgeo
import (
"fmt"
)
type Builder struct {
g Geometry
Srid uint32
stackShape stack
isGeography bool
}
type stack []*Shape
func NewBuilder(isGeography bool) *Builder {
b := &Builder{}
b.g.Version = 1
b.g.Properties.V = true
b.isGeography = isGeography
return b
}
func (b *... | vendor/github.com/gaspardle/go-mssqlclrgeo/udtgeo_builder.go | 0.525612 | 0.528959 | udtgeo_builder.go | starcoder |
package assert
import (
"reflect"
"github.com/google/gapid/core/data/compare"
)
// OnValue is the result of calling That on an Assertion.
// It provides generice assertion tests that work for any type.
type OnValue struct {
Assertion
value interface{}
}
// That returns an OnValue for the specified untyped valu... | core/assert/value.go | 0.765681 | 0.447823 | value.go | starcoder |
package main
import (
"fmt"
"math/rand"
"time"
"github.com/sandertv/mcwss"
"github.com/sandertv/mcwss/mctype"
"github.com/sandertv/mcwss/protocol/command"
)
// PlayerFill will fill the playing area with blocktype, coordinates are relative to the player position
func PlayerFill(p *mcwss.Player, x1 int, y1 int, ... | src/app/mcutil.go | 0.552057 | 0.432303 | mcutil.go | starcoder |
package pbit
import (
"bytes"
. "github.com/0xor1/tlbx/pkg/core"
)
type Pbit uint8
func (p Pbit) MarshalBinary() ([]byte, error) {
switch p {
case 0:
return []byte(`0`), nil
case 1:
return []byte(`1`), nil
case 2:
return []byte(`2`), nil
case 3:
return []byte(`3`), nil
case 4:
return []byte(`4`), ... | cmd/games/pkg/pbit/pbit.go | 0.577734 | 0.447823 | pbit.go | starcoder |
package chsutil
import (
"errors"
"github.com/silvanoneto/go-learning/pkg/chapter01"
)
const (
// Chapter01HelloWorld is a function name from chapter01 package
Chapter01HelloWorld string = "chapter01.HelloWorld"
// Chapter01Echo1 is a function name from chapter01 package
Chapter01Echo1 string = "chapter01.Echo... | pkg/chsutil/functions.go | 0.5083 | 0.545467 | functions.go | starcoder |
package co
import (
"fmt"
"reflect"
"runtime"
"sync"
)
// ParBegin multiple functions onto background goroutines. This function blocks
// until all goroutines have terminated.
func ParBegin(fs ...func()) {
var wg sync.WaitGroup
for _, f := range fs {
wg.Add(1)
go func(f func()) {
defer wg.Done()
f()
... | co/co.go | 0.560734 | 0.572633 | co.go | starcoder |
package iso20022
// Provides the details of each individual secured market transaction.
type SecuredMarketTransaction3 struct {
// Defines the status of the reported transaction, that is details on whether the transaction is a new transaction, an amendment of a previously reported transaction, a cancellation of a pr... | SecuredMarketTransaction3.go | 0.839734 | 0.671228 | SecuredMarketTransaction3.go | starcoder |
package main
import "errors"
import "fmt"
// Por convención, los errores siempre son el último valor
// que se regresa y son de tipo `error`, una interfaz que
// es parte del lenguaje.
func f1(arg int) (int, error) {
if arg == 42 {
// `errors.New` construye un valor de `error` básico
// con el m... | examples/errores/errores.go | 0.628863 | 0.455441 | errores.go | starcoder |
package dht
import (
"bytes"
"fmt"
"strings"
)
// bitmap represents a bit array.
type bitmap struct {
Size int
data []byte
}
// newBitmap returns a size-length bitmap pointer.
func newBitmap(size int) *bitmap {
div, mod := size>>3, size&0x07
if mod > 0 {
div++
}
return &bitmap{size, make([]byte, div)}
}
... | bitmap.go | 0.822688 | 0.406155 | bitmap.go | starcoder |
Package command contains the commands used by vtctldclient. It is intended only
for use in vtctldclient's main package and entrypoint. The rest of this
documentation is intended for maintainers.
Commands are grouped into files by the types of resources they interact with (
e.g. GetTablet, CreateTablet, DeleteTablet, G... | go/cmd/vtctldclient/internal/command/doc.go | 0.505371 | 0.533458 | doc.go | starcoder |
package geometry
import (
"math"
)
type Mat2x1 [2]Mat1x1
func (a Mat2x1) Add(b Mat2x1) Mat2x1 {
return Mat2x1{
Mat1x1{a[0][0] + b[0][0]},
Mat1x1{a[1][0] + b[1][0]},
}
}
func (m Mat2x1) AddScalar(f float64) Mat2x1 {
return Mat2x1{
Mat1x1{m[0][0] + f},
Mat1x1{m[1][0] + f},
}
}
func (m Mat2x1) Len() int ... | mat2.go | 0.665845 | 0.669527 | mat2.go | starcoder |
package main
import (
"encoding/csv"
"fmt"
"github.com/olekukonko/tablewriter"
"io"
"sort"
"time"
)
const (
min int = iota + 1
max
avg
p25
p50
p75
p90
p99
)
type Stats struct {
Title string
// Latency in milliseconds averages
Latency map[int]float64
DataPoints []Result
SumLatency uint64
SumByt... | stat.go | 0.591605 | 0.470189 | stat.go | starcoder |
package main
import (
"fmt"
"adventOfCode/helpers"
"strings"
"strconv"
)
/*
The elves are running low on wrapping paper, and so they need to submit an order for more.
They have a list of the dimensions (length l, width w, and height h) of each present, and only want to order exactly as much as they ... | day2/part1.go | 0.770033 | 0.521776 | part1.go | starcoder |
package halo
import (
"sort"
)
// SubhaloFinder computes which halos in a collection are subhalos of other
// halos in that collection based purely off of position information.
type SubhaloFinder struct {
g *Grid
subhaloStarts, subhalos []int
}
// Bounds is a cell-aligned bounding box.
type Bounds struct {
Origi... | render/halo/finder.go | 0.741674 | 0.450239 | finder.go | starcoder |
package holtwinters
import (
"encoding/json"
"errors"
"fmt"
"math"
"sort"
"github.com/jthomperoo/custom-pod-autoscaler/execute"
"github.com/jthomperoo/holtwinters"
"github.com/jthomperoo/predictive-horizontal-pod-autoscaler/config"
"github.com/jthomperoo/predictive-horizontal-pod-autoscaler/stored"
)
// Typ... | prediction/holtwinters/holtwinters.go | 0.752468 | 0.419588 | holtwinters.go | starcoder |
package policy
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"github.com/gobwas/glob"
)
// Condition is a single policy condition that applies an operator to two operands
type Condition struct {
// Left operand
Left string
// Right operand - type can be either number or string, so we defer parsing unti... | server/libs/hoss-service/policy/condition.go | 0.680666 | 0.422207 | condition.go | starcoder |
package flow
import "fmt"
// A FlowRequest encapsulates the flowjs protocol for uploading a file. The
// protocol supports extensions to the protocol. We extend the protocol to
// include Materials Commons specific information. It is also expected that
// the data sent by flow or another client will be placed in chun... | pkg/app/flow/flow.go | 0.675122 | 0.400573 | flow.go | starcoder |
package bitsets
import (
sparsebs "github.com/js-ojus/sparsebitset"
densebs "github.com/willf/bitset"
)
type BitSet interface {
Set(n uint) BitSet
Test(n uint) bool
IsSuperSet(other BitSet) bool
NextSet(n uint) (uint, bool)
}
func NewDense(length uint) BitSet {
return dense{densebs.New(length)}
}
type dense ... | bitsets/bitsets.go | 0.546738 | 0.50531 | bitsets.go | starcoder |
package iavl
import (
"fmt"
"strings"
dbm "github.com/tendermint/tendermint/libs/db"
)
// ImmutableTree is a container for an immutable AVL+ ImmutableTree. Changes are performed by
// swapping the internal root with a new one, while the container is mutable.
// Note that this tree is not thread-safe.
type Immutab... | immutable_tree.go | 0.762866 | 0.459076 | immutable_tree.go | starcoder |
package main
import (
"errors"
"reflect"
)
//Node represents a given point on a map
//g is the total distance of the node from the start
//h is the estimated distance of the node from the ending
//f is the total value of the node (g + h)
type node struct {
Parent *node
Position *Position
g int
h ... | astar.go | 0.673836 | 0.553747 | astar.go | starcoder |
package model
import (
"github.com/ClessLi/Game-test/sprite"
"github.com/ClessLi/resolvForGame/resolv"
"github.com/go-gl/mathgl/mgl32"
)
type Rectangle struct {
Shape *resolv.Rectangle
*MoveObj
friction float32
maxSpd float32
multiple float32
}
// NewRectangle returns a new Rectangle instance.
func NewRect... | model/rectangle.go | 0.864882 | 0.662053 | rectangle.go | starcoder |
package dxfer
import (
"fmt"
"github.com/yofu/dxf/entity"
"math"
)
type Polyline struct {
*entity.LwPolyline
}
func (p *Polyline) Translate(x, y float64) {
for j := range p.Vertices {
p.Vertices[j][0] = p.Vertices[j][0] + x
p.Vertices[j][1] = p.Vertices[j][1] + y
}
}
func (p *Polyline) Scale(scaleFactor ... | dxfer/polyline.go | 0.61451 | 0.454048 | polyline.go | starcoder |
package main
import (
"math"
)
type Item struct {
Vertex int
Distance int
}
// O((v + e) * log(v)) time | O(v) space
// where V is the number of vertices and E is the number of edges in the input graph
func DijkstrasAlgorithm(start int, edges [][][]int) []int {
numVertices := len(edges)
minDistance := make([... | src/famous-algorithms/dijkstra/go/iterative-heap.go | 0.69035 | 0.546133 | iterative-heap.go | starcoder |
package main
import (
"log"
"math"
"github.com/carbocation/genomisc/cardiaccycle"
"github.com/gonum/stat"
)
func runQC(samplesWithFlags SampleFlags, entries map[string]File, cycle []cardiaccycle.Result, nStandardDeviations float64) {
// Flag entries that have 0 at any point in the cycle -- this should be
// o... | cmd/pixelqc/qc.go | 0.554712 | 0.500366 | qc.go | starcoder |
package simplex
import (
"fmt"
"gonum.org/v1/gonum/mat"
)
// Solve solves a LP problem.
// Takes a maximize vector and the constraints as a matrix
func Solve(maximize mat.Vector, constraints *mat.Dense) float64 {
// original data
constraintCount, variablesCount := constraints.Dims()
variablesCount-- // because... | simplex.go | 0.572842 | 0.525004 | simplex.go | starcoder |
package confd
// NodeName the name of a node
type NodeName string
// Node representation of node data
type Node map[NodeName]interface{}
// NodeValue representation of one node value
type NodeValue interface{}
// NodePath representation of the path to a Node / NodeValue
type NodePath []NodeName
// GetNode 5ead no... | confd/nodes.go | 0.654011 | 0.405979 | nodes.go | starcoder |
package helpView
const HelpHeaderText = `
**Header information:**
Events - Total number of events received by the foundation.
Warm-up - It can take up to 60 seconds to receive all event
information before stats are accurate.
Duration - Amount of time stats has been collecting da... | ui/uiCommon/views/helpView/helpText.go | 0.801742 | 0.531513 | helpText.go | starcoder |
package value
import (
"bytes"
"fmt"
"math"
"strconv"
"strings"
)
type ScalarType int
func (typ ScalarType) String() string {
switch typ {
case String:
return "string"
case Bool:
return "bool"
case Number:
return "number"
}
return "<unknown>"
}
const (
String ScalarType = iota
Bool
Number
)
typ... | value/value.go | 0.675229 | 0.423041 | value.go | starcoder |
package views
import (
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/assert"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
)
type ApproveView struct{}
func (a *ApproveView) Call(contex... | integration/fabric/atsa/fsc/views/approve.go | 0.531453 | 0.62223 | approve.go | starcoder |
package nifi
import (
"encoding/json"
)
// FlowEntity struct for FlowEntity
type FlowEntity struct {
Flow *FlowDTO `json:"flow,omitempty"`
}
// NewFlowEntity instantiates a new FlowEntity object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties require... | model_flow_entity.go | 0.76366 | 0.42931 | model_flow_entity.go | starcoder |
package scorer
import (
"fmt"
"math"
"math/rand"
"strings"
)
var eps = 0.000001
type Vector struct {
Xs []float64
}
func InitVector(length int) *Vector {
return &Vector{
Xs: make([]float64, length),
}
}
func RandomVector(length int) *Vector {
result := InitVector(length)
for i := range result.Xs {
res... | spell/scorer/vector.go | 0.5564 | 0.567098 | vector.go | starcoder |
package problem5
import (
"math"
)
/**
* Smallest multiple
*
* https://projecteuler.net/problem=5
* 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
* What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
*
*... | problem-5/answer.go | 0.774754 | 0.417271 | answer.go | starcoder |
type Point struct {
r, c int
}
type SnakeGame struct {
s []Point
sLen int
foods []Point
width int
height int
}
/** Initialize your data structure here.
@param width - screen width
@param height - screen height
@param food - A list of food positions
E.g fo... | Completed/Go/353.go | 0.803868 | 0.564519 | 353.go | starcoder |
package src
/*
Via: https://github.com/awsdocs/aws-doc-sdk-examples/
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined... | src/directory_iterator.go | 0.739046 | 0.431345 | directory_iterator.go | starcoder |
package compress
import (
"bytes"
"encoding/binary"
"fmt"
"math"
)
// DecompressionBuffer holds compressed data and provides methods for decompressing it.
type DecompressionBuffer struct {
data []byte
current byte
currentByteIndex uint32
leadingZeroWindowLength uint32
lengthOfWindow ... | util/compress/decompress.go | 0.661376 | 0.493714 | decompress.go | starcoder |
package bls
import (
"encoding/binary"
"errors"
"fmt"
"math/big"
"math/bits"
)
// FRRepr represents a uint256.
type FRRepr [4]uint64
// IsOdd checks if the FRRepr is odd.
func (f FRRepr) IsOdd() bool {
return f[0]&1 == 1
}
// IsEven checks if the FRRepr is even.
func (f FRRepr) IsEven() bool {
return f[0]&1 ... | frrepr.go | 0.690037 | 0.426501 | frrepr.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPName261 struct for BTPName261
type BTPName261 struct {
BTPNode7
BtType *string `json:"btType,omitempty"`
ForExport *bool `json:"forExport,omitempty"`
GlobalNamespace *bool `json:"globalNamespace,omitempty"`
Identifier *BTPIdentifier8 `json:"identifier,omitempty"`... | onshape/model_btp_name_261.go | 0.689096 | 0.419053 | model_btp_name_261.go | starcoder |
package itertools
//CombinationIterator iterates over all ways of choosing k elements from 0, ..., n-1 in lexicographic order.
type CombinationIterator struct {
n int
k int
data []int
}
//Next moves the Iterator to the next combination, returning true if there is one and false is there isn't.
func (b *Combin... | itertools/combinations.go | 0.738575 | 0.401776 | combinations.go | starcoder |
package year2021
import (
"fmt"
"github.com/dhruvmanila/advent-of-code/go/pkg/queue"
"github.com/dhruvmanila/advent-of-code/go/util"
)
// octopusGrid contains information regarding the grid formed by all the octopuses.
type octopusGrid struct {
// grid is a map from position to the octopus energy level.
grid ma... | go/year2021/sol11.go | 0.667364 | 0.471345 | sol11.go | starcoder |
package ml
import (
"math"
"github.com/drakos74/go-ex-machina/xmath"
)
// Activation defines the activation function for an ml module.
type Activation interface {
F(x float64) float64
D(x float64) float64
}
// Sigmoid uses sigmoid activation.
var Sigmoid = sigmoid{}
type sigmoid struct {
}
// F applies the ac... | xmachina/ml/activation.go | 0.79909 | 0.716938 | activation.go | starcoder |
package a
import "fmt"
type ImplicitOrd interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
~float32 | ~float64 |
~string
}
func LessGiven[T ImplicitOrd]() Ord[T] {
return LessFunc[T](func(a, b T) bool {
return a < b
})
}
type Eq[T any] interfac... | test/typeparam/issue50485.dir/a.go | 0.685844 | 0.421284 | a.go | starcoder |
package types
import (
"fmt"
"math"
)
// Op is an identifier of a single operation of an expression.
type Op uint8
const (
// See also a description of Reverse Polish Notation to better
// understand the stack.
// OpUndefined means operation was not successfully parsed
OpUndefined = Op(iota)
// OpFetch mean... | types/op.go | 0.737725 | 0.588002 | op.go | starcoder |
package missing_identity_provider_isolation
import (
"github.com/threagile/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "missing-identity-provider-isolation",
Title: "Missing Identity Provider Isolation",
Description: "Ativos de provedor de identidade altamente con... | risks/built-in/missing-identity-provider-isolation/missing-identity-provider-isolation-rule.go | 0.518059 | 0.544135 | missing-identity-provider-isolation-rule.go | starcoder |
package gorootcheck
/*
OSSEC Rootcheck features
#1 Read the rootkit_files.txt which contains a database of rootkits and files commonly used by them. It will try to stats, fopen and opendir each specified file. We use all these system calls because some kernel-level rootkits hide files from some system calls. The m... | internal/gorootcheck/gorootcheck.go | 0.5 | 0.562417 | gorootcheck.go | starcoder |
package commons
import (
"fmt"
"math"
"time"
"github.com/CapregSoft/go-prayer-time/constants"
)
func FixAngle(angle float64) float64 {
angle = angle - 360.0*(math.Floor(angle/360.0))
if angle < 0 {
angle = angle + 360.0
}
return angle
}
// range reduce hours to 0..23
func FixHour(hour float64) float64 {... | commons/commons.go | 0.780746 | 0.612165 | commons.go | starcoder |
package vector
import (
"math/big"
"reflect"
)
// Vector class.
// Internally, this class holds an array to empty interface, i.e. arbitrary type.
type Vector []interface{}
// Create a Vector with some arguments.
func New(args ...interface{}) *Vector {
v := make(Vector, len(args))
for i, e := range args {
v.Se... | vector/generics/vector.go | 0.739893 | 0.597167 | vector.go | starcoder |
package commands
import (
"fmt"
"github.com/i582/phpstats/internal/shell"
"github.com/i582/phpstats/internal/shell/flags"
)
func Metrics() *shell.Executor {
metricsExecutor := &shell.Executor{
Name: "metrics",
Help: "shows referential information about the metrics being collected",
Flags: flags.NewFlags(... | internal/shell/commands/metrics.go | 0.509032 | 0.586345 | metrics.go | starcoder |
package reflector
import (
"encoding"
"fmt"
"reflect"
"strings"
"time"
"github.com/pkg/errors"
)
// Reflector of structure.
type Reflector struct {
stype reflect.Type
value reflect.Value
}
// New is an constructor from structure instance.
func New(i interface{}) Reflector {
r := Reflector{
stype: reflect... | reflector.go | 0.606964 | 0.441432 | reflector.go | starcoder |
package medtronic
import (
"fmt"
"log"
"time"
)
// BasalRate represents an entry in a basal rate schedule.
type BasalRate struct {
Start TimeOfDay
Rate Insulin
}
// BasalRateSchedule represents a basal rate schedule.
type BasalRateSchedule []BasalRate
func decodeBasalRateSchedule(data []byte) BasalRateSchedul... | basal.go | 0.677474 | 0.621426 | basal.go | starcoder |
package scan
import "reflect"
func indirect(v reflect.Value) reflect.Value {
switch v.Kind() {
case reflect.Interface:
return indirect(v.Elem())
case reflect.Ptr:
return v.Elem()
default:
return v
}
}
func walk(v reflect.Value, index []int, fn func(reflect.Value)) {
v = reflect.Indirect(v)
switch v.Kind... | util.go | 0.54819 | 0.419767 | util.go | starcoder |
package graph
import (
"fmt"
plotly "github.com/nboughton/go-plotlytypes"
"github.com/nboughton/stalotto/lotto"
)
const (
tScatter = "scatter"
tBar = "bar"
tLine = "line"
)
// Data groups datasets together to exported and turned into a nice graph
type Data struct {
Datasets []plotly.Dataset `json:"dat... | graph/graph.go | 0.669313 | 0.562417 | graph.go | starcoder |
package domain
const (
EmptyCellCovered = Cell('e')
EmptyCellCoveredAndMarked = Cell('X')
EmptyCellRevealed = Cell('E')
BombCellCovered = Cell('b')
BombCellCoveredAndMarked = Cell('Y')
BombCellRevealed = Cell('B')
)
type Board [][]Cell
type Cell string
type Position struct {... | internal/core/domain/board.go | 0.847179 | 0.47171 | board.go | starcoder |
package sif
import (
"fmt"
"strings"
"time"
)
// ColumnType is an interface which is implemented to define a supported fixed-width column types.
// Sif provides a variety of built-in types. Additional fixed-width types may not be created at this time.
type ColumnType interface {
Size() int // ... | column_type.go | 0.776538 | 0.456652 | column_type.go | starcoder |
package ipv6
import (
"fmt"
"net"
)
// Mask represents a prefix mask. It has any number of leading 1s and then the
// remaining bits are 0s up to the number of bits in an address. It can be all
// zeroes or all ones.
// The zero value of a Mask is "/0"
type Mask struct {
ui uint128
}
var maxUint128 = uint128{^ui... | ipv6/mask.go | 0.853058 | 0.491761 | mask.go | starcoder |
package datatable
import (
"regexp"
"strings"
"github.com/pkg/errors"
)
// InnerJoin selects records that have matching values in both tables.
// left datatable is used as reference datatable.
// <!> InnerJoin transforms an expr column to a raw column
func (left *DataTable) InnerJoin(right *DataTable, on []JoinOn... | join.go | 0.609524 | 0.466481 | join.go | starcoder |
package cmd
import (
"fmt"
"math"
"sort"
"strings"
"github.com/prometheus/client_golang/prometheus"
)
type POSHistogram struct {
bucket map[float64]uint64
count uint64
sum float64
labelKey []string
labelValue []string
}
type POSHistogramCollector struct {
desc *prometheus.Desc
metri... | tool/pos-exporter/cmd/pos-histogram.go | 0.716219 | 0.450903 | pos-histogram.go | starcoder |
package ot
/*
There are (at least) two Go packages around for parsing SFNT fonts:
▪ https://pkg.go.dev/golang.org/x/image/font/sfnt
▪ https://pkg.go.dev/github.com/ConradIrwin/font/sfnt
It's always a good idea to prefer packages from the Go core team, and the
x/image/font/sfnt package is certainly well suited for r... | core/font/opentype/ot/doc.go | 0.749454 | 0.420183 | doc.go | starcoder |
package slice
import "errors"
// SumByte returns the sum of the values of a byte Slice or an error in case of a nil or empty slice
func SumByte(a []byte) (byte, error) {
var sum byte
if len(a) == 0 {
return sum, errors.New("Cannot calculate the sum of a nil or empty slice")
}
for k := range a {
sum += a[k]
... | sum.go | 0.865494 | 0.720688 | sum.go | starcoder |
package metrics2
/*
Metrics2 Package
================
Concepts
--------
The major difference between the old metrics format and the new is that, from
the app’s point of view, the old metrics were specified using a single metric
name. In the new format, metrics are specified using a measurement name and a
map[string... | go/metrics2/docs.go | 0.69987 | 0.686547 | docs.go | starcoder |
package entities
import (
"fmt"
"math"
"github.com/Vladimiroff/vec2d"
)
type SolarSlot struct {
Data string
Position *vec2d.Vector
}
func newSolarSlot(x, y float64) *SolarSlot {
ss := new(SolarSlot)
ss.Position = vec2d.New(x, y)
ss.Data = ""
return ss
}
func (ss *SolarSlot) Key() string {
return fmt.... | entities/solar_slot.go | 0.809201 | 0.450964 | solar_slot.go | starcoder |
package types
import (
"bytes"
"fmt"
"strings"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// MaxSortableDec largest sortable sdk.Dec
var MaxSortableDec = sdk.OneDec().Quo(sdk.SmallestDec())
// ValidSortableDec sdk.Dec can't have precision of less than 10^-18
func ValidSortableDec(dec sdk.Dec) bool {
return dec... | x/cdp/types/utils.go | 0.816553 | 0.405979 | utils.go | starcoder |
package common
import (
"fmt"
"regexp"
"strconv"
"strings"
"github.com/0chain/errors"
)
// A Key represents an identifier. It can be a pool ID, client ID, smart
// contract address, etc.
type Key string
// A Size represents a size in bytes.
type Size int64
func byteCountIEC(b int64) string {
const unit = 102... | core/common/misc.go | 0.741019 | 0.40869 | misc.go | starcoder |
package tpch
var q1a = [][]string{
{`A`, `F`, `37734107.00`, `56586554400.73`, `53758257134.8700`, `55909065222.827692`, `25.522006`, `38273.129735`, `0.049985`, `1478493`},
{`N`, `F`, `991417.00`, `1487504710.38`, `1413082168.0541`, `1469649223.194375`, `25.516472`, `38284.467761`, `0.050093`, `38854`},
{`N`, `O`,... | tpch/answer.go | 0.625552 | 0.520862 | answer.go | starcoder |
package geom
import "math"
import "errors"
type Matrix4 [16]float64
func NewMatrix4Identity() Matrix4 {
return Matrix4{
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
}
}
func NewMatrix4FromColumns(cols [4]Vector4) Matrix4 {
return Matrix4{
cols[0][0], cols[1][0], cols[2][0], cols[3][0],
cols[0][1],... | geom/matrix.go | 0.794744 | 0.616965 | matrix.go | starcoder |
package wyhash
import (
"reflect"
"unsafe"
"github.com/zhangyunhao116/wyhash/internal/unalign"
)
type Digest struct {
initseed uint64
seed uint64
see1 uint64
data [64]byte
length int
total int
}
// New creates a new Digest that computes the 64-bit wyhash algorithm.
func New(seed uint64) *D... | digest.go | 0.647687 | 0.41182 | digest.go | starcoder |
package constrainediterable
import (
"sort"
"time"
)
type internalElement struct {
value interface{}
creationTime time.Time
}
// NewMap returns a Map with the passed size and age limits.
func NewMap(size int, age time.Duration) *Map {
return &Map{
innerMap: map[string]*internalElement{},
sortedKeys... | map.go | 0.752468 | 0.400661 | map.go | starcoder |
package color
import (
"fmt"
"image/color"
"math"
)
// CIEXYZ represents the CIE 1931 XYZ color space.
// For background on the experiments that produced the
// color space definition (as well as CIE RGB), see
// https://en.wikipedia.org/wiki/CIE_1931_color_space
type CIEXYZ struct {
X, Y, Z float64
// TODO con... | lib/image/color/cie_xyz.go | 0.67662 | 0.481271 | cie_xyz.go | starcoder |
package msgraph
// RatingCanadaTelevisionType undocumented
type RatingCanadaTelevisionType int
const (
// RatingCanadaTelevisionTypeVAllAllowed undocumented
RatingCanadaTelevisionTypeVAllAllowed RatingCanadaTelevisionType = 0
// RatingCanadaTelevisionTypeVAllBlocked undocumented
RatingCanadaTelevisionTypeVAllBlo... | v1.0/RatingCanadaTelevisionTypeEnum.go | 0.598195 | 0.455138 | RatingCanadaTelevisionTypeEnum.go | starcoder |
package vida
import (
"fmt"
"path/filepath"
"unsafe"
)
// Importable is the common interface for GModules and VModules.
type Importable interface {
GetModuleName() string
IsGModule() bool
IsVModule() bool
}
// GModule is the data structure to models an importable named environment written in Go.
type GModule s... | vida/module.go | 0.645343 | 0.44065 | module.go | starcoder |
package geo
// Maybe move to https://github.com/paulmach/go.geo ?
// Formulas from http://www.movable-type.co.uk/scripts/latlong.html
// Quadtree walking: https://www.cs.umd.edu/class/spring2008/cmsc420/L17-18.QuadTrees.pdf
import "math"
const (
kmtomiles = float64(0.621371192)
earthRadiusKM = float64(6371)
kKMP... | geo.go | 0.90369 | 0.665447 | geo.go | starcoder |
package parser
import (
"fmt"
"commaql/compiler/ast"
"commaql/compiler/parser/tokenizer"
)
func (p *Parser) expression() ast.Node {
return p.logicalOR()
}
func (p *Parser) logicalOR() ast.Node {
expr := p.logicalAND()
if expr == nil {
return nil
}
for p.match(tokenizer.OR) {
operator := p.previous()
... | compiler/parser/expr_parser.go | 0.576065 | 0.410697 | expr_parser.go | starcoder |
package data
// Data is the structure of the data directory.
type Data struct {
TemplateDir string `yaml:"template_dir"`
TemplatePaths []string `yaml:"template_paths"`
DataDir string `yaml:"data_dir"`
Hierarchy []string `yaml:"hierarchy"`
}
// HostData is the data relating to a particular host.
ty... | pkg/netconfig/data/data.go | 0.663669 | 0.456773 | data.go | starcoder |
package random
import (
"math/rand"
"time"
)
// Bool function is used to return a random bool value from true and false (type bool).
func Bool() bool {
a := []bool{false, true}
return a[rand.Intn(len(a))]
}
// Integer function is used to get a random integer between a range [startNum, endNum].
// startNum (type ... | random.go | 0.744099 | 0.649537 | random.go | starcoder |
package toms
import (
"github.com/dreading/gospecfunc/machine"
"github.com/dreading/gospecfunc/utils"
"math"
)
// EXP3 calculates the value of ∫ 0 to x (exp(-t*t*t)) dt
// The code uses Chebyshev expansions with the coefficients
// given to 20 decimal places
func EXP3(XVALUE float64) float64 {
const (
ZERO ... | integrals/internal/toms/exp3.go | 0.532911 | 0.460168 | exp3.go | starcoder |
package period2021
import (
"github.com/mzdyhrave/legaliosgo/internal/props"
"github.com/mzdyhrave/legaliosgo/internal/providers"
"github.com/mzdyhrave/legaliosgo/internal/types"
. "github.com/shopspring/decimal"
)
type providerTaxing2021 struct {
providers.ProviderBase
}
func NewProviderTaxing2021() providers.... | internal/providers/period2021/provider_taxing_2021.go | 0.71103 | 0.401952 | provider_taxing_2021.go | starcoder |
// Package equation implements SPOOK equations based on
// the 2007 PhD thesis of <NAME> titled
// "Ghosts and Machines: Regularized Variational Methods for
// Interactive Simulations of Multibodies with Dry Frictional Contacts"
package equation
import (
"github.com/hecate-tech/engine/math32"
)
// IBody ... | experimental/physics/equation/equation.go | 0.828315 | 0.618492 | equation.go | starcoder |
package cios
import (
"fmt"
"math"
"reflect"
"sort"
)
type NullableMultipleSeriesDataLocationUnixStream []NullableMultipleSeriesDataLocationUnix
func NullableMultipleSeriesDataLocationUnixStreamOf(arg ...NullableMultipleSeriesDataLocationUnix) NullableMultipleSeriesDataLocationUnixStream {
return arg
}
func Nul... | cios/stream_nullablemultipleseriesdatalocationunix.go | 0.528047 | 0.442034 | stream_nullablemultipleseriesdatalocationunix.go | starcoder |
package abm
import (
"encoding/json"
"errors"
"fmt"
"math"
"math/rand"
"time"
"github.com/benjamin-rood/abm-cp/calc"
"github.com/benjamin-rood/abm-cp/colour"
"github.com/benjamin-rood/abm-cp/geometry"
"github.com/benjamin-rood/abm-cp/render"
)
// ColourPolymorphicPrey – Prey agent type for Predator-Prey AB... | abm/cp-prey.go | 0.562657 | 0.410874 | cp-prey.go | starcoder |
package tree
import (
"fmt"
"regexp"
"strconv"
"strings"
"time"
)
// WeekByDate returns weeks in year.
func WeekByDate(t time.Time) int {
var week int
yearDay := t.YearDay()
yearFirstDay := t.AddDate(0, 0, -yearDay+1)
firstDayInWeek := int(yearFirstDay.Weekday())
firstWeekDays := 1
if firstDayInWeek != 0 {... | pkg/sql/sem/tree/date_part_strftime.go | 0.602412 | 0.409398 | date_part_strftime.go | starcoder |
package schedules
import (
"fmt"
"strconv"
)
// WEEKDAYS number of days in a week.
const WEEKDAYS = 7
// WORKDAYS number of days that can have lessons.
const WORKDAYS = 6
// DaysEN array with the name of the weekdays starting at monday (english).
var DaysEN = [...]string{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", ... | legacy/schedules/date.go | 0.68595 | 0.466299 | date.go | starcoder |
// Package math provides template functions for mathematical operations.
package math
import (
"errors"
"math"
_math "github.com/neohugo/neohugo/common/math"
"github.com/spf13/cast"
)
// New returns a new instance of the math-namespaced template functions.
func New() *Namespace {
return &Namespace{}
}
// Nam... | tpl/math/math.go | 0.840554 | 0.448185 | math.go | starcoder |
package bn256
// For details of the algorithms used, see "Multiplication and Squaring on
// Pairing-Friendly Fields, Devegili et al.
// http://eprint.iacr.org/2006/471.pdf.
import (
"math/big"
)
// gfP2 implements a field of size p² as a quadratic extension of the base
// field where i²=-1.
type gfP2 struct {
x, ... | vendor/github.com/ethereum/go-ethereum/crypto/bn256/google/gfp2.go | 0.795102 | 0.471953 | gfp2.go | starcoder |
package main
func (t *createMetadataTimeSeries) readLatest() timeSeriesPoint {
//get the last timeSeriesPoint that was inserted
createMetadataTimeSeriesMutex.RLock()
defer createMetadataTimeSeriesMutex.RUnlock()
dataNow := t.data
if len(dataNow) == 0 {
return timeSeriesPoint{cpm: 0, wT: 0}
}
data := t.data[le... | src/timeSeriesController.go | 0.59302 | 0.480052 | timeSeriesController.go | starcoder |
package service_registry_poisoning
import (
"github.com/threagile/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "service-registry-poisoning",
Title: "Service Registry Poisoning",
Description: "When a service registry used for discovery of trusted service... | risks/built-in/service-registry-poisoning/service-registry-poisoning-rule.go | 0.626924 | 0.44897 | service-registry-poisoning-rule.go | starcoder |
package v1_0
func init() {
Profile["/tosca/openstack/1.0/data.yaml"] = `
tosca_definitions_version: tosca_simple_yaml_1_3
data_types:
openstack.IpAddress:
derived_from:
string
openstack.MacAddress:
derived_from:
string
openstack.NetCidr:
derived_from:
string
openstack.Neutr... | tosca/profiles/openstack/v1_0/data.go | 0.692954 | 0.40751 | data.go | starcoder |
package graphic
import (
"github.com/thommil/tge-g3n/core"
"github.com/thommil/tge-g3n/geometry"
"github.com/thommil/tge-g3n/gls"
"github.com/thommil/tge-g3n/material"
"github.com/thommil/tge-g3n/math32"
)
// Points represents a geometry containing only points
type Points struct {
Graphic // Embedd... | graphic/points.go | 0.912403 | 0.495545 | points.go | starcoder |
package geojson
import (
"encoding/json"
"errors"
"github.com/paulmach/orb"
)
// A Geometry matches the structure of a GeoJSON Geometry.
type Geometry struct {
Type string `json:"type"`
Coordinates orb.Geometry `json:"coordinates,omitempty"`
Geometries []*Geometry `json:"geometries,omitempty"`
}... | geojson/geometry.go | 0.850438 | 0.547887 | geometry.go | starcoder |
package behavioral
import (
"strings"
)
// Expression represents an expression to evaluate.
type Expression interface {
Interpret(variables map[string]Expression) int
}
// Integer represents an integer number.
type Integer struct {
integer int
}
// Interpret returns the integer representation of the number.
func... | behavioral/interpreter.go | 0.890384 | 0.617801 | interpreter.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.