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 model
// DataZoom is the option set for a zoom component.
// dataZoom component is used for zooming a specific area, which enables user to
// investigate data in detail, or get an overview of the data, or get rid of outlier points.
// https://echarts.apache.org/en/option.html#dataZoom
type DataZoomInside struc... | model/data_zoom.go | 0.892574 | 0.579787 | data_zoom.go | starcoder |
package ocalver
import (
"fmt"
"path/filepath"
"regexp"
"strconv"
"time"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"golang.org/x/mod/semver"
)
const (
tagRegexp string = `^(\d+).(\d+).(\d+)$`
tagPreRegexp string = `^(\d+).(\d+).(\... | pkg/ocalver/ocalver.go | 0.57821 | 0.408867 | ocalver.go | starcoder |
package hlsqlib
import (
"fmt"
"regexp"
"strings"
)
var (
numOps = map[string]func(float64, AttrValue) bool{
">": func(t float64, a AttrValue) bool { f, ok := attrAsNum(a); return ok && f > t },
">=": func(t float64, a AttrValue) bool { f, ok := attrAsNum(a); return ok && f >= t },
"<": func(t float64, a ... | hlsqlib/query.go | 0.593374 | 0.426859 | query.go | starcoder |
package i2ptunconf
// GetEncryptLeaseset takes an argument and a default. If the argument differs from the
// default, the argument is always returned. If the argument and default are
// the same and the key exists, the key is returned. If the key is absent, the
// default is returned.
func (c *Conf) GetEncryptLeasese... | config/leasesets.go | 0.560253 | 0.406744 | leasesets.go | starcoder |
package ptree
import (
"math"
"github.com/tidwall/geoindex/child"
)
const maxEntries = 256 // max number of entries per node
const minEntries = maxEntries * 40 / 100 // min number of entries per node
const maxHeight = 16 // a limit is needed to avoid infinite splits
const rows = 16 // 16 =... | ptree.go | 0.730386 | 0.604224 | ptree.go | starcoder |
package algebra
import (
"math"
)
type Matrix struct {
tuples [][]float64
}
//NewMatrix returns a new matrix of the specified size and data
func NewMatrix(col, row int, data ...float64) (*Matrix, error) {
if len(data) != col*row {
return nil, ExpectedDimension(col * row)
}
tuples := make([][]float64, 0, 0)
... | pkg/algebra/matrix.go | 0.812793 | 0.536677 | matrix.go | starcoder |
package fastmath
// Fast, efficient 8-bit scaling functions specifically
// designed for high-performance LED programming.
// Scale8 scales one byte by a second one, which is treated as the numerator of
// a fraction whose denominator is 256. In other words, it computes i * (scale /
// 256)
func Scale8(i uint8, scale... | scale.go | 0.851459 | 0.420778 | scale.go | starcoder |
package conf
// Float64Var defines a float64 flag and environment variable with specified name, default value, and usage string.
// The argument p points to a float64 variable in which to store the value of the flag and/or environment variable.
func (c *Configurator) Float64Var(p *float64, name string, value float64, ... | value_float64.go | 0.892243 | 0.826747 | value_float64.go | starcoder |
package proto
import (
"github.com/lyraproj/data-protobuf/datapb"
"github.com/lyraproj/pcore/px"
"github.com/lyraproj/pcore/types"
)
// A Consumer consumes values and produces a datapb.Data
type Consumer interface {
px.ValueConsumer
// Value returns the created value. Must not be called until the consumption
/... | proto/convert.go | 0.651133 | 0.581481 | convert.go | starcoder |
package radar
import (
"image"
"image/color"
"image/draw"
"github.com/oakmound/oak/render"
)
type Point struct {
X, Y *float64
}
type Radar struct {
render.LayeredPoint
points map[Point]color.Color
center Point
width, height int
r *image.RGBA
outline *render.Sprite
ratio ... | examples/radar-demo/radar/radar.go | 0.876568 | 0.413892 | radar.go | starcoder |
package imaging
import (
"image"
)
// ConvolveOptions are convolution parameters.
type ConvolveOptions struct {
// If Normalize is true the kernel is normalized before convolution.
Normalize bool
// If Abs is true the absolute value of each color class is taken after convolution.
Abs bool
// Bias is added to ... | vendor/github.com/disintegration/imaging/convolution.go | 0.821975 | 0.697667 | convolution.go | starcoder |
package merkletree2
import "fmt"
// Config defines the shape of the MerkleTree.
type Config struct {
// An encoder is used to compute hashes in this configuration, and also
// manages the blinding secrets (see UseBlindedValueHashes).
Encoder Encoder
// UseBlindedValueHashes controls whether this tree blinds hash... | go/merkletree2/config.go | 0.784113 | 0.510863 | config.go | starcoder |
package xlsx
import (
"math"
"time"
)
const (
MJD_0 float64 = 2400000.5
MJD_JD2000 float64 = 51544.5
secondsInADay = float64((24*time.Hour)/time.Second)
nanosInADay = float64((24*time.Hour)/time.Nanosecond)
)
var (
timeLocationUTC, _ = time.LoadLocation("UTC")
unixEpoc = time.Date(1970, time.January, 1, 0,... | vendor/github.com/rentiansheng/xlsx/date.go | 0.625438 | 0.45417 | date.go | starcoder |
package scripts
import "errors"
// OperatorTree tree containing all supported operators
type OperatorTree struct {
OperatorNode
}
// AddOperator adds an operator to the tree
func (tree *OperatorTree) AddOperator(literal string, operator OperatorType) {
current := &tree.OperatorNode
for _, character := range lite... | scripts/operatortree.go | 0.630457 | 0.47025 | operatortree.go | starcoder |
package msgraph
// RatingAustraliaMoviesType undocumented
type RatingAustraliaMoviesType int
const (
// RatingAustraliaMoviesTypeVAllAllowed undocumented
RatingAustraliaMoviesTypeVAllAllowed RatingAustraliaMoviesType = 0
// RatingAustraliaMoviesTypeVAllBlocked undocumented
RatingAustraliaMoviesTypeVAllBlocked Ra... | v1.0/RatingAustraliaMoviesTypeEnum.go | 0.59561 | 0.48377 | RatingAustraliaMoviesTypeEnum.go | starcoder |
package gofa
/*
Fk425 Convert B1950.0 FK4 star catalog data to J2000.0 FK5
This function converts a star's catalog data from the old FK4
(Bessel-Newcomb) system to the later IAU 1976 FK5 (Fricke) system.
Given: (all B1950.0, FK4)
r1950,d1950 float64 B1950.0 RA,Dec (rad)
dr1950,dd1950 float64 B1950.0... | catalog.go | 0.68595 | 0.653991 | catalog.go | starcoder |
package vespyr
import (
"fmt"
"math/rand"
"github.com/MaxHalford/gago"
)
// RSIStrategy is a strategy for that buys and sells based on the RSI
// values.
type RSIStrategy struct {
Period uint `yaml:"period"`
BuyThreshold float64 `yaml:"buy_threshold"`
SellThreshold float64 `yaml:"sell_threshold"`
... | pkg/vespyr/rsi_strategy.go | 0.800458 | 0.440469 | rsi_strategy.go | starcoder |
package rpmalloc
// #include "rpmalloc.h"
import "C"
type Config struct {
//! Map memory pages for the given number of bytes. The returned address MUST be
// aligned to the rpmalloc span size, which will always be a power of two.
// Optionally the function can store an alignment offset in the offset variable
//... | alloc/rpmalloc/tinygo/model.go | 0.555918 | 0.492371 | model.go | starcoder |
package ml
import (
"errors"
"fmt"
"math"
"strings"
)
// Common erros.
var (
ErrBadDim = errors.New("bad dimenstion for matrix")
ErrInconsistentData = errors.New("matrix has different y dimension per x")
ErrUninitialized = errors.New("matrix not initialized")
ErrIdentityInvalidSize = err... | matrix.go | 0.747155 | 0.5083 | matrix.go | starcoder |
package matrix
// Matrix interface defines the default contract for a matrix.
type Matrix interface {
// Dim returns number of rows (1st value) and columns (2nd value) of this Matrix.
Dim() (int, int)
// Entry returns Matrix entry value in the position of given row and col.
Entry(row, col int) int
// SetEntry ... | matrix.go | 0.873309 | 0.74674 | matrix.go | starcoder |
package detect
import (
"image"
"math"
)
// Feature is a Haar-like feature.
type Feature struct {
Rect image.Rectangle
Weight float64
}
// Classifier is a set of features with a threshold.
type Classifier struct {
Feature []Feature
Threshold float64
Left float64
Right float64
}
// CascadeStage... | detect/detect.go | 0.719088 | 0.437944 | detect.go | starcoder |
package geo
import(
"fmt"
"math"
)
const kLineSnapKM = 0.3 // How far a trackpoint can be from a line, and still be on that line
const KLineSnapKM = 0.3 // How far a trackpoint can be from a line, and still be on that line
// Always using two anchor points, and then derive the equation of the line: y = m.x + b
t... | line.go | 0.79736 | 0.5169 | line.go | starcoder |
package videosource
import (
"image"
"time"
)
// ObjectInfo contains the object information
type ObjectInfo struct {
Object Image
Description string
Percentage int
}
// NewObjectInfo creates a new ObjectInfo
func NewObjectInfo(img Image) *ObjectInfo {
o := &ObjectInfo{
Object: img,
Description: ... | videosource/processedimage.go | 0.657098 | 0.460895 | processedimage.go | starcoder |
package hdrhist
import "errors"
/*
This file was ported from the Java source of HdrHistogram written
by <NAME>. See https://hdrhistogram.github.io/HdrHistogram/.
This files provides encoding and decoding functions for writing and
reading ZigZag-encoded LEB128-64b9B-variant (Little Endian Base 128)
values to/from a b... | v1/ao/internal/hdrhist/zigzag.go | 0.652906 | 0.608158 | zigzag.go | starcoder |
package p384
import (
"crypto/elliptic"
"math/big"
)
var (
// p is the order of the base field, represented as little-endian 64-bit words.
p = gfP{0xffffffff, 0xffffffff00000000, 0xfffffffffffffffe, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}
// pp satisfies r*rp - p*pp = 1 where rp and pp are b... | p384.go | 0.617051 | 0.451145 | p384.go | starcoder |
package actions
import (
"encoding/json"
)
// InputFieldDefinition Configuration for an input field on the custom action
type InputFieldDefinition struct {
TypeDefinition FieldTypeDefinition `json:"typeDefinition"`
// Controls what kind of input a customer can use to specify the field value. Must contain exactly ... | generated/actions/model_input_field_definition.go | 0.80969 | 0.425128 | model_input_field_definition.go | starcoder |
package intree
import (
"math"
"math/rand"
)
// Bounds is the main interface expected by NewINTree(); requires Limits method to access interval limits.
type Bounds interface {
Limits() (Lower, Upper float64)
StartingPoint() (ID int, Name string)
}
// INTree is the main package object;
// holds Slice of referen... | intree.go | 0.644896 | 0.451568 | intree.go | starcoder |
package d03
import (
"math"
"strconv"
"strings"
"github.com/jzimbel/adventofcode-go/solutions"
)
var (
origin = point{}
dirs = map[byte]*dir{
'D': &dir{0, 1},
'L': &dir{-1, 0},
'R': &dir{1, 0},
'U': &dir{0, -1},
}
)
type point struct {
x int
y int
}
// dir represents a unit vector in one of the ... | solutions/y2019/d03/solution.go | 0.68941 | 0.466603 | solution.go | starcoder |
package iso20022
// Describes the amount, direction and parties involved in a payment obligation between two participants (and their netting group or trading party) of a netting service.
type NetObligation1 struct {
// Unique identification for the obligation.
ObligationIdentification *Max35Text `xml:"OblgtnId"`
... | NetObligation1.go | 0.776284 | 0.437343 | NetObligation1.go | starcoder |
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/DanielTitkov/anomaly-detection-service/internal/repository/entgo/ent/anomaly"
"github.com/DanielTitkov/anomaly-detection-service/internal/repository/entgo/ent/detectionjobinstance"
)
// Anomaly is the model entity for the Anoma... | internal/repository/entgo/ent/anomaly.go | 0.675015 | 0.518485 | anomaly.go | starcoder |
Solver provides operations on packages: install, remove, upgrade,
check integrity and others.
A package is an object comprised of a unique key (tentative release name,
version, namespace, chart name), and digested information about the chart that
it relates to (dependency relations, chart and repo URL, current and des... | internal/solver/doc.go | 0.704872 | 0.684251 | doc.go | starcoder |
package ast
import (
"strings"
)
type (
Node interface {
Type() NodeType
Text() string
}
Parent interface {
Node
Nodes() []Node
}
TextNode struct {
NodeType
Txt string
}
ParentNode struct {
NodeType
Children []Node
}
)
func (n TextNode) Type() NodeType { return n.NodeType }
func (n Pare... | ast/node.go | 0.550849 | 0.419113 | node.go | starcoder |
package tin
import "math"
const (
EarthRadius = 6378137.0
MinLatitude = -85.05112878
MaxLatitude = 85.05112878
MinLongitude = -180.0
MaxLongitude = 180.0
TileSize = 256
MaxLevelOfDetail = 38
HalfCircumference = 20037508.342789243076571549020
)
func clip(n, minValue, maxV... | webmercator.go | 0.706089 | 0.45944 | webmercator.go | starcoder |
package iso20022
// Choice between formats for the identification of a financial instrument.
type SecurityIdentification1Choice struct {
// International Securities Identification Number (ISIN). A numbering system designed by the United Nation's International Organisation for Standardisation (ISO). The ISIN is comp... | SecurityIdentification1Choice.go | 0.735262 | 0.611266 | SecurityIdentification1Choice.go | starcoder |
package parse
import (
"fmt"
"reflect"
"strconv"
"time"
)
var durationType = reflect.TypeOf(time.Duration(0))
func parseNumber(strVal string, numberType reflect.Type) (reflect.Value, error) {
var castVal reflect.Value
switch numberType.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, re... | parse/number.go | 0.693161 | 0.441131 | number.go | starcoder |
package techan
import (
"github.com/sdcoffey/big"
"github.com/sdcoffey/techan"
)
// Position is a pair of two Order objects
type Position struct {
orders [2]*Order
}
// NewPosition returns a new Position with the passed-in order as the open order
func NewPosition(openOrder Order) (t *Position) {
t = new(Position... | position.go | 0.760917 | 0.431464 | position.go | starcoder |
package primitive
import (
"fmt"
"math"
"math/rand"
"github.com/fogleman/gg"
)
type Triangle struct {
W, H int
X1, Y1 int
X2, Y2 int
X3, Y3 int
}
func NewRandomTriangle(w, h int) *Triangle {
x1 := rand.Intn(w)
y1 := rand.Intn(h)
x2 := rand.Intn(w)
y2 := rand.Intn(h)
x3 := rand.Intn(w)
y3 := rand.Int... | primitive/triangle.go | 0.644001 | 0.487429 | triangle.go | starcoder |
package polygol
import (
"fmt"
"math"
)
type ringIn struct {
poly *polyIn
isExterior bool
segments []*segment
bbox bbox
}
func (o *operation) newRingIn(ring [][]float64, poly *polyIn, isExterior bool) (*ringIn, error) {
if len(ring) == 0 {
return nil, fmt.Errorf(`Input geometry is not a valid... | geom-in.go | 0.642208 | 0.509764 | geom-in.go | starcoder |
package client
var (
COND_EQ = QueryConditionType{"eq", 1}
COND_NE = QueryConditionType{"ne", 1}
COND_NULL = QueryConditionType{"null", 0}
COND_NOTNULL = QueryConditionType{"notnull", 0}
COND_IN = QueryConditionType{"in", -1}
COND_NOTIN = QueryConditionType{"notin", -1}
COND_OR = QueryC... | vnext/condition.go | 0.560974 | 0.437703 | condition.go | starcoder |
package minimum_knight_moves
import (
"container/list"
)
// MinKnightMovesBFS
// Bidirectional BFS
func MinKnightMovesBFS(x int, y int) int {
// the offsets in the eight directions
offsets := [][]int{
{1, 2}, {2, 1}, {2, -1}, {1, -2},
{-1, -2}, {-2, -1}, {-2, 1}, {-1, 2},
}
// data structures needed to move... | golang/minimum_knight_moves/minimum_knight_moves_bfs.go | 0.592195 | 0.479138 | minimum_knight_moves_bfs.go | starcoder |
package datatype
import (
"fmt"
"math"
"github.com/i-sevostyanov/NanoDB/internal/sql"
)
type Float struct {
value float64
}
func NewFloat(v float64) Float {
return Float{value: v}
}
func (f Float) Raw() interface{} {
return f.value
}
func (f Float) DataType() sql.DataType {
return sql.Float
}
func (f Floa... | internal/sql/datatype/float.go | 0.778102 | 0.51818 | float.go | starcoder |
package spinix
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/rs/xid"
"github.com/mmadfox/geojson"
)
type Expr interface {
String() string
expr()
}
type DistanceUnit int
const (
DistanceUndefined DistanceUnit = 0
DistanceMeters DistanceUnit = 1
DistanceKilometers DistanceUnit = 2
)
func (... | ast.go | 0.639511 | 0.469946 | ast.go | starcoder |
package zdb
import (
"github.com/ocdogan/rbt"
)
type dataColumn struct {
valueList
index int
name string
valueCount int
valueType ValueType
table *DataTable
btree *rbt.RbTree
nilRows map[int]*dataRow
}
func (column *dataColumn) get(valueIndex int) (interface{}, bool) {
if valu... | datacolumn.go | 0.558086 | 0.472683 | datacolumn.go | starcoder |
package treap
import (
"math/rand"
"time"
goheap "github.com/theodesp/go-heaps"
)
const MaxInt = int(^uint(0) >> 1)
type Node struct {
Priority goheap.Integer
Key goheap.Item
Left, Right *Node
}
// Split treap into 2 treaps:
// - All key in left treap <= key
// - All key in right treap > key
func... | treap/treap.go | 0.727395 | 0.485356 | treap.go | starcoder |
package main
import (
"context"
"fmt"
"strings"
"time"
)
type Move struct {
startIndex uint8
endIndex uint8
}
func (m *Move) String() string {
return fmt.Sprintf("%s to %s", indexToStringPos(m.startIndex), indexToStringPos(m.endIndex))
}
func indexFromStringLoc(pos string) (uint8, error) {
if len(pos) != ... | board.go | 0.576542 | 0.541409 | board.go | starcoder |
package optimize
import (
"errors"
"log"
"net/http"
"os"
)
// ErrFormat indicates that optimize encountered an unknown format.
var ErrFormat = errors.New("optimize: unknown format")
type OptimizeSummary struct {
// Size in bytes before passing in the optimization function
SizeBefore int64
// Size in bytes aft... | optimize/optimize.go | 0.763043 | 0.44342 | optimize.go | starcoder |
package sequences
import . "github.com/objecthub/containerkit"
type DependentSequence interface {
Sequence
}
func EmbeddedDependentSequence(obj DependentSequence) SequenceDerived {
return &dependentSequence{obj, EmbeddedSequence(obj)}
}
type dependentSequence struct {
obj DependentSequence
SequenceDerived... | sequences/dependentsequence.go | 0.795896 | 0.466724 | dependentsequence.go | starcoder |
package czml
// Material is a definition of how a surface is colored or shaded
// https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Material
type Material struct {
SolidColor *SolidColorMaterial `json:"solidColor,omitempty"`
Image *ImageMaterial `json:"image,omitempty"`
Grid *GridM... | materials.go | 0.893466 | 0.40439 | materials.go | starcoder |
package gpu
import (
"fmt"
"github.com/goki/ki/kit"
)
// See: https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)
// Types is a list of GPU data types
type Types int32
const (
UndefType Types = iota
Bool
Int
UInt
Float32
Float64
TypesN
)
//go:generate stringer -type=Types
var KiT_Types = kit.Enums.Add... | oswin/gpu/types.go | 0.840161 | 0.563498 | types.go | starcoder |
package game
type Tileish interface {
tile() *Tile
dist(tileish Tileish) Distance
stepOn(p Platform, s *State, monster Monstrous) error
setEffect(sprite SpriteIndex)
}
type Tile struct {
monster Monstrous
x, y Position
sprite SpriteIndex
passable bool
treasure bool
effect ... | go/game/tile.go | 0.655557 | 0.44354 | tile.go | starcoder |
package xiaobattery
import (
"machine"
)
// ChargeStatus returns the state of the battery.
type ChargeStatus uint8
// Charge status of the battery: discharging, charging, and fully charged.
const (
Discharging ChargeStatus = iota + 1
Charging
FullyCharged
)
type voltagePercentPosition struct {
millivolts int
... | utils/xiaoexpansion/battery/battery.go | 0.65368 | 0.544014 | battery.go | starcoder |
package main
/* Given the attached text file as an argument, your program will read the file, and output the 20 most frequently
used words in the file in order, along with their frequency.
The output should be the same to that of the following bash commands,
where the first argument is the text file to proces... | hashtables/frequsedwords.go | 0.595493 | 0.564579 | frequsedwords.go | starcoder |
package secp256k1
import (
"crypto/cipher"
"fmt"
"io"
"math/big"
"go.dedis.ch/kyber/v3"
"go.dedis.ch/kyber/v3/util/key"
"golang.org/x/crypto/sha3"
)
// btcec's public interface uses this affine representation for points on the
// curve. This does not naturally accommodate the point at infinity. btcec
// repre... | lib/signatures/secp256k1/point.go | 0.759136 | 0.519217 | point.go | starcoder |
package lib
import (
"errors"
"image"
"image/color"
)
// Offsets of channels within RGBA pixels:
const r = 0
const g = 1
const b = 2
// filter pattern, addressable as [y][x]
var pattern = [][]int{
{r, g},
{g, b},
}
// Simple-minded, I am. Generate indices of "neighbors" of a value at a given index.
func getIn... | lib/demosaic.go | 0.792263 | 0.437343 | demosaic.go | starcoder |
package opc
// Raver plaid
// A rainbowy pattern with moving diagonal black stripes
import (
"github.com/longears/pixelslinger/colorutils"
"github.com/longears/pixelslinger/config"
"github.com/longears/pixelslinger/midi"
"math"
"time"
)
func MakePatternRaverPlaid(locations []float64) ByteThread {
return func... | opc/pattern-raver-plaid.go | 0.574992 | 0.595287 | pattern-raver-plaid.go | starcoder |
package gohome
import (
"github.com/PucklaMotzer09/mathgl/mgl32"
)
// A 2D camera used for showing different parts of the world
type Camera2D struct {
// It's position in world space
Position mgl32.Vec2
// It's zoom (>1.0 -> Zoom In and <1.0 -> Zoom Out)
Zoom float32
// It's rotation in degrees
... | src/gohome/camera2d.go | 0.695752 | 0.439326 | camera2d.go | starcoder |
package entities
import (
"fmt"
"math"
"math/rand"
)
// Point represents geographical location on game map
type Point struct {
X float64 `gorm:"index" json:"x"`
Y float64 `gorm:"index" json:"y"`
}
// NewPoint create Point
func NewPoint(x float64, y float64) Point {
return Point{X: x, Y: y}
}
// IsIn returns t... | entities/point.go | 0.906943 | 0.621196 | point.go | starcoder |
package glc
import "errors"
// MapT0T1 is a type wrapper, implements IMap interfaces.
type MapT0T1 map[T0]T1
// PairMpT0T1 is a type alias used only in Map methods to avoid code generation issues.
type PairMpT0T1 = struct {
X1 T0
X2 T1
}
func (m MapT0T1) Copy() MapT0T1 {
if m == nil {
return nil
}
m1 := make... | pkg/glc/map_01.go | 0.808408 | 0.412234 | map_01.go | starcoder |
package ttt
import (
"log"
)
// O is the integer value for O player
const O int = 1
// X is the integer value for X player
const X int = 2
// EMPTY is the integer value for empty space
const EMPTY int = 0
// EvaluateGame evaluates the game with given state (1: Max player wins, -1: Min player wins, 0: Draw or Game... | ttt/ttt.go | 0.58676 | 0.48871 | ttt.go | starcoder |
package analytics
import (
"math"
"strconv"
"strings"
)
var (
nan = math.NaN()
)
type Window struct {
values []float64
}
// NewWindow returns a new window able to hold up to capacity values.
func NewWindow(capacity int) *Window {
w := Window{
values: make([]float64, 0, capacity),
}
return &w
}
// Len ret... | analytics/window.go | 0.804367 | 0.429908 | window.go | starcoder |
package day9
import (
"fmt"
"sort"
"github.com/pietrodll/aoc2021/utils/collections"
"github.com/pietrodll/aoc2021/utils/grid"
)
func parseInput(input string) grid.Grid {
return grid.NewGridFromString(input, "\n", "")
}
func findLowPoints(g *grid.Grid) []grid.GridPoint {
lowPoints := make([]grid.GridPoint, 0)
... | advent-of-code-2021/day9/day9.go | 0.67662 | 0.426023 | day9.go | starcoder |
package memfs
import "strings"
// Formatters for representing the date and time as a string.
const (
JSONDateTime = "2006-01-02T15:04:05-07:00"
)
//===========================================================================
// String Helpers
//=======================================================================... | utils.go | 0.757525 | 0.440108 | utils.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPLiteralNumber258 struct for BTPLiteralNumber258
type BTPLiteralNumber258 struct {
Atomic *bool `json:"atomic,omitempty"`
BtType *string `json:"btType,omitempty"`
DocumentationType *string `json:"documentationType,omitempty"`
EndSourceLocation *int32 `json:"endSour... | onshape/model_btp_literal_number_258.go | 0.727007 | 0.432902 | model_btp_literal_number_258.go | starcoder |
package mat
import (
"math"
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
func NewSphere() *Sphere {
return &Sphere{
Id: rand.Int63(),
Transform: New4x4(),
Inverse: New4x4(),
InverseTranspose: New4x4(),
Material: NewDefaultMaterial(),
sa... | internal/pkg/mat/sphere.go | 0.741674 | 0.507812 | sphere.go | starcoder |
package sdk
import (
"encoding/binary"
"math"
"time"
"unicode/utf16"
)
type IntGetter func(Record) (int, bool)
type FloatGetter func(Record) (float64, bool)
type BoolGetter func(Record) (bool, bool)
type TimeGetter func(Record) (time.Time, bool)
type StringGetter func(Record) (string, bool)
func bytesToByte(getB... | sdk/field_getters.go | 0.568176 | 0.408454 | field_getters.go | starcoder |
package activation
import (
"fmt"
"math"
"sort"
"strings"
)
//function types
const (
FuncTypeSigmoid = "sig"
FuncTypeTanh = "tanh"
FuncTypeRelu = "relu"
FuncTypeLeakyRelu = "leaky_relu"
FuncTypeElu = "elu"
FuncTypeIden = "iden"
FuncTypeCustom = "custom"
)
var validFtypes = map[st... | internal/activation/activation.go | 0.808559 | 0.486941 | activation.go | starcoder |
package matrix
import (
"fmt"
"math"
"math/rand"
"os"
"time"
)
// Ternary simple function for simulating ternary operator
func Ternary(statement bool, a, b interface{}) interface{} {
if statement {
return a
}
return b
}
// AbsInt returns absolute value of input int
func AbsInt(n int) int {
if n < 0 {
re... | matrix/utils.go | 0.738198 | 0.538801 | utils.go | starcoder |
package dconv
import (
"github.com/osgochina/donkeygo/errors/derror"
"reflect"
)
// Scan automatically calls MapToMap, MapToMaps, Struct or Structs function according to
// the type of parameter `pointer` to implement the converting.
// It calls function MapToMap if `pointer` is type of *map to do the converting.
... | util/dconv/dconv_scan.go | 0.687315 | 0.4206 | dconv_scan.go | starcoder |
package simpleflow
// BatchSlice takes a slice and breaks it up into sub-slices of `size` length each
func BatchSlice[T any](items []T, size int) [][]T {
batches := make([][]T, 0, (len(items)+size-1)/size)
for size < len(items) {
items, batches = items[size:], append(batches, items[0:size:size])
}
batches = app... | batches.go | 0.870941 | 0.625781 | batches.go | starcoder |
package zcl
import (
"errors"
"fmt"
"github.com/shimmeringbee/bytecodec"
"github.com/shimmeringbee/bytecodec/bitbuffer"
"github.com/shimmeringbee/zigbee"
"math"
)
func marshalZCLType(bb *bitbuffer.BitBuffer, ctx bytecodec.Context, dt AttributeDataType, v interface{}) error {
switch dt {
case TypeNull:
retur... | zcl_types_marshal.go | 0.522933 | 0.483283 | zcl_types_marshal.go | starcoder |
package iavl
import (
"bytes"
"fmt"
"strings"
"github.com/pkg/errors"
)
// pathWithLeaf is a path to a leaf node and the leaf node itself.
type pathWithLeaf struct {
Path PathToLeaf `json:"path"`
Leaf proofLeafNode `json:"leaf"`
}
func (pwl pathWithLeaf) String() string {
return pwl.StringIndented("")
}
... | vendor/github.com/tendermint/iavl/proof_path.go | 0.615897 | 0.456652 | proof_path.go | starcoder |
package rgb
import (
"image/color"
"math"
"math/rand"
"github.com/rrothenb/pbr/pkg/geom"
)
const sRGB = 1.8
// Energy stores RGB light energy as a 3D Vector.
type Energy geom.Vec
var White = Energy{1, 1, 1}
var Black = Energy{0, 0, 0}
// Merged merges energy b into energy a with a given signal strength.
func ... | pkg/rgb/energy.go | 0.88856 | 0.60644 | energy.go | starcoder |
*/
//-----------------------------------------------------------------------------
package sdf
import (
"errors"
"math"
)
//-----------------------------------------------------------------------------
// Box3 is a 3d bounding box.
type Box3 struct {
Min, Max V3
}
// Box2 is a 2d bounding box.
type Box2 struc... | sdf/box.go | 0.915949 | 0.637242 | box.go | starcoder |
package main
/*
Given a 2D matrix of zeros and ones that represent an image,
replace all ones that are not connected to a one that's in a
border of the image with zero.
1 represents black.
0 represents white.
Example:
Input:
[
[1, 0, 0, 0, 0, 0],
[0, 1, 0, 1, 1, 1],
[0, 0, 1, 0, 1, 0],
[1, 1, 0, 0, ... | golang/algorithms/others/remove_islands/main.go | 0.647464 | 0.73874 | main.go | starcoder |
package resolver
import (
"context"
models "go.edusense.io/storage/models"
)
// PersonInferenceResolver resolves query-agnostic PersonInference model.
type PersonInferenceResolver struct {
Inference models.PersonInference
}
// Posture extracts collection of posture inferences from given PersonInference
// resol... | storage/query/resolver/videoinference.go | 0.802439 | 0.434881 | videoinference.go | starcoder |
package iso20022
// Execution of the subscription part, in a switch between investment funds or investment fund classes.
type SwitchSubscriptionLegExecution2 struct {
// Unique technical identifier for an instance of a leg within a switch.
LegIdentification *Max35Text `xml:"LegId,omitempty"`
// Unique identifier ... | SwitchSubscriptionLegExecution2.go | 0.789193 | 0.418222 | SwitchSubscriptionLegExecution2.go | starcoder |
package compute
// MachineImagesClient is a client for the MachineImage functions of the Compute API.
type MachineImagesClient struct {
ResourceClient
}
// MachineImages obtains an MachineImagesClient which can be used to access to the
// MachineImage functions of the Compute API
func (c *ComputeClient) MachineImage... | vendor/github.com/mitchellh/packer/vendor/github.com/hashicorp/go-oracle-terraform/compute/machine_images.go | 0.847558 | 0.447038 | machine_images.go | starcoder |
package days
const input2 = `
forward 5
down 8
down 6
down 7
down 8
forward 7
down 3
up 6
forward 6
down 2
forward 5
down 6
up 3
down 4
forward 4
down 6
down 1
up 5
forward 5
down 1
down 7
up 2
down 7
forward 1
forward 6
down 1
up 1
up 4
forward 3
forward 6
forward 1
forward 4
up 3
forward 1
forward 4
down 9
forward 4... | days/input2.go | 0.793826 | 0.492249 | input2.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPExpressionSwitch2632 struct for BTPExpressionSwitch2632
type BTPExpressionSwitch2632 struct {
BTPExpression9
BtType *string `json:"btType,omitempty"`
Choices *BTPLiteralMap256 `json:"choices,omitempty"`
Selector *BTPExpression9 `json:"selector,omitempty"`
SpaceAf... | onshape/model_btp_expression_switch_2632.go | 0.729231 | 0.417093 | model_btp_expression_switch_2632.go | starcoder |
package main
import (
"github.com/g3n/engine/core"
"github.com/g3n/engine/geometry"
"github.com/g3n/engine/gls"
"github.com/g3n/engine/graphic"
"github.com/g3n/engine/light"
"github.com/g3n/engine/material"
"github.com/g3n/engine/math32"
"github.com/g3n/engine/window"
"math/rand"
)
type Raycast struct {
rc ... | other_raycast.go | 0.553023 | 0.410993 | other_raycast.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"log"
"strings"
"strconv"
"math"
)
type Pair struct {
X, Y int64
}
func main() {
// read input
data, err := ioutil.ReadFile("input.txt")
handleError(err)
// parse input
wires := strings.Split(string(data), "\n")
wire1 := wires[0]
wire2 := wires[1]
// follow an... | 2019/3/part1/main.go | 0.530236 | 0.50238 | main.go | starcoder |
package header
/**
* The From header field indicates the logical identity of the initiator
* of the request, possibly the user's address-of-record. This may be different
* from the initiator of the dialog. Requests sent by the callee to the caller
* use the callee's address in the From header field.
* <p>
... | sip/header/FromHeader.go | 0.893728 | 0.641605 | FromHeader.go | starcoder |
package bipbuffer
import "errors"
// BipBuffer is a spsc circular non-thread safe buffer that always
// supports writing a contiguous chunk of data. Write requests that
// cannot fit in an available contiguous area will be failed with
// an error.
type BipBuffer struct {
buf []byte
idxRegionA int
sizeOfRegionA... | bipbuffer/bip_buffer.go | 0.810441 | 0.580857 | bip_buffer.go | starcoder |
package astits
import (
"fmt"
"time"
"github.com/asticode/go-astikit"
)
// parseDVBTime parses a DVB time
// This field is coded as 16 bits giving the 16 LSBs of MJD followed by 24 bits coded as 6 digits in 4 - bit Binary
// Coded Decimal (BCD). If the start time is undefined (e.g. for an event in a NVOD referenc... | dvb.go | 0.605566 | 0.460168 | dvb.go | starcoder |
package datadog
import (
"encoding/json"
"fmt"
)
// LogsCategoryProcessor Use the Category Processor to add a new attribute (without spaces or special characters in the new attribute name) to a log matching a provided search query. Use categories to create groups for an analytical view. For example, URL groups, ma... | api/v1/datadog/model_logs_category_processor.go | 0.75037 | 0.403038 | model_logs_category_processor.go | starcoder |
package iso20022
// Set of elements used to provide information on the original amount.
type AmountAndCurrencyExchange3 struct {
// Identifies the amount of money to be moved between the debtor and creditor, before deduction of charges, expressed in the currency as ordered by the initiating party and provides curren... | AmountAndCurrencyExchange3.go | 0.804367 | 0.666124 | AmountAndCurrencyExchange3.go | starcoder |
package rs485
import (
"math"
. "github.com/volkszaehler/mbmd/meters"
)
func init() {
Register("SEMTR", NewSEMTRProducer)
}
type SEMTRProducer struct {
Opcodes
}
func NewSEMTRProducer() Producer {
/**
* Opcodes as defined by SolarEdge SE-MTR-3Y
* reverse engineered from: https://github.com/nmakel/solaredg... | meters/rs485/semtr3y.go | 0.742515 | 0.467271 | semtr3y.go | starcoder |
package mock
import (
"testing"
"time"
"github.com/ActiveState/cli/internal/progress"
"github.com/autarch/testify/assert"
)
var _ progress.Incrementer = &Incrementer{}
// TestProgress is wrapper around a Progress that can be used in test to ensure that the progress bar
// loop terminates after a configurable ti... | internal/progress/mock/mock.go | 0.618896 | 0.403156 | mock.go | starcoder |
Copyright 2016 https://github.com/AsynkronIT/protoactor-go
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agree... | actor/doc.go | 0.846356 | 0.601067 | doc.go | starcoder |
package convexhull
import "github.com/yukirin/algo/geo"
// Solve2 is Quickhull
func Solve2(ps []complex128) []complex128 {
lp, rp := leftMost(ps), rightMost(ps)
ret := make([]complex128, 2, 500)
ret[0], ret[1] = lp, rp
return append(ret, solve(lp, rp, ps)...)
}
func solve(lp, rp complex128, ps []complex128) []co... | convexhull/quickhull.go | 0.584864 | 0.408336 | quickhull.go | starcoder |
package assert
import (
"testing"
"github.com/ppapapetrou76/go-testing/internal/pkg/values"
"github.com/ppapapetrou76/go-testing/types"
)
// AssertableMap is the structure to assert maps
type AssertableMap struct {
t *testing.T
actual types.Map
}
// ThatMap returns a proper assertable structure based on t... | assert/map.go | 0.766643 | 0.768255 | map.go | starcoder |
package game
import (
"snake/utils"
)
type direction int
const (
directionUp direction = iota
directionRight
directionLeft
directionDown
)
var oppositeDirections map[direction]direction
var moves map[direction]utils.Vector
func init() {
oppositeDirections = map[direction]direction{
directionUp: directio... | controller/game/snake.go | 0.560974 | 0.491151 | snake.go | starcoder |
package triangulate
import (
"github.com/go-spatial/geom"
"github.com/go-spatial/geom/planar/triangulate/quadedge"
)
/*
Segment models a constraint segment in a triangulation.
A constraint segment is an oriented straight line segment between a start point
and an end point.
Author <NAME>
Author <NAME>
Ported to Go... | planar/triangulate/segment.go | 0.886297 | 0.707186 | segment.go | starcoder |
package game
import (
"github.com/mokiat/lacking-gl/internal"
"github.com/mokiat/lacking/game/graphics"
)
func newDirectionalLightShaderSet() graphics.ShaderSet {
vsBuilder := internal.NewShaderSourceBuilder(directionalLightVertexShader)
fsBuilder := internal.NewShaderSourceBuilder(directionalLightFragmentShader)... | game/shader_dir_light.go | 0.632049 | 0.458409 | shader_dir_light.go | starcoder |
package cache
import (
"fmt"
"github.com/ghodss/yaml"
"github.com/intel/cri-resource-manager/pkg/cri/resource-manager/kubernetes"
"strings"
)
const (
// annotation key for specifying container affinity rules
keyAffinity = "affinity"
// annotation key for specifying container anti-affinity rules
keyAntiAffini... | pkg/cri/resource-manager/cache/affinity.go | 0.765856 | 0.411998 | affinity.go | starcoder |
Regexp like a Perl Pumpking in Go!
Rationale:
#Perl5:
$str =~ m/This is how (?<we>party!)/g
$we = $1;
$we = $+{we}
//Golang:
M(str, `m/This is how (?P<we>party!)/g`)
we := R0.S[1] // access the first capture group
we = R0.Z["we"] // access the named capture group
Flags supported:
- g
- x
- m
- s
- i
... | v0/re.go | 0.620392 | 0.403743 | re.go | starcoder |
package types
import (
"strings"
"github.com/fabulousduck/proto/src/tokens"
)
//DetermineType takes a char and determines its type
func DetermineType(str string) (string, string) {
chars := []string{
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", ... | src/types/types.go | 0.614047 | 0.44065 | types.go | starcoder |
package paint
import (
"encoding/binary"
"image"
"image/color"
"image/draw"
"math"
"gioui.org/f32"
"gioui.org/internal/opconst"
"gioui.org/op"
)
// ImageOp sets the material to an image.
type ImageOp struct {
uniform bool
color color.RGBA
src *image.RGBA
size image.Point
}
// ColorOp sets the ... | op/paint/paint.go | 0.796015 | 0.473292 | paint.go | starcoder |
package ut
import (
"reflect"
"strings"
"testing"
"runtime"
"bytes"
"fmt"
)
// Test is the testing.T instance for the test being run.
var test *testing.T = &testing.T{}
// Run sets up an individual test.
func Run(t *testing.T) {
test = t
}
// Test returns the testing.T passed to the Run() method.
func Test()... | vendor/github.com/headzoo/ut/ut.go | 0.661814 | 0.519887 | ut.go | starcoder |
package ast
import (
"errors"
"fmt"
"strings"
)
type Package struct {
BaseScope
Name string
Comment string
Imports []*Import
Consts map[string]*Const
Subtypes map[string]*Subtype
InstantiatedTypes map[string]*InstantiateType
Enums map[string]*Enum
Unions ... | internal/ast/package.go | 0.61173 | 0.457318 | package.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.