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 maps
import (
"fmt"
. "github.com/flowonyx/functional"
"github.com/flowonyx/functional/errors"
"github.com/flowonyx/functional/list"
"github.com/flowonyx/functional/option"
"golang.org/x/exp/constraints"
"golang.org/x/exp/maps"
)
func withClone[K comparable, T any](m map[K]T, f func(map[K]T)) map[K]T ... | maps/map.go | 0.867303 | 0.444324 | map.go | starcoder |
package swampopcodeinst
// BinaryOperatorType defines the type of binary operator.
type BinaryOperatorType uint8
// The binary operator types.
const (
BinaryOperatorArithmeticIntPlus BinaryOperatorType = iota
BinaryOperatorArithmeticIntMinus
BinaryOperatorArithmeticIntDivide
BinaryOperatorArithmeticIntMultiply
B... | instruction/binary_operator.go | 0.817429 | 0.58519 | binary_operator.go | starcoder |
package game
import (
"image"
"math"
"github.com/hajimehoshi/ebiten"
)
// hi there, future Tom or Mike. I'm not sure if this is how ebiten works, but the negatives on centerX calcs is
// to move left along the screen, and the seemingly inverted calculations for moving up / down are because screens typically
// ha... | game/shape.go | 0.788094 | 0.508605 | shape.go | starcoder |
package message
import (
"container/list"
"github.com/use-go/gosips/sip/header"
)
/**
* A SIP message is either a request from a client to a server, or a
* response from a server to a client. Both Request and Response messages
* use the basic format of <a href ="http://www.ietf.org/rfc/rfc2822.txt">
* RFC 2822</... | sip/message/Message.go | 0.854369 | 0.426023 | Message.go | starcoder |
package slopeone
type SlopeOne struct {
diffMatrix map[string]map[string]float32
freqMatrix map[string]map[string]int
}
func NewSlopeOne(users []map[string]float32) *SlopeOne {
so := &SlopeOne{}
so.diffMatrix = make(map[string]map[string]float32)
so.freqMatrix = make(map[string]map[string]int)
so.buildDiffMatr... | slope_one.go | 0.782122 | 0.541409 | slope_one.go | starcoder |
package ondatra
import (
opb "github.com/openconfig/ondatra/proto"
)
// Network is a group of simulated device interfaces.
type Network struct {
pb *opb.Network
}
// Implement the Endpoint marker interface.
func (*Network) isEndpoint() {}
// Ethernet creates an Ethernet config for the network or returns the exis... | network.go | 0.812682 | 0.400427 | network.go | starcoder |
package game
import (
"errors"
"fmt"
"strconv"
"strings"
"github.com/squee1945/threespot/server/pkg/deck"
)
// PassingRound round is a collection of passed cards.
type PassingRound interface {
// IsDone returns true if the passing is complete (4 cards).
IsDone() bool
// passCard passes a card for the player... | server/pkg/game/passing.go | 0.697918 | 0.462776 | passing.go | starcoder |
package image_conversions
import (
"image"
"image/color"
)
type AsciiPixel struct {
charDepth uint32
grayscaleValue [3]uint32
rgbValue [3]uint32
}
/*
This function shrinks the passed image according to specified or default dimensions.
Stores each pixel's grayscale and RGB values in an AsciiPixel inst... | image_manipulation/image_conversions.go | 0.635901 | 0.432842 | image_conversions.go | starcoder |
package assert
import "reflect"
type AnyType struct {
logFacade *logFacade
actual interface{}
}
func (a *AnyType) IsEqualTo(expected interface{}) *AnyType {
return a.isTrue(reflect.DeepEqual(a.actual, expected),
"Expected <%v>, but was <%v>.", expected, a.actual)
}
func (a *AnyType) IsNotEqualTo(expected in... | vendor/github.com/assertgo/assert/any_type.go | 0.733643 | 0.613121 | any_type.go | starcoder |
package draw
// Path consists of straight line connections between each point defined in an array of points.
type Path struct {
Points []Point
}
// NewPath returns a new empty path.
func NewPath() Path {
return Path{}
}
// AppendPoint adds the specified point to the path.
func (p Path) AppendPoint(point Point) Pat... | bot/vendor/github.com/pzduniak/unipdf/contentstream/draw/path.go | 0.888324 | 0.72027 | path.go | starcoder |
package main
import (
"image/color"
"math"
"github.com/Bredgren/gogame/geo"
"github.com/Bredgren/gogame/ggweb"
)
func main() {
ggweb.Init(testSurface)
}
func testSurface() {
width, height := 900, 600
display := ggweb.NewSurfaceFromID("main")
display.SetSize(width, height)
Rect(display, 10, 10)
Styles(dis... | ggweb/examples/surface/main.go | 0.67694 | 0.400984 | main.go | starcoder |
package main
import (
"image"
"image/color"
"sync"
"github.com/hajimehoshi/ebiten/v2"
)
var palette = []color.Color{
color.RGBA{R: 0x00, G: 0x00, B: 0xff, A: 0xFF},
color.RGBA{R: 0xFF, G: 0xFF, B: 0x00, A: 0xFF},
color.RGBA{R: 0x33, G: 0xFF, B: 0xFF, A: 0xFF},
color.RGBA{R: 0x99, G: 0x4C, B: 0x00, A: 0xFF},
... | sandpiles/world.go | 0.521959 | 0.532668 | world.go | starcoder |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
log "github.com/sirupsen/logrus"
)
// CurrencyConverter to cache rates of different currency pairs
type CurrencyConverter struct {
rates map[string]float64
}
// NewCurrencyConverter to create a CurrencyConverter
func NewCurrencyConv... | currency_converter.go | 0.729616 | 0.410756 | currency_converter.go | starcoder |
package circuit
import (
"fmt"
"io"
"math/big"
"regexp"
"strconv"
"strings"
"github.com/markkurossi/tabulate"
)
// Operation specifies gate function.
type Operation byte
// Gate functions.
const (
XOR Operation = iota
XNOR
AND
OR
INV
Count
)
// Stats holds statistics about circuit operations.
type St... | circuit/circuit.go | 0.694199 | 0.453685 | circuit.go | starcoder |
package arc
import (
"context"
"chromiumos/tast/local/arc"
"chromiumos/tast/local/bundles/cros/arc/motioninput"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/ash"
"chromiumos/tast/local/chrome/ui/mouse"
"chromiumos/tast/local/coords"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(... | src/chromiumos/tast/local/bundles/cros/arc/mouse_input.go | 0.570571 | 0.413536 | mouse_input.go | starcoder |
package spatial
import (
"mm"
"geo"
)
const (
Degree = 4
)
type RTreeNode struct {
// encoded bbox
Bounds [4]int32
// An index into an rtree has to distinguish three cases:
// * i == 0: child does not exist
// * i > 0: child is another RTreeNode with index i - 1
// * i < 0: child is a leaf with index -i... | src/spatial/rtree.go | 0.58261 | 0.441312 | rtree.go | starcoder |
package dlshared
import (
"time"
"syscall"
)
const (
nanosecondsPerMillisecond float64 = 1000000.0
)
// Returns the minute of the day (0 - 1439) for the time passed. This does not look at seconds or nanoseconds.
func MinuteOfTheDay(checkTime *time.Time) int16 { return int16((checkTime.Hour() * 60) + checkTime.Min... | time_utils.go | 0.825238 | 0.599602 | time_utils.go | starcoder |
package filter
import (
"math"
"github.com/ffardo/go-event-vision"
"github.com/ffardo/go-event-vision/sae"
)
func intMax(a, b int) int {
if a >= b {
return a
}
return b
}
func intMin(a, b int) int {
if a < b {
return a
}
return b
}
/*
SpatioTemporal generate a filtered set of events.
Uses a background... | filter/filter.go | 0.677261 | 0.412589 | filter.go | starcoder |
package jingo
// sliceencoder.go manages SliceEncoder and its responsibilities.
// SliceEncoder follows the same principle of structencoder.go in that it generates lightweight
// instructions as part of its compile stage which are executed later during the Marshal. The
// slight difference here is that instruction is ... | sliceencoder.go | 0.652352 | 0.489137 | sliceencoder.go | starcoder |
package cpebiten
import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/jakecoffman/cp"
"math"
)
const DrawPointLineScale = 1
var shader *ebiten.Shader
func (o *DrawOptions) DrawBB(bb cp.BB, outline cp.FColor) {
verts := []cp.Vector{
{bb.R, bb.B},
{bb.R, bb.T},
{bb.L, bb.T},
{bb.L, bb.B},
}
o.DrawPol... | drawing.go | 0.641085 | 0.556219 | drawing.go | starcoder |
package doublearray
import "sort"
const endKey rune = 0
// Node is a node of dobule-array trie tree.
type Node struct {
Base int
Check int
}
// DoubleArray is a dobule-array trie tree.
type DoubleArray struct {
Nodes []Node
}
// New builds a dobule-array trie tree from keywords.
func New(keywords []string) *Do... | doublearray.go | 0.672869 | 0.432962 | doublearray.go | starcoder |
package hex
import (
"math"
"github.com/go-gl/mathgl/mgl64"
)
// Grid is an interface for 2D polygon grids, such as a hexagonal or square grid.
type Grid interface {
ToWorld(c, r float64) (float64, float64)
ToGrid(x, y float64) (float64, float64)
Vertices(c, r int) []mgl64.Vec2
Get(c, r int) (interface{}, bool... | hex/square.go | 0.90277 | 0.778607 | square.go | starcoder |
package environment
import (
"context"
"sync"
"testing"
"knative.dev/reconciler-test/pkg/feature"
)
func categorizeSteps(steps []feature.Step) map[feature.Timing][]feature.Step {
res := make(map[feature.Timing][]feature.Step, 4)
res[feature.Setup] = filterStepTimings(steps, feature.Setup)
res[feature.Require... | vendor/knative.dev/reconciler-test/pkg/environment/execution.go | 0.54819 | 0.416559 | execution.go | starcoder |
package main
import (
"fmt"
"strconv"
)
func generateParenthesis(n int) []string {
// The min number will be have the correct number of bits to correspond with desired parentheses.
// For valid parentheses, the first character will always be a "(", which corresponds to 1 with
// The binary analogy. n correspond... | parenthesis/main.go | 0.687105 | 0.47384 | main.go | starcoder |
package finverse
import (
"encoding/json"
)
// IncomeEstimate struct for IncomeEstimate
type IncomeEstimate struct {
// Income amount
Amount float32 `json:"amount"`
// Currency
Currency string `json:"currency"`
}
// NewIncomeEstimate instantiates a new IncomeEstimate object
// This constructor will assign defa... | finverse/model_income_estimate.go | 0.809991 | 0.468912 | model_income_estimate.go | starcoder |
package table
import (
"strconv"
"strings"
)
// Body is a list of mn values.
type Body []interface{}
// NewBody returns a new body of values.
func NewBody(values ...interface{}) Body {
return append(make(Body, 0, len(values)), values...)
}
// Copy returns a copy of a body.
func (b Body) Copy() Body {
return app... | body.go | 0.694924 | 0.450359 | body.go | starcoder |
package geocache
import (
"fmt"
"sync"
"github.com/dhconnelly/rtreego"
gogeo "github.com/kellydunn/golang-geo"
"github.com/paulmach/orb"
orbgeo "github.com/paulmach/orb/geo"
"github.com/paulmach/orb/planar"
"github.com/pkg/errors"
"github.com/X-Keeper/geoborder/internal/storage"
"github.com/X-Keeper/geobor... | internal/storage/geocache/memorygeocache.go | 0.502197 | 0.409752 | memorygeocache.go | starcoder |
package render
import (
"math"
"github.com/samuelyuan/go-quake2/q2file"
)
// Contains all the triangles of a face to be passed to the renderer
type Surface struct {
TexInfo q2file.TexInfo
TexturedVertices []TexturedVertex
}
type TexturedVertex struct {
// Position coordinates
X float32
Y float32
Z ... | src/render/surface.go | 0.730578 | 0.424293 | surface.go | starcoder |
package series
import (
"fmt"
"math"
"sort"
)
// Series represents a time series instance.
type Series struct {
Points []Point `json:"points"`
Summary map[string]Value `json:"summary"`
}
// Scale applies a factor on a series of points.
func (s *Series) Scale(factor Value) {
for i := range s.Points {
... | series/series.go | 0.817137 | 0.437343 | series.go | starcoder |
package primitives
import (
"math"
)
type Line struct {
P1, P2 Point
}
func (l Line) ToVector() Vector {
return V(l.P2.X-l.P1.X, l.P2.Y-l.P1.Y, l.P2.Z-l.P1.Z)
}
func (l Line) Reverse() Line {
return Line{l.P2, l.P1}
}
func (l Line) Len() float64 {
v := math.Sqrt(math.Pow(l.P2.X-l.P1.X, 2) +
math.Pow(l.P2.Y-... | primitives/line.go | 0.648132 | 0.578924 | line.go | starcoder |
package intset
func popCount(x uint) int {
bitCount := 0
for ; x != 0; bitCount++ {
x &= (x - 1)
}
return bitCount
}
const offset = 32 << (^uint(0) >> 63)
// An IntSet is a set of small non-negative integers.
// Its zero value represents the empty set.
type IntSet struct {
words []uint
}
// Has reports wheth... | ch6/intset/intset.go | 0.678327 | 0.433262 | intset.go | starcoder |
package model
import (
"github.com/peterhoward42/skilldrill/util/sets"
)
/*
The tree type owns the storage of the skill nodes and their tree-like topology.
The skills themselves are modelled by the closely-couple skillNode type, and
each skill node individually contains references to its parent and children.
However... | model/tree.go | 0.687735 | 0.448064 | tree.go | starcoder |
package formula
import (
"math"
"sort"
"baliance.com/gooxml"
)
func init() {
RegisterFunction("AVERAGE", Average)
RegisterFunction("AVERAGEA", Averagea)
RegisterFunction("COUNT", Count)
RegisterFunction("COUNTA", Counta)
RegisterFunction("COUNTBLANK", CountBlank)
RegisterFunction("MAX", Max)
RegisterFunct... | spreadsheet/formula/fnstatistical.go | 0.651577 | 0.443299 | fnstatistical.go | starcoder |
// Package imgutil ...
// Supplies machine vision utilities for
// extracting and processing image features in imgdb
package imgutil
import (
"image"
"math"
)
// =============================================
// Declarations
// =============================================
type RGBHistogram stru... | imgutil/histogram.go | 0.76533 | 0.403391 | histogram.go | starcoder |
package check
import (
"reflect"
"github.com/m4gshm/gollections/c"
)
//Not inverts a predicate.
func Not[T any](p c.Predicate[T]) c.Predicate[T] {
return func(v T) bool { return !p(v) }
}
//Nil checks a reference for nil value.
func Nil[T any](val *T) bool {
return val == nil
}
//NotNil checks a reference for ... | check/api.go | 0.712232 | 0.515681 | api.go | starcoder |
package equidistant
import (
"fmt"
"github.com/ready-steady/adapt/internal"
)
// Closed is a grid in [0, 1]^n.
type Closed struct {
nd uint
}
// NewClosed creates a grid.
func NewClosed(dimensions uint) *Closed {
return &Closed{dimensions}
}
// Compute returns the nodes corresponding to a set of indices.
func ... | grid/equidistant/closed.go | 0.727589 | 0.555194 | closed.go | starcoder |
package bits
// SwapHorizontal takes a matrix of bytes and swaps a section from left to right.
func SwapHorizontal(matrix [][]byte, xStart, yStart, singleSectionWidth, height int) [][]byte {
if int(singleSectionWidth) > (len(matrix)*8)/2 {
panic("Single section width must be less or equal to than half the bits in a... | swap.go | 0.616012 | 0.640552 | swap.go | starcoder |
package gubrak
import (
"math"
"reflect"
"time"
)
func typeIs(data interface{}, types ...reflect.Kind) bool {
valueOfData := reflect.ValueOf(data)
for _, tipe := range types {
if tipe == valueOfData.Kind() {
return true
}
}
return false
}
// IsSlice is alias of IsSlice()
func IsSlice(data interface{})... | operation_is.go | 0.712132 | 0.548432 | operation_is.go | starcoder |
package msgraph
// RatingNewZealandTelevisionType undocumented
type RatingNewZealandTelevisionType int
const (
// RatingNewZealandTelevisionTypeVAllAllowed undocumented
RatingNewZealandTelevisionTypeVAllAllowed RatingNewZealandTelevisionType = 0
// RatingNewZealandTelevisionTypeVAllBlocked undocumented
RatingNew... | v1.0/RatingNewZealandTelevisionTypeEnum.go | 0.568655 | 0.466542 | RatingNewZealandTelevisionTypeEnum.go | starcoder |
package internal
import (
"math/big"
"reflect"
"github.com/tada/catch"
"github.com/tada/dgo/dgo"
)
type (
bigIntVal struct {
*big.Int
}
defaultBigIntType struct {
defaultIntegerType
}
bigIntType struct {
integerType
}
)
// DefaultBigIntType is the unconstrained Int64 type
var DefaultBigIntType = &... | internal/bigint.go | 0.671686 | 0.552117 | bigint.go | starcoder |
package gohorizon
import (
"encoding/json"
)
// ApplicationAntiAffinityData Anti-affinity data required to create an application pool.
type ApplicationAntiAffinityData struct {
// Maximum number of other applications that can be running on the RDS Server before the RDS Server is rejected for new application sessio... | model_application_anti_affinity_data.go | 0.837354 | 0.454714 | model_application_anti_affinity_data.go | starcoder |
package geo2d
import (
"errors"
"math"
)
var errLineIntersect = errors.New("lines do not intersect")
var errPolygonMinVex = errors.New("polygon has a minimum of 3 (different) vertices")
var errTriangleNuVex = errors.New("triangle must have exactly 3 (different) vertices")
// Point reprsents a 2D point
type Point s... | geo2d.go | 0.867022 | 0.64447 | geo2d.go | starcoder |
package stripe
import "encoding/json"
// A unit of time.
type ShippingRateDeliveryEstimateMaximumUnit string
// List of values that ShippingRateDeliveryEstimateMaximumUnit can take
const (
ShippingRateDeliveryEstimateMaximumUnitBusinessDay ShippingRateDeliveryEstimateMaximumUnit = "business_day"
ShippingRateDeliv... | shippingrate.go | 0.871598 | 0.423935 | shippingrate.go | starcoder |
package resolver
import (
"strconv"
"github.com/google/gapid/gapil/ast"
"github.com/google/gapid/gapil/semantic"
)
// entity translates the ast expression to a semantic expression,
// genericSubroutine or imported API.
func entity(rv *resolver, in ast.Node) interface{} {
var out interface{}
switch in := in.(ty... | gapil/resolver/expression.go | 0.526099 | 0.433682 | expression.go | starcoder |
package schema
const (
// JSONSchema is the libStorage API JSON schema
JSONSchema = `{
"id": "https://github.com/rexray/libstorage",
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "libStorage JSON Schema",
"definitions": {
"volume": {
"title": "Volume",
... | libstorage/api/utils/schema/schema_generated.go | 0.754463 | 0.533701 | schema_generated.go | starcoder |
package timesheet
import (
"fmt"
"io"
"time"
)
// Sheet contains the list of times in the timesheet.
type Sheet struct {
DateFormat string // Format used to write and parse dates.
TimeFormat string // Format used to write and parse times.
Times []time.Time
}
// Load initializes a timesheet from the suppli... | pkg/timesheet/timesheet.go | 0.730578 | 0.420838 | timesheet.go | starcoder |
package resolv
import (
"github.com/kvartborg/vector"
)
// Collision contains the results of an Object.Check() call, and represents a collision between an Object and cells that contain other Objects.
// The Objects array indicate the Objects collided with.
type Collision struct {
checkingObject *Object // The che... | collision.go | 0.869756 | 0.715995 | collision.go | starcoder |
package gfxapi
import (
"context"
"fmt"
"github.com/google/gapid/core/data/protoutil"
"github.com/google/gapid/core/image"
)
func (l *CubemapLevel) faces() [6]*image.Info2D {
return [6]*image.Info2D{
l.NegativeX,
l.PositiveX,
l.NegativeY,
l.PositiveY,
l.NegativeZ,
l.PositiveZ,
}
}
func (l *Cubema... | gapis/gfxapi/texture.go | 0.724675 | 0.403332 | texture.go | starcoder |
package stringset
import (
"fmt"
"strings"
)
type (
// Set implements set operations for string values.
Set map[string]nothing
nothing struct{}
)
// Deduplicate utilizes the Set type to generate a unique list of strings from the input slice.
func Deduplicate(input []string) []string {
return New(input...).Sli... | stringset/set.go | 0.818556 | 0.446917 | set.go | starcoder |
package bigints
import (
"math/big"
"sort"
"github.com/mmcloughlin/addchain/internal/bigint"
)
// Int64s converts a list of int64s into a slice of big integers.
func Int64s(xs ...int64) []*big.Int {
bs := make([]*big.Int, len(xs))
for i, x := range xs {
bs[i] = big.NewInt(x)
}
return bs
}
// ascending sort... | vendor/github.com/mmcloughlin/addchain/internal/bigints/bigints.go | 0.7478 | 0.419232 | bigints.go | starcoder |
// Package perfutil provides utilities of storing performance data for UI tests.
package perfutil
import (
"context"
"sort"
"chromiumos/tast/common/perf"
"chromiumos/tast/errors"
"chromiumos/tast/testing"
)
// Values keeps the reporting values for multiple runs.
type Values struct {
metrics map[string]perf.Me... | src/chromiumos/tast/local/bundles/cros/ui/perfutil/values.go | 0.723212 | 0.46217 | values.go | starcoder |
package cpebiten
import (
"github.com/fogleman/gg"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/ebitenutil"
"github.com/jakecoffman/cp"
"image/color"
"math"
)
func AddWall(space *cp.Space, body *cp.Body, a, b cp.Vector, radius float64) *cp.Shape {
// swap so we always draw the same direction ... | shapes.go | 0.718989 | 0.459682 | shapes.go | starcoder |
package unneko
// completeCond will indicate when the uncompressed file is finished
// Compared to normal lz4 decompression we do not know the file boundaries
// so we need to know when to stop the decompression in other ways.
type completeCond interface {
Complete(neko *nekoData, uncompressed []byte) bool
}
func tr... | lz4.go | 0.566498 | 0.49823 | lz4.go | starcoder |
package auth
import "github.com/benthosdev/benthos/v4/internal/docs"
// BasicAuthFieldSpec returns a basic authentication field spec.
func BasicAuthFieldSpec() docs.FieldSpec {
return docs.FieldAdvanced("basic_auth",
"Allows you to specify basic authentication.",
).WithChildren(
docs.FieldCommon(
"enabled", ... | internal/http/docs/auth/docs.go | 0.766731 | 0.481698 | docs.go | starcoder |
package geojson
// String is a not a geojson object, but just a string
type String string
func (s String) bboxPtr() *BBox {
return nil
}
func (s String) hasPositions() bool {
return false
}
// WithinBBox detects if the object is fully contained inside a bbox.
func (s String) WithinBBox(bbox BBox) bool {
return fa... | pkg/geojson/string.go | 0.910017 | 0.473414 | string.go | starcoder |
package main
import "fmt"
type Node struct {
data int
next *Node
}
//Returns an initialized list
func (n *Node) Init() *Node {
n.data = -1
return n
}
//Returns an new list
func New() *Node {
return new(Node).Init()
}
//Returns the first node in list
func (n *Node) Next() *Node {
return n.next
}
//Returns... | linked-list-circular-singly-1-insertion/linked-list-circular-singly-1-insertion.go | 0.512693 | 0.41484 | linked-list-circular-singly-1-insertion.go | starcoder |
package primenumbers
import (
"math"
"github.com/Bisdow/projecteuler/tools/arraytools"
)
var primeArray = []int{2, 3}
// ResetPrimenumbers - Setze alle ermittelten Primzahlen zurück
func ResetPrimenumbers() {
primeArray = []int{2, 3}
}
// GetPrimeArray - Returns Array with known Prime numbers
func GetPrimeArray... | tools/primenumbers/primenumbers.go | 0.52342 | 0.415314 | primenumbers.go | starcoder |
package meters
const (
METERTYPE_DZG = "DZG"
/***
* Opcodes for DZG DVH4014.
* See "User Manual DVH4013", not public.
*/
OpCodeDZGTotalImportPower = 0x0000
OpCodeDZGTotalExportPower = 0x0002
OpCodeDZGL1Voltage = 0x0004
OpCodeDZGL2Voltage = 0x0006
OpCodeDZGL3Voltage = 0x0008
OpCodeDZ... | internal/meters/dzg.go | 0.566498 | 0.505188 | dzg.go | starcoder |
package neuron
import (
"math/rand"
)
// A Unit is a single neuron unit with weights, a bias, and input/output
// channels for forward and backward. Weights are represented as maps from
// string unit IDs to values.
type Unit struct {
ID string
W *Weight
nin int
activ Activation
opt Optimizer
// Sin... | neuron.go | 0.762424 | 0.525064 | neuron.go | starcoder |
package util
import (
"container/heap"
"math"
"math/rand"
"github.com/golang/glog"
)
// A WeightedValue is used to represent the items sampled by
// WeightedReservoirSample.
type WeightedValue struct {
Value interface{}
key float64
}
// Less implements the Ordered interface.
func (wv WeightedValue) Less(zv... | util/sampling.go | 0.873498 | 0.4133 | sampling.go | starcoder |
package datadog
import (
"encoding/json"
"time"
)
// UsageIngestedSpansHour Ingested spans usage for a given organization for a given hour.
type UsageIngestedSpansHour struct {
// The hour for the usage.
Hour *time.Time `json:"hour,omitempty"`
// Contains the total number of bytes ingested during a given hour.
... | api/v1/datadog/model_usage_ingested_spans_hour.go | 0.774242 | 0.504272 | model_usage_ingested_spans_hour.go | starcoder |
package main
import (
"math"
"time"
"github.com/embeddedgo/stm32/hal/gpio"
)
const deg = math.Pi / 180
// TransitDaytime returns the Sun transit time and the daytime for a given
// latiude, longitude (in radians) and t.UTC().Date() day. Based on
// https://en.wikipedia.org/wiki/Sunrise_equation.
func (l *Lanter... | devboard/minipro-f405/examples/relay/lanterns.go | 0.63443 | 0.465448 | lanterns.go | starcoder |
package xex
import (
"fmt"
"reflect"
)
func registerCollectionBuiltins() {
RegisterFunction(
NewFunction(
"slice",
FunctionDocumentation{
Text: `Makes a new slice containing the passed in values. The type of slice created is determined by the type passed in the first element of values.
slice can be... | builtins_collections.go | 0.697609 | 0.680985 | builtins_collections.go | starcoder |
package finverse
import (
"encoding/json"
)
// IncomeStream struct for IncomeStream
type IncomeStream struct {
// Account this income estimate is associated with
AccountId string `json:"account_id"`
EstimatedMonthlyIncome *IncomeEstimate `json:"estimated_monthly_income,omitempty"`
// Numbe... | finverse/model_income_stream.go | 0.79053 | 0.457076 | model_income_stream.go | starcoder |
package jutil
import (
"fmt"
"time"
)
func GetTimeAgo(ts time.Time) string {
delta := time.Now().Sub(ts)
hours := int(delta.Hours())
if hours > 0 {
if hours >= 24 {
if hours < 48 {
return "1 day ago"
}
return fmt.Sprintf("%d days ago", hours/24)
}
if hours == 1 {
return "1 hour ago"
}
r... | jutil/time.go | 0.652131 | 0.528655 | time.go | starcoder |
package tsm1
/*
This code is originally from: https://github.com/dgryski/go-tsz and has been modified to remove
the timestamp compression fuctionality.
It implements the float compression as presented in: http://www.vldb.org/pvldb/vol8/p1816-teller.pdf.
This implementation uses a sentinel value of NaN which means tha... | tsdb/tsm1/float.go | 0.730963 | 0.533944 | float.go | starcoder |
package atomix
import (
"context"
atomixlock "github.com/atomix/atomix-go-client/pkg/client/lock"
"github.com/atomix/atomix-go-client/pkg/client/session"
"github.com/onosproject/onos-test/pkg/runner"
"github.com/onosproject/onos-test/test"
"github.com/onosproject/onos-test/test/env"
"github.com/stretchr/testif... | test/atomix/locktest.go | 0.500488 | 0.418935 | locktest.go | starcoder |
package datadog
import (
"encoding/json"
"time"
)
// UsageIndexedSpansHour The hours of indexed spans usage.
type UsageIndexedSpansHour struct {
// The hour for the usage.
Hour *time.Time `json:"hour,omitempty"`
// Contains the number of spans indexed.
IndexedEventsCount *int64 `json:"indexed_events_count,omit... | api/v1/datadog/model_usage_indexed_spans_hour.go | 0.732592 | 0.416144 | model_usage_indexed_spans_hour.go | starcoder |
package main
import (
"io"
"math"
"strconv"
"github.com/armsnyder/aoc2020/aocutil"
)
var _ = declareDay(20, func(part2 bool, inputReader io.Reader) interface{} {
if part2 {
return day20Part2(inputReader)
}
return day20Part1(inputReader)
})
func day20Part1(inputReader io.Reader) interface{} {
result := 1
... | day20.go | 0.590661 | 0.464112 | day20.go | starcoder |
package licensee
import (
"encoding/json"
"fmt"
"github.com/flexiant/concerto/api/types"
"github.com/flexiant/concerto/utils"
"github.com/stretchr/testify/assert"
"testing"
)
// GetLicenseeReportListMocked test mocked function
func GetLicenseeReportListMocked(t *testing.T, licenseeReportsIn *[]types.LicenseeRep... | api/licensee/licensee_reports_api_mocked.go | 0.629661 | 0.467149 | licensee_reports_api_mocked.go | starcoder |
package bitfield
import (
"math/bits"
)
var _ = Bitfield(Bitvector4{})
// Bitvector4 is a bitfield with a known size of 4. There is no length bit
// present in the underlying byte array.
type Bitvector4 []byte
const bitvector4ByteSize = 1
const bitvector4BitSize = 4
// NewBitvector4 creates a new bitvector of siz... | bitvector4.go | 0.823931 | 0.53522 | bitvector4.go | starcoder |
Connecting two processes at TCP/IP level might seem scary at first, but in Go
it is easier as one might think.
<!--more-->
While preparing another blog post, I realized that the networking part of the
code was quickly becoming larger than the part of the code that was meant to
illustrate the topic of the post. So I dec... | networking.go | 0.924287 | 0.669202 | networking.go | starcoder |
package overlay
import (
"fmt"
"strconv"
"strings"
"github.com/k14s/ytt/pkg/filepos"
"go.starlark.net/starlark"
)
const (
MatchAnnotationKwargBy string = "by"
MatchAnnotationKwargExpects string = "expects"
MatchAnnotationKwargMissingOK string = "missing_ok"
)
type MatchAnnotationExpectsKwarg struct... | pkg/yttlibrary/overlay/match_annotation_expects_kwarg.go | 0.560734 | 0.432303 | match_annotation_expects_kwarg.go | starcoder |
package geojson
import (
"github.com/tidwall/geojson/geometry"
"github.com/tidwall/gjson"
)
// Polygon ...
type Polygon struct {
base geometry.Poly
extra *extra
}
// NewPolygon ...
func NewPolygon(poly *geometry.Poly) *Polygon {
return &Polygon{base: *poly}
}
// Empty ...
func (g *Polygon) Empty() bool {
ret... | vendor/github.com/tidwall/geojson/polygon.go | 0.709623 | 0.453625 | polygon.go | starcoder |
package collection
import (
"math/rand"
"reflect"
"time"
"github.com/pkg/errors"
)
// template type Slice(T)
type SliceFloat64 []float64
type IsNumberSliceFloat64 string
func ChunkSliceFloat64(slice []float64, size int) [][]float64 {
var chunks [][]float64
for i := 0; i < len(slice); i += size {
end := i ... | collection_SliceFloat64.go | 0.576542 | 0.418935 | collection_SliceFloat64.go | starcoder |
package filter
import (
"gonum.org/v1/gonum/mat"
)
// Filter is a dynamical system filter.
type Filter interface {
// Predict estimates the next internal state of the system
Predict(mat.Vector, mat.Vector) (Estimate, error)
// Update updates the system state based on external measurement
Update(mat.Vector, mat.V... | filter.go | 0.735167 | 0.646363 | filter.go | starcoder |
package nist_sp800_22
import (
"math"
)
func recommandedInputSize(n uint64) (L uint64, Q uint64) {
if n >= 1059061760 {
L = 16
Q = 655360
} else if n >= 496435200 {
L = 15
Q = 327680
} else if n >= 231669760 {
L = 14
Q = 163840
} else if n >= 107560960 {
L = 13
Q = 81920
} else if n >= 49643520... | nist_sp800_22/universal.go | 0.540681 | 0.573798 | universal.go | starcoder |
// Copied and only lightly modified from:
// https://github.com/nickng/bibtex
// Licenced under an Apache-2.0 licence
// and presumably Copyright (c) 2017 by <NAME>
package bibtex
import (
"bufio"
"bytes"
"io"
"strconv"
"strings"
)
var parseField bool
// Scanner is a lexical scanner
type Scanner struct {
r ... | langs/bibtex/scanner.go | 0.572723 | 0.400398 | scanner.go | starcoder |
package trie
import "errors"
const sizeAlphabet = 256
type Trie struct {
root *Node
}
type Node struct {
next []*Node
value *Value
}
type Value int
var initCap = 8
func Constructor() Trie {
return Trie{}
}
func (this Trie) Get(key string) (int, error) {
n := this.get(this.root, key, 0)
if n == nil || n.v... | algorithms/search/trie/trie.go | 0.531939 | 0.416975 | trie.go | starcoder |
// package observ contains logic pertaining to the internal observation
// of the fluent forward receiver.
package observ
import (
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
)
var (
ConnectionsOpened = stats.Int64(
"fluent_opened_connections",
"Number of connections opened to the fluentforward rec... | receiver/fluentforwardreceiver/observ/metrics.go | 0.667798 | 0.51879 | metrics.go | starcoder |
package spacego
/*
<NAME> - An O(ND)Difference Algorithm and Its Variations
a
0 1 2 3 4 5
0*-*-*-*-*-*
|\|\|\|\|\|
1*-*-*-*-*-*
|\|\|\|\|\|
b 2*-*-*-*-*-*
|\|\|\|\|\|
3*-*-*-*-*-*
|\|\|\|\|\|
4*-*-*-*-*-*
|\|\|\|\|\|
5*-*-*-*-*-*
* x, y ... | vendor/aletheiaware.com/spacego/diff.go | 0.685318 | 0.485722 | diff.go | starcoder |
package neural
import (
"encoding/json"
"io/ioutil"
"os"
"sort"
)
// Neural is a set of layers
type Neural struct {
MaxLayers int `json:"-"`
Layers []*Layer `json:"Layers"`
// Average of loss (used in Learns, LearnsRaw and Evolve)
Loss float64 `json:"-"`
}
// Evolve is the config for evolution proces... | neural.go | 0.820254 | 0.526282 | neural.go | starcoder |
package sim
import (
"encoding/binary"
"fmt"
)
type registers struct {
a int
x int
l int
b int
s int
t int
f int
pc int
sw int
}
// SW register values
const (
LT = 0x00
EQ = 0x40
GT = 0x80
)
// Reg returns the value of register reg
func (m *Machine) Reg(reg int) (int, error) {
switch reg {
ca... | sim/registers.go | 0.652131 | 0.415788 | registers.go | starcoder |
package rickshaw
import (
"encoding/json"
"fmt"
"sort"
"strconv"
"strings"
"time"
"github.com/grokify/mogo/time/timeutil"
"github.com/grokify/mogo/type/number"
"github.com/grokify/gocharts/v2/data/slot"
"github.com/grokify/gocharts/v2/data/timeseries/interval"
)
// DataInfoJS is the series item to be sent... | charts/rickshaw/rickshaw.go | 0.611034 | 0.408454 | rickshaw.go | starcoder |
package generic
import (
"errors"
"fmt"
"strconv"
"github.com/benthosdev/benthos/v4/internal/batch/policy"
"github.com/benthosdev/benthos/v4/internal/bundle"
"github.com/benthosdev/benthos/v4/internal/component/output"
"github.com/benthosdev/benthos/v4/internal/component/processor"
"github.com/benthosdev/bent... | internal/impl/generic/output_broker.go | 0.727104 | 0.560674 | output_broker.go | starcoder |
package nbody
import (
"fmt"
"math"
c "github.com/chr-ras/advent-of-code-2019/util/calc"
v "github.com/chr-ras/advent-of-code-2019/util/geometry/vector3"
)
// SimulateJupiterMoons runs the moon movement simulation for n steps and returns the total energy in the system.
func SimulateJupiterMoons(positions []v.Vec... | 12-the-n-body-problem/nbody/nbody.go | 0.781414 | 0.457682 | nbody.go | starcoder |
package dataflow
type NumericValues map[string]NumericValue
type NumericValue struct {
Value float64
Unit string
}
type Registers []Register
type RegisterType int
const (
StringRegister RegisterType = iota
NumberRegister
EnumRegister
)
type Register interface {
Category() string
Name() string
Description... | dataflow/register.go | 0.621081 | 0.411939 | register.go | starcoder |
package column
import (
"github.com/kelindar/bitmap"
"github.com/kelindar/column/commit"
"github.com/kelindar/genny/generic"
)
// --------------------------- Numbers ----------------------------
type number = generic.Number
// columnNumber represents a generic column
type columnNumber struct {
fill bitmap.Bitm... | column_generate.go | 0.7696 | 0.444263 | column_generate.go | starcoder |
package dither
import (
"image"
"image/color"
)
func Monochrome(original image.Image, filter Filter, errorMultiplier float32) image.Image {
bounds := original.Bounds()
dx, dy := bounds.Dx(), bounds.Dy()
ydim := len(filter.Matrix) - 1
xdim := len(filter.Matrix[0]) / 2
img := image.NewGray(bounds)
for x := ... | dither.go | 0.741206 | 0.526465 | dither.go | starcoder |
package plot
import (
"image/color"
"math"
"sync"
"github.com/karlek/wasabi/fractal"
"github.com/karlek/wasabi/histo"
"github.com/karlek/wasabi/render"
)
// TODO(_): Rewrite importance mapping.
func Importance(ren *render.Render, frac *fractal.Fractal) {
fscale := func(v, max float64) float64 {
return value... | plot/plot.go | 0.721547 | 0.498901 | plot.go | starcoder |
package elasticsearch
const mapping = `{
"aliases": {
"heapster-events": {
}
},
"mappings": {
"k8s-heapster": {
"properties": {
"MetricsName": {
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
... | vendor/k8s.io/heapster/common/elasticsearch/mapping.go | 0.684475 | 0.560734 | mapping.go | starcoder |
package mikrotik
import (
"fmt"
"log"
"time"
// . "github.com/ErebusBat/mikrotik/core"
)
// Single point in time sample of the interface state
type InterfaceBandwidthSample struct {
Interface RbInterface
IsRx bool
Date time.Time
ByteCount int64
}
// Calculates the delta between two samples
// The ... | bandwidth_types.go | 0.717309 | 0.413892 | bandwidth_types.go | starcoder |
package model2d
import "github.com/heustis/tsp-solver-go/model"
// BuildPerimiter produces the smallest convex perimeter that can encompass all the vertices in the supplied array.
// This returns both the edges comprising the convex perimeter and the set of unattached (interior) vertices.
// This will panic if any of... | model2d/perimeterbuilder2d.go | 0.773088 | 0.869049 | perimeterbuilder2d.go | starcoder |
package pure
import (
"archive/tar"
"archive/zip"
"bytes"
"context"
"fmt"
"os"
"time"
"github.com/benthosdev/benthos/v4/internal/batch"
"github.com/benthosdev/benthos/v4/internal/message"
"github.com/benthosdev/benthos/v4/public/service"
)
func archiveProcConfig() *service.ConfigSpec {
return service.NewC... | internal/impl/pure/processor_archive.go | 0.674479 | 0.66647 | processor_archive.go | starcoder |
package utils
import (
"crypto/rand"
"encoding/binary"
"math/bits"
)
// RandUint64 return a random value between 0 and 0xFFFFFFFFFFFFFFFF
func RandUint64() uint64 {
b := []byte{0, 0, 0, 0, 0, 0, 0, 0}
if _, err := rand.Read(b); err != nil {
panic(err)
}
return binary.BigEndian.Uint64(b)
}
// RandFloat64 ret... | utils/utils.go | 0.77137 | 0.458409 | utils.go | starcoder |
package main
import (
"fmt"
"log"
"math/rand"
"time"
"gonum.org/v1/gonum/mat"
"github.com/LdDl/cnns"
"github.com/LdDl/cnns/tensor"
"github.com/LdDl/cnns/utils/u"
)
func main() {
CheckXOR()
}
// CheckXOR - solve "XOR" problem
func CheckXOR() {
rand.Seed(time.Now().UnixNano())
// fully-connected layer wi... | examples/boolean/xor/main.go | 0.530723 | 0.464112 | main.go | starcoder |
package v1
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Creates a target pool in the specified project and region using the data included in the request.
type TargetPool struct {
pulumi.CustomResourceState
// The server-defined URL for the resource. Th... | sdk/go/google/compute/v1/targetPool.go | 0.754192 | 0.402216 | targetPool.go | starcoder |
package money
// Currency provides information about a particular currency.
type Currency interface {
// ISO 4217 currency code.
Code() string
// ISO 4217 three-digit numeric code.
NumericCode() int
// Number of digits in the currency minor unit.
// This is the number of digits after the decimal separator.
Mi... | money/currency.go | 0.67405 | 0.489381 | currency.go | starcoder |
package pairingheap
/*
https://en.wikipedia.org/wiki/Pairing_heap
*/
type (
Iterator func(Item) bool
Item interface {
Less(Item) bool
}
Node struct {
item Item
parent *Node
children []*Node
}
Heap struct {
root *Node
}
)
func (node *Node) detach() []*Node {
for i, child := range node.parent.... | PairingHeap/pairing_heap.go | 0.701917 | 0.430985 | pairing_heap.go | starcoder |
package hmath
import (
"fmt"
math "github.com/chewxy/math32"
"github.com/barnex/fmath"
)
type Vec3 [3]float32
func (vec3 *Vec3) Pointer() *[3]float32 { return (*[3]float32)(vec3) }
func (vec3 *Vec3) Slice() []float32 { return vec3[:] }
func (vec3 Vec3) X() float32 ... | code/pkg/hmath/vec3.go | 0.824321 | 0.653569 | vec3.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.