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 multi
import (
"errors"
"github.com/matrixorigin/matrixone/pkg/container/nulls"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/encoding"
"github.com/matrixorigin/matrixone/pkg/vectorize/ceil"
"githu... | pkg/sql/plan2/function/builtin/multi/ceil.go | 0.547706 | 0.504822 | ceil.go | starcoder |
package missing_build_infrastructure
import (
"github.com/threagile/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "missing-build-infrastructure",
Title: "Missing Build Infrastructure",
Description: "A arquitetura modelada não contém uma infraestrutura de construção ... | risks/built-in/missing-build-infrastructure/missing-build-infrastructure-rule.go | 0.536556 | 0.421611 | missing-build-infrastructure-rule.go | starcoder |
package gotabulate
import "strconv"
import "fmt"
// Create normalized Array from strings
func createFromString(data [][]string) []*TabulateRow {
rows := make([]*TabulateRow, len(data))
for index, el := range data {
rows[index] = &TabulateRow{Elements: el}
}
return rows
}
// Create normalized array of rows fro... | vendor/github.com/bndr/gotabulate/utils.go | 0.57678 | 0.563858 | utils.go | starcoder |
package main
import "math"
type Tuple struct {
X float64
Y float64
Z float64
W float64
}
// Add a tuple to the instance and return the result. Note that the sum of two
// vectors is a vector, the sum of a point and a vector is a point, and the sum
// of two points is nonsensical.
func (t Tuple) Add(other Tuple) ... | tuple.go | 0.928959 | 0.850033 | tuple.go | starcoder |
package cbp
import (
"fmt"
cb "github.com/preichenberger/go-coinbasepro/v2"
"github.com/rs/zerolog/log"
"math"
"strconv"
"strings"
)
// Pattern defines the criteria for matching rates and placing orders.
type Pattern struct {
// Id is concatenation of two currencies. eg. BTC-USD
ID string `yaml:"id" json:"id... | pkg/cbp/pattern.go | 0.738198 | 0.454654 | pattern.go | starcoder |
package graphicx
import "image/color"
// ARGB像素值
type Pixel uint32
func (p Pixel) RGBA() (R, G, B, A uint8) {
A, R, G, B = Pixel2ARGB(uint32(p))
return
}
// ARGB像素值
type Pixel64 uint64
func (p Pixel64) RGBA() (R, G, B, A uint16) {
A, R, G, B = Pixel2ARGB64(uint64(p))
return
}
//-------------------------------... | graphicx/pixel.go | 0.74158 | 0.506897 | pixel.go | starcoder |
package writer
import (
"errors"
"io"
)
// Writer is the structure used to write bits, bytes into predefined data.
// It allows to write the bits in two modes. The first and default
// writes bytes with the initial bitIndex 0 as the LSB (Least Significant Bit)
// The second mode writes bits in an opposite manner st... | bot/vendor/github.com/pzduniak/unipdf/internal/jbig2/writer/writer.go | 0.577614 | 0.453262 | writer.go | starcoder |
package glucose
import (
"math"
"github.com/tidepool-org/platform/data"
"github.com/tidepool-org/platform/structure"
)
type Target struct {
High *float64 `json:"high,omitempty" bson:"high,omitempty"`
Low *float64 `json:"low,omitempty" bson:"low,omitempty"`
Range *float64 `json:"range,omitempty" bson:"ran... | data/blood/glucose/target.go | 0.694406 | 0.483831 | target.go | starcoder |
package mask
import (
"regexp"
"unicode/utf8"
"github.com/ozontech/file.d/fd"
"github.com/ozontech/file.d/pipeline"
"github.com/ozontech/file.d/stats"
insaneJSON "github.com/vitkovskii/insane-json"
"go.uber.org/zap"
)
/*{ introduction
Mask plugin matches event with regular expression and substitutions success... | plugin/action/mask/mask.go | 0.751283 | 0.610512 | mask.go | starcoder |
package parser
import (
"fmt"
"net/url"
"github.com/kasperisager/pak/pkg/asset/css/ast"
"github.com/kasperisager/pak/pkg/asset/css/token"
)
type SyntaxError struct {
Offset int
Message string
}
func (err SyntaxError) Error() string {
return err.Message
}
func Parse(tokens []token.Token) (*ast.StyleSheet, e... | pkg/asset/css/parser/parse.go | 0.679817 | 0.402568 | parse.go | starcoder |
package plaid
import (
"encoding/json"
)
// Pay An object representing a monetary amount.
type Pay struct {
// A numerical amount of a specific currency.
Amount NullableFloat32 `json:"amount,omitempty"`
// Currency code, e.g. USD
Currency NullableString `json:"currency,omitempty"`
AdditionalProperties map[stri... | plaid/model_pay.go | 0.838878 | 0.411229 | model_pay.go | starcoder |
package forGraphBLASGo
import (
"github.com/intel/forGoParallel/parallel"
"github.com/intel/forGoParallel/pipeline"
"sync/atomic"
)
/*
Matrix is the exported representation of matrices. It uses Matrix.ref as an indirection to a matrixReference
representation.
When a Matrix is side-effected, then assignments are m... | api_Matrix.go | 0.583678 | 0.695748 | api_Matrix.go | starcoder |
package polyhedra
// NewPolyhedron creates a Polyhedron from the given vertices, edges and faces.
func NewPolyhedron(vertices []Vertex, edges []Edge, faces []Face) (*Polyhedron, error) {
poly := Polyhedron{vertices: vertices}
poly.setFaces(faces)
poly.vertexNeighbors = make(map[Vertex][]Vertex)
poly.addEdges(edges... | polyhedra/polyhedron.go | 0.89222 | 0.737867 | polyhedron.go | starcoder |
package ahocorasick
// ConstructTrie Function that constructs Trie as an automaton for a set of reversed & trimmed strings.
func ConstructTrie(p []string) (trie map[int]map[uint8]int, stateIsTerminal []bool, f map[int][]int) {
trie = make(map[int]map[uint8]int)
stateIsTerminal = make([]bool, 1)
f = make(map[int][]i... | strings/ahocorasick/shared.go | 0.67104 | 0.464112 | shared.go | starcoder |
package iotmaker_platform_textMetrics
type TextMetrics struct {
// en: Is a double giving the calculated width of a segment of inline text in CSS
// pixels. It takes into account the current font of the context.
Width float64
// en: Is a double giving the distance parallel to the baseline from the alignment
// p... | typeTextMetrics.go | 0.728169 | 0.714142 | typeTextMetrics.go | starcoder |
package deep
import math "github.com/chewxy/math32"
// Mode denotes inference mode
type Mode int
const (
// ModeDefault is unspecified mode
ModeDefault Mode = 0
// ModeMultiClass is for one-hot encoded classification, applies softmax output layer
ModeMultiClass Mode = 1
// ModeRegression is regression, applies ... | activation.go | 0.846863 | 0.529203 | activation.go | starcoder |
package score
import (
"math"
cvssv3 "go.zenithar.org/mitre/pkg/protocol/mitre/cvss/v3"
)
func weightAttackVector(av cvssv3.AttackVector) float64 {
switch av {
case cvssv3.AttackVector_ATTACK_VECTOR_NETWORK:
return 0.85
case cvssv3.AttackVector_ATTACK_VECTOR_ADJACENT:
return 0.62
case cvssv3.AttackVector_A... | pkg/services/cvss/v3/score/tables.go | 0.685423 | 0.429609 | tables.go | starcoder |
package term
import (
"fmt"
"reflect"
)
// Subst takes a Term and finds all instances of a variable called
// `name` and replaces them with the replacement.
func Subst(name string, replacement, t Term) Term {
return substAtLevel(0, name, replacement, t)
}
func substAtLevel(i int, name string, replacement, t Term)... | term/subst.go | 0.503906 | 0.440289 | subst.go | starcoder |
package promql
import (
"fmt"
"github.com/m3db/m3/src/query/functions"
"github.com/m3db/m3/src/query/functions/linear"
"github.com/m3db/m3/src/query/functions/logical"
"github.com/m3db/m3/src/query/models"
"github.com/m3db/m3/src/query/parser"
"github.com/m3db/m3/src/query/parser/common"
"github.com/prometh... | src/query/parser/promql/types.go | 0.566258 | 0.406155 | types.go | starcoder |
package passthepoop
import (
"math"
"mondaynightpoker-server/pkg/deck"
)
// PairsEdition is a variant of Pass the Poop where pairs on the board good
// Any pair on the board is better than any single card
// Trips or better on the board and the rest of the board loses all their lives
type PairsEdition struct {
}
/... | pkg/playable/passthepoop/edition_pairs.go | 0.608827 | 0.400808 | edition_pairs.go | starcoder |
package xy
import "github.com/twpayne/go-geom"
// PointsCentroid computes the centroid of the point arguments
//
// Algorithm: average of all points
func PointsCentroid(point *geom.Point, extra ...*geom.Point) geom.Coord {
calc := NewPointCentroidCalculator()
calc.AddCoord(geom.Coord(point.FlatCoords()))
... | xy/point_centroid.go | 0.812012 | 0.520862 | point_centroid.go | starcoder |
package sql
import (
"io"
"gopkg.in/src-d/go-errors.v1"
)
// IndexBatchSize is the number of rows to save at a time when creating indexes.
const IndexBatchSize = uint64(10000)
// ChecksumKey is the key in an index config to store the checksum.
const ChecksumKey = "checksum"
// IndexDriver manages the coordinatio... | sql/index_driver.go | 0.764452 | 0.407392 | index_driver.go | starcoder |
package benford
import (
"gonum.org/v1/gonum/stat"
)
// Benford = result of the Benford's Test,
// Benford.Dist is a array with float64 which describe the distribution of the numbers 1 to 9,
// Benford.ChiSquared is a float and describes how well Benford's Law was matched. Lower is better.
type Benford struct {
Dis... | main.go | 0.669961 | 0.631353 | main.go | starcoder |
package quadedge
import (
"fmt"
"github.com/go-spatial/geom/cmp"
)
/*
QuadEdge represents the edge data structure which implements the quadedge
algebra. The quadedge algebra was described in a well-known paper by Guibas
and Stolfi, "Primitives for the manipulation of general subdivisions and the
computation of Vor... | planar/triangulate/quadedge/quadedge.go | 0.880322 | 0.670676 | quadedge.go | starcoder |
package stdlib
import (
"fmt"
"math"
"math/cmplx"
"github.com/vida-lang/vida/vida"
)
// loadMath loads the stdlib for mathematical computations over Floats.
func loadMath() vida.Importable {
gmodule := vida.GModule{Name: "math", Namespace: vida.Namespace{
"e": vida.Float(math.E),
"pi": vida.F... | stdlib/math.go | 0.596668 | 0.584419 | math.go | starcoder |
package graph
import (
"fmt"
"github.com/heustis/tsp-solver-go/model"
)
type GraphEdge struct {
path []*GraphVertex
distance float64
}
func (e *GraphEdge) Delete() {
// Note: Deleting a graph edge should not delete the graph itself, use Graph.Delete() to delete all GraphVertexes.
e.path = nil
}
func (e *... | graph/graphedge.go | 0.73782 | 0.486514 | graphedge.go | starcoder |
package lib
import (
"fmt"
"math"
"math/rand"
"runtime"
"gonum.org/v1/gonum/mat"
gtet_rand "github.com/phil-mansfield/gotetra/math/rand"
"github.com/phil-mansfield/gotetra/render/geom"
"github.com/phil-mansfield/gotetra/render/io"
"github.com/phil-mansfield/nbody-utils/thread"
)
// GetDensities writes d... | lib/analysis.go | 0.606498 | 0.435361 | analysis.go | starcoder |
package exif
import (
"errors"
"fmt"
"time"
"github.com/dsoprea/go-logging"
"github.com/golang/geo/s2"
"github.com/dsoprea/go-exif/v3/common"
)
var (
// ErrGpsCoordinatesNotValid means that some part of the geographic data was
// unparseable.
ErrGpsCoordinatesNotValid = errors.New("GPS coordinates not vali... | v3/gps.go | 0.773388 | 0.555616 | gps.go | starcoder |
package matchers
import "bytes"
// Zip matches a zip archive.
func Zip(in []byte) bool {
return len(in) > 3 &&
in[0] == 0x50 && in[1] == 0x4B &&
(in[2] == 0x3 || in[2] == 0x5 || in[2] == 0x7) &&
(in[3] == 0x4 || in[3] == 0x6 || in[3] == 0x8)
}
// SevenZ matches a 7z archive.
func SevenZ(in []byte) bool {
ret... | internal/matchers/archive.go | 0.60778 | 0.637666 | archive.go | starcoder |
package ui
import (
"image"
"image/color"
"strings"
"gioui.org/f32"
"gioui.org/layout"
"gioui.org/op"
)
type grid struct {
Background color.NRGBA
cellSize image.Point
data [][]texture
}
// Init initializes the grid with size as the available space.
func (g *grid) Init(width, height int) {
g.data =... | blocks/internal/ui/grid.go | 0.69987 | 0.416381 | grid.go | starcoder |
package main
import (
"math"
"github.com/unixpickle/model3d/model2d"
"github.com/unixpickle/model3d/model3d"
)
const (
PeelLongSide = 0.12
PeelSmallSide = 0.05
PeelStops = 800
PeelRounding = 0.01
PeelEdgeInset = 0.01
)
func NewPeel() model3d.Solid {
mesh := PeelMesh(PeelStops)
return model3d.NewColl... | examples/decoration/orange_slices/peel.go | 0.715225 | 0.46563 | peel.go | starcoder |
package fads
import (
"go-hep.org/x/hep/fmom"
"go-hep.org/x/hep/hepmc"
)
type Particle interface {
P4() fmom.P4
Charge() int32
}
type MissingEt struct {
MET float64 // missing transverse energy
Phi float64 // missing energy azimuthal angle
}
// scalar sum of transverse momenta
type ScalarHt float64
// rho e... | fads/datamodel.go | 0.742982 | 0.536374 | datamodel.go | starcoder |
package nimgobus
// drawCursor draws the cursor
func (n *Nimbus) drawCursor() {
// Set up cursor
var charPixels [][]int
if n.deleteMode {
charPixels = n.deleteModeCursorImage
} else {
switch n.cursorCharset {
case 0:
charPixels = n.charImages0[n.cursorChar]
case 1:
charPixels = n.charImages1[n.cursor... | pkg/nimgobus/cursor.go | 0.587115 | 0.432842 | cursor.go | starcoder |
package strconvh
import (
"github.com/apaxa-go/helper/mathh"
"strconv"
)
// ParseUint64 interprets a string s in 10-base and returns the corresponding value i (uint64) and error.
func ParseUint64(stringValue string) (uint64, error) {
return strconv.ParseUint(stringValue, defaultIntegerBase, mathh.Uint64Bits)
}
/... | back/vendor/github.com/apaxa-go/helper/strconvh/parseint-gen.go | 0.740644 | 0.426979 | parseint-gen.go | starcoder |
package com
import (
"fmt"
"strconv"
"strings"
"time"
)
// Format unix time int64 to string
func Date(ti int64, format string) string {
t := time.Unix(int64(ti), 0)
return DateT(t, format)
}
// Format unix time string to string
func DateS(ts string, format string) string {
i, _ := strconv.ParseInt(ts, 10, 64... | vendor/github.com/webx-top/com/time.go | 0.591487 | 0.400867 | time.go | starcoder |
package day24
import "log"
type BlackHexes map[Hex]bool
// Stores a hex coordinate where x + y + z = 0
type Hex struct {
x, y, z int
}
// Returns a map of all the black hexes after initialising from the instructions.
func GetBlackHexes(instructions []string) BlackHexes {
blackHexes := make(BlackHexes)
for _, in... | day24/day24.go | 0.789883 | 0.488588 | day24.go | starcoder |
package main
import "fmt"
func first() {
// first make a mask to reset the bits from position i to j
var i uint = 2
var j uint = 6
var m uint = 19 // 10011
m = m << i
var n uint = 1044 // 10000010100
var ib uint = ^uint(0) >> (64-i)
var jb uint = ^uint(0) << j
var k = jb ^ ib
... | bits.go | 0.546012 | 0.404155 | bits.go | starcoder |
package primitives
import (
"fmt"
"math"
)
var (
AxisX = V(1, 0, 0)
AxisY = V(0, 1, 0)
AxisZ = V(0, 0, 1)
)
type Vector struct {
X, Y, Z float64
}
func ToVector(p1, p2 Point) Vector {
return V(p2.X-p1.X, p2.Y-p1.Y, p2.Z-p1.Z)
}
func (a Vector) String() string {
return fmt.Sprintf("X%s Y%s Z%s", StrF(a.X), St... | primitives/vector.go | 0.856377 | 0.697873 | vector.go | starcoder |
package core
// High level, ORM-like bindings. Like Domain, the models here mirror crust objects. Unlike
// the crust, Models do not store their mirror's data-- this interface is much more functional.
// All functions return the model's "contents"
// Note that this implementation assumes that there's a global, single... | model.go | 0.85738 | 0.438725 | model.go | starcoder |
package engine
import (
"fmt"
"math"
)
const (
// BlockSize is the size of a block when splitting the image plane.
BlockSize = 128
// Overlap is the size of the pixels that the image overlaps.
Overlap = 14
)
// ImagePlane represents an image in which each pixel has a continuous value.
type ImagePlane struct {
... | engine/image_plane.go | 0.757974 | 0.592048 | image_plane.go | starcoder |
package prometheus
import (
"sync"
"time"
"github.com/prometheus/common/model"
kialiConfig "github.com/kiali/kiali/config"
"github.com/kiali/kiali/log"
)
type (
timeInResult struct {
queryTime time.Time
inResult model.Vector
}
timeInOutResult struct {
queryTime time.Time
inResult model.Vector
o... | prometheus/cache.go | 0.516108 | 0.443661 | cache.go | starcoder |
package tort
import (
"strings"
"github.com/go-playground/validator/v10"
)
// ValidatorAssertions test validation errors from https://github.com/go-playground/validator.
type ValidatorAssertions struct {
Assertions
err validator.ValidationErrors
}
// Valid assists in validating validation errors,
func (assert A... | validator.go | 0.726329 | 0.583708 | validator.go | starcoder |
package gocudnn
/*
#include <cudnn.h>
*/
import "C"
import (
"runtime"
"unsafe"
"github.com/dereklstinson/cutil"
)
//RNNDataD is a RNNDataDescriptor
type RNNDataD struct {
d C.cudnnRNNDataDescriptor_t
dtype DataType
seqlensize int32
gogc bool
}
//CreateRNNDataD creates an RNNDataD through... | cudnnRNN_data_padding.go | 0.663342 | 0.444203 | cudnnRNN_data_padding.go | starcoder |
package zflag
import "strconv"
// -- float64 Value
type float64Value float64
func newFloat64Value(val float64, p *float64) *float64Value {
*p = val
return (*float64Value)(p)
}
func (f *float64Value) Set(s string) error {
v, err := strconv.ParseFloat(s, 64)
*f = float64Value(v)
return err
}
func (s *float64Va... | float64.go | 0.793306 | 0.457864 | float64.go | starcoder |
package list
import (
"fmt"
"github.com/flowonyx/functional/errors"
)
// InsertAt inserts newValue into existing at the given index.
// If the index is not in the range of indexes for values, it will return a nil slice and a IndexOutOfRangeErr.
func InsertAt[T any](index int, newValue T, existing []T) ([]T, error)... | list/insertRemove.go | 0.662469 | 0.553023 | insertRemove.go | starcoder |
package nist_sp800_22
import (
"math"
)
// Input Size Recommendation
// NIST recommends m = 9 or m = 10, n >= 10^6
// m should be chosen so that m ≈ log_2(M)
func OverlappingTemplateMatching(B []uint8, eachBlockSize uint64) (float64, bool, error) {
// Original Parameter
var m int = len(B)
var n int = len(epsilon... | nist_sp800_22/overlappingTemplateMatching.go | 0.518059 | 0.439026 | overlappingTemplateMatching.go | starcoder |
package afm
import (
"fmt"
"io"
"star-tex.org/x/tex/font/fixed"
)
type direction struct {
// underlinePosition is the distance from the baseline for centering
// underlining strokes.
underlinePosition fixed.Int16_16
// underlineThickness is the stroke width for underlining.
underlineThickness fixed.Int16_1... | font/afm/font.go | 0.547706 | 0.487124 | font.go | starcoder |
package g
// Zero2 zero vec 2
var Zero2 = V2{}
// V2 vec2
type V2 struct{ X, Y float32 }
// RandomV2 random vec2
func RandomV2(r Rect) V2 {
return V2{
RandomBetween(r.Min.X, r.Max.X),
RandomBetween(r.Min.Y, r.Max.Y),
}
}
// RandomV2Circle random vec2 circle
func RandomV2Circle(radius float32) V2 {
v := V2{Ra... | g/vector.go | 0.933499 | 0.780181 | vector.go | starcoder |
package packets
import "github.com/orionowy/f1-telemetry-go/pkg/math"
// The motion packet gives physics data for all the cars being driven.
// There is additional data for the car being driven with the goal of being able to drive a motion platform setup.
// Frequency: Rate as specified in menus
// Size: 1464 bytes
... | pkg/packets/motion.go | 0.82748 | 0.723212 | motion.go | starcoder |
package search
import (
"github.com/christat/search"
"math"
"time"
)
// BranchAndBound performs depth search iteratively. An upper bound is set every time a solution is found,
// pruning costlier descendants and stopping once no better solution was found. Because of its nature (minimization of positive costs)
// i... | blind/depth_first_branch_and_bound.go | 0.759671 | 0.600042 | depth_first_branch_and_bound.go | starcoder |
package switchboard
// Board represents a set of supplies and demands for which a universes of choices can be explored.
type Board struct {
supplies []Supply
demands []Demand
choices []Choice
comparator BoardComparator
}
// NewBoard constructs a new board with the given supplies and demands
func NewBoard(... | board.go | 0.805211 | 0.586079 | board.go | starcoder |
package exporter
var (
gaugeMetrics = map[string]string{
"indices_fielddata_memory_size_bytes": "Field data cache memory usage in bytes",
"indices_filter_cache_memory_size_bytes": "Filter cache memory usage in bytes",
"indices_query_cache_memory_size_bytes": "Query cache memory usage... | exporter/metrics.go | 0.61231 | 0.420243 | metrics.go | starcoder |
package gates
import (
"math"
"reflect"
"strings"
)
type Array struct {
values []Value
}
type arrayIter struct {
i int
a *Array
}
func NewArray(values []Value) Array {
return Array{
values: values,
}
}
func NewArrayFromStringSlice(a []string) Array {
values := make([]Value, len(a))
for i := range a {
... | array.go | 0.649356 | 0.505859 | array.go | starcoder |
// Package chans contains utility constraints, functions, and types regarding
// Go channels, such as the PubSub type for fan-out events.
package chans
import (
"context"
"time"
"gopkg.in/typ.v4"
)
// SendTimeout sends a value to a channel, or cancels after a given duration.
func SendTimeout[C Sender[V], V any](... | chans/chans.go | 0.673406 | 0.408188 | chans.go | starcoder |
package testdata
// GetSubscriptionResponse example
const GetSubscriptionResponse = `{
"resource": "subscription",
"id": "sub_rVKGtNd6s3",
"mode": "live",
"createdAt": "2016-06-01T12:23:34+00:00",
"status": "active",
"amount": {
"value": "25.00",
"currency": "EUR"
},
"ti... | testdata/subscriptions.go | 0.741768 | 0.432483 | subscriptions.go | starcoder |
package codexec
import "time"
type (
// ContainerNode node that stores the container id, next and prev and metrics information
ContainerNode struct {
ID string
ExecutionCount int64
AvgResTime time.Duration
MaxResTime time.Duration
MinResTime time.Duration
Prev *ContainerNode
N... | internal/codexec/pool.go | 0.540196 | 0.467271 | pool.go | starcoder |
package object
import (
"github.com/carlosroman/aun-otra-ray-tracer/go/internal/ray"
)
const (
epsilon = 1e-5
)
type Object interface {
LocalIntersect(ray ray.Ray) Intersections
LocalNormalAt(worldPoint ray.Vector, hit Intersection) ray.Vector
Transform() ray.Matrix
TransformInverse() ray.Matrix
SetTransform... | go/internal/object/object.go | 0.804021 | 0.655095 | object.go | starcoder |
package fractales
import (
"github.com/Balise42/marzipango/fractales/orbits"
"github.com/Balise42/marzipango/params"
"image"
"image/color"
"math"
"math/rand"
"sync"
)
func CreateFlameComputer(params params.ImageParams) Computation {
flameFuncs := createFlameFuncs()
ifsMap := createFlameMap(params, flameFuncs... | fractales/flame.go | 0.534127 | 0.544862 | flame.go | starcoder |
package lru
/**
题目:https://leetcode-cn.com/problems/lru-cache/
LRU 缓存
请你设计并实现一个满足 LRU (最近最少使用) 缓存 约束的数据结构。
实现 LRUCache 类:
LRUCache(int Capacity) 以 正整数 作为容量capacity 初始化 LRU 缓存
int get(int Key) 如果关键字 Key 存在于缓存中,则返回关键字的值,否则返回 -1 。
void put(int Key, int Value)如果关键字key 已经存在,则变更其数据值value ;如果不存在,则向缓存中插入该组key-Value 。如果插入操作导... | datastruct/lru/lru/lru.go | 0.585338 | 0.402187 | lru.go | starcoder |
// Package scanner provides the Scanner type that is able to read from any
// io.Reader and generate tokens.
package scanner
import (
"bufio"
"fmt"
"io"
"unicode"
"github.com/campoy/groto/token"
)
// New creates a new Scanner reading from the given io.Reader.
func New(r io.Reader) *Scanner {
return &Scanner{r... | scanner/scanner.go | 0.729423 | 0.438785 | scanner.go | starcoder |
package theme
import (
"image/color"
"gioui.org/font/gofont"
"gioui.org/widget/material"
)
// PairFor wraps the provided theme color in a Color type with an automatically
// populated Text color. The Text field value is chosen based on the luminance
// of the provided color.
func PairFor(bg color.NRGBA) ContrastP... | widget/theme/theme.go | 0.765067 | 0.412648 | theme.go | starcoder |
package main
import (
"bufio"
"encoding/csv"
"fmt"
"io"
"log"
"math"
"math/rand"
"os"
"runtime"
"sort"
"strconv"
"time"
)
// Data is a struct to store attributes of a row in csv
type Data struct {
X1 float64 // atribut 1
X2 float64 // atribut 2
X3 float64 // atribut 3
X4 float64 // atribut 4
Y strin... | main.go | 0.517815 | 0.560674 | main.go | starcoder |
package util
import "math"
func getExpectedValue(values []float64) float64 {
var sum float64
for _, element := range values {
sum = sum + element
}
return sum / float64(len(values))
}
func getDispersion(values []float64, expectedValue float64) float64 {
var sum float64
for _, element := range values {
sum ... | src/main/util/math.go | 0.661267 | 0.644057 | math.go | starcoder |
package geometries
import (
"github.com/go-gl/mathgl/mgl32"
three "github.com/tobscher/go-three"
)
// Box defines a box geometry consisting of 6 faces
type Box struct {
three.Geometry
width float32
height float32
depth float32
}
// NewBox creates a new Box with the given width, height and depth.
// This met... | geometries/box.go | 0.840848 | 0.655763 | box.go | starcoder |
package rand
import (
"github.com/pkg/errors"
"github.com/seehuhn/mt19937"
)
// A Generator uses a goroutine to populate batches of random numbers.
// Currently we use a Mersenne twister implementation instead of the
// default Go implementation (which is fast, but has a much shorter
// period than MT, and we use a... | rand/rand.go | 0.680772 | 0.404213 | rand.go | starcoder |
package main
type problemMapping map[int]chapter
type chapter struct {
Number int
Name string
Problems []problem
}
type problem struct {
Name string
Folder string
}
func isChapterNumberValid(n int) bool {
_, ok := chapters[n]
return ok
}
func getAllChapterNumbers() []int {
chapterKeys := make([]int... | progress/problem_mapping.go | 0.654343 | 0.537648 | problem_mapping.go | starcoder |
package measurement
import (
"bytes"
"fmt"
"sync"
"time"
"github.com/HdrHistogram/hdrhistogram-go"
)
type Histogram struct {
*hdrhistogram.Histogram
m sync.RWMutex
sum int64
startTime time.Time
}
type HistInfo struct {
Elapsed float64
Sum float64
Count int64
Ops float64
Avg ... | pkg/measurement/hist.go | 0.5794 | 0.415492 | hist.go | starcoder |
package layer
import (
"github.com/varrrro/gonn/internal/functions"
"gonum.org/v1/gonum/mat"
)
// SigmoidalLayer with logistic activation function.
type SigmoidalLayer struct {
inputSize int
outputSize int
input mat.Vector
output mat.Vector
weights mat.Matrix
biases mat.Vector
deltas mat... | internal/layer/sigmoidal.go | 0.812607 | 0.561936 | sigmoidal.go | starcoder |
package p472
/**
Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words.
A concatenated word is defined as a string that is comprised entirely of at least two shorter words in the given array.
Example:
Input: ["cat","cats","catsdogcats","dog"... | algorithms/p472/472.go | 0.744471 | 0.627409 | 472.go | starcoder |
package equitytest
const TrivialLock = `
contract TrivialLock() locks amount of asset {
clause trivialUnlock() {
unlock amount of asset
}
}
`
const LockWithPublicKey = `
contract LockWithPublicKey(publicKey: PublicKey) locks amount of asset {
clause unlockWithSig(sig: Signature) {
verify checkTxSig(publ... | vendor/github.com/bytom/equity/compiler/equitytest/equitytest.go | 0.677687 | 0.483161 | equitytest.go | starcoder |
package bits
import (
"math"
)
// ShiftDown takes a matrix of bytes and shifts a column of bits down
// by 'count'. Bits pushed off the bottom are rotated back around to
// the top. Each slice in the matrix is expected to be the same length.
func ShiftDown(matrix [][]byte, index float64, count float64) [][]byte {
y... | shiftvertical.go | 0.828662 | 0.674667 | shiftvertical.go | starcoder |
package jbtracer
import (
"fmt"
"math"
)
// Epsilon is the expected precision for our floating point operations
const Epsilon = 0.00001
type Tuple struct {
X, Y, Z float64 // 3D coordinates
W float64 // 1.0 when a point, 0.0 when a vector
}
// String returns a string representation of the tuple
func (a *T... | tuples.go | 0.905216 | 0.625724 | tuples.go | starcoder |
package assert
import (
"fmt"
"path/filepath"
"reflect"
"runtime"
"testing"
)
// ObjectsAreEqual checks two interfaces with reflect.DeepEqual.
func ObjectsAreEqual(expected, actual interface{}) bool {
if expected == nil || actual == nil {
return expected == actual
}
return reflect.DeepEqual(expected, actua... | assert/assert.go | 0.729134 | 0.48987 | assert.go | starcoder |
package generator
import (
"errors"
"fmt"
"go/ast"
"go/token"
"reflect"
"strconv"
"strings"
"unicode"
"github.com/asdine/genji/value"
)
const recordsTmpl = `
{{- define "records" }}
{{- range .Records }}
{{- template "record" . }}
{{- end }}
{{- end }}
`
const recordTmpl = `
{{- define "record" }}
... | cmd/genji/generator/record.go | 0.690768 | 0.40439 | record.go | starcoder |
package ioutil
// A ByteOrder specifies how to convert byte sequences into
// 16-, 24-, 32-, 40-, 48-, 56- or 64-bit unsigned integers.
// It is compatible with the standard library ByteOrder but contains
// more integer types.
type ByteOrder interface {
// Uint16 reads 2 bytes
Uint16([]byte) uint16
// Uint24 reads... | byteorder.go | 0.573201 | 0.50354 | byteorder.go | starcoder |
package tai64n
import "time"
// Represents the first moment after a leap second occurs.
type LeapSecond struct {
Threshold time.Time
Offset int
}
var AllLeapSeconds = []*LeapSecond{
&LeapSecond{time.Date(1972, time.January, 1, 0, 0, 0, 0, time.UTC), 10},
&LeapSecond{time.Date(1972, time.July, 1, 0, 0, 0, 0, t... | leapsecond.go | 0.551332 | 0.522263 | leapsecond.go | starcoder |
package interpreter
import (
"fmt"
"reflect"
)
type List struct {
Elements []Value
}
func (l List) Compare(other Value) (Value, error) {
if r, ok := other.(List); ok {
if reflect.DeepEqual(l, r) {
return Number(0), nil
}
}
return nil, nil
}
func (l List) Add(other Value) (Value, error) {
return nil, f... | internal/interpreter/list.go | 0.663451 | 0.491578 | list.go | starcoder |
// Package set defines a Set type that holds a set of elements.
package set
// A Set is a set of elements of some comparable type.
// Sets are implemented using maps, and have similar performance characteristics.
// Like maps, Sets are reference types.
// That is, for Sets s1 = s2 will leave s1 and s2 pointing to the... | container/set/set.go | 0.805747 | 0.508483 | set.go | starcoder |
package boxlayout
import (
"github.com/jesseduffield/generics/slices"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/samber/lo"
)
type Dimensions struct {
X0 int
X1 int
Y0 int
Y1 int
}
type Direction int
const (
ROW Direction = iota
COLUMN
)
// to give a high-level explanation of what's going on... | pkg/gui/boxlayout/boxlayout.go | 0.561455 | 0.558207 | boxlayout.go | starcoder |
package palette
import (
"fmt"
"image/color"
)
// Rainbow creates a palette of colors in rainbow order. It accepts a step
// parameter which determines the distance between each color shift. The smaller
// the step, the more individual colors will result in the palette. The smallest
// possible step is 7, which res... | internal/palette/rainbow.go | 0.744563 | 0.458712 | rainbow.go | starcoder |
package nem12
import (
"fmt"
"strings"
)
const (
// QualityUndefined is for undefined quality flags.
QualityUndefined Quality = iota
// QualityActual is the quality flag value for actual data.
QualityActual
// QualityEstimated is the quality flag value for forward estimated data.
QualityEstimated
// QualityF... | nem12/quality.go | 0.68721 | 0.455259 | quality.go | starcoder |
package tranquil
import (
"fmt"
"reflect"
"time"
)
// Assertion provides functions for performing assertions when testing.
type Assertion struct {
Test *Test
Value interface{}
}
// NewAssertion creates and returns a new Assertion instance.
func NewAssertion(t *Test, value interface{}) *Assertion {
return &Ass... | Godeps/_workspace/src/github.com/davelaursen/tranquil/assertion.go | 0.787319 | 0.662339 | assertion.go | starcoder |
package engine
import (
"errors"
"machassert/config"
"machassert/machine"
"sort"
)
// Executor stores state/configuration for applying assertions to targets.
type Executor struct {
machines *config.MachineSpec
assertions []*config.AssertionSpec
logger Logger
}
// New creates a new executor.
func New(mac... | src/machassert/engine/executor.go | 0.620852 | 0.454956 | executor.go | starcoder |
package heap
// pi returns parent's index.
func pi(i int) int {
return (i - 1) >> 1
}
// li returns left child's index.
func li(i int) int {
return i<<1 + 1
}
// ri returns right child's index.
func ri(i int) int {
return i<<1 + 2
}
type MaxHeap struct {
Elems []int
HeapSize int
}
// Size returns heap's si... | dsa/heap/max_heap.go | 0.762689 | 0.402392 | max_heap.go | starcoder |
package v1
import (
"github.com/turbinelabs/cli/command"
"github.com/turbinelabs/codec"
tbnflag "github.com/turbinelabs/nonstdlib/flag"
"github.com/turbinelabs/nonstdlib/flag/usage"
"github.com/turbinelabs/rotor"
)
const (
envoyV1FileDescription = `Watches the given JSON or YAML Envoy
configuration file and upd... | plugins/envoy/v1/cmd.go | 0.620047 | 0.477981 | cmd.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// SynchronizationProgress
type SynchronizationProgress struct {
// Stores additi... | models/synchronization_progress.go | 0.872782 | 0.407392 | synchronization_progress.go | starcoder |
package isogram
import (
"regexp"
"strings"
"unicode"
)
var regexPattern, _ = regexp.Compile("[^a-zA-Z]+")
// IsIsogramV1 receive a word and return true if word is a isogram and false if it is not
func IsIsogramV1(word string) (isIsogram bool) {
cleanedWord := regexPattern.ReplaceAllString(word, "")
cleanedWor... | exercism/go/isogram/isogram.go | 0.586404 | 0.413714 | isogram.go | starcoder |
package executetest
import (
"fmt"
"github.com/influxdata/flux/semantic"
"github.com/influxdata/flux"
"github.com/influxdata/flux/execute"
"github.com/influxdata/flux/values"
)
// Table is an implementation of execute.Table
// It is designed to make it easy to statically declare the data within the table.
// N... | execute/executetest/table.go | 0.69181 | 0.462898 | table.go | starcoder |
package simplefunctionrules
import "fmt"
// DoSomeThing example to a simple function
func DoSomeThing() {
fmt.Println("Hello World! print in a simple function")
}
// PrintUserName print the user name string that pass in argument
func PrintUserName(userName string) {
fmt.Println("Hello " + userName)
}
// As discus... | example-functions/simplefunctionrules/simplefunctionrules.go | 0.625667 | 0.485234 | simplefunctionrules.go | starcoder |
package leveldb
import (
"encoding/binary"
)
const batchHeaderLen = 12
// Batch is a sequence of Sets and/or Deletes that are applied atomically.
type Batch struct {
// Data is the wire format of a batch's log entry:
// - 8 bytes for a sequence number of the first batch element,
// or zeroes if the batch ... | leveldb/batch.go | 0.649134 | 0.479869 | batch.go | starcoder |
package parser
import (
"fmt"
"github.com/bazo-blockchain/lazo/lexer/token"
"github.com/bazo-blockchain/lazo/parser/node"
)
// Expressions
// -------------------------
func (p *Parser) parseExpression() node.ExpressionNode {
return p.parseTernaryExpression()
}
func (p *Parser) parseTernaryExpression() node.Expr... | parser/parser_expression.go | 0.655336 | 0.457016 | parser_expression.go | starcoder |
package classic
import (
"math"
"sort"
"github.com/grafana/grafana/pkg/expr/mathexp"
)
func nilOrNaN(f *float64) bool {
return f == nil || math.IsNaN(*f)
}
func (cr classicReducer) ValidReduceFunc() bool {
switch cr {
case "avg", "sum", "min", "max", "count", "last", "median":
return true
case "diff", "dif... | pkg/expr/classic/reduce.go | 0.541651 | 0.425367 | reduce.go | starcoder |
package labels
import (
"fmt"
"k8s.io/kubernetes/pkg/api/unversioned"
)
// Clones the given map and returns a new map with the given key and value added.
// Returns the given map, if labelKey is empty.
func CloneAndAddLabel(labels map[string]string, labelKey string, labelValue uint32) map[string]string {
if label... | vendor/k8s.io/kubernetes/pkg/util/labels/labels.go | 0.71123 | 0.499451 | labels.go | starcoder |
package expression
import (
"fmt"
"strconv"
"strings"
"time"
"gopkg.in/src-d/go-errors.v1"
"github.com/dolthub/go-mysql-server/sql"
)
// ErrConvertExpression is returned when a conversion is not possible.
var ErrConvertExpression = errors.NewKind("expression '%v': couldn't convert to %v")
const (
// Conver... | sql/expression/convert.go | 0.595728 | 0.441854 | convert.go | starcoder |
package blocks
import (
"fmt"
"retroio/spectrum/tap"
"retroio/spectrum/tzx/blocks/types"
"retroio/storage"
)
// Select
// ID: 28h (40d)
// This block is useful when the tape consists of two or more separately-loadable parts. With this
// block, you are able to select one of the parts and the utility/emulator wil... | spectrum/tzx/blocks/select.go | 0.607547 | 0.439206 | select.go | starcoder |
package fp
func (a Int) Min(b Int) Int {
if a <= b {
return a
} else {
return b
}
}
func (a Int64) Min(b Int64) Int64 {
if a <= b {
return a
} else {
return b
}
}
func (a Byte) Min(b Byte) Byte {
if a <= b {
return a
} else {
return b
}
}
func (a Rune) Min(b Rune) Rune {
if a <= b {
return a
... | fp/bootstrap_base_numeric.go | 0.773986 | 0.566798 | bootstrap_base_numeric.go | starcoder |
package trafficpolicy
// EgressTrafficPolicy is the type used to represent the different egress traffic policy configurations
// applicable to a client of Egress destinations.
type EgressTrafficPolicy struct {
// TrafficMatches defines the list of traffic matches for matching Egress traffic.
// The matches specified... | pkg/trafficpolicy/egress_types.go | 0.697815 | 0.464537 | egress_types.go | starcoder |
package wchart
import (
"github.com/grokify/gocharts/data/statictimeseries"
"github.com/grokify/gotilla/time/month"
"github.com/grokify/gotilla/time/quarter"
"github.com/grokify/gotilla/time/timeutil"
"github.com/wcharczuk/go-chart"
)
func DataSeriesMapToContinuousSeriesMonths(dsm map[string]statictimeseries.Dat... | charts/wchart/continuous_series.go | 0.602412 | 0.419707 | continuous_series.go | starcoder |
// Package grammars parses XML GEP grammar representations for a particular output language.
// It can then be used to generate code from Karva expressions for that language.
package grammars
import (
"encoding/xml"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
"github.com/gmlewis/gep/v2/functions"
)
cons... | grammars/grammars.go | 0.826257 | 0.486271 | grammars.go | starcoder |
package geometry
// Poly ...
type Poly struct {
Exterior Ring
Holes []Ring
}
// NewPoly ...
func NewPoly(exterior []Point, holes [][]Point, opts *IndexOptions) *Poly {
poly := new(Poly)
poly.Exterior = newRing(exterior, opts)
if len(holes) > 0 {
poly.Holes = make([]Ring, len(holes))
for i := range holes ... | geometry/poly.go | 0.770983 | 0.528229 | poly.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.