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 azure
import (
"fmt"
"strings"
"github.com/infracost/infracost/internal/schema"
"github.com/shopspring/decimal"
"github.com/tidwall/gjson"
)
func GetAzureRMSynapseWorkspacRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "azurerm_synapse_workspace",
RFunc: NewAzureRMSynapseW... | internal/providers/terraform/azure/synapse_workspace.go | 0.548915 | 0.400544 | synapse_workspace.go | starcoder |
package chart
// Interface Assertions.
var (
_ Series = (*PercentChangeSeries)(nil)
_ FirstValuesProvider = (*PercentChangeSeries)(nil)
_ LastValuesProvider = (*PercentChangeSeries)(nil)
_ ValueFormatterProvider = (*PercentChangeSeries)(nil)
)
// PercentChangeSeriesSource is a series that
/... | vendor/github.com/wcharczuk/go-chart/v2/percent_change_series.go | 0.883663 | 0.512998 | percent_change_series.go | starcoder |
package modelzooserver
const sampleInitCode = `from .my_test_model import DNNClassifier`
const sampleDockerfile = `FROM ubuntu:bionic
ADD my_test_models /models/my_test_models/
ENV PYTHONPATH=/models:/usr/local/sqlflow/python
`
const sampleModelCode = `import tensorflow as tf
class DNNClassifier(tf.keras.Model):
... | go/modelzooserver/templates.go | 0.737536 | 0.460835 | templates.go | starcoder |
package main
import (
"fmt"
"math"
)
// TESTE ...
func main() {
fmt.Println("IR")
ir := IR(1.3, 1, 36, 100000, 0)
fmt.Println(ir)
}
// IPMT ...
func IPMT(rate float64, period int32, periods int32, present float64, future float64, tipo float64) float64 {
tipo = 0.0
future = 0.0
payment := PMT(rate, periods... | golang-exemples/finance_calc/main.go | 0.503906 | 0.455925 | main.go | starcoder |
package iotmaker_geo_osm
import (
"fmt"
"math"
)
//todo unidades para constantes
type DistanceStt struct {
Meters float64 // distance
Kilometers float64 // distance
unit string // distance unit
preserveUnit string // original unit
}
type DistanceListStt struct {
List []DistanceStt
}
// Get ... | typeDistance.go | 0.620966 | 0.587588 | typeDistance.go | starcoder |
package advent
import (
"strconv"
"strings"
)
var _ Problem = &dive{}
type dive struct {
dailyProblem
}
func NewDive() Problem {
return &dive{
dailyProblem{
day: 2,
},
}
}
func (d *dive) Solve() interface{} {
input := d.GetInputLines()
var results []int
results = append(results, d.getPositionProduct... | internal/advent/day2.go | 0.814311 | 0.67046 | day2.go | starcoder |
package k2tree
import "fmt"
type quartileIndex struct {
bits bitarray
offsets [3]int
counts [3]int
}
var _ bitarray = (*quartileIndex)(nil)
func newQuartileIndex(bits bitarray) *quartileIndex {
q := &quartileIndex{
bits: bits,
offsets: [3]int{
bits.Len() / 4,
bits.Len() / 2,
(bits.Len()/2 + bit... | quartileindex.go | 0.679604 | 0.551211 | quartileindex.go | starcoder |
// Package lut provides a look up table, which compresses indexed data
package lut
import (
"sort"
"dawn.googlesource.com/tint/tools/src/list"
)
// LUT is a look up table.
// The table holds a number of items that are stored in a linear list.
type LUT interface {
// Add adds a sequence of items to the table.
//... | third_party/tint/tools/src/lut/lut.go | 0.792344 | 0.511534 | lut.go | starcoder |
package game
import (
"github.com/oakmound/oak/collision"
"github.com/oakmound/oak/entities"
"github.com/oakmound/oak/event"
"github.com/oakmound/oak/physics"
"github.com/oakmound/oak/render"
)
type Entity struct {
entities.Interactive
physics.Mass
Dir physics.Vector
speedMax float... | game/entity.go | 0.544075 | 0.474753 | entity.go | starcoder |
package binpacker
import "errors"
func New(width, height int) *Packer {
return &Packer{
root: node{Rect: Rect{Width: width, Height: height}},
binWidth: width,
binHeight: height,
}
}
type Packer struct {
root node
binWidth, binHeight int
}
type node struct {
Rect
left, right *node
}
... | binpacker.go | 0.786295 | 0.456894 | binpacker.go | starcoder |
package aoc2020
/*
https://adventofcode.com/2020/day/12
--- Day 12: Rain Risk ---
Your ferry made decent progress toward the island, but the storm came in faster than anyone expected. The ferry needs to take evasive actions!
Unfortunately, the ship's navigation computer seems to be malfunctioning; rather than givin... | app/aoc2020/aoc2020_12.go | 0.746878 | 0.6395 | aoc2020_12.go | starcoder |
package lib
/*
A single zone can be anything from a room to a patch of land or space.
It is represented as a square area in which a player can find him/her self
All events/characters/actions take place in discrete zones.
Every zone defines a maximum of 8 exit points, which link to adjascent zones.
By linking one zone... | lib/game/components/zone.go | 0.572006 | 0.618089 | zone.go | starcoder |
package common
import (
"github.com/coschain/contentos-go/common"
"github.com/coschain/contentos-go/common/constants"
. "github.com/coschain/contentos-go/dandelion"
"github.com/coschain/contentos-go/prototype"
"github.com/stretchr/testify/assert"
"math/big"
"strings"
"testing"
)
type TrxTester struct{}
func ... | tests/common/trx.go | 0.609873 | 0.45423 | trx.go | starcoder |
package slices
func Extract_columns_from_2d_slices(original_slice [][]string, columns_to_extract []int) [][]string {
length := len(columns_to_extract)
breadth := len(original_slice)
extracted_slice := Make_dynamic_2d_string_slice(length, breadth)
for row_index, original_slice_row := range original_slice {
fo... | code/services/in_memory/slices/slice_management.go | 0.53777 | 0.597402 | slice_management.go | starcoder |
package raylib
//#include "raylib.h"
import "C"
import "unsafe"
const (
MaxMeshVertices = 1 << 28
MaxMeshIndices = 1 << 28
MaxMeshTexCoords = 1 << 28
MaxMeshAnimatedVertices = 1 << 28
MaxMeshBones = 1 << 28
)
//Mesh is vertex data that is stored in CPU and GPU memory.
// Note ... | raylib/models.go | 0.731442 | 0.489015 | models.go | starcoder |
package gtrie
// SearchType of Search func
// [SearchExactly, SearchByPrefix, SearchLongestMatchingPrefix, SearchMatcingPrefix, SearchApproximate]
type SearchType int
const (
// SearchExactly - finds the key exactly matching to input `key`.
SearchExactly = 0
// SearchByPrefix - finds all matching keys that start... | trie.search.go | 0.738858 | 0.522263 | trie.search.go | starcoder |
package rfc3464
import (
"net/textproto"
"strings"
)
/*
RecipientRecord represents per-recipient DSN record
A DSN contains information about attempts to deliver a message to one
or more recipients. The delivery information for any particular
recipient is contained in a group of contiguous per-recipient fields.... | rfc3464/RecipientRecord.go | 0.534612 | 0.514461 | RecipientRecord.go | starcoder |
// package retention implements models for liquid retention curves
// References:
// [1] <NAME>, <NAME> and <NAME> (2009) The concept of reference curves for constitutive
// modelling in soil mechanics, Computers and Geotechnics, 36(1-2), 149-165,
// http://dx.doi.org/10.1016/j.compgeo.2008.01.009
// ... | mdl/retention/model.go | 0.832883 | 0.544438 | model.go | starcoder |
package ccCalc
import (
"github.com/bejohi/gococomp/model"
"math"
"image"
)
func CountConnectedComponents(uniformImg *image.Gray, radius int) int{
height := uniformImg.Rect.Max.Y
width := uniformImg.Rect.Max.X
count := 0
for y := 0; y < height; y++{
for x := 0; x < width; x++{
// we only want to add thes... | ccCalc/ccCalculator.go | 0.823577 | 0.521349 | ccCalculator.go | starcoder |
// See also:
// - https://gobyexample.com/slices
// - https://golang.org/doc/
// - https://tour.golang.org/moretypes/7
// - https://blog.golang.org/slices-intro
// Slices are typically used far more often than arrays in Go.
// Slices are a key data type in Go, giving a more powerful interface
// to sequence than ar... | examples/09-slices.go | 0.721547 | 0.506469 | 09-slices.go | starcoder |
package types
import (
"io"
"github.com/lyraproj/pcore/px"
)
type IterableType struct {
typ px.Type
}
var IterableMetaType px.ObjectType
func init() {
IterableMetaType = newObjectType(`Pcore::IterableType`,
`Pcore::AnyType {
attributes => {
type => {
type => Optional[Type],
value => Any
... | types/iterabletype.go | 0.645902 | 0.526282 | iterabletype.go | starcoder |
package balance
import (
"strconv"
"github.com/iotaledger/hive.go/marshalutil"
)
// Balance represents a balance in the IOTA ledger. It consists out of a numeric value and a color.
type Balance struct {
value int64
color Color
}
// New creates a new Balance with the given details.
func New(color Color, balance ... | dapps/valuetransfers/packages/balance/balance.go | 0.856242 | 0.507934 | balance.go | starcoder |
package additionalPractice
/*
Problem : https://www.interviewbit.com/problems/array-sum/
Solution :
1) Two Pointer Approach
- Keep pointers at the end of each array.
- keep adding the values pointed at each array and decrease the pointer value.
- reverse the resultant array.
Follow up :
1) Try to do ... | src/arrays/additionalPractice/arraySum.go | 0.797951 | 0.739399 | arraySum.go | starcoder |
package cartogram
import (
"encoding/json"
"io/ioutil"
"time"
)
// Cartogram defines a set of accounts and their metadata
type Cartogram struct {
Version int `json:"version"`
Created time.Time `json:"created"`
AccountSet AccountSet `json:"accounts"`
}
// dummyCartogram just parses the Version
// ... | cartogram/cartogram.go | 0.681409 | 0.404155 | cartogram.go | starcoder |
package carbon
import (
"strconv"
"strings"
"time"
)
// Parse parses a standard string as a Carbon instance.
// 将标准格式时间字符串解析成 Carbon 实例
func (c Carbon) Parse(value string, timezone ...string) Carbon {
layout := DateTimeFormat
if _, err := strconv.ParseInt(value, 10, 64); err == nil {
switch {
case len(value)... | parser.go | 0.571767 | 0.434821 | parser.go | starcoder |
package threefish
import (
"crypto/cipher"
)
const (
// Size of a 1024-bit block in bytes
blockSize1024 = 128
// Number of 64-bit words per 1024-bit block
numWords1024 = blockSize1024 / 8
// Number of rounds when using a 1024-bit cipher
numRounds1024 = 80
)
type cipher1024 struct {
t [(tweakSize / 8) + 1]... | threefish/threefish1024.go | 0.61231 | 0.502991 | threefish1024.go | starcoder |
package types
import (
"fmt"
"strings"
"github.com/frankkopp/FrankyGo/internal/assert"
)
// Move is a 32bit unsigned int type for encoding chess moves as a primitive data type
// 16 bits for move encoding - 16 bits for sort value
type Move uint32
const (
// MoveNone empty non valid move
MoveNone Move = 0
)
/... | internal/types/move.go | 0.698124 | 0.475423 | move.go | starcoder |
package collections
// Splitter represents an ordered collection that can be split into smaller
// units.
type Splitter interface {
Bounded
// Implementation of comparable should at the very least be able to compare
// the current element to its predecessor.
Comparable
// Split splits the collection from i up to ... | split.go | 0.851645 | 0.527986 | split.go | starcoder |
package types
import (
"bytes"
"errors"
"fmt"
"io"
"github.com/c0mm4nd/wasman/leb128decode"
)
// ErrInvalidTypeByte means the type byte mismatches the one from wasm binary
var ErrInvalidTypeByte = errors.New("invalid byte")
// ValueType classifies the individual values that WebAssembly code can compute with an... | types/value.go | 0.678753 | 0.427576 | value.go | starcoder |
package gi3d
import (
"sync"
"github.com/goki/ki/ki"
"github.com/goki/ki/kit"
"github.com/goki/mat32"
)
// Camera defines the properties of the camera
type Camera struct {
Pose Pose `desc:"overall orientation and direction of the camera, relative to pointing at negative Z axis with up (posit... | gi3d/camera.go | 0.841858 | 0.536252 | camera.go | starcoder |
package btrand
import (
"math/rand"
)
/************************************************************
Core probabilities/rates/stds/averages of the generator
Mu -> average
Sigma -> standard deviation
Prob -> probabilities
*************************************************************/
const (
timePaceRateCore ... | clients/btrand/randgen.go | 0.746693 | 0.485966 | randgen.go | starcoder |
package approximations
import (
"errors"
"math"
"strings"
"github.com/j4rv/gostuff/log"
)
// CellType indicates the structure of the function that will be approximated
type CellType int8
const (
//Cubes f(x) = ? + ?x + ?x^2 + ?x^3
Cubes CellType = iota
//Sines2 f(x) = ? + ?x + sin(?x+?)*? + sin(?x+?)*?
Sine... | approximations/main.go | 0.624179 | 0.486271 | main.go | starcoder |
// Package push tests only test the oras transport (and a invalid transport) against a local registry
package push
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
"github.com/pkg/errors"
"github.com/sylabs/singularity/e2e/internal/e2e"
"github.com/sylabs/singularity/e2e/internal/testhelp... | e2e/push/push.go | 0.591369 | 0.47171 | push.go | starcoder |
package dagger
import (
"github.com/autom8ter/dagger/primitive"
)
// Edge is an edge in the directed graph. It represents a relationship between two nodes.
type Edge struct {
primitive.TypedID
}
// NewEdge creates a new edge node in the global, in-memory graph.
func NewEdge(relationship string, from, to *Node, mut... | edge.go | 0.866655 | 0.528108 | edge.go | starcoder |
package gorgonia
import (
"fmt"
"hash"
"github.com/chewxy/hm"
"github.com/pkg/errors"
"gorgonia.org/tensor"
)
/* MIN BETWEEN */
type minBetween struct{}
// Arity returns the number of inputs the Op expects. -1 indicates that it's n-ary and will be determined at runtime
func (op minBetween) Arity() int { retur... | op_minmaxBetween.go | 0.758868 | 0.591487 | op_minmaxBetween.go | starcoder |
package atomic
import "sync/atomic"
// This file contains some simplified atomics primitives that Golang default library does not offer
// like, Boolean
// Takes in a uint32 and converts to bool by checking whether the last bit is set to 1
func toBool(n uint32) bool {
return n&1 == 1
}
// Takes in a bool and retur... | atomic/atomic.go | 0.851814 | 0.490175 | atomic.go | starcoder |
package talgo
//Function defines a function that applies to the ith elements of a collection
type Function func(i int)
//Predicate defines a predicate that applies to the ith elements of a collection
type Predicate func(i int) bool
//Selector defines a selection function, a selector return i value or j value
type Se... | talgo.go | 0.635449 | 0.549399 | talgo.go | starcoder |
package types
import (
"fmt"
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/hash"
)
type valueDecoder struct {
nomsReader
vr ValueReader
tc *TypeCache
}
// |tc| must be locked as long as the valueDecoder is being used
func newValueDecoder(nr nomsReader, vr ValueReader, tc *TypeCache) *value... | go/types/value_decoder.go | 0.631935 | 0.413122 | value_decoder.go | starcoder |
package merkle
import (
"bytes"
cmn "github.com/torusresearch/tendermint/libs/common"
)
//----------------------------------------
// ProofOp gets converted to an instance of ProofOperator:
// ProofOperator is a layer for calculating intermediate Merkle roots
// when a series of Merkle trees are chained together.... | crypto/merkle/proof.go | 0.657428 | 0.541591 | proof.go | starcoder |
package bls
import (
mat "github.com/nlpodyssey/spago/pkg/mat32"
"github.com/nlpodyssey/spago/pkg/ml/ag"
"github.com/nlpodyssey/spago/pkg/ml/nn"
"log"
)
// BroadLearningAlgorithm performs the ridge regression approximation to optimize the output params (Wo).
// The parameters for feature mapping (Wz) can also be... | pkg/ml/nn/bls/bla.go | 0.727007 | 0.539408 | bla.go | starcoder |
package testutil
import (
"encoding/json"
"fmt"
"reflect"
"sync"
"sync/atomic"
"testing"
"time"
"github.com/influxdata/telegraf"
"github.com/stretchr/testify/assert"
)
// Metric defines a single point measurement
type Metric struct {
Measurement string
Tags map[string]string
Fields map[strin... | testutil/accumulator.go | 0.723212 | 0.454593 | accumulator.go | starcoder |
package openapi
import (
"encoding/json"
"net/url"
"strings"
)
// Optional parameters for the method 'CreateVerification'
type CreateVerificationParams struct {
// The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
Amount *string `json:"Amount,omitempty"`
// Your [... | rest/verify/v2/services_verifications.go | 0.799677 | 0.417687 | services_verifications.go | starcoder |
package redis
import (
"fmt"
"net"
"reflect"
"sort"
"strconv"
"strings"
"time"
"github.com/golang/glog"
)
const (
// ClusterInfoUnset status of the cluster info: no data set
ClusterInfoUnset = "Unset"
// ClusterInfoPartial status of the cluster info: data is not complete (some nodes didn't respond)
Clust... | pkg/redis/clusterinfo.go | 0.657648 | 0.435962 | clusterinfo.go | starcoder |
package stats
import (
"context"
"time"
"github.com/deixis/spine/contextutil"
"github.com/deixis/spine/log"
)
// Stats is an interface for app statistics
type Stats interface {
Start()
Stop()
// Count is a simple counter
Count(key string, n interface{}, meta ...map[string]string)
// Inc increments the give... | stats/stats.go | 0.704973 | 0.427217 | stats.go | starcoder |
package fast
// FindCorners - Finds corners coordinates on the graysacaled image.
func FindCorners(pixels map[int]int, width, height, threshold int) []int {
var circleOffsets = getCircleOffsets(width)
var circlePixels [16]int
var corners []int
// When looping through the image pixels, skips the first three lines ... | fast.go | 0.866655 | 0.533154 | fast.go | starcoder |
package scan
import (
"fmt"
"reflect"
"strings"
"github.com/jmoiron/sqlx/reflectx"
)
// Allocator allocates values
type Allocator struct {
types []reflect.Type
create func(values []interface{}) reflect.Value
}
// Create sets the given values
func (r *Allocator) Create(values []interface{}) reflect.Value {
r... | dialect/sql/scan/alloc.go | 0.654011 | 0.434941 | alloc.go | starcoder |
package wire
import (
"bytes"
"fmt"
"io"
log "github.com/p9c/logi"
"github.com/p9c/chainhash"
)
// defaultTransactionAlloc is the default size used for the backing array for transactions. The transaction array will dynamically grow as needed, but this figure is intended to provide enough space for the number ... | msgblock.go | 0.667364 | 0.462291 | msgblock.go | starcoder |
package timeperiods
import (
"errors"
"sort"
"time"
"github.com/openware/pkg/common"
)
// FindTimeRangesContainingData will break the start and end into time periods using the provided period
// it will then check whether any comparisonTimes are within those periods and concatenate them
// eg if no comparisonTim... | common/timeperiods/timeperiods.go | 0.654122 | 0.598782 | timeperiods.go | starcoder |
package wkb
import (
"bytes"
"database/sql/driver"
"fmt"
"github.com/twpayne/go-geom"
"github.com/twpayne/go-geom/encoding/wkbcommon"
)
// ErrExpectedByteSlice is returned when a []byte is expected.
type ErrExpectedByteSlice struct {
Value interface{}
}
func (e ErrExpectedByteSlice) Error() string {
return f... | vendor/github.com/whosonfirst/go-whosonfirst-static/vendor/github.com/whosonfirst/go-whosonfirst-readwrite-sqlite/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-features/vendor/github.com/twpayne/go-geom/encoding/wkb/sql.go | 0.75392 | 0.461866 | sql.go | starcoder |
package ImageData
import (
"image/color"
)
// LUT from https://github.com/guidocioni/eumetsat-python/blob/master/IR4AVHRR6.cpt
var TemperatureScaleLUT = []color.Color{
color.RGBA{R: 255, G: 255, B: 255, A: 255},
color.RGBA{R: 255, G: 255, B: 255, A: 255},
color.RGBA{R: 255, G: 255, B: 255, A: 255},
color.RGBA{R:... | ImageProcessor/ImageData/temperatureScale.go | 0.872619 | 0.481576 | temperatureScale.go | starcoder |
package types
import (
"bytes"
"github.com/attic-labs/noms/go/hash"
)
type ValueCallback func(v Value)
type RefCallback func(ref Ref)
// Valuable is an interface from which a Value can be retrieved.
type Valuable interface {
// Kind is the NomsKind describing the kind of value this is.
Kind() NomsKind
Value(... | go/types/value.go | 0.771241 | 0.583708 | value.go | starcoder |
package geometry
import (
"math"
"github.com/tab58/v1/spatial/pkg/numeric"
)
// Point3DReader is a read-only interface for vectors.
type Point3DReader interface {
GetX() float64
GetY() float64
GetZ() float64
Clone() *Point3D
AsVector() *Vector3D
DistanceTo(q Point3DReader) (float64, error)
IsEqualTo(q Poin... | pkg/geometry/point3d.go | 0.887101 | 0.678084 | point3d.go | starcoder |
package exporters
import (
"fmt"
"strings"
"github.com/cs3org/reva/pkg/mentix/exchangers"
"github.com/cs3org/reva/pkg/mentix/meshdata"
)
// Exporter is the interface that all exporters must implement.
type Exporter interface {
exchangers.Exchanger
// MeshData returns the mesh data.
MeshData() *meshdata.Mesh... | pkg/mentix/exchangers/exporters/exporter.go | 0.646795 | 0.451629 | exporter.go | starcoder |
package builder
import (
"fmt"
"github.com/ulule/loukoum/v3/stmt"
"github.com/ulule/loukoum/v3/types"
)
// Insert is a builder used for "INSERT" query.
type Insert struct {
query stmt.Insert
}
// NewInsert creates a new Insert.
func NewInsert() Insert {
return Insert{
query: stmt.NewInsert(),
}
}
// Into s... | builder/insert.go | 0.74826 | 0.47859 | insert.go | starcoder |
package gamemap
import (
"math/rand"
"github.com/torlenor/asciiventure/assets"
"github.com/torlenor/asciiventure/utils"
)
//NewRandomMap returns a random game map with the specified number of rooms and sizes.
func NewRandomMap(maxRooms int, roomMinSize, roomMaxSize, mapWidth, mapHeight int, glyphTexture *assets.G... | gamemap/randommap.go | 0.617859 | 0.402451 | randommap.go | starcoder |
package bitonic
import (
"sync"
)
// SortOrder represents sort order.
type SortOrder bool
const (
// Ascending represents ascending order.
Ascending SortOrder = true
// Descending represents descending order.
Descending SortOrder = false
)
// SortInts sorts `x` by `ord` order (concurrent).
// `len(x)` must be ... | sort.go | 0.666497 | 0.502747 | sort.go | starcoder |
package lib
import (
"image"
lib_image "github.com/mchapman87501/go_mars_2020_img_utils/lib/image"
)
// I *think* this is a more traditional exposure matcher than that of
// Compositor.matchColors. The latter needs to exactly match subimages
// of the same scene. This just tries to make the exposure (CIE Lab "L"... | lib/image_exposure.go | 0.672439 | 0.568416 | image_exposure.go | starcoder |
package mouse
import (
"github.com/go-vgo/robotgo"
"github.com/haroflow/go-macros/automation"
)
func Commands() []automation.Command {
moduleName := "mouse"
return []automation.Command{
{
ModuleName: moduleName,
MethodName: "move",
Parameters: "x: int, y: int",
Description: "Moves the mouse curso... | automation/mouse/mouse.go | 0.610453 | 0.499329 | mouse.go | starcoder |
package hyper
// Hypercube is represented by a slice of its coordinates.
type Cube []int
type Cubes []Cube
// Parameters of space discretization.
type Params struct {
// Value limits per dimension. For example 0, 255 for pixel values.
Min, Max float64
// Uncertainty interval expressed as a fraction of bucketWidth
... | cubes.go | 0.713032 | 0.592608 | cubes.go | starcoder |
package schedule
// There are a total of n courses you have to take, labeled from 0 to n-1.
// Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]
// Given the total number of courses and a list of prerequisite pairs, is it possible f... | graphs/course/schedule/schedule.go | 0.797202 | 0.814938 | schedule.go | starcoder |
package common
import (
"log"
"engo.io/engo"
"engo.io/gl"
)
// Spritesheet is a class that stores a set of tiles from a file, used by tilemaps and animations
type BasicSpritesheet struct {
texture *gl.Texture // The original texture
width, height float32 // The dimensions of th... | common/basic_spritesheet.go | 0.70416 | 0.574813 | basic_spritesheet.go | starcoder |
package inflect
import (
"fmt"
"regexp"
"strings"
)
func Pluralize(str string) string {
if inflector, ok := Languages[Language]; ok {
return inflector.Pluralize(str)
}
return str
}
func Singularize(str string) string {
if inflector, ok := Languages[Language]; ok {
return inflector.Singularize(str)
}
r... | go/src/github.com/chuckpreslar/inflect/inflect.go | 0.634317 | 0.443179 | inflect.go | starcoder |
package fixtures
import (
"fmt"
)
// argument encodes an argument as per the go text/template library.
// Only scalar types are supported.
// https://golang.org/pkg/text/template/#hdr-Arguments
func argument(value interface{}) string {
switch t := value.(type) {
case string:
return fmt.Sprintf(`"%s"`, t)
case ... | test/unit/fixtures/template.go | 0.867106 | 0.495789 | template.go | starcoder |
package c
import (
. "github.com/maxinehazel/chroma" // nolint
"github.com/maxinehazel/chroma/lexers/internal"
)
// Coq lexer.
var Coq = internal.Register(MustNewLexer(
&Config{
Name: "Coq",
Aliases: []string{"coq"},
Filenames: []string{"*.v"},
MimeTypes: []string{"text/x-coq"},
},
Rules{
"root"... | lexers/c/coq.go | 0.537527 | 0.646418 | coq.go | starcoder |
package state
import (
"fmt"
"sort"
"strings"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/dapr/components-contrib/state"
"github.com/dapr/components-contrib/tests/conformance/utils"
)
type ValueType struct {
Message string `json:"message"`
}
type scenario struct {
... | tests/conformance/state/state.go | 0.540439 | 0.415729 | state.go | starcoder |
package parse
// WalkTreerBFS walks the Treer level by level.
// See: https://en.wikipedia.org/wiki/Breadth-first_search
func WalkTreerBFS(tree Treer, fn func(int, Treer) error) error {
var (
stack = Treers{}
current Treer
childs Treers
// starting from the root element
// only one element left to jump
... | treer_walk.go | 0.654784 | 0.430985 | treer_walk.go | starcoder |
package env
import (
"fmt"
"github.com/aunum/gold/pkg/v1/dense"
sphere "github.com/aunum/sphere/api/gen/go/v1alpha"
"gorgonia.org/tensor"
)
// Normalizer will normalize the data coming from an environment.
type Normalizer interface {
// Init the normalizer.
Init(env *Env) error
// Norm normalizes the input d... | pkg/v1/env/norm.go | 0.722233 | 0.431165 | norm.go | starcoder |
package openapi
import (
"encoding/json"
"time"
)
// WorkflowRunState struct for WorkflowRunState
type WorkflowRunState struct {
// Time at which the workflow execution ended
EndedAt NullableTime `json:"ended_at"`
// Time at which workflow execution started
StartedAt NullableTime `json:"started_at"`
// Curren... | client/pkg/client/openapi/model_workflow_run_state.go | 0.734691 | 0.500671 | model_workflow_run_state.go | starcoder |
package graph
import (
"fmt"
"math/rand"
"strconv"
"sync"
)
// Input are the inputs for each experiment
type Input struct {
rounds, carCount, threads int
trafficSlowdown float64
root, destination string
}
// NewInput defines a new Input struct
func NewInput(rounds, carsCount, threads int,
t... | graph/generate.go | 0.64512 | 0.455501 | generate.go | starcoder |
package buffer
import (
"bytes"
"io"
"io/ioutil"
"github.com/buildbarn/bb-storage/pkg/digest"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
type validatedByteSliceBuffer struct {
data []byte
}
// NewValidatedBufferFromByteSlice creates a Buffer that is ... | pkg/blobstore/buffer/validated_byte_slice_buffer.go | 0.800107 | 0.476823 | validated_byte_slice_buffer.go | starcoder |
package vec
import (
"github.com/chewxy/math32"
"github.com/foxis/EasyRobot/pkg/core/math"
)
type Vector3D [3]float32
func (v *Vector3D) Sum() float32 {
var sum float32
for _, val := range v {
sum += val
}
return sum
}
func (v *Vector3D) Vector() Vector {
return v[:]
}
func (v *Vector3D) Slice(start, end... | pkg/core/math/vec/vec3d.go | 0.774583 | 0.683215 | vec3d.go | starcoder |
package geoindex
import (
"fmt"
"time"
)
type Minutes int
type counter interface {
Add(point Point)
Remove(point Point)
Point() *CountPoint
}
type timestampedCounter struct {
counter accumulatingCounter
timestamp time.Time
}
// Expiring counter.
type expiringCounter struct {
counters *queue
minutes ... | hotelReservation/vendor/github.com/hailocab/go-geoindex/counters.go | 0.702122 | 0.416678 | counters.go | starcoder |
package orbcore
import (
"fmt"
"math"
"time"
)
/*
BoundingBox defines a four dimensional bounding box in space and time.
*/
type BoundingBox struct {
MinX float64
MinY float64
MinZ float64
MinTime time.Time
MaxX float64
MaxY float64
MaxZ float64
MaxTime time.Time
}
func (bb *BoundingBox)... | orbcore/boundingbox.go | 0.790813 | 0.433682 | boundingbox.go | starcoder |
package webrtc
// RefBool returns a pointer to a newly created bool.
func RefBool(value bool) *bool {
return &value
}
// RefUint returns a pointer to a newly created uint.
func RefUint(value uint) *uint {
return &value
}
// RefUint8 returns a pointer to a newly created uint8.
func RefUint8(value uint8) *uint8 {
r... | reftypereturn.go | 0.913058 | 0.562177 | reftypereturn.go | starcoder |
package router
import (
"fmt"
"strconv"
"strings"
"time"
)
// Params is similar to url.Values, but with a few more utility functions
type Params map[string][]string
// Map gets the params as a flat map[string]string, discarding any multiple values.
func (p Params) Map() map[string]string {
flat := make(map[stri... | params.go | 0.770119 | 0.489015 | params.go | starcoder |
package kvsql
import (
"github.com/meshplus/gosdk/kvsql/types"
)
// Row represents a row of data, can be used to access values.
type Row struct {
c *Chunk
idx int
}
// Chunk returns the Chunk which the row belongs to.
func (r Row) Chunk() *Chunk {
return r.c
}
// IsEmpty returns true if the Row is empty.
func... | kvsql/row.go | 0.867906 | 0.601213 | row.go | starcoder |
package bitfield
import (
"encoding/hex"
"errors"
)
func NumBytes(length uint32) int {
return int((uint64(length) + 7) / 8)
}
// Bitfield is described in BEP 3.
type Bitfield struct {
bytes []byte
length uint32
}
// New creates a new Bitfield of length bits.
func New(length uint32) *Bitfield {
return &Bitfie... | internal/bitfield/bitfield.go | 0.762247 | 0.453625 | bitfield.go | starcoder |
package gorocksdb
// #include "rocksdb/c.h"
import "C"
// A SliceTransform can be used as a prefix extractor.
type SliceTransform interface {
// Transform a src in domain to a dst in the range.
Transform(src []byte) []byte
// Determine whether this is a valid src upon the function applies.
InDomain(src []byte) ... | internal/logdb/kv/rocksdb/gorocksdb/slice_transform.go | 0.770724 | 0.410343 | slice_transform.go | starcoder |
package obi
import (
"encoding/binary"
"fmt"
"reflect"
)
// Encode uses obi encoding scheme to encode the given input into bytes.
func Encode(v interface{}) ([]byte, error) {
rv := reflect.ValueOf(v)
switch rv.Kind() {
case reflect.Uint8:
return EncodeUnsigned8(uint8(rv.Uint())), nil
case reflect.Uint16:
r... | chain/pkg/obi/encode.go | 0.746971 | 0.407569 | encode.go | starcoder |
package bridge
import (
"fmt"
)
const (
NullType = iota
UnresolvedType
NamedType
AliasType
ReferenceType
TupleType
RecordType
FunctionType
ListType
MapType
)
type Type struct {
// One of the above type classes
TypeClass int
TypeData interface{}
}
func (t *Type) TypeClassString() string {
switch t.Ty... | types.go | 0.623262 | 0.65379 | types.go | starcoder |
package spdx
type SnippetRangePointer struct {
// 5.3: Snippet Byte Range: [start byte]:[end byte]
// Cardinality: mandatory, one
Offset int `json:"offset,omitempty"`
// 5.4: Snippet Line Range: [start line]:[end line]
// Cardinality: optional, one
LineNumber int `json:"lineNumber,omitempty"`
FileSPDXIdentif... | spdx/snippet.go | 0.7478 | 0.434701 | snippet.go | starcoder |
package intrusive
import (
"math"
"unsafe"
)
// HashMap presents a hash map.
type HashMap struct {
maxLoadFactor float64
keyHasher HashMapKeyHasher
nodeMatcher HashMapNodeMatcher
slots []hashMapSlot
minSlotCountShift int
nodeCount int
}
// Init initializes the map and th... | hashmap.go | 0.870721 | 0.509947 | hashmap.go | starcoder |
package dst
// Beta distribution reparametrized using mean and standard deviation.
// BetaμσPDF returns the PDF of the Beta distribution reparametrized using mean and standard deviation.
func BetaμσPDF(μ, σ float64) func(x float64) float64 {
α := μ * (μ*(1-μ)/(σ*σ) - 1)
β := (1 - μ) * (μ*(1-μ)/(σ*σ) - 1)
return... | dst/beta-mu-sigma.go | 0.932083 | 0.656713 | beta-mu-sigma.go | starcoder |
package draw
func doellipse(cmd byte, dst *Image, c Point, xr, yr, thick int, src *Image, sp Point, alpha uint32, phi int, op Op) {
setdrawop(dst.Display, op)
a := dst.Display.bufimage(1 + 4 + 4 + 2*4 + 4 + 4 + 4 + 2*4 + 2*4)
a[0] = cmd
bplong(a[1:], dst.id)
bplong(a[5:], src.id)
bplong(a[9:], uint32(c.X))
bplo... | draw/ellipse.go | 0.64232 | 0.495239 | ellipse.go | starcoder |
package builtins
import "github.com/xav/go-script/types"
var (
// AppendType is the definition of the append built-in function (https://golang.org/ref/spec#Appending_and_copying_slices)
AppendType = &types.FuncType{Builtin: "append"}
// CapType is the definition of the cap(s) built-in function (https://golang.org... | builtins/functions.go | 0.54698 | 0.506469 | functions.go | starcoder |
package plotter
import (
"image"
"math"
"github.com/hneemann/nplot"
"github.com/hneemann/nplot/vg"
"github.com/hneemann/nplot/vg/draw"
)
// Image is a plotter that draws a scaled, raster image.
type Image struct {
img image.Image
cols int
rows int
xmin, xmax, dx float64
ymin... | plotter/image.go | 0.829112 | 0.520862 | image.go | starcoder |
package main
import (
"fmt"
"github.com/theatlasroom/advent-of-code/go/utils"
)
/**
--- Day 1: Sonar Sweep ---
You're minding your own business on a ship at sea when the overboard alarm goes off! You rush to see if you can help. Apparently, one of the Elves tripped and accidentally sent the sleigh keys flying int... | go/2021/1.go | 0.657318 | 0.570062 | 1.go | starcoder |
package metric
// BatchObserver represents an Observer callback that can report
// observations for multiple instruments.
type BatchObserver struct {
meter Meter
runner AsyncBatchRunner
}
// Int64ValueObserver is a metric that captures a set of int64 values at a
// point in time.
type Int64ValueObserver struct {
... | vendor/go.opentelemetry.io/otel/api/metric/observer.go | 0.903286 | 0.533701 | observer.go | starcoder |
package geom
import (
"fmt"
"github.com/peterstace/simplefeatures/rtree"
)
// Intersects return true if and only the two geometries intersect with each
// other, i.e. the point sets that the geometries represent have at least one
// common point.
func Intersects(g1, g2 Geometry) bool {
if rank(g1) > rank(g2) {
... | geom/alg_intersects.go | 0.618204 | 0.516169 | alg_intersects.go | starcoder |
package main
import (
"crypto/rand"
"crypto/sha256"
"math/big"
)
// RandomBytes sample B random Bytes.
func RandomBytes() []byte {
r := make([]byte, B)
rand.Read(r)
return r
}
// HashToCurve hash t to a curve point T.
// If T is not valid, then Ty = nil.
func HashToCurve(t []byte) (Tx *big.Int, Ty *big.Int) {
... | computation.go | 0.761716 | 0.515254 | computation.go | starcoder |
package tsm1
/*
This code is originally from: https://github.com/dgryski/go-tsz and has been modified to remove
the timestamp compression fuctionality.
It implements the float compression as presented in: http://www.vldb.org/pvldb/vol8/p1816-teller.pdf.
This implementation uses a sentinel value of NaN which means tha... | vendor/github.com/influxdata/influxdb/tsdb/engine/tsm1/float.go | 0.66061 | 0.497131 | float.go | starcoder |
package gofpdf
import (
"bytes"
)
// Version of FPDF from which this package is derived
const (
cnFpdfVersion = "1.7"
)
type blendModeType struct {
strokeStr, fillStr, modeStr string
objNum int
}
type gradientType struct {
tp int // 2: linear, 3: radial
clr1Str, clr2Str st... | def.go | 0.709422 | 0.499878 | def.go | starcoder |
package iso20022
// Details of the securities trade.
type SecuritiesTradeDetails59 struct {
// Market in which a trade transaction has been executed.
PlaceOfTrade *PlaceOfTradeIdentification2 `xml:"PlcOfTrad,omitempty"`
// Infrastructure which may be a component of a clearing house and wich facilitates clearing a... | SecuritiesTradeDetails59.go | 0.842345 | 0.442877 | SecuritiesTradeDetails59.go | starcoder |
package avl
// Range is the basic node for the AVL tree leaves.
// The concept Range can be a real data range in most cases, such as
// [LOWER_BOUND, UPPER_BOUND] .
// A Range can also be a single value, such as [VALUE_A, VALUE_A] .
type Range interface {
// Compare returns an integer comparing two elements.
// The... | avl/avl.go | 0.850732 | 0.605478 | avl.go | starcoder |
package sqldatabase
import (
"database/sql"
"fmt"
"reflect"
"time"
)
var (
KindString reflect.Kind = reflect.String
KindInt reflect.Kind = reflect.Int64
KindBool reflect.Kind = reflect.Bool
KindFloat32 reflect.Kind = reflect.Float32
KindFloat64 reflect.Kind = reflec... | sqldatabase/TestHelpers.go | 0.663451 | 0.50415 | TestHelpers.go | starcoder |
package scte35
import (
"bytes"
"encoding/base64"
"encoding/binary"
"encoding/hex"
"fmt"
"strconv"
"strings"
"unicode/utf8"
"github.com/bamiaux/iobit"
)
const (
// SegmentationUPIDTypeNotUsed is the segmentation_upid_type for Not Used.
SegmentationUPIDTypeNotUsed = 0x00
// SegmentationUPIDTypeUserDefine... | pkg/scte35/segmentation_upid.go | 0.524151 | 0.469703 | segmentation_upid.go | starcoder |
package plaid
import (
"encoding/json"
)
// CreditCardLiability An object representing a credit card account.
type CreditCardLiability struct {
// The ID of the account that this liability belongs to.
AccountId NullableString `json:"account_id"`
// The various interest rates that apply to the account.
Aprs []AP... | plaid/model_credit_card_liability.go | 0.750095 | 0.558688 | model_credit_card_liability.go | starcoder |
package data
// A sequence of runs (each step is a ConditionParams object)
type RunParams struct {
Nm string `desc:"Name of the sequence"`
Desc string `desc:"Description"`
Cond1Nm string `desc:"name of condition 1"`
Cond2Nm string `desc:"name of condition 2"`
Cond3Nm string `desc:"name of condition 3"`
... | ch7/pvlv/data/run_params.go | 0.593256 | 0.673219 | run_params.go | starcoder |
package item
var (
// ArmourTierLeather is the ArmourTier of leather armour.
ArmourTierLeather = ArmourTier{BaseDurability: 55, Name: "leather"}
// ArmourTierGold is the ArmourTier of gold armour.
ArmourTierGold = ArmourTier{BaseDurability: 77, Name: "golden"}
// ArmourTierChain is the ArmourTier of chain armour.... | server/item/armour.go | 0.586404 | 0.407245 | armour.go | starcoder |
package langreg
import (
"errors"
"fmt"
)
// RegionCodeInfo returns the English regional name that
// corresponds to the ISO 3166-1 alpha-2 region codes.
// Region codes should always be uppercase, and this is enforced.
// E.g. "US" is valid, but "us" is not.
func RegionCodeInfo(s string) (region string, err error... | vendor/github.com/johngb/langreg/region_code_info.go | 0.514888 | 0.491761 | region_code_info.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.