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 uvr1611
import (
"fmt"
"github.com/brutella/gouvr/uvr"
)
// IsUnusedInputValue returns true when the value for an input is unused
func IsUnusedInputValue(value uvr.Value) bool {
return InputTypeFromValue(value) == InputTypeUnused
}
// RoomTemperatureModeFromValue returns the room temperature mode from the... | uvr/1611/input_value.go | 0.78469 | 0.476092 | input_value.go | starcoder |
package shuffle
import (
"errors"
"math/bits"
)
func masks(max FeistelWord) (int, FeistelWord) {
/* special case when you want to traverse all the inclusive range of FeistelWord type space */
if max == 0 {
max = MaxFeistelWord
}
/* bit offset and bit mask */
bitOffset := (bits.Len64(uint64(max-1)) + 1) >> 1
... | shuffle.go | 0.685529 | 0.432902 | shuffle.go | starcoder |
package set
const orderedFunctions = `
{{if .Type.Ordered}}
//-------------------------------------------------------------------------------------------------
// These methods require {{.TName}} be ordered.
// Min returns the element with the minimum value. In the case of multiple items being equally minimal,
// any... | internal/set/ordered.go | 0.794584 | 0.59887 | ordered.go | starcoder |
package structural
import "fmt"
// TimeImp is the interface for different implementations of telling the time.
type TimeImp interface {
Tell()
}
// BasicTimeImp defines a TimeImp which tells the time in 24 hour format.
type BasicTimeImp struct {
hour int
minute int
}
// NewBasicTimeImp creates a new TimeImp.
f... | structural/bridge.go | 0.785514 | 0.455744 | bridge.go | starcoder |
package tt
import "testing"
// Assertions provides assertion methods around the
// TestingT interface.
type Assertions struct {
t TestingT
}
// New makes a new Assertions object for the specified TestingT.
func New(t TestingT) *Assertions {
return &Assertions{
t: t,
}
}
// BM func Benchmark1(b *testing.B, fn f... | vendor/github.com/vcaesar/tt/assert.go | 0.688887 | 0.653362 | assert.go | starcoder |
package intcode
// Instruction is a single instruction read from the memory of a VM.
type Instruction struct {
// Op is the opcode for the action the instruction should perform.
Op Op
// Params is the list of parameters provided to the instruction.
Params []Param
}
// Get reads the value for a parameter of the in... | pkg/intcode/instruction.go | 0.715821 | 0.587085 | instruction.go | starcoder |
package smartapi
import (
"errors"
"fmt"
"reflect"
"strings"
)
func parseArgument(tag string, fieldType reflect.Type) (Argument, error) {
var kind string
var data string
eqAt := strings.Index(tag, "=")
if eqAt >= 0 {
kind = tag[:eqAt]
data = tag[(eqAt + 1):]
} else {
kind = tag
}
a, err := getArgumen... | tagstruct.go | 0.539711 | 0.406214 | tagstruct.go | starcoder |
package astmodel
import (
"fmt"
"go/token"
"sort"
"github.com/Azure/azure-service-operator/hack/generator/pkg/astbuilder"
"github.com/dave/dst"
"github.com/pkg/errors"
kerrors "k8s.io/apimachinery/pkg/util/errors"
)
// StoragePropertyConversion represents a function that generates the correct AST to convert a... | hack/generator/pkg/astmodel/storage_conversion_function.go | 0.80525 | 0.418637 | storage_conversion_function.go | starcoder |
package yarn
import (
"fmt"
"math"
"strconv"
yarnpb "github.com/DrJosh9000/yarn/bytecode"
)
// ConvertToBool attempts conversion of the standard Yarn Spinner VM types
// (bool, number, string, null) to bool.
func ConvertToBool(x interface{}) (bool, error) {
if x == nil {
return false, nil
}
switch x := x.(... | convert.go | 0.68215 | 0.504639 | convert.go | starcoder |
package node
// AbstractVisitor holds a concrete visitor
// and implements the basic tree traversal logic using the visitor pattern.
// By doing so, concrete visitors should not re-implement the same traversal logic in their visit functions.
type AbstractVisitor struct {
ConcreteVisitor Visitor
}
// VisitProgramNode... | parser/node/abstract_visitor.go | 0.834879 | 0.625924 | abstract_visitor.go | starcoder |
package vaporization
import (
"fmt"
"sort"
g "github.com/chr-ras/advent-of-code-2019/util/geometry"
)
// VaporizeAsteroids simulates a laser going clockwise vaporizing the asteroids one by one.
func VaporizeAsteroids(asteroidMap []string, monitoringStation g.Point) {
asteroidsByAngleMap, angles, totalAsteroids :... | 10-monitoring-station/vaporization/vaporization.go | 0.775945 | 0.528108 | vaporization.go | starcoder |
package main
/*****************************************************************************************************
*
* There are a total of n courses you have to take labelled from 0 to n - 1.
*
* Some courses may have prerequisites, for example, if prerequisites[i] = [ai, bi] this means you
* must take the cour... | basic/Algorithm/graph/210.course_schedule_ii/210.CourseScheduleII_zmillionaire.go | 0.546254 | 0.64607 | 210.CourseScheduleII_zmillionaire.go | starcoder |
package exchange
import "fmt"
func FmtBalance(balance float64, usdt float64, usdtFrozen float64, currency float64, currencyFrozen float64, ft float64, ftFrozen float64) string {
return fmt.Sprintf("balance: %s, usdt: %s, usdtFrozen: %s, currency: %s, currencyFrozen: %s, ft: %s, ftFrozen: %s",
FloatToStringForEx(ba... | exchange/format_utils.go | 0.772874 | 0.486454 | format_utils.go | starcoder |
package delegated
import (
"encoding/binary"
"fmt"
"github.com/pkg/errors"
"github.com/skythen/gobalplatform/aid"
"github.com/skythen/gobalplatform/command"
"github.com/skythen/gobalplatform/internal/util"
"github.com/skythen/gobalplatform/open"
)
// Confirmation is a confirmation for a delegated card content... | delegated/delegated.go | 0.637821 | 0.441854 | delegated.go | starcoder |
package cartego
import (
"math"
)
// Radius of the earth in meters
const R = 6378100
const TILESIZE = 256
type Point struct {
Lat, Lon float64
}
func toRad(deg float64) float64 {
return deg * math.Pi / 180
}
func toDeg(rad float64) float64 {
return rad * 180 / math.Pi
}
func latToYPixels(lat float64, zoom... | coords.go | 0.858807 | 0.601477 | coords.go | starcoder |
package terminal
import "github.com/lucasb-eyer/go-colorful"
const (
Xterm0 = 0
Xterm1 = 128.0 / 255.0
Xterm2 = 95.0 / 255.0
Xterm3 = 135.0 / 255.0
Xterm4 = 175.0 / 255.0
Xterm5 = 215.0 / 255.0
Xterm6 = 1
)
// Based on https://www.ditig.com/256-colors-cheat-sheet
var Xterm256 = []colorful.Color{
{R: Xterm0, ... | terminal/xterm.go | 0.524882 | 0.563018 | xterm.go | starcoder |
package continuous
import (
"github.com/jtejido/ggsl/specfunc"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
smath "github.com/jtejido/stats/math"
"math"
"math/rand"
)
// Kumaraswamy distribution
// https://en.wikipedia.org/wiki/Kumaraswamy_distribution
type Kumaraswamy struct {
a, b float64
src ... | dist/continuous/kumaraswamy.go | 0.687105 | 0.416737 | kumaraswamy.go | starcoder |
package stats
import (
"bytes"
"fmt"
"sync"
)
// MatrixType provides a common interface for Matrix and MatrixFunc.
type MatrixType interface {
LabelX() string
LabelY() string
Data() map[string]map[string]int64
}
// Matrix provides a two-dimentional map from string.string to int64.
// It also provides a Data m... | go/stats/matrix.go | 0.641759 | 0.54256 | matrix.go | starcoder |
package calver
import (
"fmt"
"math"
)
type Convention struct {
representation string
format string
extract func(*Version) int
validate func(int) error
}
func (c *Convention) Format(value int) string {
return fmt.Sprintf(c.format, value)
}
var (
YYYY = Convention{
representation: "YYY... | calver/conventions.go | 0.517083 | 0.482795 | conventions.go | starcoder |
package graph
// V is a vertex/node of the graph represented as an integer value
type V int
// G is a graph represented as an adjacency list of nodes
type G map[V][]V
// E is an edge between two vertexes u and v
type E [2]V
// NewNode returns a new node
func NewNode(i int) V {
return V(i)
}
// Value returns the i... | graph/graph.go | 0.8746 | 0.646125 | graph.go | starcoder |
package deltas_computation
import (
. "github.com/protolambda/zrnt/eth2/beacon"
. "github.com/protolambda/zrnt/eth2/core"
"github.com/protolambda/zrnt/eth2/util/math"
)
type ValidatorStatusFlag uint64
func (flags ValidatorStatusFlag) hasMarkers(markers ValidatorStatusFlag) bool {
return flags & markers == marker... | eth2/beacon/deltas_computation/deltas_justification.go | 0.558568 | 0.428293 | deltas_justification.go | starcoder |
package proj
import (
"fmt"
"math"
)
// EqdC is an Equidistant Conic projection.
func EqdC(this *SR) (forward, inverse Transformer, err error) {
// Standard Parallels cannot be equal and on opposite sides of the equator
if math.Abs(this.Lat1+this.Lat2) < epsln {
return nil, nil, fmt.Errorf("proj: Equidistant Co... | proj/eqdc.go | 0.672117 | 0.468912 | eqdc.go | starcoder |
package decstree
import (
"fmt"
"strings"
)
type (
// Question represent one question that can be answered by data
// We answer question by looking Data and find it's key.
// Question only can be answered by choosing the Answer that have
// correct value
Question struct {
ID string `json:"i,omitempty"`... | main.go | 0.593727 | 0.478894 | main.go | starcoder |
package g4
import (
"github.com/go-gl/gl/v3.3-core/gl"
"github.com/amortaza/go-g4/ace"
)
type ColorRect struct {
program *ace.Program
vao uint32
vbo uint32
}
func NewColorRect() *ColorRect {
r := &ColorRect{}
r.program = ace.NewProgram("github.com/amortaza/go-g4/shader/rgb.vertex.txt", "github.com/amortaza/... | ColorRect.go | 0.683525 | 0.432842 | ColorRect.go | starcoder |
package cache
import (
"mmapcache/byteio"
)
const (
mmapDataHeadLen = 12
mmapDataHeadUsedPos = 4
mmapDataHeadTagPos = mmapDataHeadUsedPos + 4
mmapDataHeadKeyLenPos = mmapDataHeadTagPos + 2
mmapDataPos = mmapDataHeadLen
)
// MMapData mmap数据块
// | ------------------------------------------- ... | src/cache/mmapdata.go | 0.516595 | 0.518973 | mmapdata.go | starcoder |
package model
import (
"fmt"
"sort"
"strconv"
mat "github.com/nlpodyssey/spago/pkg/mat32"
)
// NameMap implements a bidirectional mapping between a name and an index
type NameMap struct {
NameToIndex map[string]int
IndexToName map[int]string
}
func (f *NameMap) Set(name string, index int) {
f.NameToIndex[nam... | pkg/model/metadata.go | 0.795221 | 0.559711 | metadata.go | starcoder |
package main
import (
"fmt"
"github.com/keep94/gocombinatorics"
)
const (
kMax = 1000000000 // operands must be less than this number
)
const (
kNumExpressions = 200
)
// postfixEntry represents an entry in a postfix expression.
type postfixEntry struct {
value int64 // The value of the entry
op byte // ... | reach.go | 0.668556 | 0.411879 | reach.go | starcoder |
package scaler
import (
"strconv"
"strings"
"time"
)
type Expression string
func (e Expression) Match(t time.Time) bool {
a := strings.Split(string(e), " ")
if len(a) != 6 {
return false
}
minute := pattern(a[0])
hour := pattern(a[1])
day := pattern(a[2])
month := pattern(a[3])
year := pattern(a[4])
... | internal/scaler/expression.go | 0.592902 | 0.400046 | expression.go | starcoder |
package nanodate
import (
"fmt"
"log"
"strconv"
"errors"
)
var DebugLevel int = 0
/// Definition of what a Date contains
type Date struct {
Milis uint16 `json:"milis"`
Seconds uint8 `json:"seconds"`
Minutes uint8 `json:"minutes"`
Hour uint8 `json:"hour"`
Day uint8 `json:"day"`... | nanodate.go | 0.757256 | 0.410638 | nanodate.go | starcoder |
package kurobako
import (
"encoding/json"
"fmt"
)
// Capabilities of a solver.
type Capabilities int64
const (
// UniformContinuous indicates that the solver can handle numerical parameters that have uniform continuous range.
UniformContinuous Capabilities = 1 << iota
// UniformDiscrete indicates that the solv... | capability.go | 0.752195 | 0.40342 | capability.go | starcoder |
package edlib
import (
"errors"
"github.com/hbollon/go-edlib/internal/utils"
)
// LCS takes two strings and compute their LCS(Longuest Common Subsequence)
func LCS(str1, str2 string) int {
// Convert strings to rune array to handle no-ASCII characters
runeStr1 := []rune(str1)
runeStr2 := []rune(str2)
if len(r... | vendor/github.com/hbollon/go-edlib/lcs.go | 0.602763 | 0.414366 | lcs.go | starcoder |
package gfmatrix
import (
"fmt"
"github.com/OpenWhiteBox/primitives/number"
)
// Row is a row / vector of elements from GF(2^8).
type Row []number.ByteFieldElem
// NewRow returns an empty n-component row.
func NewRow(n int) Row {
return Row(make([]number.ByteFieldElem, n))
}
// LessThan returns true if row i is... | gfmatrix/row.go | 0.841956 | 0.434641 | row.go | starcoder |
package core
import (
"image"
"math"
)
var NoDirection = Vector{0, 0, 0}
type Tracer interface {
Trace(x, y float64, ray Vector) (bool, float64, Vector, Color)
TraceDeep(x, y float64, ray Vector) (bool, TraceIntervals)
GetBounds() Bounds
Pruned(rp RenderingParameters) Tracer // okay to return nil or self
}
fu... | unicornify/core/tracer.go | 0.692018 | 0.480844 | tracer.go | starcoder |
package torch
// #include "gotorch.h"
import "C"
import (
"runtime"
"unsafe"
"github.com/pkg/errors"
)
type Tensor struct {
ptr C.AtTensor
data []float32
}
func TensorFromScalar(f float32) *Tensor {
t, err := TensorFromBlob([]float32{f}, nil)
if err != nil {
panic(err)
}
return t
}
func TensorFromBlob(... | tensor.go | 0.601711 | 0.495545 | tensor.go | starcoder |
package graphs
import (
"errors"
"fmt"
)
// UnDirectedGraph defines a undirected graph
type UnDirectedGraph struct {
vertexCount int
edgeCount int
adjacentVertices [][]int
visited []bool
pathTo []int
distanceTo []int
connectedComponent [][]int
}
// NewUnDirec... | datastructure/graphs/undirected_graph.go | 0.806052 | 0.617426 | undirected_graph.go | starcoder |
package solid
import "github.com/cpmech/gosl/fun/dbf"
// OnedLinElast implements a linear elastic model for 1D elements
type OnedLinElast struct {
E float64 // Young's modulus
G float64 // shear modulus
A float64 // cross-sectional area
I22 float64 // moment of inertia of cross section about y2-axis
I11 f... | mdl/solid/onedlinelast.go | 0.793586 | 0.41253 | onedlinelast.go | starcoder |
package lsp
import "github.com/nokia/ntt/internal/lsp/protocol"
type PredefFunctionDetails struct {
Label string
InsertText string
Signature string
Documentation string
NrOfParameters int
TextFormat protocol.InsertTextFormat
}
var PredefinedFunctions = []PredefFunctionDetails{
{
Label... | internal/lsp/predef_func_descr.go | 0.626924 | 0.434821 | predef_func_descr.go | starcoder |
package display
import (
"fmt"
mgl "github.com/go-gl/mathgl/mgl32"
"github.com/inkyblackness/shocked-client/graphics"
"github.com/inkyblackness/shocked-client/opengl"
)
var basicHighlighterVertexShaderSource = `
#version 150
precision mediump float;
in vec3 vertexPosition;
uniform mat4 modelMatrix;
uniform ma... | src/github.com/inkyblackness/shocked-client/editor/display/BasicHighlighter.go | 0.752559 | 0.538437 | BasicHighlighter.go | starcoder |
package validator
import (
"bytes"
"context"
"fmt"
"math"
"reflect"
"strconv"
"github.com/go-courier/ptr"
"github.com/go-courier/validator/errors"
"github.com/go-courier/validator/rules"
)
var (
TargetFloatValue = "float value"
TargetDecimalDigitsOfFloatValue = "decimal digits of float valu... | float_validator.go | 0.651687 | 0.460713 | float_validator.go | starcoder |
package evo
import "math"
// A Network provides the ability to process a set of inputs and returns the outputs
type Network interface {
Activate(Matrix) (Matrix, error)
}
// Neuron is the type of neuron to create within the network
type Neuron byte
// Complete list of neuron types
const (
Input Neuron = iota + 1
... | network.go | 0.752195 | 0.581065 | network.go | starcoder |
package async
import (
"reflect"
)
/*
Map allows you to manipulate data in a slice in Waterfall mode.
Each Routine will be called with the value and index of the current position
in the slice. When calling the Done function, an error will cause the
mapping to immediately exit. All other arguments are sent back as ... | map.go | 0.657648 | 0.502319 | map.go | starcoder |
package mysql
import (
"context"
"errors"
"testing"
"time"
sushiapi "github.com/sergiorra/sushi-api-go/pkg"
"github.com/DATA-DOG/go-sqlmock"
_ "github.com/lib/pq"
"github.com/stretchr/testify/assert"
)
func Test_SushiRepository_CreateSushi_RepositoryError(t *testing.T) {
sushi := buildSushi()
db, sqlMock... | pkg/storage/mysql/repository_text.go | 0.529263 | 0.409752 | repository_text.go | starcoder |
// Code has been adapted from Go standard time package.
// Copyright 2009 The Go Authors. All rights reserved.
//go:generate stringer -type=Weekday,Month
// Package date implements support for Gregorian date, following ISO 8601
// standard.
package date
import (
"time"
)
// A Duration represents the elapsed time ... | date.go | 0.81946 | 0.44553 | date.go | starcoder |
// Package intree provides a very fast, static, flat, augmented interval tree for reverse range searches.
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)
... | intree.go | 0.776665 | 0.641493 | intree.go | starcoder |
package layout
import (
"image"
"github.com/gop9/olt/gio/op"
"github.com/gop9/olt/gio/unit"
)
// Constraints represent a set of acceptable ranges for
// a widget's width and height.
type Constraints struct {
Width Constraint
Height Constraint
}
// Constraint is a range of acceptable sizes in a single
// dime... | gio/layout/layout.go | 0.72086 | 0.474692 | layout.go | starcoder |
package merger
import "github.com/suggest-go/suggest/pkg/utils"
// MaxOverlap is the largest value of an overlap count for a merge candidate
const MaxOverlap = 0xFFFF
// ListMerger solves `threshold`-occurrence problem:
// For given inverted lists find the set of strings ids, that appears at least
// `threshold` tim... | pkg/merger/list_merger.go | 0.855685 | 0.575588 | list_merger.go | starcoder |
package deepcopy
import (
"reflect"
"github.com/sirupsen/logrus"
)
// MergeInterface can be implemented by types to have custom deep copy logic.
type MergeInterface interface {
Merge(interface{}) interface{}
}
// Merge returns a merge of x and y.
// Supports everything except Chan, Func and UnsafePointer.
func M... | common/deepcopy/merge.go | 0.538498 | 0.480418 | merge.go | starcoder |
package ast
import (
"fmt"
"path/filepath"
"strings"
"github.com/Konstantin8105/c4go/util"
)
// Position is type of position in source code
type Position struct {
File string // The relative or absolute file path.
Line int // Start line
LineEnd int // End line
Column int // Start colu... | ast/position.go | 0.602646 | 0.50354 | position.go | starcoder |
package main
import (
"fmt"
"strconv"
"time"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
const textView1 = `[green]func[white] [yellow]main[white]() {
app := tview.[yellow]NewApplication[white]()
textView := tview.[yellow]NewTextView[white]().
[yellow]SetTextColor[white](tcell.ColorYell... | demos/presentation/textview.go | 0.567697 | 0.449574 | textview.go | starcoder |
package vec
import (
"log"
"math"
)
// Vec is a 3 dimensional vector.
// It's represented as a point relative to the origin
// So we also use Vec as if they were points.
// But it's implementation should be considered as private
type Vec struct {
X float64
Y float64
Z float64
}
// Origin is the point representi... | vec/vec.go | 0.915285 | 0.744285 | vec.go | starcoder |
package maths
import "github.com/wdevore/Ranger-Go-IGE/api"
type zoomTransform struct {
// An optional (occasionally used) translation.
position api.IVector
// The zoom factor generally incremented in small steps.
// For example, 0.1
scale api.IVector
// The focal point where zooming occurs
zoomAt api.IVecto... | engine/maths/zoom_transform.go | 0.843251 | 0.498047 | zoom_transform.go | starcoder |
package cucumberexpressions
import (
"errors"
"fmt"
"reflect"
"strconv"
)
// can be imported from "math/bits". Not yet supported in go 1.8
const uintSize = 32 << (^uint(0) >> 32 & 1) // 32 or 64
type ParameterByTypeTransformer interface {
// toValueType accepts either reflect.Type or reflect.Kind
Transform(fro... | cucumber-expressions/go/parameter_by_type_transformer.go | 0.595963 | 0.418816 | parameter_by_type_transformer.go | starcoder |
package ring
import (
"github.com/ldsec/lattigo/utils"
"math/bits"
)
// GenGaloisParams generates the generators for the galois endomorphisms.
func GenGaloisParams(n, gen uint64) (galElRotCol []uint64) {
var m, mask uint64
m = n << 1
mask = m - 1
galElRotCol = make([]uint64, n>>1)
galElRotCol[0] = 1
for... | ring/ring_galois.go | 0.547464 | 0.47725 | ring_galois.go | starcoder |
package ast
import (
"encoding/json"
"fmt"
"strings"
)
// TypeAnnotation
type TypeAnnotation struct {
IsResource bool
Type Type `json:"AnnotatedType"`
StartPos Position `json:"-"`
}
func (t *TypeAnnotation) String() string {
if t.IsResource {
return fmt.Sprintf("@%s", t.Type)
}
return fmt.Spr... | runtime/ast/type.go | 0.778144 | 0.434881 | type.go | starcoder |
package main
import (
"errors"
"fmt"
"math"
"math/big"
"strings"
"github.com/pachisi456/sia-hostdb-profiles/types"
)
var errUnableToParseSize = errors.New("unable to parse size")
// filesize returns a string that displays a filesize in human-readable units.
func filesizeUnits(size int64) string {
if size == ... | cmd/siac/parse.go | 0.68595 | 0.463444 | parse.go | starcoder |
// Package day19 solves AoC 2021 day 19.
package day19
import (
"fmt"
"sort"
"strconv"
"strings"
"github.com/fis/aoc/glue"
"github.com/fis/aoc/util"
)
func init() {
glue.RegisterSolver(2021, 19, glue.ChunkSolver(solve))
}
func solve(chunks []string) ([]string, error) {
scanners, err := parseInput(chunks)
... | 2021/day19/day19.go | 0.521227 | 0.469399 | day19.go | starcoder |
package casee
import (
"github.com/fatih/camelcase"
"strings"
"unicode"
)
// Convert argument to snake_case style string.
// If argument is empty, return itself.
func ToSnakeCase(s string) string {
if len(s) == 0 {
return s
}
fields := splitToLowerFields(s)
return strings.Join(fields, "_")
}
// If argument... | vendor/github.com/pinzolo/casee/casee.go | 0.593374 | 0.441191 | casee.go | starcoder |
package growthbook
import (
"encoding/json"
"reflect"
"regexp"
"strings"
)
// Condition represents conditions used to target features/experiments
// to specific users.
type Condition interface {
Eval(attrs Attributes) bool
}
// Concrete condition representing ORing together a list of
// conditions.
type orCondi... | conditions.go | 0.654122 | 0.456713 | conditions.go | starcoder |
package client
// NetworkPolicySpec provides the specification of a NetworkPolicy
type V1NetworkPolicySpec struct {
// List of egress rules to be applied to the selected pods. Outgoing traffic is allowed if there are no NetworkPolicies selecting the pod (and cluster policy otherwise allows the traffic), OR if the tr... | pkg/client/v1_network_policy_spec.go | 0.770853 | 0.786213 | v1_network_policy_spec.go | starcoder |
package evalengine
import (
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/sqlparser"
)
type (
LogicalOp interface {
eval(left, right EvalResult) (boolean, error)
String()
}
LogicalExpr struct {
BinaryExpr
op func(left, right boolean) boolean
opname string
}
NotExpr struct {
UnaryExpr
... | go/vt/vtgate/evalengine/logical.go | 0.678966 | 0.457621 | logical.go | starcoder |
package softwarebackend
import (
"image"
"image/color"
"math"
"github.com/tfriedel6/canvas/backend/backendbase"
)
func (b *SoftwareBackend) Clear(pts [4]backendbase.Vec) {
iterateTriangles(pts[:], func(tri []backendbase.Vec) {
b.fillTriangleNoAA(tri, func(x, y int) {
if b.clip.AlphaAt(x, y).A == 0 {
re... | backend/softwarebackend/fill.go | 0.510985 | 0.458288 | fill.go | starcoder |
package day_21
const input = `
move position 2 to position 1
move position 2 to position 5
move position 2 to position 4
swap position 0 with position 2
move position 6 to position 5
swap position 0 with position 4
reverse positions 1 through 6
move position 7 to position 2
rotate right 4 steps
rotate left 6 steps
rot... | adventofcode_2016/day_21/input.go | 0.871324 | 0.996604 | input.go | starcoder |
package main
import (
"time"
)
// ReportFactory generates data structures that define reports about the comments made between two dates,
// and provides method to deal with week numbers, so as to easily generate reports for a specific week.
type ReportFactory struct {
cutOff int64 // Max acceptable comme... | report.go | 0.76999 | 0.529263 | report.go | starcoder |
package sweetiebot
import (
"fmt"
"sort"
"strconv"
"strings"
"github.com/bwmarrin/discordgo"
)
type HelpCommand struct {
}
func (c *HelpCommand) Name() string {
return "Help"
}
func (c *HelpCommand) Process(args []string, msg *discordgo.Message, info *GuildInfo) (string, bool) {
if len(args) == 0 {
s := []... | sweetiebot/help_command.go | 0.596903 | 0.481637 | help_command.go | starcoder |
// Package pl provides holiday definitions for Poland.
package pl
import (
"time"
"github.com/devechelon/cal/v2"
"github.com/devechelon/cal/v2/aa"
)
var (
// NewYear represents New Year's Day on 1-Jan
NewYear = aa.NewYear.Clone(&cal.Holiday{Name: "Nowy Rok", Type: cal.ObservancePublic})
// ThreeKings represe... | v2/pl/pl_holidays.go | 0.514644 | 0.523238 | pl_holidays.go | starcoder |
package explain
import (
"fmt"
"github.com/crillab/gophersat/solver"
)
// MUSMaxSat returns a Minimal Unsatisfiable Subset for the problem using the MaxSat strategy.
// A MUS is an unsatisfiable subset such that, if any of its clause is removed,
// the problem becomes satisfiable.
// A MUS can be useful to underst... | explain/mus.go | 0.699254 | 0.446736 | mus.go | starcoder |
package suture
/*
Service is the interface that describes a service to a Supervisor.
Serve Method
The Serve method is called by a Supervisor to start the service.
The service should execute within the goroutine that this is
called in. If this function either returns or panics, the Supervisor
will call it again.
A S... | vendor/github.com/thejerf/suture/service.go | 0.609989 | 0.435601 | service.go | starcoder |
// Package cursor defines the oswin cursor interface and standard system
// cursors that are supported across platforms
package cursor
import (
"fmt"
"log"
"github.com/goki/ki/kit"
)
// todo: apps can add new named shapes starting at ShapesN
// Shapes are the standard cursor shapes available on all platforms
ty... | oswin/cursor/cursor.go | 0.530236 | 0.441673 | cursor.go | starcoder |
package algorithms
import (
"math"
)
func unDef(f float64) bool {
if math.IsNaN(f) {
return true
}
if math.IsInf(f, 1) {
return true
}
if math.IsInf(f, -1) {
return true
}
return false
}
func Ewma(series []float64, com float64) []float64 {
var cur float64
var prev float64
var oldw float64
var adj f... | algorithms/auto1.go | 0.611614 | 0.414662 | auto1.go | starcoder |
package dns
// NameUsed sets the RRs in the prereq section to
// "Name is in use" RRs. RFC 2136 section 2.4.4.
func (u *Msg) NameUsed(rr []RR) {
u.Answer = make([]RR, len(rr))
for i, r := range rr {
u.Answer[i] = &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
}
}
// NameNot... | github.com/miekg/dns/update.go | 0.544559 | 0.419648 | update.go | starcoder |
package log
import "time"
// Interface represents the API of both Logger and Entry and exposes 3 types of
// functions:
// - functions named like WithXX and Watch return entries that can be used in chained call
// - xxf are in printf style with message format and arguments
// - logging functions - like Info - log a m... | interface.go | 0.522689 | 0.470919 | interface.go | starcoder |
package dualshock
import (
"encoding/binary"
"io"
)
// Controller describes the reference to the hardware device
type Controller struct {
reader io.Reader
queue chan []byte
errors chan error
interrupt chan int
}
// DPad is the data structure describing the joysticks on the controller
type DPad struct... | dualshock.go | 0.631253 | 0.568296 | dualshock.go | starcoder |
package wikifier
// A collection of elements.
type elements struct {
elements []element
metas map[string]bool
cachedHTML HTML
parentElement element
shouldHide bool
}
// Creates a collection of elements.
func newElements(els []element) *elements {
return &elements{elements: els, metas: make(ma... | wikifier/elements.go | 0.831314 | 0.421254 | elements.go | starcoder |
package toolbox
import (
"fmt"
"strings"
"unicode"
)
//Matcher represents a matcher, that matches input from offset position, it returns number of characters matched.
type Matcher interface {
//Match matches input starting from offset, it return number of characters matched
Match(input string, offset int) (match... | tokenizer.go | 0.7478 | 0.437223 | tokenizer.go | starcoder |
package iso20022
// Set of elements providing information specific to the individual transaction(s) included in the message.
type CreditTransferTransactionInformation2 struct {
// Set of elements to reference a payment instruction.
PaymentIdentification *PaymentIdentification2 `xml:"PmtId"`
// Set of elements use... | CreditTransferTransactionInformation2.go | 0.761006 | 0.583055 | CreditTransferTransactionInformation2.go | starcoder |
package integration
import (
"errors"
"testing"
"github.com/devhossamali/ari"
)
func TestLoggingList(t *testing.T, s Server) {
runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
expected := []*ari.Key{
ari.NewKey(ari.LoggingKey, "n1"),
}
m.Logging.On("List", (*ari.Key)(nil)).Return(expect... | internal/integration/logging.go | 0.581184 | 0.533823 | logging.go | starcoder |
package gorhsm
import (
"encoding/json"
)
// ImageInContentSet Image Details in a content set image listing.
type ImageInContentSet struct {
Arch *string `json:"arch,omitempty"`
Checksum *string `json:"checksum,omitempty"`
// Date represents the date format used for API returns
DatePublished *string `json:"... | model_image_in_content_set.go | 0.807347 | 0.404743 | model_image_in_content_set.go | starcoder |
// Package at provides holiday definitions for Austria.
package at
import (
"time"
"github.com/devechelon/cal/v2"
"github.com/devechelon/cal/v2/aa"
)
var (
// Neujahr represents New Year's Day on 1-Jan
Neujahr = aa.NewYear.Clone(&cal.Holiday{Name: "Neujahrstag", Type: cal.ObservancePublic})
// HeiligeDreiKoe... | v2/at/at_holidays.go | 0.535827 | 0.41947 | at_holidays.go | starcoder |
package models
type HasPrices interface {
MinPrice() int
GuaranteedPrice() int
MaxPrice() int
}
type pricesVal struct {
// Price info
minPrice int
guaranteedPrice int
maxPrice int
// chance info
minChance float64
maxChance float64
midChance float64
}
// The absolute minimum price that may o... | models/analysisPrices.go | 0.798029 | 0.447219 | analysisPrices.go | starcoder |
package main
/*
Helper method fills a singly-even order matrix.
Key:
- Fill each quarter of a singly-even order matrix to make each an odd-order
magic square.
- Calculate the number of columns we need to shift, then exchange values of
top quarters with bottom quarters. Note: the middle rows of the left quarters
need... | golang/singly-even-order.go | 0.640523 | 0.601008 | singly-even-order.go | starcoder |
package redel
import (
"bufio"
"bytes"
"crypto/rand"
"io"
)
type (
// Redel provides an interface (around Scanner) for replace string occurrences
// between two string delimiters.
Redel struct {
Reader io.Reader
Delimiters []Delimiter
eof []byte
}
// Delimiter defines a replacement delimite... | redel.go | 0.651244 | 0.408336 | redel.go | starcoder |
package ipv4
import (
"math/bits"
)
// setNode is currently the same data structure as trieNode. However,
// its purpose is to implement a set of keys. Hence, values in the underlying
// data structure are completely ignored. Aliasing it in this way allows me to
// provide a completely different API on top of the sa... | ipv4/setnode.go | 0.724481 | 0.558086 | setnode.go | starcoder |
package iso20022
// Calculation of the current situation of a baseline as a result of the submission of a commercial data set.
type LineItem14 struct {
// Calculated information about the goods of the underlying transaction.
LineItemDetails []*LineItemDetails12 `xml:"LineItmDtls"`
// Line items total amount as in... | LineItem14.go | 0.794185 | 0.415907 | LineItem14.go | starcoder |
package giso
import (
"fmt"
"math"
)
// Point is a position in a 3D space.
type Point struct {
x float64
y float64
z float64
}
// At returns a point.
func At(x, y, z float64) *Point {
return &Point{x, y, z}
}
func (p *Point) X() float64 {
return p.x
}
func (p *Point) Y() float64 {
return p.y
}
func (p *Po... | point.go | 0.924713 | 0.692993 | point.go | starcoder |
package aoc
type Matrix3x3 struct {
// 0 1 2
// 3 4 5
// 6 7 8
v [9]int
}
func NewMatrix3x3(values [9]int) Matrix3x3 {
return Matrix3x3{v: values}
}
func NewIdentityMatrix3x3() Matrix3x3 {
return NewMatrix3x3([9]int{1, 0, 0, 0, 1, 0, 0, 0, 1})
}
func (m Matrix3x3) MulVector3(v Vector3) Vector3 {
return Vecto... | aoc/matrix3x3.go | 0.741487 | 0.72911 | matrix3x3.go | starcoder |
package iter
type mapIterableForInt struct {
iter IterableForInt
mapper func(item int) int
}
func (m *mapIterableForInt) Next() OptionForInt {
item := m.iter.Next()
if item.IsNone() {
return NoneInt()
}
return SomeInt(m.mapper(item.Unwrap()))
}
var _ IterableForInt = &mapIterableForInt{}
type chainForIn... | examples/iterators.go | 0.5769 | 0.441071 | iterators.go | starcoder |
package conditions
import (
"fmt"
"github.com/zimmski/tavor/log"
"github.com/zimmski/tavor/token"
"github.com/zimmski/tavor/token/lists"
"github.com/zimmski/tavor/token/primitives"
)
// BooleanExpression defines a boolean expression
type BooleanExpression interface {
token.Token
// Evaluate evaluates the boo... | token/conditions/expressions.go | 0.830525 | 0.537163 | expressions.go | starcoder |
package fields
import (
"errors"
"reflect"
)
// AreEqual is comparing two given Fields using DefaultEquality.
func AreEqual(left, right Fields) (bool, error) {
if v := DefaultEquality; v != nil {
return v.AreFieldsEqual(left, right)
}
return false, nil
}
// DefaultEquality is the default instance of a Equalit... | fields/equality.go | 0.896311 | 0.557665 | equality.go | starcoder |
package validationparams
import "github.com/calvine/simplevalidation/validator"
// ValidationParams is a struct that represents the parameters for validating a value.
type ValidationParams struct {
/*
ArrayDepth tells the validator how many layers deep an array is.
So for instance:
[][]int would have an Arr... | validation/validationparams/validationparams.go | 0.719186 | 0.670709 | validationparams.go | starcoder |
package main
import (
"flag"
"image"
"image/png"
"math"
"math/rand"
"os"
"sync"
"github.com/Sirupsen/logrus"
"github.com/karlek/bygget/plane"
"github.com/karlek/bygget/ray"
"github.com/karlek/bygget/sphere"
"github.com/karlek/bygget/vector"
"github.com/karlek/bygget/world"
"github.com/pkg/profile"
)
fu... | cmd/bygget/bygget.go | 0.52342 | 0.418727 | bygget.go | starcoder |
package main
import (
"math"
)
type meanVarianceCouple struct {
mean float64
variance float64
}
type caracteristicsStats struct {
noiseLevel meanVarianceCouple
brakeDistance meanVarianceCouple
vibrations meanVarianceCouple
}
type caracteristicsStatsByPlaneType map[PlaneType]caracteristicsStats
func... | caracteristics.go | 0.84607 | 0.525856 | caracteristics.go | starcoder |
package grapher
import (
"fmt"
"io/ioutil"
"gopkg.in/yaml.v2"
)
// NodeSpec defines the structure expected from the yaml file to define each nodes.
type NodeSpec struct {
Name string `yaml:"name"` // unique name assigned to this node
Category string `yaml:"category"` // ... | request-manager/grapher/spec.go | 0.72331 | 0.484685 | spec.go | starcoder |
package spatial
import (
"golina/matrix"
"math"
)
func PointToPointDistance(p1, p2 *matrix.Vector) float64 {
return p1.Sub(p2).Norm()
}
func PointToLineDistance(pt, linePt, lineDir *matrix.Vector) float64 {
return pt.Sub(linePt).Sub(lineDir.MulNum(lineDir.Dot(pt.Sub(linePt)))).Norm()
}
func PointToPlaneDistance... | spatial/distance.go | 0.643441 | 0.602237 | distance.go | starcoder |
package math
import (
"unsafe"
"math/rand"
"math"
"korok.io/korok/math/f32"
)
const MaxFloat32 float32 = 3.40282346638528859811704183484516925440e+38
const Pi = math.Pi
/// This is A approximate yet fast inverse square-root.
func InvSqrt(x float32) float32 {
xhalf := float32(0.5) * x
i := *(*int32)(unsafe.Poin... | math/f32.go | 0.835718 | 0.48054 | f32.go | starcoder |
package fractal
import (
"bytes"
"github.com/nfnt/resize"
"image"
"image/color"
"io"
"math"
)
const (
GAMMA = 0.75
DECODE_ITERATIONS = 16
)
type imagePanel struct {
x, y, mean int
pixels []uint16
}
type image8 struct {
xPanels, yPanels, panelSize int
bounds image.Rectangle
pix... | _vendor/src/github.com/pointlander/compress/fractal/fractal.go | 0.613584 | 0.465995 | fractal.go | starcoder |
package day09
import (
"errors"
"advent2021.com/util"
)
type FloorMap struct {
values []int
columnLength int
}
func ParseFloorMap(lines []string) (*FloorMap, error) {
columnLength := -1
size := 0
for _, line := range lines {
size += len(line)
if columnLength == -1 {
columnLength = len(line)
} ... | day09/day09.go | 0.554953 | 0.498291 | day09.go | starcoder |
package master
import (
"encoding/json"
"fmt"
"github.com/chubaofs/cfs/proto"
"github.com/chubaofs/cfs/util/log"
"github.com/juju/errors"
"runtime"
"sync"
"time"
)
// DataPartitionMap stores all the data partitionMap
type DataPartitionMap struct {
sync.RWMutex
partitionMap map[uint64]*DataPartiti... | master/data_partition_map.go | 0.544075 | 0.402803 | data_partition_map.go | starcoder |
package set
import "github.com/rickb777/golist/internal/collection"
const Set = collection.Collection + `
//-------------------------------------------------------------------------------------------------
// {{.TName}}Set is a typesafe set of {{.TName}} items. {{if .Has.Tag.Mutate}}
// The implementation is based o... | internal/set/set.go | 0.648578 | 0.541591 | set.go | starcoder |
package assert
import (
"fmt"
"reflect"
"testing"
)
func equal(expected, actual interface{}) bool {
if expected == nil || actual == nil {
return expected == actual
}
if reflect.DeepEqual(expected, actual) {
return true
}
actualType := reflect.TypeOf(actual)
if actualType == nil {
return false
}
exp... | internal/assert/assert.go | 0.718693 | 0.552117 | assert.go | starcoder |
package util
import (
"fmt"
"math"
"reflect"
"time"
)
// Define the Type enum
const (
// bool
TypeBooleanField = 1 << iota
// string
TypeStringField
// time.Time
TypeDateTimeField
// int8
TypeBitField
// int16
TypeSmallIntegerField
// int32
TypeInteger32Field
// int
TypeIntegerField
// int64
TypeB... | util/const.go | 0.582016 | 0.472623 | const.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.