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 tsm1
import (
"github.com/influxdata/influxdb/tsdb"
)
// ReadFloatBlockAt returns the float values corresponding to the given index entry.
func (t *TSMReader) ReadFloatBlockAt(entry *IndexEntry, vals *[]FloatValue) ([]FloatValue, error) {
t.mu.RLock()
v, err := t.accessor.readFloatBlock(entry, vals)
t.mu... | tsdb/engine/tsm1/reader.gen.go | 0.754463 | 0.469399 | reader.gen.go | starcoder |
package layers
import (
"encoding/binary"
"errors"
"external/google/gopacket"
)
// PPP is the layer for PPP encapsulation headers.
type PPP struct {
BaseLayer
PPPType PPPType
HasPPTPHeader bool
}
// PPPEndpoint is a singleton endpoint for PPP. Since there is no actual
// addressing for the two ends of ... | src/external/google/gopacket/layers/ppp.go | 0.682574 | 0.453443 | ppp.go | starcoder |
package farmer
const guide = `
Automated Testing Tool Guide
We practice "Continuous Integration" (CI), that is, we
automatically run a set of tests on every commit, before
we land it. We do this with an tool called testbot.
Testbot is oriented around pull requests. For any open
pull request, it runs tests on the com... | farmer/guide.go | 0.544317 | 0.703753 | guide.go | starcoder |
package xgp
import (
"bytes"
"fmt"
"math/rand"
"strconv"
"strings"
"github.com/MaxHalford/eaopt"
"github.com/MaxHalford/xgp/metrics"
"github.com/MaxHalford/xgp/op"
)
// A GPConfig contains all the information needed to instantiate an GP.
type GPConfig struct {
// Learning parameters
LossMetric metrics... | gp_config.go | 0.774413 | 0.433022 | gp_config.go | starcoder |
package maps
import (
"github.com/dairaga/gs"
"github.com/dairaga/gs/funcs"
"github.com/dairaga/gs/slices"
)
// Keys returns a slices of all keys.
func (m M[K, V]) Keys() slices.S[K] {
return Fold(
m,
make(slices.S[K], 0, len(m)),
func(z slices.S[K], k K, _ V) slices.S[K] {
return append(z, k)
},
)
}... | maps/map_method.go | 0.824108 | 0.462534 | map_method.go | starcoder |
package main
const appDescription = `parq is a tool for exploring parquet files.
parq helps with viewing data in a parquet file, viewing a
file's schema, and converting data to/from parquet files.
Read more here: https://github.com/a-poor/parq
Submit issues here: https://github.com/a-poor/parq/issues
`
const cmdS... | cliDocs.go | 0.715623 | 0.792304 | cliDocs.go | starcoder |
package nn
import (
"encoding/json"
"fmt"
"io/ioutil"
"github.com/klahssen/go-mat"
"github.com/klahssen/nn/internal/activation"
)
//Perceptron is the simplest neuron, representing a function P. It applies an activation function f to s which is the weighted sum of its inputs + bias: output=f(w*x+b). the multipli... | perceptron.go | 0.733738 | 0.41401 | perceptron.go | starcoder |
package shack
import (
"encoding/json"
"errors"
"net/url"
"reflect"
"strconv"
"strings"
)
type (
rawFlow string
valueFlow string
bodyFlow []byte
formFlow map[string][]string
)
func newRawFlow(value string) rawFlow {
value, _ = url.QueryUnescape(value)
return rawFlow(value)
}
func newValueFlow(valu... | flow.go | 0.728555 | 0.500671 | flow.go | starcoder |
package triangulate
import (
"sort"
"github.com/go-spatial/geom"
"github.com/go-spatial/geom/cmp"
"github.com/go-spatial/geom/planar/triangulate/quadedge"
)
/*
DelaunayTriangulationBuilder is a utility class which creates Delaunay
Triangulations from collections of points and extract the resulting
triangulation ... | planar/triangulate/delaunaytriangulationbuilder.go | 0.869867 | 0.55917 | delaunaytriangulationbuilder.go | starcoder |
package texture
import (
"github.com/jphsd/graphics2d/util"
"math"
)
// NonLinear is used to create a field of circles that uses a non-linear function to fill the circles.
type NonLinear struct {
LambdaX, LambdaY float64 // [1,...)
PhaseX, PhaseY float64 // [0,1]
OffsetX, OffsetY float64 // [0,1]
FFunc ... | nonlinear.go | 0.752377 | 0.607372 | nonlinear.go | starcoder |
package coordtarns
import (
"gonum.org/v1/gonum/mat"
"math"
)
const Re = 6378.137 //地球赤道半径2002.4.7
const Ra = 6378137.0 //WGS84椭球长半轴
const Rb = 6356752.314245179497 //WGS84椭球短半轴
const e1 = 0.081819190842621 //第一偏心率,计算公式为e1=sqrt(Ra*Ra-Rb*Rb)/Ra
const e22 = 0.082094437949656 //第二偏心率
const ... | coordTransformRadar.go | 0.522689 | 0.428114 | coordTransformRadar.go | starcoder |
package models
// Extension is documented here http://hl7.org/fhir/StructureDefinition/Extension
type Extension struct {
ID *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
URL string `bson:"url" json:"url"`
// A... | models/extension.gen.go | 0.89115 | 0.500977 | extension.gen.go | starcoder |
package exp
import (
"fmt"
"xelf.org/xelf/ast"
"xelf.org/xelf/knd"
"xelf.org/xelf/lit"
"xelf.org/xelf/typ"
)
// ErrDefer is a marker error used to indicate a deferred resolution and not a failure per-se.
// The user can errors.Is(err, ErrDefer) and resume program resolution with more context provided.
var ErrDe... | exp/prog.go | 0.580471 | 0.443781 | prog.go | starcoder |
package solution
// pos is a board position
type pos struct {
r, c int
}
func (p pos) Neighbors() []pos {
return []pos{
{p.r + 1, p.c},
{p.r - 1, p.c},
{p.r, p.c + 1},
{p.r, p.c - 1},
}
}
// grid represents a grid of characters.
type grid struct {
char [][]byte
}
func (g grid) Height() int {
return len... | leetcode/word-search-ii/solution.go | 0.754825 | 0.570451 | solution.go | starcoder |
package ast
type (
SourceType string
Program struct {
SourceType SourceType
Body []ProgramBody
}
ProgramBody interface {
VisitProgramBody(ProgramBodyVisitor)
}
ProgramBodyVisitor struct {
Statement func(Statement)
ModuleDeclaration func(ModuleDeclaration)
}
Expression interface {
... | pkg/asset/js/ast/ast.go | 0.5083 | 0.702632 | ast.go | starcoder |
package wrand
import (
"math"
"math/rand"
"sort"
)
// SelectIndex takes a list of weights and returns an index with a probability corresponding
// to the relative weight of each index. Behavior is undefined if len(weights) == 0. A weight
// of 0 will never be selected unless all are 0, in which case any index may ... | wrand.go | 0.753285 | 0.506103 | wrand.go | starcoder |
package edge_compute_networking
import (
"encoding/json"
"time"
)
// NetworkMetadata Metadata associated with an entity
type NetworkMetadata struct {
// A string to string key/value pair
Annotations *map[string]string `json:"annotations,omitempty"`
// A string to string key/value pair
Labels *map[string]string ... | pkg/edge_compute_networking/model_network_metadata.go | 0.800224 | 0.42931 | model_network_metadata.go | starcoder |
package shortest_distance_to_target_color
import (
"math"
"sort"
)
/*
1182. 与目标颜色间的最短距离
https://leetcode-cn.com/problems/shortest-distance-to-target-color
给你一个数组 colors,里面有 1、2、 3 三种颜色。
我们需要在 colors 上进行一些查询操作 queries,其中每个待查项都由两个整数 i 和 c 组成。
现在请你帮忙设计一个算法,查找从索引 i 到具有目标颜色 c 的元素之间的最短距离。
如果不存在解决方案,请返回 -1。
示例 1:
输入:co... | solutions/shortest-distance-to-target-color/d.go | 0.654122 | 0.462655 | d.go | starcoder |
package fp
func (a BoolArray) ZipBoolArray(a2 BoolArray) Tuple2Array {
minLen := int(Int(len(a)).Min(Int(len(a2))))
zipped := make([]Tuple2, minLen)
for i := 0; i < minLen; i++ {
zipped[i] = Tuple2 { a[i], a2[i] }
}
return zipped
}
func (a BoolArray) ZipStringArray(a2 StringArray) Tuple2Array {
minLe... | fp/bootstrap_array_zip.go | 0.680135 | 0.474022 | bootstrap_array_zip.go | starcoder |
package spread
import "github.com/onwsk8r/goption-pricing/formula"
// BearCall involves selling an ITM call and buying an OTM call.
// The is a credit spread, and is most effective when the stock deceeds the
// strike price of the ITM call and both options expire worthless. An example
// would be buying a Mar 130 Cal... | spread/bcbp.go | 0.669205 | 0.449513 | bcbp.go | starcoder |
package cal
import (
"math"
"time"
)
// AddUkraineHolidays adds all Ukraine holidays to the Calendar
func AddUkraineHolidays(c *Calendar) {
c.AddHoliday(uaHolidays()...)
}
type holidayRule struct {
name string
startYear int
endYear int
day int
month time.Month
... | holiday_defs_ua.go | 0.635788 | 0.50177 | holiday_defs_ua.go | starcoder |
package qhull
import (
"fmt"
"log"
"math"
"github.com/celer/csg/csg"
)
const AUTOMATIC_TOLERANCE = 0.0
const DOUBLE_PREC = 2.2204460492503131e-16
//Hull creates a hull between two 3d meshes
type Hull struct {
findIndex int
charLength float64
Debug bool
points []*Ver... | qhull/hull.go | 0.566978 | 0.483892 | hull.go | starcoder |
package backup
import (
"sync"
"github.com/zero-os/0-Disk"
"github.com/zero-os/0-Disk/errors"
)
// unpackRawDedupedMap allows you to unpack a raw deduped map
// and start using it as an actual dedupedMap.
// If the count of the given raw deduped map is `0`, a new dedupedMap is created instead.
// NOTE: the slice ... | nbd/ardb/backup/deduped_map.go | 0.757077 | 0.475544 | deduped_map.go | starcoder |
package gmap
import (
"strconv"
)
// Helper function to convert an interface{} to string
func interfaceToString(v interface{}, def string) (string, error) {
switch v.(type) {
case string:
return v.(string), nil
case bool:
return strconv.FormatBool(v.(bool)), nil
case float64:
return strconv.FormatFloat(v.(... | helpers.go | 0.518546 | 0.478346 | helpers.go | starcoder |
package judgment
// Some code below is taken directly from colorful's doc examples.
// https://github.com/lucasb-eyer/go-colorful/blob/master/doc/gradientgen/gradientgen.go
// May be useful later:
// c, err := colorful.Hex(s)
import (
"errors"
"fmt"
"github.com/lucasb-eyer/go-colorful"
"image/color"
)
// Create... | judgment/colors.go | 0.8618 | 0.455622 | colors.go | starcoder |
package utils
import (
"encoding/binary"
"math"
)
// BytesToUint64 takes a slice of 8 bytes and returns an uint64 value
// NOTE: bytes must be 8 length here, or else it will panic. it should just return an error value
func BytesToUint64(bytes []uint8) (v uint64) {
if len(bytes) != 8 {
panic("Invalid bytes array ... | binary.go | 0.780913 | 0.492798 | binary.go | starcoder |
package main
import (
"fmt"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/stat"
)
type SummaryDoc struct {
// Roots is the set of roots in the Gene Ontology.
Roots []string
// Summaries contains the summaries of a smeargol
// analysis.
Summaries [][]*Summary
}
type Summary stru... | cmd/smeargol/optimal_truncation.go | 0.784278 | 0.512632 | optimal_truncation.go | starcoder |
package bulletproof
import (
"github.com/pkg/errors"
"github.com/coinbase/kryptology/pkg/core/curves"
)
// innerProduct takes two lists of scalars (a, b) and performs the dot product returning a single scalar
func innerProduct(a, b []curves.Scalar) (curves.Scalar, error) {
if len(a) != len(b) {
return nil, err... | pkg/bulletproof/helpers.go | 0.782122 | 0.527621 | helpers.go | starcoder |
package raytracer
import (
"errors"
)
type Matrix struct {
Data [][]float64
Dim int
}
func NewMatrix(dim int, vals [][]float64) *Matrix {
m := new(Matrix)
m.Dim = dim
m.Data = make([][]float64, dim)
for i := range m.Data {
m.Data[i] = make([]float64, dim)
}
copy(m.Data, vals)
return m
}
func ZeroMatrix(... | raytracer/matrices.go | 0.588534 | 0.464537 | matrices.go | starcoder |
package _752_Open_the_Lock
/*https://leetcode.com/problems/open-the-lock/
You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely and wrap around: for example we can turn '9' to be '0', or '0' to be '9'. Each move ... | 752_Open_the_Lock/solution.go | 0.840717 | 0.528959 | solution.go | starcoder |
package lexer
const (
// White space is used to improve legibility of source text and act as separation between tokens, and any amount of white space may appear before or after any token. White space between tokens is not significant to the semantic meaning of a GraphQL Document, however white space characters may ap... | pkg/language/lexer/runes.go | 0.597608 | 0.627181 | runes.go | starcoder |
package cem
import (
"errors"
"fmt"
"math"
"gonum.org/v1/gonum/mat"
)
// This file contains helper functions for matrix calculations.
func choleskySymmetricFromCovariance(covariance *mat.Dense, num int) (*mat.Cholesky, error) {
covariance, err := nearestPD(covariance)
if err != nil {
return nil, err
}
sy... | lib/cem/matrix.go | 0.61057 | 0.452294 | matrix.go | starcoder |
package main
import "fmt"
var interations int
type Tree struct {
node *Node
}
type Node struct {
value int
left *Node
right *Node
}
// Tree's Insert function
func (t *Tree) Insert(value int) *Tree {
if t.node == nil {
t.node = &Node{value: value}
} else {
t.node.Insert(value)
}
return t // Returning ... | 08-Binary-Search/main.go | 0.651798 | 0.442817 | main.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// PositionDetail
type PositionDetail struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for se... | models/position_detail.go | 0.647575 | 0.429609 | position_detail.go | starcoder |
package simulation
import (
"bytes"
"crypto/sha1"
"encoding/binary"
"image"
"log"
)
const MaxCharge = 6
type Circuit struct {
wires []*Wire
transistors []*Transistor
}
func (c *Circuit) Wires() []*Wire {
return c.wires
}
type WireState struct {
charge uint8
wire *Wire
}
func (w WireState) Charge... | simulation/simulation.go | 0.549641 | 0.438424 | simulation.go | starcoder |
Package driver provides a standard database/sql compatible SQL driver for Hazelcast.
This driver supports Hazelcast 5.0 and up. Check out the Hazelcast SQL documentation here: https://docs.hazelcast.com/hazelcast/latest/sql/sql-overview
The documentation for the database/sql package is here: https://pkg.go.dev/databa... | sql/driver/doc.go | 0.866203 | 0.619356 | doc.go | starcoder |
package gates
// --- Given Primitive Gates ---
func Nand(x, y bool) bool {
return !(x && y)
}
// --- End of Given Primitive Gates ---
func Not(x bool) bool {
return Nand(x, x)
}
func And(x, y bool) bool {
return Not(Nand(x, y))
}
func Or(x, y bool) bool {
return Nand(Not(x), Not(y))
}
func Xor(x, y bool) bool... | src/gates/gates.go | 0.680135 | 0.708515 | gates.go | starcoder |
package main
import (
"fmt"
"github.com/aaronjanse/3mux/render"
)
// A Split splits a region of the screen into a areas reserved for multiple child nodes
type Split struct {
elements []Node
selectionIdx int
verticallyStacked bool
renderRect Rect
}
func (s *Split) serialize() string {
var out s... | split.go | 0.507568 | 0.409929 | split.go | starcoder |
package profilescmdline
// HelpMsg returns a detailed help message for the profiles packages.
func HelpMsg() string {
return `
Profiles are used to manage external sofware dependencies and offer a balance
between providing no support at all and a full blown package manager.
Profiles can be built natively as well as ... | profiles/profilescmdline/help.go | 0.840029 | 0.58599 | help.go | starcoder |
package countries
// TypeCurrencyCode for Typer interface
const TypeCurrencyCode string = "countries.CurrencyCode"
// TypeCurrency for Typer interface
const TypeCurrency string = "countries.Currency"
// Currencies. Two codes present, for example CurrencyUSDollar == CurrencyUSD == 840.
const (
CurrencyUnknown ... | currenciesconst.go | 0.568176 | 0.662824 | currenciesconst.go | starcoder |
package dtw
import "math"
// WarpDistance is a more memory efficient O(N) way to calculate the warp
// distance since it only needs to keep 2 columns instead of N*M costs O(N^2)
func WarpDistance(ts1, ts2 TimeSeries, distFunc DistanceFunc) float64 {
n1 := ts1.Len()
n2 := ts2.Len()
mem := make([]float64, n1*2)
las... | dtw/dtw.go | 0.726911 | 0.621282 | dtw.go | starcoder |
package main
import (
"github.com/gen2brain/raylib-go/physics"
"github.com/gen2brain/raylib-go/raylib"
)
const (
velocity = 0.5
)
func main() {
screenWidth := float32(800)
screenHeight := float32(450)
raylib.SetConfigFlags(raylib.FlagMsaa4xHint)
raylib.InitWindow(int32(screenWidth), int32(screenHeight), "Phy... | examples/physics/physac/movement/main.go | 0.658198 | 0.510008 | main.go | starcoder |
package v1
import (
"fmt"
"strings"
"github.com/prometheus/prometheus/pkg/textparse"
)
// A MetricConverter contains the logic to convert a Metric to a Panel.
type MetricConverter interface {
// Can indicates that a MetricConverter can handle a Metric.
Can(metric Metric) bool
// Do contains the the code that t... | pkg/converter.go | 0.809653 | 0.407274 | converter.go | starcoder |
package pso
import (
"math"
"math/rand"
"time"
)
type (
particle struct {
position, best, velocity []float64
bestCost float64
}
dimension struct {
min, max float64
}
ParticleSwarmOptimizer struct {
Iterations, Size int
Ω, Φp, Φg float64
Rand *rand.Ran... | pso/pso.go | 0.525856 | 0.416322 | pso.go | starcoder |
package quantum
import (
"bytes"
"fmt"
"math"
"strconv"
)
// Qubit is a representation of a qubit.
type Qubit struct {
basis0 complex128
basis1 complex128
}
// MakeQubit creates a qubit from the provided basis states.
// It returns a Qubit struct if the provided states represent a unit vector.
// It returns an... | qubit.go | 0.86592 | 0.766162 | qubit.go | starcoder |
package outputs
import (
"time"
"barista.run/bar"
"barista.run/timing"
)
// AtTimeDelta creates a TimedOutput from a function by repeatedly calling it at
// different times, using a fixed point in time as a reference point.
type AtTimeDelta func(time.Duration) bar.Output
// From sets the reference point and cre... | outputs/timedelta.go | 0.81457 | 0.639624 | timedelta.go | starcoder |
package cellularautomata
import (
"math"
"github.com/arbori/population.git/population/lattice"
"github.com/arbori/population.git/population/rule"
)
type Cellularautomata struct {
env lattice.Lattice
mirror lattice.Lattice
states []float32
motion [][]int
rule rule.Rule
dimention int
}
fu... | cellularautomata/cellularautomata.go | 0.57344 | 0.519278 | cellularautomata.go | starcoder |
package main
import (
"fmt"
"math"
"os"
"github.com/pointlander/datum/iris"
)
var MaxEntropy = math.Log2(3)
// Embeddings is a set of embeddings
type Embeddings struct {
Columns int
Network *Network
Embeddings []Embedding
}
// Embedding is an embedding with a label and features
type Embedding struct ... | embedding.go | 0.806777 | 0.596727 | embedding.go | starcoder |
package measurement
import (
"log"
"time"
"github.com/tarent/gomulocity/measurement"
)
var Example1NewMeasurements = measurement.NewMeasurement{
Time: timeToPointer(time.Now().Format(time.RFC3339)),
MeasurementType: "P",
Metrics: map[string]interface{}{
"P": struct {
P struct {
Unit string... | examples/measurement/example_newMeasurements.go | 0.636918 | 0.486271 | example_newMeasurements.go | starcoder |
package main
import (
"math"
"math/rand"
)
type Weight struct {
Weight Dual
Delta, Gradient float32
}
type Network struct {
Sizes []int
Layers [][]Weight
Biases [][]Weight
}
func random32(a, b float32) float32 {
return (b-a)*rand.Float32() + a
}
func NewNetwork(sizes ...int) Network {
last, lay... | network.go | 0.652352 | 0.448004 | network.go | starcoder |
package tileset
import (
"image"
"github.com/mewkiz/pkg/imgutil"
)
// A TileSet is a collection of one or more tile images, all of which have the
// same width and height.
type TileSet struct {
// Tile set sprite sheet.
imgutil.SubImager
// Tile width.
TileWidth int
// Tile height.
TileHeight int
// Tile se... | tileset/tileset.go | 0.661595 | 0.492188 | tileset.go | starcoder |
package dfl
import (
"fmt"
"github.com/pkg/errors"
"github.com/spatialcurrent/go-adaptive-functions/pkg/af"
)
// Add is a BinaryOperator that represents the addition of two nodes.
type Add struct {
*BinaryOperator
}
// Dfl returns the DFL representation of this node as a string
func (a Add) Dfl(quotes []strin... | pkg/dfl/Add.go | 0.87401 | 0.54153 | Add.go | starcoder |
package awk
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"regexp"
"time"
"github.com/Jeffail/gabs/v2"
"github.com/benhoyt/goawk/interp"
"github.com/benhoyt/goawk/parser"
"github.com/benthosdev/benthos/v4/internal/bundle"
"github.com/benthosdev/benthos/v4/internal/component/processor"
... | internal/impl/awk/processor.go | 0.682468 | 0.626653 | processor.go | starcoder |
package gtasa
import (
"github.com/jamiemansfield/gtasave/io"
"github.com/jamiemansfield/gtasave/util"
"math"
"reflect"
)
func Parse(data []byte, v interface{}) error {
// Separate the blocks
var blocks [34][]byte
var index = 0
reader := io.CreateReader(data)
for reader.Available() {
if isAtBoundary(reader... | gtasa/parser.go | 0.638046 | 0.457621 | parser.go | starcoder |
package enumerable
// MapIntToInt maps a slice of int to int
func MapIntToInt(in []int, f func(int) int) []int {
out := make([]int, len(in))
for i, value := range in {
out[i] = f(value)
}
return out
}
// MapIntToFloat64 maps a slice of int to float64
func MapIntToFloat64(in []int, f func(int) float64) []float64... | generated_map_funcs.go | 0.788013 | 0.431285 | generated_map_funcs.go | starcoder |
package prop
import (
"math"
"time"
)
// DurationConstraint is an interface to represent time.Duration constraint.
type DurationConstraint interface {
Compare(time.Duration) (float64, bool)
Value() (time.Duration, bool)
}
// Duration specifies ideal duration value.
// Any value may be selected, but closest value... | pkg/prop/duration.go | 0.861378 | 0.523116 | duration.go | starcoder |
package coord
import (
"math"
)
// WGS84坐标系:即地球坐标系,国际上通用的坐标系。
// GCJ02坐标系:即火星坐标系,WGS84坐标系经加密后的坐标系。Google Maps,高德在用。
// BD09坐标系:即百度坐标系,GCJ02坐标系经加密后的坐标系。
const (
X_PI = math.Pi * 3000.0 / 180.0
OFFSET = 0.00669342162296594323
AXIS = 6378245.0
)
//BD09toGCJ02 百度坐标系->火星坐标系
func BD09toGCJ02(lon, lat float64) (fl... | tools/coord/transform.go | 0.526343 | 0.434761 | transform.go | starcoder |
package enginetest
import (
"github.com/dolthub/go-mysql-server/enginetest/queries"
)
// DoltDiffPlanTests are tests that check our query plans for various operations on the dolt diff system tables
var DoltDiffPlanTests = []queries.QueryPlanTest{
{
Query: `select * from dolt_diff_one_pk where to_pk=1`,
Expecte... | go/libraries/doltcore/sqle/enginetest/dolt_query_plans.go | 0.613005 | 0.634458 | dolt_query_plans.go | starcoder |
package graph
import (
"fmt"
"io"
"math"
"path/filepath"
"strings"
"github.com/google/pprof/internal/measurement"
)
// DotAttributes contains details about the graph itself, giving
// insight into how its elements should be rendered.
type DotAttributes struct {
Nodes map[*Node]*DotNodeAttributes // A map all... | vendor/github.com/google/pprof/internal/graph/dotgraph.go | 0.690142 | 0.509947 | dotgraph.go | starcoder |
package policy
import "github.com/benthosdev/benthos/v4/internal/docs"
// FieldSpec returns a spec for a common batching field.
func FieldSpec() docs.FieldSpec {
return docs.FieldSpec{
Name: "batching",
Type: docs.FieldTypeObject,
Description: `
Allows you to configure a [batching policy](/docs/configuration/b... | internal/batch/policy/docs.go | 0.77768 | 0.498718 | docs.go | starcoder |
package unitcapturereduce
import (
"bytes"
"container/list"
"encoding/json"
"fmt"
)
/*
Reduction algorithm:
Assume UnitCapture outputs keyframes that are linearly interpolated between by UnitPlay (an approximation of actual behaviour)
Goal: Remove keyframes that do not greatly effect the followed 'path' ('path'... | armatools/unitcapturereduce/unitcapturereduce.go | 0.815416 | 0.48987 | unitcapturereduce.go | starcoder |
package result
import (
"fmt"
)
type container[T any] struct {
value T
}
// Result is a helper type for error handling without returning multiple values.
// Any Result will either contain a value or an error.
type Result[S, F any] struct {
value *container[S]
failure *container[F]
}
func (r *Result[_, _]) Str... | result/result.go | 0.76366 | 0.429489 | result.go | starcoder |
package feature
import (
"encoding/json"
"errors"
"fmt"
"github.com/tomchavakis/turf-go/geojson"
"github.com/tomchavakis/turf-go/geojson/geometry"
)
// Feature defines a new feature type
// A Feature object represents a spatially bounded thing. Every object is a GeoJSON object no matter where it
// occurs in a ... | geojson/feature/feature.go | 0.769687 | 0.533397 | feature.go | starcoder |
package gozxing
import (
"math/bits"
errors "golang.org/x/xerrors"
)
type BitArray struct {
bits []uint32
size int
}
func NewEmptyBitArray() *BitArray {
return &BitArray{makeArray(1), 0}
}
func NewBitArray(size int) *BitArray {
return &BitArray{makeArray(size), size}
}
func (b *BitArray) GetSize() int {
re... | bit_array.go | 0.604866 | 0.473596 | bit_array.go | starcoder |
package zcl
import (
"errors"
"github.com/shimmeringbee/bytecodec"
"github.com/shimmeringbee/bytecodec/bitbuffer"
)
/*
* Zigbee Cluster List data types, as per 2.6.2 in ZCL Revision 6 (14 January 2016).
* Downloaded From: https://zigbeealliance.org/developer_resources/zigbee-cluster-library/
*/
const (
TypeNu... | zcl_types.go | 0.590779 | 0.46308 | zcl_types.go | starcoder |
package model
// LocaleInfo holds the data to specify a standard locale.
type LocaleInfo struct {
Ident string
Language string
Country string
}
// Locales is mapping of standard locale idents to LocaleInfo
var Locales = map[string]LocaleInfo{
"sq_AL": LocaleInfo{Ident: "sq_AL", Language: "Albanian", Cou... | parrot-api/model/localeinfo.go | 0.546012 | 0.428413 | localeinfo.go | starcoder |
package main
import (
"errors"
"fmt"
"strconv"
"github.com/openblockchain/obc-peer/openchain/chaincode/shim"
)
/*
This is a system chaincode used to update the validity period on the ledger. It needs to be deployed at genesis time to avoid the need of
a TCert during deployment and It will be invoked by a system... | openchain/system_chaincode/validity_period_update/validity_period_update.go | 0.50415 | 0.453201 | validity_period_update.go | starcoder |
package commands
import (
"fmt"
"strings"
"github.com/BurntSushi/gribble"
"github.com/BurntSushi/xgb/xproto"
"github.com/BurntSushi/xgbutil/xrect"
"github.com/xsrc/wingo/logger"
"github.com/xsrc/wingo/prompt"
"github.com/xsrc/wingo/workspace"
"github.com/xsrc/wingo/wm"
"github.com/xsrc/wingo/xclient"
)
... | commands/misc.go | 0.567218 | 0.449091 | misc.go | starcoder |
package aoc
import (
"fmt"
)
type FP2 uint64
func NewFP2(x, y int32) FP2 {
return FP2(uint64(uint32(x))<<32 + uint64(uint32(y)))
}
func (p FP2) String() string {
x, y := p.XY()
return fmt.Sprintf("%d,%d", x, y)
}
func (p FP2) XY() (int32, int32) {
y := int32(p & 0xffffffff)
x := int32((p >> 32) & 0xffffffff)... | lib-go/fastpoint2d.go | 0.508544 | 0.407451 | fastpoint2d.go | starcoder |
package types
import (
"github.com/juju/errors"
mysql "github.com/pingcap/tidb/mysqldef"
)
// CompareInt64 returns an integer comparing the int64 x to y.
func CompareInt64(x, y int64) int {
if x < y {
return -1
} else if x == y {
return 0
}
return 1
}
// CompareUint64 returns an integer comparing the uin... | util/types/compare.go | 0.710729 | 0.62701 | compare.go | starcoder |
package sliceutil
import "reflect"
func findFist(s interface{}, a interface{}) (int, bool) {
si := reflect.ValueOf(s)
if si.IsNil() || si.Len() == 0 {
return -1, false
}
for i := 0; i < si.Len(); i++ {
if reflect.DeepEqual(si.Index(i).Interface(), a) {
return i, true
}
}
return -1, false
}
func fin... | find.go | 0.816443 | 0.473414 | find.go | starcoder |
package throttle
import (
"sync/atomic"
"time"
)
//------------------------------------------------------------------------------
// Type is a throttle of retries to avoid endless busy loops when a message
// fails to reach its destination.
type Type struct {
// unthrottledRetries is the number of concecutive ret... | lib/util/throttle/type.go | 0.738669 | 0.438424 | type.go | starcoder |
package clock
import (
"context"
"time"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/venus/pkg/specactors/builtin"
)
// DefaultEpochDuration is the default duration of epochs
const DefaultEpochDuration = builtin.EpochDurationSeconds * time.Second
// DefaultPropagationDelay is t... | pkg/clock/chainclock.go | 0.811527 | 0.479382 | chainclock.go | starcoder |
package tensor
import (
"runtime"
)
// MultIterator is an iterator that iterates over multiple tensors, including masked tensors.
// It utilizes the *AP of a Tensor to determine what the next index is.
// This data structure is similar to Numpy's flatiter, with some standard Go based restrictions of course
// (such... | vendor/gorgonia.org/tensor/iterator_mult.go | 0.591251 | 0.429968 | iterator_mult.go | starcoder |
package gender
import (
"github.com/akhripko/gremlin-ent/ent/predicate"
"github.com/facebook/ent/dialect/gremlin/graph/dsl"
"github.com/facebook/ent/dialect/gremlin/graph/dsl/__"
"github.com/facebook/ent/dialect/gremlin/graph/dsl/p"
)
// ID filters vertices based on their identifier.
func ID(id int) predicate.Ge... | ent/gender/where.go | 0.713032 | 0.404743 | where.go | starcoder |
package longest_continuous_subarray_with_absolute_diff_less_than_or_equal_to_limit
import (
"container/heap"
"github.com/zrcoder/leetcodeGo/util/intheap"
)
/*
1438. 绝对差不超过限制的最长连续子数组 https://leetcode-cn.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/
给你一个整数数组 nums ,和一个表示限制的整数... | solutions/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/d.go | 0.647464 | 0.446434 | d.go | starcoder |
package fitness
import (
"github.com/RH12503/Triangula/geom"
"github.com/RH12503/Triangula/image"
"github.com/RH12503/Triangula/rasterize"
"github.com/RH12503/Triangula/triangulation/incrdelaunay"
)
type polygonsImageFunction struct {
target pixelData // pixels data of the target image.
// Variance data stored... | fitness/polygons.go | 0.794465 | 0.561455 | polygons.go | starcoder |
package types
import (
"fmt"
"regexp"
"strconv"
"github.com/TheThingsNetwork/ttn/utils/errors"
"github.com/brocaar/lorawan/band"
)
type DataRate struct {
SpreadingFactor uint `json:"spreading_factor,omitempty"`
Bandwidth uint `json:"bandwidth,omitempty"`
}
// ParseDataRate parses a 32-bit hex-encoded... | core/types/data_rate.go | 0.754734 | 0.400368 | data_rate.go | starcoder |
package power
import . "github.com/deinspanjer/units/unit"
// Power represents a SI unit of power (in watts, W)
type Power Unit
// ...
const (
// SI
Yoctowatt = Watt * 1e-24
Zeptowatt = Watt * 1e-21
Attowatt = Watt * 1e-18
Femtowatt = Watt * 1e-15
Picowatt = Watt * 1e-12
Nanowa... | power/power.go | 0.804675 | 0.401189 | power.go | starcoder |
package ckmeans
func fill_dp_matrix(x, w []float64, S [][]float64, J [][]int) {
K := len(S)
N := len(S[0])
sum_x := make([]float64, N)
sum_x_sq := make([]float64, N)
sum_w := make([]float64, len(w))
sum_w_sq := make([]float64, len(w))
// //jseq := []int{}
shift := x[N/2] // median. used to shift the values... | taps2beats/ckmeans/dp.go | 0.531209 | 0.429071 | dp.go | starcoder |
package analyzer
import (
"fmt"
"strings"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/expression"
"github.com/dolthub/go-mysql-server/sql/plan"
)
// applyIndexesFromOuterScope attempts to apply an indexed lookup to a subquery using variables from the outer scope.
// It func... | sql/analyzer/apply_indexes_from_outer_scope.go | 0.659953 | 0.427695 | apply_indexes_from_outer_scope.go | starcoder |
package maybe
import (
"testing"
"github.com/calebcase/base/control/monad"
"github.com/calebcase/base/data"
)
type Class[A, B, C any] interface {
monad.Class[A, B, C, Maybe[func(A) B], Maybe[A], Maybe[B], Maybe[C]]
NewJust(A) Just[A]
NewNothing() Nothing[A]
}
type Type[A, B, C any] struct{}
// Ensure Type i... | data/maybe/maybe.go | 0.607547 | 0.656355 | maybe.go | starcoder |
package smd
import (
"math"
"github.com/gonum/floats"
"github.com/gonum/matrix/mat64"
)
const (
deg2rad = math.Pi / 180
rad2deg = 1 / deg2rad
)
// Norm returns the Norm of a given vector which is supposed to be 3x1.
func Norm(v []float64) float64 {
return math.Sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
}
// Uni... | math.go | 0.832849 | 0.735974 | math.go | starcoder |
package graph
import (
"fmt"
"sync"
)
// Identifier has an ID method.
type Identifier interface {
ID() string
}
// Simple is an implementation of an undirected unweighted graph.
type Simple struct {
sync.RWMutex
vertices []Identifier
edges map[string][]Identifier
}
// NewSimple initialises a new Simple str... | graph/simple.go | 0.734501 | 0.427277 | simple.go | starcoder |
// Package stdlib implements functions to standard library.
package stdlib
var Modules = []string{
`module Enum
val size = fn (array: Array) -> Integer
var count = 0
repeat v in array
count += 1
end
count
end
val empty? = fn (array: Array) -> Boolean
size(array) == 0
end
val r... | runtime/stdlib/stdlib.go | 0.615897 | 0.565719 | stdlib.go | starcoder |
package web
import (
"github.com/cadmean-ru/amphion/engine"
"github.com/cadmean-ru/amphion/rendering"
)
func drawPoint(p5 *p5, primitive rendering.Primitive) {
t := primitive.GetTransform()
pos := t.Position
point := primitive.(*rendering.GeometryPrimitive)
p5.fill(point.Appearance.FillColor)
p5.point(pos.X,... | frontend/web/primitiveDrawingFunctions.go | 0.594669 | 0.428114 | primitiveDrawingFunctions.go | starcoder |
package continuous
import (
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Johnson SU Distribution (Unbounded)
// https://reference.wolfram.com/language/ref/JohnsonDistribution.html
type JohnsonSU struct {
gamma, delta, location, scale float64 // γ, δ, location μ, and scale σ
... | dist/continuous/johnson_su.go | 0.840488 | 0.458288 | johnson_su.go | starcoder |
package client
import (
"encoding/json"
)
// YearlyScheduleSettings struct for YearlyScheduleSettings
type YearlyScheduleSettings struct {
TimeLocal Time `json:"timeLocal"`
DayNumberInMonth DayNumbersInMonth `json:"dayNumberInMonth"`
DayOfWeek *DaysOfWeek `json:"da... | client/model_yearly_schedule_settings.go | 0.815343 | 0.480844 | model_yearly_schedule_settings.go | starcoder |
package ameda
import (
"strconv"
)
// BoolToInterface converts bool to interface.
func BoolToInterface(v bool) interface{} {
return v
}
// BoolToInterfacePtr converts bool to *interface.
func BoolToInterfacePtr(v bool) *interface{} {
r := BoolToInterface(v)
return &r
}
// BoolToString converts bool to string.
f... | vendor/github.com/henrylee2cn/ameda/bool.go | 0.639511 | 0.44734 | bool.go | starcoder |
package pcapng
import (
"bytes"
"fmt"
"net"
"strings"
"github.com/bearmini/pcapng-go/pcapng/blocktype"
"github.com/bearmini/pcapng-go/pcapng/optioncode"
"github.com/pkg/errors"
)
/*
4.5. Name Resolution Block
The Name Resolution Block (NRB) is used to support the correlation of
numeric addresses (pres... | pcapng/name_resolution_block.go | 0.698946 | 0.505676 | name_resolution_block.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
"strconv"
)
// VarBitArrayFromBoolSliceSlice returns a driver.Valuer that produces a PostgreSQL varbit[] from the given Go [][]bool.
func VarBitArrayFromBoolSliceSlice(val [][]bool) driver.Valuer {
return varBitArrayFromBoolSliceSlice{val: val}
}
// Var... | pgsql/varbitarr.go | 0.603465 | 0.570152 | varbitarr.go | starcoder |
package mmaths
import (
"math/rand"
"sort"
)
// QsortInterface interface to sort.Sort
type QsortInterface interface {
sort.Interface
// Partition returns slice[:i] and slice[i+1:]
// These should references the original memory
// since this does an in-place sort
Partition(i int) (left QsortInterface, right Qso... | sort.go | 0.782455 | 0.467453 | sort.go | starcoder |
package main
import "fmt"
/*
Here we'll look at different ways of writing components.
We'll use `chan string` as the port, we'll look the connections
in a separate folder.
*/
/*
First of all the usual verison, you have a struct per component,
where fields may define configuration.
The `In` could be hooked ... | 09-component-definition/definitions.go | 0.557966 | 0.551332 | definitions.go | starcoder |
package continuous
import (
integ "github.com/jtejido/ggsl/integration"
"github.com/jtejido/ggsl/specfunc"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
smath "github.com/jtejido/stats/math"
"math"
"math/rand"
)
// Q-Gaussian distribution
// https://en.wikipedia.org/wiki/Q-Gaussian_distribution
typ... | dist/continuous/q_gaussian.go | 0.807005 | 0.468851 | q_gaussian.go | starcoder |
package main
import (
"container/list"
"math"
"github.com/gazed/vu"
)
// end is the screen that shows the end of game animation. This is a model of
// a silicon atom. No one is expected to get here based on the current game
// difficulty settings.
type end struct {
scene *vu.Ent // 3D scene.
bg *v... | end.go | 0.711431 | 0.48987 | end.go | starcoder |
package amcl
import (
fmt "fmt"
math "github.com/IBM/mathlib"
)
type Fp256bn struct {
C *math.Curve
}
func (a *Fp256bn) G1ToProto(g1 *math.G1) *ECP {
if g1 == nil {
panic("nil argument")
}
bytes := g1.Bytes()[1:]
l := len(bytes) / 2
return &ECP{
X: bytes[:l],
Y: bytes[l:],
}
}
func (a *Fp256bn) G1F... | vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/fp256bn.go | 0.59972 | 0.441131 | fp256bn.go | starcoder |
package curves
import (
"github.com/wieku/danser-go/framework/math/vector"
)
// NewBSpline creates a spline that goes through all given control points.
// points[1] and points[len(points)-2] are terminal tangents.
func NewBSpline(points []vector.Vector2f) *Spline {
beziers := SolveBSpline(points)
beziersC := make(... | framework/math/curves/bspline.go | 0.796055 | 0.478407 | bspline.go | starcoder |
package gl
// #include "gl.h"
import "C"
//void glFrustum (float64 left, float64 right, float64 bottom, float64 top, float64 zNear, float64 zFar)
func Frustum(left float64, right float64, bottom float64, top float64, zNear float64, zFar float64) {
C.glFrustum(C.GLdouble(left), C.GLdouble(right), C.GLdouble(bottom),... | src/github.com/go-gl/gl/matrix.go | 0.674158 | 0.547887 | matrix.go | starcoder |
package main
import "strconv"
// Device is the representation of the wrist device
type Device [4]int
func (d Device) isEqual(other Device) bool {
for i, value := range d {
if other[i] != value {
return false
}
}
return true
}
func initDevice(strslice []string) Device {
result := Device{}
for i := 0; i <... | 2018/16_1/device.go | 0.722233 | 0.450541 | device.go | starcoder |
package struct2struct
import (
"errors"
"fmt"
"reflect"
"strconv"
)
var appliers []applier
func init() {
appliers = []applier{
interfaceApplier,
settableTestApplier,
matchedTypeApplier,
pointerApplier,
sliceApplier,
mapApplier,
structApplier,
intApplier,
uintApplier,
floatApplier,
stringAp... | vendor/github.com/theothertomelliott/struct2struct/appliers.go | 0.533641 | 0.41567 | appliers.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.