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 main
import (
"fmt"
"math"
"os"
"sort"
)
var bricksNum int
func main() {
fmt.Scan(&bricksNum)
fmt.Printf("%d %d\n",
logMin(buildNormalizedCuboid()).a,
logMax(buildTallCuboid()).a,
)
}
// Maximum (experienced that by doing manual experiments with small number of bricks).
func buildTallCuboid() mat... | weekly/MaxSurfaceBox/main.go | 0.692434 | 0.530297 | main.go | starcoder |
package accounting
import (
"encoding/json"
)
// CreateInvoiceSubFeatures Lists the individual aspects of creating invoices that are enabled for the integration, as part of the create invoice flow in HubSpot.
type CreateInvoiceSubFeatures struct {
// Indicates if a new customer can be created in the external accou... | generated/accounting/model_create_invoice_sub_features.go | 0.764804 | 0.526769 | model_create_invoice_sub_features.go | starcoder |
package token
import (
"fmt"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
token2 "github.com/hyperledger-labs/fabric-token-sdk/token/token"
)
type QueryService interface {
IsMine(id *token2.ID) (bool, error)
}
// Output models the output of a token action
type Output struct {
ActionInde... | token/stream.go | 0.793546 | 0.401512 | stream.go | starcoder |
package graph
import (
"fmt"
"github.com/moorara/algo/list"
"github.com/moorara/algo/pkg/graphviz"
)
// DirectedEdge represents a weighted directed edge data type.
type DirectedEdge struct {
from, to int
weight float64
}
// From returns the vertex this edge points from.
func (e DirectedEdge) From() int {
re... | graph/weighted_directed.go | 0.839635 | 0.521898 | weighted_directed.go | starcoder |
package twittership
import (
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
"os"
)
type userImage struct {
height int
width int
tileHeight int
tileWidth int
img *image.RGBA
}
// GameImage stores the current information for the game image
type GameImage struct {
fullImage *image.R... | image.go | 0.640411 | 0.446676 | image.go | starcoder |
// Package aa provides common holiday definitions that are frequently used.
package aa
import (
"github.com/uchti/cal"
"time"
)
var (
// NewYear represents New Year's Day on 1-Jan
NewYear = &cal.Holiday{
Name: "New Year's Day",
Month: time.January,
Day: 1,
Func: cal.CalcDayOfMonth,
}
// Epiphany r... | aa/aa_holidays.go | 0.565179 | 0.528655 | aa_holidays.go | starcoder |
package main
import (
"fmt"
"os"
"text/tabwriter"
)
func main() {
tw := tabwriter.NewWriter(os.Stdout, 1, 4, 1, ' ', 0)
defer tw.Flush()
zero := NewPolynomial(0, 0)
p1 := NewPolynomial(4, 3)
p2 := NewPolynomial(3, 2)
p3 := NewPolynomial(1, 0)
p4 := NewPolynomial(2, 1)
p := p1.Add(p2).Add(p3).Add(p4)
q1 ... | math/chebysev-polynomial.go | 0.542863 | 0.478224 | chebysev-polynomial.go | starcoder |
package jsonpath
import (
"errors"
"fmt"
httputil "github.com/steinfletcher/apitest-jsonpath/http"
"github.com/steinfletcher/apitest-jsonpath/jsonpath"
"net/http"
"reflect"
regex "regexp"
)
// Contains is a convenience function to assert that a jsonpath expression extracts a value in an array
func Contains(exp... | vendor/github.com/steinfletcher/apitest-jsonpath/jsonpath.go | 0.682785 | 0.402157 | jsonpath.go | starcoder |
package vm
import (
"reflect"
"strings"
)
type theArrayVectorType struct{}
func (t *theArrayVectorType) String() string { return t.Name() }
func (t *theArrayVectorType) Type() ValueType { return TypeType }
func (t *theArrayVectorType) Unbox() interface{} { return reflect.TypeOf(t) }
func (lt *theArrayVecto... | pkg/vm/vector.go | 0.598312 | 0.492798 | vector.go | starcoder |
package aran
// simple binary serach tree to find the maximum lower range of incoming key
type node struct {
root *node
left *node
right *node
lowerRange uint32
idx []uint32
}
func (n *node) insert(lowerRange, idx uint32) {
if n.lowerRange == lowerRange {
n.idx = append(n.idx, idx)
... | tree.go | 0.614857 | 0.41941 | tree.go | starcoder |
package keras2go
import (
"math"
)
/**
* Linear activation function.
* y=x
*
* :param x: Array of input values. Gets overwritten by output.
*/
func K2c_linear(x []float64) {
}
/**
* Exponential activation function.
* y = exp(x)
*
* :param x: Array of input values. Gets overwritten by output.
*/
func K2c_expo... | activations.go | 0.777046 | 0.617138 | activations.go | starcoder |
package datadog
import (
"encoding/json"
)
// GetCreator returns the Creator field if non-nil, zero value otherwise.
func (a *Alert) GetCreator() int {
if a == nil || a.Creator == nil {
return 0
}
return *a.Creator
}
// GetOkCreator returns a tuple with the Creator field if it's non-nil, zero value otherwise
/... | vendor/github.com/zorkian/go-datadog-api/datadog-accessors.go | 0.789031 | 0.434761 | datadog-accessors.go | starcoder |
package flac
import (
"bytes"
)
// BlockType representation of types of FLAC Metadata Block
type BlockType int
// BlockData data in a FLAC Metadata Block. Custom Metadata decoders and modifiers should accept/modify whole MetaDataBlock instead.
type BlockData []byte
const (
// StreamInfo METADATA_BLOCK_STREAMINFO
... | metablock.go | 0.572723 | 0.438004 | metablock.go | starcoder |
package features2d
import (
"runtime"
. "github.com/gooid/gocv/opencv3/core"
. "github.com/gooid/gocv/opencv3/internal/native"
)
const gRIDDETECTORFeatureDetector = 1000
const pYRAMIDDETECTORFeatureDetector = 2000
const dYNAMICDETECTORFeatureDetector = 3000
const FeatureDetectorFAST = 1
const FeatureDetectorSTAR ... | opencv3/features2d/FeatureDetector.java.go | 0.528047 | 0.479016 | FeatureDetector.java.go | starcoder |
package measurement
import (
"fmt"
"sync"
"sync/atomic"
"time"
)
type Measurement struct {
warmUp int32 // use as bool, 1 means in warmup progress, 0 means warmup finished.
sync.RWMutex
OpCurMeasurement map[string]*Histogram
OpSumMeasurement map[string]*Histogram
}
func (m *Measurement) getHist(op string, e... | pkg/measurement/measure.go | 0.638385 | 0.510619 | measure.go | starcoder |
package main
import (
"errors"
"fmt"
)
// Functions main purpose is to break a large program into a number of smaller
// tasks (functions). It also helps enforce the D-R-Y (dont repeat yourself)
// principle, the same task can be invoked several times, so a function promotes code reuse.
// There are 3 types of fun... | 11.function/1.function.go | 0.616474 | 0.608856 | 1.function.go | starcoder |
package day12
import (
"math"
"strconv"
)
// Waypoint creates a waypoint
type Waypoint struct {
Movements map[Direction]int
}
// NewWaypoint creates a new way point
func NewWaypoint() *Waypoint {
return &Waypoint{
Movements: map[Direction]int{
North: 1,
East: 10,
},
}
}
// Move moves the waypoint a ... | day12/day12.go | 0.766337 | 0.491456 | day12.go | starcoder |
package scheme
import (
"errors"
"fmt"
"math"
"strconv"
"github.com/iomz/go-llrp/binutil"
)
// PartitionTableKey is used for PartitionTables
type PartitionTableKey int
// PartitionTable is used to get the related values for each coding scheme
type PartitionTable map[int]map[PartitionTableKey]int
// Key values... | scheme/epc.go | 0.668339 | 0.46393 | epc.go | starcoder |
package schema
// ExtensionSchemaJSON is the content of the file "extension.schema.json".
const ExtensionSchemaJSON = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://sourcegraph.com/v1/extension.schema.json#",
"title": "Sourcegraph extension manifest",
"description": "The Sourcegraph ... | schema/extension_stringdata.go | 0.826852 | 0.517876 | extension_stringdata.go | starcoder |
package block
import "errors"
// Service facilitates the creation and management of stored data.
type Service struct {
BlockStore Store
ChainStore ChainStore
}
// NewBlock creates a new block for the provided chain and
// guarantees it as a valid next block on the chain.
func (s *Service) NewBlock(c *Chain, data [... | internal/xzor/block/service.go | 0.657758 | 0.424591 | service.go | starcoder |
package scw
import (
"net"
"time"
)
// StringPtr returns a pointer to the string value passed in.
func StringPtr(v string) *string {
return &v
}
// StringSlicePtr converts a slice of string values into a slice of
// string pointers
func StringSlicePtr(src []string) []*string {
dst := make([]*string, len(src))
f... | scw/convert.go | 0.690559 | 0.418578 | convert.go | starcoder |
package detector
import (
"fmt"
"strings"
"talisman/git_repo"
)
//DetectionResults represents all interesting information collected during a detection run.
//It serves as a collecting parameter for the tests performed by the various Detectors in the DetectorChain
//Currently, it keeps track of failures and ignore... | detector/detection_results.go | 0.735262 | 0.494934 | detection_results.go | starcoder |
package parsetime
import (
"strings"
)
const (
year = `(2[0-9]{3}|19[7-9][0-9])`
month = `(1[012]|0?[1-9])`
day = `([12][0-9]|3[01]|0?[1-9])`
hour = `(2[0-3]|[01]?[0-9])`
min = `([0-5]?[0-9])`
sec = min
nsec = `(?:[.])?([0-9]{1,9})?`
weekday = `(... | const.go | 0.510496 | 0.402921 | const.go | starcoder |
package goh
// IncludeStrings replace a value with new value
// and returns a new slice without modifying original.
func Replace(values []int, old, newValue int) []int {
result := make([]int, len(values))
for i, v := range values {
if v == old {
result[i] = newValue
continue
}
result[i] = v
}
return r... | goh.go | 0.859103 | 0.499573 | goh.go | starcoder |
// Package gpucuj tests GPU CUJ tests on lacros Chrome and Chrome OS Chrome.
package gpucuj
import (
"context"
"math"
"time"
"chromiumos/tast/common/perf"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/ash"
"chromiumos/tast/local/chrome/cdputil"
"chromiumos/tast/local/... | src/chromiumos/tast/local/bundles/cros/lacros/gpucuj/gpu_cuj.go | 0.665193 | 0.438364 | gpu_cuj.go | starcoder |
package parsed
// Uninomial are details for names with cardinality 1.
type Uninomial struct {
// Value is the uninomial name.
Value string `json:"uninomial"`
// Rank of the uninomial in a combination name, for example
// "Pereskia subg. <NAME> ex F.A.C.Weber, 1898"
Rank string `json:"rank,omitempty"`
// Cultivar... | ent/parsed/details.go | 0.819677 | 0.448487 | details.go | starcoder |
package repeatgenome
import (
"unsafe"
)
/*
Converts a TextSeq to the more memory-efficient Seq type. Upper- and
lower-case base bytes are currently supported, but stable code should
immediately convert to lower-case. The logic works and is sane, but could be
altered in the future for brevity and efficie... | repeatgenome/seq-rg.go | 0.672117 | 0.449695 | seq-rg.go | starcoder |
package imagediff
import (
"errors"
"image"
"image/color"
)
// SmartImageComparer uses perceptual color difference metrics to determine if pixels look the same.
// See http://www.progmat.uaem.mx:8080/artVol2Num2/Articulo3Vol2Num2.pdf
type SmartImageComparer struct {
ignoreColor *color.NRGBA
useignoreColor boo... | imagediff/SmartImageComparer.go | 0.877405 | 0.61341 | SmartImageComparer.go | starcoder |
package easycel
import (
"fmt"
"reflect"
"github.com/google/cel-go/checker/decls"
"github.com/google/cel-go/common/types"
"github.com/google/cel-go/common/types/ref"
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
)
type adapter struct {
adapter ref.TypeAdapter
}
func newAdapter(a ref.TypeAd... | adapter.go | 0.547706 | 0.453685 | adapter.go | starcoder |
package main
import (
"fmt"
)
func main() {
/*
Decisions and Loops are some of the most basic bread and butter of not
only a Go program, but programs in general. Without decisions and loops,
programs would not be of much computational use (see Turing machines
and their impact -... | decisions-loops/dl.go | 0.635562 | 0.545165 | dl.go | starcoder |
package ipmigo
// Event/Reading Type (Table 42-2)
type EventType uint8
func (e EventType) IsUnspecified() bool { return e == 0x00 }
func (e EventType) IsThreshold() bool { return e == 0x01 }
func (e EventType) IsGeneric() bool { return e >= 0x02 && e <= 0x0c }
func (e EventType) IsSensorSpecific() bool... | event.go | 0.541409 | 0.60013 | event.go | starcoder |
package sm9curve
import "math/big"
// For details of the algorithms used, see "Multiplication and Squaring on
// Pairing-Friendly Fields, Devegili et al.
// http://eprint.iacr.org/2006/471.pdf.
// gfP2 implements a field of size p² as a quadratic extension of the base field
// where i²=-2.
type gfP2 struct {
x, y g... | elliptic/sm9curve/gfp2.go | 0.788583 | 0.415907 | gfp2.go | starcoder |
// Mapping from PC to SP offset (called CFA - Canonical Frame Address - in DWARF).
// This value is the offset from the stack pointer to the virtual frame pointer
// (address of zeroth argument) at each PC value in the program.
package dwarf
import "fmt"
// http://www.dwarfstd.org/doc/DWARF4.pdf Section 6.4 page 12... | vendor/cloud.google.com/go/cmd/go-cloud-debug-agent/internal/debug/dwarf/frame.go | 0.564219 | 0.517632 | frame.go | starcoder |
package math
import (
"fmt"
"math"
)
// Vec4 represents a four component vector.
type Vec4 struct {
X, Y, Z, W float64
}
// String returns an string representation of this vector.
func (a Vec4) String() string {
return fmt.Sprintf("Vec4(X=%f, Y=%f, Z=%f, W=%f)", a.X, a.Y, a.Z, a.W)
}
// AlmostEquals tells if a... | math/vec4.go | 0.927058 | 0.729712 | vec4.go | starcoder |
package beehive
import "fmt"
// CellKey represents a key in a dictionary.
type CellKey struct {
Dict string
Key string
}
// AppCellKey represents a key in a dictionary of a specific app.
type AppCellKey struct {
App string
Dict string
Key string
}
// Cell returns the CellKey of this AppCellKey.
func (ack Ap... | cell.go | 0.709623 | 0.458288 | cell.go | starcoder |
package jet
// TimestampzExpression interface
type TimestampzExpression interface {
Expression
EQ(rhs TimestampzExpression) BoolExpression
NOT_EQ(rhs TimestampzExpression) BoolExpression
IS_DISTINCT_FROM(rhs TimestampzExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs TimestampzExpression) BoolExpression
LT(r... | internal/jet/timestampz_expression.go | 0.810479 | 0.495545 | timestampz_expression.go | starcoder |
package game
import "github.com/anilmisirlioglu/Tic-Tac-Toe-AI/math"
type Controller struct {
game *Game
scores map[int]int
}
type MinimaxPacket struct {
Vector2 math.Vector2
Score int
}
const (
MaxInt = int(^uint(0) >> 1)
MinInt = -MaxInt - 1
)
func (c Controller) Minimax(matrix math.Matrix, depth int, ... | game/controller.go | 0.57821 | 0.524577 | controller.go | starcoder |
package graphql
import (
gql "github.com/graphql-go/graphql"
)
var settingsType = gql.NewObject(gql.ObjectConfig{
Name: "settings",
Description: "Settings represents the current deloominator",
Fields: gql.Fields{
"isReadOnly": &gql.Field{
Description: "Readonly server value",
Type: gql.Boole... | pkg/api/graphql/types.go | 0.523908 | 0.471953 | types.go | starcoder |
package slice
// CopyBool creates a copy of a bool slice.
// The resulting slice has the same elements as the original but the underlying array is different.
// See https://github.com/go101/go101/wiki
func CopyBool(a []bool) []bool {
return append(a[:0:0], a...)
}
// CopyByte creates a copy of a byte slice.
// The r... | copy.go | 0.894081 | 0.821152 | copy.go | starcoder |
package matrix
import (
"fmt"
"log"
"math"
"math/rand"
)
//Vector type
type Vector struct {
row []float64
}
//NewVector returns a vector type
func NewVector(slice []float64) Vector {
return Vector{row: slice}
}
// PrintVector prints the vector components
func PrintVector(vec Vector) {
fm... | vector.go | 0.805861 | 0.567877 | vector.go | starcoder |
package event
import (
"context"
"reflect"
"github.com/google/gapid/core/fault"
"github.com/google/gapid/core/log"
)
var (
contextType = reflect.TypeOf((*context.Context)(nil)).Elem()
errorType = reflect.TypeOf((*error)(nil)).Elem()
boolType = reflect.TypeOf(true)
)
// checkSignature is an internal fun... | core/event/function.go | 0.509032 | 0.40028 | function.go | starcoder |
// This file contains an implementation of IndexColumn which is
// a storage for n-ngram tree nodes with the same depth (= position
// within an n-gram)
package column
// MetadataWriter is used for writing metadata attributes
// during indexing. It collects individual metadata
// columns into a single object providi... | index/column/metadata.go | 0.53777 | 0.41401 | metadata.go | starcoder |
package drw
import (
"github.com/jakubDoka/mlok/ggl"
"github.com/jakubDoka/mlok/mat"
)
type LineProcessor struct {
Points []mat.Vec
Indices ggl.Indices
}
func (l *LineProcessor) Process(g *Geom, ld LineDrawer, points ...mat.Vec) {
if ld == nil {
ld = Default
}
ld.Init(g.thickness)
l.Indices.Clear()
l.P... | ggl/drw/lines.go | 0.530236 | 0.417628 | lines.go | starcoder |
package day14
import (
"fmt"
)
// KnotHash is adapted from the day 10 challenge and returns a hash of the
// given input.
func KnotHash(input []byte) []byte {
input = append(input, 17, 31, 73, 47, 23)
A := make([]byte, 256)
for i := 0; i < len(A); i++ {
A[i] = byte(i)
}
var pos, skip, a, b int
for r := 0; r ... | go/2017/day14/day14.go | 0.717903 | 0.403244 | day14.go | starcoder |
package svg
func opDataToSVG(op *Op, sf *svgFlow, x0, y0, y1 int,
) (nsf *svgFlow, lsr *svgRect, ny0 int, xn, yn int) {
var y int
opW := maxTextWidth(op.Main) + 2*12 // text + padding
opH := y1 - y0
for _, f := range op.Plugins {
w := maxPluginWidth(f)
opW = max(opW, w)
}
if sf.completedMerge != nil {
x0... | svg/op.go | 0.549399 | 0.540863 | op.go | starcoder |
package day6
import (
"ryepup/advent2021/utils"
)
/*
The sea floor is getting steeper. Maybe the sleigh keys got carried this way?
A massive school of glowing lanternfish swims past. They must spawn quickly to
reach such large numbers - maybe exponentially quickly? You should model their
growth rate to be sure.
Al... | day6/part1.go | 0.596316 | 0.53959 | part1.go | starcoder |
package godate
import (
"math"
"strconv"
"strings"
"time"
)
type goDate struct {
Time time.Time
TimeZone *time.Location
FirstDayOfWeek time.Weekday
}
//IsBefore checks if the goDate is before the passed goDate
func (d *goDate) IsBefore(compare *goDate) bool {
return d.Time.Before(compare.Time)
}
//IsAft... | godate.go | 0.809615 | 0.626181 | godate.go | starcoder |
package moreland
import (
"image/color"
"math"
)
// rgb represents a physically linear RGB color.
type rgb struct {
R, G, B float64
}
// cieXYZ returns a CIE XYZ color representation of the receiver.
func (c rgb) cieXYZ() cieXYZ {
return cieXYZ{
X: 0.4124*c.R + 0.3576*c.G + 0.1805*c.B,
Y: 0.2126*c.R + 0.715... | palette/moreland/convert.go | 0.865082 | 0.481027 | convert.go | starcoder |
package slicemultimap
import multimap "github.com/jwangsadinata/go-multimap"
// MultiMap holds the elements in go's native map.
type MultiMap struct {
m map[interface{}][]interface{}
}
// New instantiates a new multimap.
func New() *MultiMap {
return &MultiMap{m: make(map[interface{}][]interface{})}
}
// Get sear... | vendor/github.com/jwangsadinata/go-multimap/slicemultimap/slicemultimap.go | 0.818954 | 0.445288 | slicemultimap.go | starcoder |
package tfimage
// Modified from github.com/fogleman/gg
// Oct 28, 2019
// <NAME> and Contributors
// LICENSE: MIT
import (
"math"
"golang.org/x/image/math/f64"
)
// Matrix -
type Matrix struct {
XX, YX, XY, YY, X0, Y0 float64
}
// NewMatrix - Create a new Matrix
func NewMatrix() Matrix {
return Matrix{
1, 0... | matrix.go | 0.820829 | 0.680695 | matrix.go | starcoder |
package parser
import (
"fmt"
"go/ast"
"strconv"
"github.com/switchupcb/copygen/cli/models"
)
type parsedTypes struct {
fromTypes []models.Type
toTypes []models.Type
}
// parseTypes parses an ast.Field (of type func) for to-types and from-types.
func (p *Parser) parseTypes(function *ast.Field, options []Opt... | cli/parser/type.go | 0.585575 | 0.422386 | type.go | starcoder |
package kafka
import "go.k6.io/k6/stats"
var (
ReaderDials = stats.New("kafka.reader.dial.count", stats.Counter)
ReaderFetches = stats.New("kafka.reader.fetches.count", stats.Counter)
ReaderMessages = stats.New("kafka.reader.message.count", stats.Counter)
ReaderBytes = stats.New("kafka.reader.messa... | stats.go | 0.52074 | 0.517266 | stats.go | starcoder |
package forecast
import "math"
type weighted struct {
value float64
weight float64
rate float64
}
func (w *weighted) get() float64 {
return w.value
}
func (w *weighted) observe(y float64) {
if math.IsNaN(y) {
w.skip()
return
}
if w.weight == 0 || math.IsNaN(w.value) || math.IsInf(w.value, 0) { // Spec... | function/builtin/forecast/rolling.go | 0.831006 | 0.551332 | rolling.go | starcoder |
package nzproj
import (
"math"
)
/*
The Lambert Conformal Conic projection is a projection in which geographic meridians are
represented by straight lines which meet at the projection of the pole and geographic parallels
are represented by a series of arcs of circles with this point as their centre.
*/
// Lamber... | lambert_conformal_conic.go | 0.797951 | 0.669934 | lambert_conformal_conic.go | starcoder |
package fields
import "reflect"
// DefaultValueEquality is the default instance of a ValueEquality. The initial
// initialization of this global variable should be able to deal with
// the majority of the cases.
var DefaultValueEquality ValueEquality = ValueEqualityFunc(func(key string, leftValue, rightValue interfac... | fields/equality_value.go | 0.811228 | 0.531939 | equality_value.go | starcoder |
package trietree
import (
"errors"
"github.com/howz97/algorithm/alphabet"
"github.com/howz97/algorithm/queue"
)
// Three direction trie tree
type TSTNode struct {
r rune
v T
left, mid, right *TSTNode
}
func newTSTNode(r rune) *TSTNode {
return &TSTNode{r: r}
}
func (t *TSTNode) ... | trie_tree/tst_node.go | 0.52829 | 0.431584 | tst_node.go | starcoder |
package sssa
import (
"bytes"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"fmt"
"math"
"math/big"
"strings"
)
var prime *big.Int
/**
* Returns a random number from the range (0, prime-1) inclusive
**/
func random() *big.Int {
result := big.NewInt(0).Set(prime)
result = result.Sub(result, big.NewInt(1))... | pkg/sssa/utils.go | 0.76454 | 0.417687 | utils.go | starcoder |
package ijson
// Del deletes element form the the data pointed by the path.
// An error is returned if it fails to resolve the path.
func Del(data interface{}, path ...string) (interface{}, error) {
if len(path) == 0 || data == nil {
return data, nil
}
pathType := DetectDelPath(path[0])
switch pathType {
case ... | del.go | 0.622459 | 0.463019 | del.go | starcoder |
// Package xor implements a nearest-neighbor data structure for the XOR-metric
package xor
import (
"errors"
"fmt"
"strconv"
"unsafe"
)
// Key represents a point in the XOR-space
type Key uint64
// Key implements interface Item
func (id Key) Key() Key {
return id
}
// Bit returns the k-th bit from metric poin... | kit/xor/xor.go | 0.855957 | 0.436622 | xor.go | starcoder |
package main
import (
"fmt"
"regexp"
"strconv"
"github.com/theatlasroom/advent-of-code/go/utils"
)
/**
--- Day 2: Password Philosophy ---
Your flight departs in a few days from the coastal airport; the easiest way down to the coast from here is via toboggan.
The shopkeeper at the North Pole Toboggan Rental Sho... | go/2020/2.go | 0.650023 | 0.52756 | 2.go | starcoder |
package main
import (
"strings"
"github.com/cucumber/gherkin-go"
"github.com/willf/pad/utf8"
)
type renderer struct {
*strings.Builder
}
func newRenderer() renderer {
return renderer{&strings.Builder{}}
}
func (r renderer) Render(d *gherkin.GherkinDocument) string {
r.renderFeature(d.Feature)
return r.Buil... | renderer.go | 0.535584 | 0.433622 | renderer.go | starcoder |
package DG2D
import (
"fmt"
"math"
"strings"
"github.com/notargets/gocfd/types"
"github.com/notargets/gocfd/readfiles"
graphics2D "github.com/notargets/avs/geometry"
"github.com/notargets/gocfd/geometry2D"
"github.com/notargets/gocfd/utils"
)
type DFR2D struct {
N int
SolutionElement ... | DG2D/dfr_startup.go | 0.678753 | 0.664363 | dfr_startup.go | starcoder |
package agozon
var LocaleESMap = map[string]LocaleSearchIndex{
"All": LocaleES.All, "Apparel": LocaleES.Apparel, "Automotive": LocaleES.Automotive, "Baby": LocaleES.Baby, "Books": LocaleES.Books,
"DVD": LocaleES.DVD, "Electronics": LocaleES.Electronics, "ForeignBooks": LocaleES.ForeignBooks, "GiftCards": LocaleES.Gi... | LocaleES.go | 0.572484 | 0.426023 | LocaleES.go | starcoder |
package graphs
import (
"github.com/howz97/algorithm/util"
)
func NewGraph(size uint) *Graph {
return &Graph{
Digraph: NewDigraph(size),
}
}
// Graph has no direction
type Graph struct {
*Digraph
}
// NumEdge get the number of no-direction edges
func (g *Graph) NumEdge() uint {
return g.Digraph.NumEdge() / 2... | graphs/graph.go | 0.721743 | 0.441673 | graph.go | starcoder |
package main
import ("fmt"; "math"; "os"; "strconv")
type segment struct {
x float64
y float64
}
func no_struct_distance(x1, x2, y1, y2 float64) float64 {
delta_x := x2 - x1
delta_y := y2 - y1
return math.Sqrt(math.Pow(delta_x, 2) + math.Pow(delta_y, 2))
}
func struct_distance(segment_1, segmen... | Tutorial/Chapter8/structs.go | 0.802826 | 0.622832 | structs.go | starcoder |
package main
import (
"bufio"
"errors"
"fmt"
"io"
"log"
"math"
"os"
"sort"
)
// Asteroid is a celestial body in the asteroid belt.
type Asteroid struct {
x, y int
}
// LineOfSight represent the direction or angle from one Asteroid to another.
// The zero value represent the direction from an Asteroid to its... | day10/main.go | 0.703753 | 0.496887 | main.go | starcoder |
package leetcode
func knightProbability(n int, k int, row int, column int) float64 {
dp := make([]map[[2]int]float64, k+1)
for i := range dp {
dp[i] = make(map[[2]int]float64)
}
return dynamicProgramming(dp, n, k, row, column)
}
func dynamicProgramming(dp []map[[2]int]float64, n, k, r, c int) float64 {
if !val... | leetcode/688.knight-probability-in-chessboard/knight_probability.go | 0.700895 | 0.464112 | knight_probability.go | starcoder |
package ui
import (
"github.com/Yeicor/sdfx-ui/internal"
"github.com/deadsy/sdfx/sdf"
"image"
"image/color"
"image/color/palette"
"math"
)
//-----------------------------------------------------------------------------
// CONFIGURATION
//--------------------------------------------------------------------------... | impl2.go | 0.623721 | 0.447219 | impl2.go | starcoder |
package salience
import (
"image"
"image/color"
"image/draw"
"math"
)
type Section struct {
x, y int
e float64
}
// Crop crops an image to its most interesting area with the specified extents
func Crop(img image.Image, cropWidth, cropHeight int) image.Image {
r := img.Bounds()
imageWidth := r.Max.X - r.Mi... | vendor/github.com/iand/salience/salience.go | 0.733356 | 0.526647 | salience.go | starcoder |
package zgeo
import (
"math"
"github.com/torlangballe/zutil/zmath"
)
// Created by <NAME> on /21/10/15.
type PathLineType int
type PathPartType int
const (
PathLineSquare PathLineType = iota
PathLineRound
PathLineButt
)
const (
PathMove PathPartType = iota
PathLine
PathQuadCurve
PathCurve
PathClose
)
... | zgeo/path.go | 0.576304 | 0.540196 | path.go | starcoder |
package config
import "fmt"
type array struct {
storage map[string][]interface{}
}
func (a *array) String() string {
return fmt.Sprintf("%v", a.storage)
}
func (a *array) Add(name string, value ...interface{}) {
_, ok := a.storage[name]
if !ok {
a.storage[name] = make([]interface{}, 0)
}
a.storage[name] = a... | internal/config/array.go | 0.538741 | 0.415254 | array.go | starcoder |
package vfilter
import (
"image"
"sync"
"github.com/emer/etable/etensor"
"github.com/emer/vision/nproc"
)
// ConvDiff computes difference of two separate filter convolutions
// (fltOn - fltOff) over two images into out. There are separate gain
// multipliers for On and overall gain.
// images *must* have borde... | vfilter/convdiff.go | 0.562417 | 0.461927 | convdiff.go | starcoder |
package mosaic
import (
"errors"
"fmt"
"github.com/disintegration/imaging"
"github.com/fogleman/gg"
"github.com/gieseladev/mosaic/pkg/geom"
"image"
"math"
"sync"
)
var (
// ErrInvalidImageCount is the error returned, when an invalid amount of
// images is passed to a composer.
ErrInvalidImageCount = errors... | composers.go | 0.68437 | 0.416144 | composers.go | starcoder |
package bitslice
import (
"strconv"
)
// BitSlice is a bit array
type BitSlice struct {
// buf is the underlying byte slice storing the bits
buf []byte
// len is the number of bits stored in buf
len int64
}
// New creates a BitSlice with l zeroed bits with the capacity to store c bits,
// rounded up to the near... | bitslice.go | 0.737914 | 0.563558 | bitslice.go | starcoder |
package msgpack
import (
"encoding/binary"
"fmt"
"io"
"math"
"reflect"
"time"
xbytes "go.nanasi880.dev/x/bytes"
xunsafe "go.nanasi880.dev/x/unsafe"
)
// Unmarshaler is the interface implemented by types that
// can unmarshal themselves into valid message pack.
type Unmarshaler interface {
UnmarshalMsgPack(d... | encoding/msgpack/decoder.go | 0.711732 | 0.433322 | decoder.go | starcoder |
package unique
import "sort"
// Types that implement unique.Interface can have duplicate elements removed by
// the functionality in this package.
type Interface interface {
sort.Interface
// Truncate reduces the length to the first n elements.
Truncate(n int)
}
// Unique removes duplicate elements from data. It... | vendor/github.com/mpvl/unique/unique.go | 0.739799 | 0.558809 | unique.go | starcoder |
package square
// Defines how discounts are automatically applied to a set of items that match the pricing rule during the active time period.
type CatalogPricingRule struct {
// User-defined name for the pricing rule. For example, \"Buy one get one free\" or \"10% off\".
Name string `json:"name,omitempty"`
// A li... | square/model_catalog_pricing_rule.go | 0.753376 | 0.519095 | model_catalog_pricing_rule.go | starcoder |
package resmgr
import (
"fmt"
"path"
"path/filepath"
"strings"
logger "github.com/intel/cri-resource-manager/pkg/log"
)
// Evaluable is the interface objects need to implement to be evaluable against Expressions.
type Evaluable interface {
Eval(string) interface{}
}
// Expression is used to describe a criter... | pkg/apis/resmgr/expression.go | 0.68679 | 0.438545 | expression.go | starcoder |
package retina
import (
"fmt"
"github.com/pkg/errors"
"github.com/yaricom/goESHyperNEAT/eshyperneat"
"strings"
)
// DetectionSide the side of retina where VisualObject is valid to be detected
type DetectionSide string
const (
RightSide = DetectionSide("right")
LeftSide = DetectionSide("left")
BothSide = Det... | experiments/retina/environment.go | 0.715921 | 0.495484 | environment.go | starcoder |
package vm
func DivFunc(left, right func(Context) (Value, error)) func(Context) (Value, error) {
return func(ctx Context) (Value, error) {
leftValue, err := left(ctx)
if err != nil {
return Null(), err
}
rightValue, err := right(ctx)
if err != nil {
return Null(), err
}
return Div(leftValue, righ... | vm/div.go | 0.620047 | 0.649301 | div.go | starcoder |
package audio
import "math"
// IntMaxSignedValue returns the max value of an integer
// based on its memory size
func IntMaxSignedValue(b int) int {
switch b {
case 8:
return 255 / 2
case 16:
return 65535 / 2
case 24:
return 16777215 / 2
case 32:
return 4294967295 / 2
default:
return 0
}
}
// IEEEFl... | vendor/github.com/go-audio/audio/conv.go | 0.682468 | 0.448306 | conv.go | starcoder |
package financial
// Sma (simple moving average (SMA)) calculates the average of a selected range of prices,
//usually closing prices, by the number of periods in that range.
type Sma struct {
MovingAverage
}
// Calculate SMA. Formula for SMA https://www.investopedia.com/terms/s/sma.asp
// There are 3 cases:
// - Wh... | business/strategies/financial/sma.go | 0.670608 | 0.697995 | sma.go | starcoder |
package logic
import (
"context"
"fmt"
"log"
"net/http"
"time"
"cloud.google.com/go/firestore"
"google.golang.org/api/iterator"
"google.golang.org/genproto/googleapis/type/latlng"
"github.com/tidwall/geojson"
"github.com/tidwall/geojson/geometry"
)
// the GPS has some jitter. In general, lets discount rea... | cloud-processing/process-gps-points/logic/processCoords.go | 0.628407 | 0.419172 | processCoords.go | starcoder |
package muxgo
import (
"encoding/json"
)
// AssetNonStandardInputReasons An object containing one or more reasons the input file is non-standard. See [the guide on minimizing processing time](https://docs.mux.com/guides/video/minimize-processing-time) for more information on what a standard input is defined as. Thi... | model_asset_non_standard_input_reasons.go | 0.852429 | 0.529081 | model_asset_non_standard_input_reasons.go | starcoder |
package rectangle
import (
"github.com/gravestench/pho/geom/point"
)
type RectangleNamespace interface {
Contains(r *Rectangle, x, y float64) bool
GetPoint(r *Rectangle, position float64, p *point.Point) *point.Point
GetPoints(r *Rectangle, quantity int, stepRate float64, points []*point.Point) []*point.Point
Ge... | geom/rectangle/namespace.go | 0.962594 | 0.764628 | namespace.go | starcoder |
package api
import (
"encoding/json"
)
// MeasurementSchemaList A list of measurement schemas returning summary information
type MeasurementSchemaList struct {
MeasurementSchemas []MeasurementSchema `json:"measurementSchemas" yaml:"measurementSchemas"`
}
// NewMeasurementSchemaList instantiates a new MeasurementS... | api/model_measurement_schema_list.gen.go | 0.773131 | 0.407569 | model_measurement_schema_list.gen.go | starcoder |
package main
import (
"sync"
)
// JumpingLargestFreeAIJumpAtLessThanFree is the number of free cells connected at which the AI tries to jump.
const JumpingLargestFreeAIJumpAtLessThanFree = 50
// JumpingLargestFreeAI behaves like LargestFreeAI but tries to jump out of small areas.
type JumpingLargestFreeAI struct {... | ai_jumpinglargestfree.go | 0.591251 | 0.463809 | ai_jumpinglargestfree.go | starcoder |
package main
import (
"math"
"github.com/fmi/go-homework/geom"
)
// Triangle is an Intersectable which represents a triangle in the 3D space.
type Triangle struct {
a, b, c vector
}
// Intersect implements the geom.Intersecatble interface. It uses the
// Möller–Trumbore ray-triangle intersection algorithm from 1... | tasks/03/solution.go | 0.882314 | 0.562837 | solution.go | starcoder |
package interval
import (
g "github.com/zyedidia/generic"
"github.com/zyedidia/generic/iter"
)
type KV[V any] struct {
Low, High int
Val V
}
// intrvl represents an interval over [low, high).
type intrvl struct {
Low, High int
}
func overlaps(i1 intrvl, low, high int) bool {
return i1.Low < high && i1.H... | interval/itree.go | 0.849207 | 0.586878 | itree.go | starcoder |
package types
import (
"fmt"
"strconv"
"time"
)
// TimeframeUnit represents the unit for a timeframe
type TimeframeUnit string
const (
// TuSec second unit
TuSec = TimeframeUnit("s")
// TuMin minute unit
TuMin = TimeframeUnit("m")
// TuHour hour unit
TuHour = TimeframeUnit("h")
// TuDay day unit
TuDay ... | types/timeframe.go | 0.713432 | 0.452778 | timeframe.go | starcoder |
package display
import (
"fmt"
"github.com/go-gl/mathgl/mgl32"
"github.com/ob-algdatii-20ss/leistungsnachweis-teammaze/common"
)
func defaultCubeColor() mgl32.Vec4 {
return mgl32.Vec4{0, 0.75, 0.75, 1}
}
func pathCubeColor() mgl32.Vec4 {
return mgl32.Vec4{1, 0, 0, 1}
}
type LabyrinthVisualizer struct {
mapVi... | display/labyrinthVisualizer.go | 0.676406 | 0.557364 | labyrinthVisualizer.go | starcoder |
package statictimeseries
import (
"fmt"
"sort"
"strconv"
"strings"
"time"
"github.com/grokify/gocharts/data/table"
"github.com/grokify/gotilla/sort/sortutil"
"github.com/grokify/gotilla/time/timeutil"
tu "github.com/grokify/gotilla/time/timeutil"
"github.com/grokify/gotilla/type/stringsutil"
)
type DataSer... | data/statictimeseries/data_series_set.go | 0.562898 | 0.444384 | data_series_set.go | starcoder |
package image
import (
"image"
"image/draw"
)
type Drawer interface {
Draw(r image.Rectangle, src image.Image, sp image.Point)
}
type Writer struct {
Drawer Drawer
Point image.Point
}
func (w *Writer) SkipX(x int) {
w.Point.X += x
}
func (w *Writer) WriteImages(img []image.Image) {
for _, v := range img {
... | pkg/image/writer.go | 0.771843 | 0.49707 | writer.go | starcoder |
package slicefn
import (
"github.com/wearemojo/mojo-public-go/lib/merr"
)
const ErrNotFound = merr.Code("not_found")
func Map[T1, T2 any](slice []T1, fn func(T1) T2) []T2 {
res := make([]T2, len(slice))
for i, v := range slice {
res[i] = fn(v)
}
return res
}
func MapE[T1, T2 any](slice []T1, fn func(T1) (T... | lib/slicefn/slicefn.go | 0.632616 | 0.472197 | slicefn.go | starcoder |
package data
import (
"math"
"github.com/calummccain/coxeter/vector"
)
const (
eVal33n = 5.1042993121 //math.Pi / math.Atan(Rt_2)
pVal33n = 6.0
eVal33nTrunc = 5.1042993121 //math.Pi / math.Atan(Rt_2)
pVal33nTrunc = 10.727915991 //math.Pi / math.Atan(Rt_11)
eVal33nRect = 5.1042993121 //math.Pi / math.Atan(Rt... | data/33n.go | 0.587115 | 0.551695 | 33n.go | starcoder |
package vo2percolation
type PointSet struct {
// The PointSet needs to be able to represent a Point as an int.
convertFrom1D func(int) Point
convertTo1D func(Point) int
// data's keys are 1D coordinates covering the grid. When the value
// associated with a key is true, that key is part of the point set.
data... | point_set.go | 0.782247 | 0.649481 | point_set.go | starcoder |
package tetra3d
import (
"image/color"
"math"
)
// Color represents a color, containing R, G, B, and A components, each expected to range from 0 to 1.
type Color struct {
R, G, B, A float32
}
// NewColor returns a new Color, with the provided R, G, B, and A components expected to range from 0 to 1.
func NewColor(... | color.go | 0.916652 | 0.75069 | color.go | starcoder |
package Openapi
import (
"encoding/json"
)
// CartItem A cart item that represents a single cart line item for a transaction. Note that some optional properties are required for certain payment service providers. If no value is set for these properties, we will use their default value. If the total due to be paid ... | api/model_cart_item.go | 0.907284 | 0.516656 | model_cart_item.go | starcoder |
package main
import (
"fmt"
"log"
"github.com/razziel89/astar"
)
// tag::solution[]
const (
numNeigh = 4
replicas = 5
)
func gridToNodes(grid Grid) (map[*astar.Node]struct{}, *astar.Node, *astar.Node, error) {
result := map[*astar.Node]struct{}{}
var start, end *astar.Node
// Remember which node belonged t... | day15/go/razziel89/solution.go | 0.582491 | 0.518485 | solution.go | starcoder |
package aoc2021
import (
"strings"
)
// contains 4 digits
type Display struct {
Digits []*Digit
}
type Helper struct {
Zero *Pattern
One *Pattern
Two *Pattern
Three *Pattern
Four *Pattern
Five *Pattern
Six *Pattern
Seven *Pattern
Eight *Pattern
Nine *Pattern
}
func NewHelper(data string) *Help... | app/aoc2021/aoc2021_08_objects.go | 0.628635 | 0.495484 | aoc2021_08_objects.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.