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 auditortest
import (
"context"
"errors"
"fmt"
"reflect"
"github.com/ONSdigital/go-ns/audit"
"github.com/ONSdigital/go-ns/common"
. "github.com/smartystreets/goconvey/convey"
)
//ErrAudit is the test error returned from a MockAuditor if the audit action & result match error trigger criteria
var ErrAudi... | vendor/github.com/ONSdigital/go-ns/audit/auditortest/helper.go | 0.673943 | 0.409575 | helper.go | starcoder |
package data
import (
"encoding/json"
)
type Rentability struct {
NodesDefault `json:"nodes_default"`
FluxReward float64 `json:"flux_reward,omitempty"`
FluxInstantPaReward float64 `json:"flux_instant_pa_reward,omitempty"`
FluxLaterPaReward float64 `json:"flux_later_pa_re... | data/rentability.go | 0.529993 | 0.482856 | rentability.go | starcoder |
package proto
import (
"fmt"
"io"
"github.com/azmodb/ninep/binary"
)
// Qid represents the server's unique identification for the file being
// accessed. Two files on the same server hierarchy are the same if and
// only if their qids are the same.
type Qid struct {
Type uint8 // type of a file (directory, etc)
... | proto/qid.go | 0.592902 | 0.40869 | qid.go | starcoder |
package geo
import (
"math"
"github.com/paulmach/orb"
)
// Distance returns the distance between two points on the earth.
func Distance(p1, p2 orb.Point) float64 {
dLat := deg2rad(p1[1] - p2[1])
dLon := deg2rad(p1[0] - p2[0])
dLon = math.Abs(dLon)
if dLon > math.Pi {
dLon = 2*math.Pi - dLon
}
// fast way... | geo/distance.go | 0.883179 | 0.752149 | distance.go | starcoder |
package misc
import (
"errors"
"math"
"github.com/heedy/pipescript"
"github.com/heedy/pipescript/resources"
)
// EarthRadius is the earth radius in meters
var EarthRadius = float64(6371000)
// Radians is the multiplication constant to convert degrees to radians
var Radians = math.Pi / 180.0
var Distance = &pip... | transforms/misc/distance.go | 0.782039 | 0.445771 | distance.go | starcoder |
package ast
//Visitor is used to do a top down walk through the expression tree using the Walk methods.
type Visitor interface {
//Visit takes in an ast type and should return another type that implementes the Visitor interface.
Visit(node interface{}) interface{}
}
//Walk visits the Grammar instance and all its p... | relapse/ast/walk.go | 0.678007 | 0.535766 | walk.go | starcoder |
package graph
import (
"container/list"
"fmt"
"io"
)
type Vertex struct {
Name string
}
type Edge struct {
Parent *Vertex
Child *Vertex
}
type DAG struct {
Root *Vertex
Edges *list.List
Vertices map[*Vertex][]*Edge
}
func NewDAG() *DAG {
return &DAG{Vertices: make(map[*Vertex][]*Edge), Edges: lis... | graph/dag.go | 0.600774 | 0.422862 | dag.go | starcoder |
package geometry
import "fmt"
func min(x, y int) int {
if x < y {
return x
}
return y
}
func max(x, y int) int {
if x > y {
return x
}
return y
}
func abs(x int) int {
if x < 0 {
return 0 - x
}
return x
}
// x and y correspond to column and row
type Point struct {
x int
y int
}
func MakePoint(x, ... | geometry/geometry.go | 0.907896 | 0.724688 | geometry.go | starcoder |
package main
import "fmt"
/*
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
You are given a target value to search. If found in the array return its index, otherwise return -1.
You may assume no duplicate exists i... | Programs/033 Search in Rotated Sorted Array/033 Search in Rotated Sorted Array.go | 0.531939 | 0.63385 | 033 Search in Rotated Sorted Array.go | starcoder |
package io
import (
"reflect"
"sync"
)
var decoderMap sync.Map
// ValueDecoder is the interface that groups the basic Decode methods.
type ValueDecoder interface {
Decode(dec *Decoder, p interface{}, tag byte)
}
func registerValueDecoder(t reflect.Type, valdec ValueDecoder) {
decoderMap.Store(t, valdec)
}
// R... | io/value_decoder.go | 0.552781 | 0.5752 | value_decoder.go | starcoder |
package datatypes
// TNode
func (node TNode) Exec (t Time, _ interface{}, _ InPipes) EvPayload {
return Some(t)
}
func (node TNode) Rinse (_ InPipes) {
}
// WNode
func (node WNode) Exec (_ Time, w interface{}, _ InPipes) EvPayload {
return Some(w)
}
func (node WNode) Rinse (inpipes InPipes) {
}
// aux fu... | striver-go/datatypes/valueNodes.go | 0.633297 | 0.430267 | valueNodes.go | starcoder |
// Package slice implements some functions to manipulate slice.
package slice
import (
"fmt"
"math"
"math/rand"
"reflect"
"sort"
)
// Contain check if the value is in the slice or not
func Contain[T any](slice []T, value T) bool {
for _, v := range slice {
if reflect.DeepEqual(v, value) {
return true
}
... | slice/slice.go | 0.789031 | 0.435601 | slice.go | starcoder |
package utils
import "time"
// String returns a pointer to the string value passed in.
func String(v string) *string {
return &v
}
// StringSlice converts a slice of string values into a slice of
// string pointers
func StringSlice(src []string) []*string {
dst := make([]*string, len(src))
for i := 0; i < len(src... | src/cmd/linuxkit/vendor/github.com/scaleway/scaleway-sdk-go/utils/convert.go | 0.825343 | 0.49408 | convert.go | starcoder |
package prop
// EqCapable defines the capability to perform 'eq' operations, and by logic, 'ne' operations. It should be implemented
// by capable Property implementations.
type EqCapable interface {
// EqualsTo return true if the property's value is equal to the given value.
// If the given value is nil, always ret... | pkg/v2/prop/op.go | 0.792785 | 0.589244 | op.go | starcoder |
package engine
import (
"github.com/cadmean-ru/amphion/common"
"github.com/cadmean-ru/amphion/common/a"
"github.com/cadmean-ru/amphion/rendering"
)
// Transform describes how a scene object is positioned on the screen.
type Transform struct {
Position a.Vector3
Pivot a.Vector3
Rotation a.Vector3
Size a.... | engine/transform.go | 0.846324 | 0.765681 | transform.go | starcoder |
package marvel
import (
"fmt"
"net/http"
"time"
"github.com/dghubble/sling"
)
// SeriesService provides methods for querying series information from the API.
type SeriesService struct {
sling *sling.Sling
}
// NewSeriesService returns a new SeriesService.
func NewSeriesService(sling *sling.Sling) *SeriesServic... | series.go | 0.825765 | 0.411347 | series.go | starcoder |
package main
import (
"bufio"
"fmt"
"log"
"math"
"os"
"strconv"
"strings"
)
// Color contains data regarding the colors characters
type Color struct {
colors string
binSize float64
}
// Parse the line and create a new Color
func NewColor(line string) *Color {
return &Color{colors: line}
}
type Gradient i... | 208-intermediate/gradient.go | 0.790247 | 0.409339 | gradient.go | starcoder |
package floyds
import (
"errors"
)
/*
The Detector struct is a cycle detector using Floyd's tortoise and hare algorithm. It is designed to be used in
recursive algorithms, but will work just as well in simple loops (it is very easy to manually implement in simple
loops, however). This implementation requires each st... | floyds/floyds.go | 0.834002 | 0.673688 | floyds.go | starcoder |
package pugjs
import (
"bytes"
"github.com/stretchr/testify/mock"
)
// Render blocks
// see https://github.com/pugjs/pug-ast-spec/blob/master/parser.md
// Not complete, and some minor things have been stripped
type (
// Node objects
// Node is something renderable
Node interface {
Render(r *renderState, wr ... | pugjs/pug_blocks.go | 0.787114 | 0.428771 | pug_blocks.go | starcoder |
package wavelength
// A color is stored internally using sRGB (standard RGB) values in the range 0-1
type Color struct {
R, G, B float64
}
// Implement the Go color.Color interface.
func (col Color) RGBA() (r, g, b, a uint32) {
r = uint32(col.R * 65535.0)
g = uint32(col.G * 65535.0)
b = uint32(col.B * 65535.0)
a... | wavelength/wavToRGB.go | 0.810554 | 0.445168 | wavToRGB.go | starcoder |
package kernel
import (
"image"
"image/color"
"sync"
)
//Convolution does the convolution operation per channel on an image. threads will parallelize the convolution
func Convolution(img image.Image, kernel [][]float64, stride, dilation, padding []int, zeronegatives bool, threads bool) image.Image {
if len(stride... | kernel.go | 0.73029 | 0.483161 | kernel.go | starcoder |
package matrix
import (
"fmt"
"strings"
)
// TwoDimMatrix represents a matrix in a 2D array
type TwoDimMatrix []row
// row represents a 1D array belonging to a TwoDimMatrix
type row []float64
// NewTwoDimMatrix creates and initializes a 2D array representing a matrix
func NewTwoDimMatrix(initialValue float64, n i... | model/matrix/two_dim_matrix.go | 0.795181 | 0.739611 | two_dim_matrix.go | starcoder |
package neural
import (
"fmt"
"math"
)
// An activator function just maps float values to other
// float values. The function can be as simplistic or complicated
// as desired-- eventually a set of common activators will be
// collected.
type ActivatorFunc func(float64) float64
var (
activatorTests = []float64{
... | neural/activators.go | 0.589244 | 0.50116 | activators.go | starcoder |
package scene
import (
"fmt"
"github.com/mikee385/GolangRayTracer/geometry"
"github.com/mikee385/GolangRayTracer/table"
"math"
)
type Camera struct {
position geometry.Point3D
orientation geometry.Matrix3D
imageWidth int
imageHeight int
xMin float32
yMax float32
dx... | scene/Camera.go | 0.846768 | 0.779951 | Camera.go | starcoder |
package gorand
import (
"math/rand"
"sort"
"time"
)
// ProbabilityElement is a interface that can be random selected from slice
type ProbabilityElement interface {
GetValue() interface{}
GetProbability() float64
}
// RandomSelectN selects n elements from slice randomly according to the elements' probability dis... | rand.go | 0.795777 | 0.591576 | rand.go | starcoder |
package main
import (
"math/rand"
"time"
"github.com/anaseto/gruid"
"github.com/anaseto/gruid/paths"
"github.com/anaseto/gruid/rl"
)
// These constants represent the different kind of map tiles.
const (
Wall rl.Cell = iota
Floor
)
// Map represents the rectangular map of the game's level.
type Map struct {
... | map.go | 0.760917 | 0.434521 | map.go | starcoder |
package datadog
import (
"encoding/json"
)
// SLOHistorySLIData An object that holds an SLI value and its associated data. It can represent an SLO's overall SLI value or the SLI value for a specific monitor (in multi-monitor SLOs) or group (in grouped SLOs). The uptime history is included for monitor SLOs.
type SLO... | api/v1/datadog/model_slo_history_sli_data.go | 0.82887 | 0.47317 | model_slo_history_sli_data.go | starcoder |
// Package correlationvector contains library functions to manipulate CorrelationVectors.
package correlationvector
import (
"math/rand"
"strconv"
"time"
)
// SpinCounterInterval is the interval (proportional to time) by which the counter increments.
type SpinCounterInterval int
const (
// CoarseInterval drops ... | correlationvector/spin.go | 0.834811 | 0.712307 | spin.go | starcoder |
package execution
import (
"reflect"
"github.com/pkg/errors"
"gorgonia.org/tensor/internal/storage"
)
func (e E) Neg(t reflect.Type, a *storage.Header) (err error) {
switch t {
case Int:
NegI(a.Ints())
return nil
case Int8:
NegI8(a.Int8s())
return nil
case Int16:
NegI16(a.Int16s())
return nil
ca... | internal/execution/eng_unary.go | 0.569853 | 0.450239 | eng_unary.go | starcoder |
package goldi
import "reflect"
// The ParameterResolver is used by type factories to resolve the values of the dynamic factory arguments
// (parameters and other type references).
type ParameterResolver struct {
Container *Container
}
// NewParameterResolver creates a new ParameterResolver and initializes it with t... | parameter_resolver.go | 0.774242 | 0.497131 | parameter_resolver.go | starcoder |
package sweetiebot
import (
"encoding/json"
"fmt"
"reflect"
"strings"
"strconv"
"github.com/bwmarrin/discordgo"
)
type ConfigModule struct {
}
func (w *ConfigModule) Name() string {
return "Configuration"
}
func (w *ConfigModule) Register(info *GuildInfo) {}
func (w *ConfigModule) Commands() []Command {
... | sweetiebot/config_command.go | 0.617282 | 0.548492 | config_command.go | starcoder |
package cryptospecials
import (
"crypto/elliptic"
"fmt"
"hash"
"math/big"
)
// big.Int representation of Zero & One
var (
blank = new(big.Int)
zero = new(big.Int).SetInt64(int64(0))
one = new(big.Int).SetInt64(int64(1))
)
//ECPoint is an exportable struct
type ECPoint struct {
X *big.Int
Y *big.Int
}
//... | cryptospecials/cryptospecials.go | 0.666497 | 0.504333 | cryptospecials.go | starcoder |
package calendar
import (
"time"
)
type holidayCalc func(*Holiday, int, *time.Location) time.Time
type Holiday struct {
Name string
OnYear int // Used if holiday occures only on specific year
BeforeYear int // Used if holiday occures before a specific year
AfterYear int // Used i... | holiday.go | 0.713332 | 0.588357 | holiday.go | starcoder |
package maximum_flow
// MaximumFlow returns the maximum flow from source to sink in g.
func MaximumFlow(g Graph, source, sink int) int {
// r is the residual flow graph of g. Initially, that's just the same as g.
r := NewAdjacencyMatrix(g)
flow := 0
for {
pathCapacity := r.addAugmentingPath(source, sink)
if p... | maximum_flow/go/maximum_flow.go | 0.908475 | 0.53522 | maximum_flow.go | starcoder |
package types
import (
"fmt"
"strconv"
"strings"
"unicode"
"github.com/markkurossi/tabulate"
"github.com/markkurossi/vt100"
)
var (
_ Column = NullColumn{}
_ Column = ValueColumn{}
_ Column = StringColumn("")
_ Column = StringsColumn([]string{})
)
// Source is an interface that defines data input sources... | types/source.go | 0.650023 | 0.44354 | source.go | starcoder |
// package types provides an interface and many implementations of that
// interface as an abstraction, however leaky, of the union of the Go type
// system and the Ruby Object system.
package types
import (
"go/ast"
"reflect"
"regexp"
"strings"
"github.com/redneckbeard/thanos/bst"
)
type Type interface {
Blo... | types/types.go | 0.643665 | 0.512937 | types.go | starcoder |
package regions
var REGION_DATA = map[string]Region{
"asia-east1": Region{
Name: "Taiwan",
Flag: "https://upload.wikimedia.org/wikipedia/commons/7/72/Flag_of_the_Republic_of_China.svg",
Latitude: 23.69781,
Longitude: 120.960515,
},
"asia-east2": Region{
Name: "Hong Kong",
Flag: "ht... | data.go | 0.593374 | 0.535584 | data.go | starcoder |
package stream
import (
"fmt"
"github.com/golang/protobuf/proto"
"github.com/google/gapid/core/data/protoutil"
)
var (
// U1 represents a 1-bit unsigned integer.
U1 = DataType{Signed: false, Kind: &DataType_Integer{&Integer{Bits: 1}}}
// U2 represents a 2-bit unsigned integer.
U2 = DataType{Signed: false, Ki... | core/stream/datatype.go | 0.657978 | 0.765506 | datatype.go | starcoder |
package valuation
import (
"errors"
"strconv"
"github.com/cimomo/alphavantage-go"
)
// Input defines the company specific input data for the valuation
type Input struct {
Company *Company
Revenue float64
EBIT float64
TotalEquity float64
TotalDebt ... | pkg/valuation/input.go | 0.723114 | 0.480844 | input.go | starcoder |
package widgets
import (
"image"
"math"
. "github.com/grafana/termui/v3"
)
const (
piechartOffsetUp = -.5 * math.Pi // the northward angle
resolutionFactor = .0001 // circle resolution: precision vs. performance
fullCircle = 2.0 * math.Pi // the full circle angle
xStretch = 2.0 ... | widgets/piechart.go | 0.788135 | 0.458106 | piechart.go | starcoder |
package gocql
import (
"math/big"
"reflect"
"strings"
"time"
"gopkg.in/inf.v0"
)
type RowData struct {
Columns []string
Values []interface{}
}
func goType(t TypeInfo) reflect.Type {
switch t.Type() {
case TypeVarchar, TypeAscii, TypeInet:
return reflect.TypeOf(*new(string))
case TypeBigInt, TypeCounte... | test/fixtures/godep-massage-vendor/vendor/github.com/gocql/gocql/helpers.go | 0.519034 | 0.572185 | helpers.go | starcoder |
package in_toto
import (
"fmt"
)
/*
Set represents a data structure for set operations. See `NewSet` for how to
create a Set, and available Set receivers for useful set operations.
Under the hood Set aliases map[string]struct{}, where the map keys are the set
elements and the map values are a memory-efficient way o... | vendor/github.com/in-toto/in-toto-golang/in_toto/util.go | 0.702326 | 0.466785 | util.go | starcoder |
package models
import (
context "context"
fmt "fmt"
_ "github.com/infobloxopen/protoc-gen-gorm/options"
math "math"
gorm2 "github.com/infobloxopen/atlas-app-toolkit/gorm"
errors1 "github.com/infobloxopen/protoc-gen-gorm/errors"
gorm1 "github.com/jinzhu/gorm"
field_mask1 "google.golang.org/genproto/protobuf... | src/models/transaction.pb.gorm.go | 0.645455 | 0.446495 | transaction.pb.gorm.go | starcoder |
package mat3
import (
"fmt"
"math"
"github.com/flywave/go3d/float64/generic"
"github.com/flywave/go3d/float64/mat2"
"github.com/flywave/go3d/float64/quaternion"
"github.com/flywave/go3d/float64/vec2"
"github.com/flywave/go3d/float64/vec3"
)
var (
// Zero holds a zero matrix.
Zero = T{}
// Ident holds an i... | float64/mat3/mat3.go | 0.834845 | 0.677614 | mat3.go | starcoder |
package math
import "math"
import "math/rand"
const (
DEG2RAD = math.Pi / 180
RAD2DEG = 180 / math.Pi
)
func GenerateUUID() string {
chars := `0123456789ABCDEFGHIJKLMNOPQQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
uuid := make([]byte, 36)
rnd := 0
r := 0
for i := 0 ; i < 36; i++ {
if i == 8 || i == 13 ||... | math/math.go | 0.721743 | 0.441131 | math.go | starcoder |
package goment
import (
"math"
"time"
)
type weekYear struct {
week int
year int
}
type dayOfYear struct {
year int
dayOfYear int
}
// IsGoment will check if a variable is a Goment object.
func IsGoment(obj interface{}) bool {
_, ok := obj.(*Goment)
return ok
}
// IsTime will check if a variable is a ... | query.go | 0.717111 | 0.514827 | query.go | starcoder |
package plaid
import (
"encoding/json"
)
// StudentLoanStatus An object representing the status of the student loan
type StudentLoanStatus struct {
// The date until which the loan will be in its current status. Dates are returned in an [ISO 8601](https://wikipedia.org/wiki/ISO_8601) format (YYYY-MM-DD).
EndDate... | plaid/model_student_loan_status.go | 0.673514 | 0.459501 | model_student_loan_status.go | starcoder |
package arts
import (
"image/color"
"math"
"math/rand"
"github.com/andrewwatson/generativeart"
"github.com/andrewwatson/generativeart/common"
"github.com/fogleman/gg"
)
type circleGrid struct {
circleNumMin, circleNumMax int
}
// NewCircleGrid returns a circleGrid object.
func NewCircleGrid(circleNumMin, cir... | arts/circlegrid.go | 0.706596 | 0.46642 | circlegrid.go | starcoder |
package cashflow
import (
"context"
"github.com/stack11/go-exactonline/api"
"github.com/stack11/go-exactonline/types"
)
// ReceivablesEndpoint is responsible for communicating with
// the Receivables endpoint of the Cashflow service.
type ReceivablesEndpoint service
// Receivables:
// Service: Cashflow
// Entity... | services/cashflow/receivables.go | 0.699768 | 0.425904 | receivables.go | starcoder |
package sdl
// #include "sdl_wrapper.h"
import "C"
import "unsafe"
// Point defines a two dimensional point.
// (https://wiki.libsdl.org/SDL_Point)
type Point struct {
X int32 // the x coordinate of the point
Y int32 // the y coordinate of the point
}
// Rect contains the definition of a rectangle, with the origin... | sdl/rect.go | 0.638272 | 0.691735 | rect.go | starcoder |
package semantic
import "github.com/google/gapid/gapil/ast"
// Node represents any semantic-tree node type.
type Node interface {
isNode() // A dummy function that's implemented by all semantic node types.
}
// NamedNode represents any semantic-tree node that carries a name.
type NamedNode interface {
Node
Name(... | gapil/semantic/node.go | 0.614163 | 0.456955 | node.go | starcoder |
package nonempty
import (
"reflect"
"time"
)
// Byte if value == byte zero value, return def otherwise return value
func Byte(value, def byte) byte {
if isZero(value) {
return def
}
return value
}
// Float32 if value == float32 zero value, return def otherwise return value
func Float32(value, def float32) flo... | pkg/nonempty/nonempty.go | 0.590661 | 0.639764 | nonempty.go | starcoder |
package phys
import (
"phys/transform"
"phys/vect"
"log"
//"fmt"
"math"
)
type PolygonAxis struct {
// The axis normal.
N vect.Vect
D float32
}
type PolygonShape struct {
Shape *Shape
// The raw vertices of the polygon. Do not touch!
// Use polygon.SetVerts() to change this.
Verts Vertices
// The trans... | vendor/phys/polygonShape.go | 0.757884 | 0.530966 | polygonShape.go | starcoder |
package scheme
// Quasi-Quotation
var cosSym = NewSym("cons")
var listSym = NewSym("list")
// QqExpand expands x of any quasi-quote `x into the equivalent S-expression.
func QqExpand(x Any) Any {
return qqExpand0(x, 0) // Begin with the nesting level 0.
}
// QqQuote quotes x so that the result evaluates to x.
func... | scheme/quasiquote.go | 0.593374 | 0.45944 | quasiquote.go | starcoder |
package linenumber
import (
"sort"
"unicode/utf16"
)
// UTF16Map converts utf16 code-unit offsets to and from (line number, column) pairs.
// Code-unit offsets, line numbers, and columns are all zero-based.
type UTF16Map struct {
CodeUnitCount int // CodeUnitCount is the number of utf16 code-units in the buffer
... | kite-golib/linenumber/utf16map.go | 0.552298 | 0.426083 | utf16map.go | starcoder |
package codegen
import (
"bytes"
"fmt"
"reflect"
"strings"
"llvm/bindings/go/llvm"
"github.com/google/gapid/core/math/sint"
)
// SizeOf returns the size of the type in bytes as a uint64.
// If ty is void, a value of 1 is returned.
func (b *Builder) SizeOf(ty Type) *Value {
return b.m.SizeOf(ty).Value(b).
... | core/codegen/types.go | 0.743541 | 0.50061 | types.go | starcoder |
package sudokuDlx
import "github.com/evjrob/dlx"
func getRowIndex(cellIndex, puzzleDim int) int {
return cellIndex / puzzleDim
}
func getColumnIndex(cellIndex, puzzleDim int) int {
return cellIndex % puzzleDim
}
func getCellIndex(rowIndex, columnIndex, puzzleDim int) int {
return rowIndex * puzzleDim + column... | sudokuDlx.go | 0.778144 | 0.580055 | sudokuDlx.go | starcoder |
package iso20022
// Set of elements used to provide information on the charges related to the payment transaction.
type ChargesInformation6 struct {
// Total of all charges and taxes applied to the entry.
TotalChargesAndTaxAmount *ActiveOrHistoricCurrencyAndAmount `xml:"TtlChrgsAndTaxAmt,omitempty"`
// Transactio... | ChargesInformation6.go | 0.808143 | 0.569134 | ChargesInformation6.go | starcoder |
package gridhelper
import (
"math"
"math/rand"
"time"
)
func TerrainGenerator(x, y int, xFrequency, yFrequency, gain float64) [][]uint16 {
groundHeight := [][]uint16{}
for i := 0; i < x; i++ {
array := []uint16{}
for j := 0; j < y; j++ {
array = append(array, uint16(0))
}
groundHeight = append(ground... | internal/gridhelper/mountain.go | 0.752286 | 0.515742 | mountain.go | starcoder |
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
/*
Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked lists:
begin to intersect at node c1.
Example 1:
Input: intersectVa... | go/160.go | 0.754101 | 0.557183 | 160.go | starcoder |
package binlog
import (
"encoding/binary"
"math"
)
// Mysql extensions to binary.LittleEndian.
var LittleEndian = littleEndian{binary.LittleEndian}
type littleEndian struct {
binary.ByteOrder
}
func (littleEndian) Uint8(b []byte) uint8 {
return uint8(b[0])
}
func (littleEndian) Uint24(b []byte) uint32 {
retur... | database/binlog/endian.go | 0.531696 | 0.415729 | endian.go | starcoder |
package schemaorg
/*
FloorLevel is https://schema.org/floorLevel
The floor level for an [[Accommodation]] in a multi-storey building. Since counting
systems [vary internationally](https://en.wikipedia.org/wiki/Storey#Consecutive_number_floor_designations), the local system should be used where possible.
*/
type Fl... | types.go | 0.797675 | 0.557062 | types.go | starcoder |
package main
import (
"fmt"
"math"
"strconv"
"strings"
"sync/atomic"
"time"
)
type U8Color struct {
R, G, B, A uint8
}
func (color U8Color) pack() uint32 {
rgb24 := uint32(color.R)
rgb24 = (rgb24 << 8) | uint32(color.G)
rgb24 = (rgb24 << 8) | uint32(color.B)
return rgb24
}
func unpackColor(color uint32) ... | src/utils.go | 0.765067 | 0.406744 | utils.go | starcoder |
package reflect
import (
refl "reflect"
"strings"
"time"
"github.com/winstarshl/pip-services3-commons-go-vgo/convert"
)
type TTypeMatcher struct{}
var TypeMatcher = &TTypeMatcher{}
func (c *TTypeMatcher) MatchValue(expectedType interface{}, actualValue interface{}) bool {
if expectedType == nil {
return tru... | reflect/TypeMatcher.go | 0.729038 | 0.605478 | TypeMatcher.go | starcoder |
package bayes
import s "github.com/ematvey/gostat"
/*
Mean of posterior distribution of unknown difference of binomial proportions, approximated by Normal distribution
Bolstad 2007 (2e): 248.
untested ...
*/
func BinomDiffPropNormApproxMean(a1, b1, a2, b2 float64, n1, n2 int64) float64 {
a1_post := a1 + y1
b1_post... | bayes/binom_p_diff.go | 0.763396 | 0.690311 | binom_p_diff.go | starcoder |
package math
import (
"fmt"
"math"
)
// NodeActivationType defines the type of activation function to use for the neuron node
type NodeActivationType byte
// The neuron Activation function Types
const (
// The sigmoid activation functions
SigmoidPlainActivation NodeActivationType = iota + 1
SigmoidReducedActiva... | neat/math/activations.go | 0.826677 | 0.762137 | activations.go | starcoder |
package draw
import (
"image"
"image/color"
)
/*
* Support for the Image type so it can satisfy the standard Color and Image interfaces.
*/
// At returns the standard Color value for the pixel at (x, y).
// If the location is outside the clipping rectangle, it returns color.Transparent.
// This operation does a ... | vendor/9fans.net/go/draw/color.go | 0.741112 | 0.503967 | color.go | starcoder |
// Package drivertest provides a conformance test for implementations of
// driver.
package drivertest
import (
"bytes"
"context"
"io/ioutil"
"path/filepath"
"testing"
"github.com/google/go-cloud/blob"
"github.com/google/go-cmp/cmp"
)
// Harness descibes the functionality test harnesses must provide to run
/... | blob/drivertest/drivertest.go | 0.713032 | 0.511717 | drivertest.go | starcoder |
package finder
import (
"math"
"github.com/alextanhongpin/stringdist"
"github.com/xrash/smetrics"
)
// Algorithm the type to comply with to create your own algorithm
// Note that the return value must be greater than WorstScoreValue and less than BestScoreValue
type Algorithm func(a, b string) float64
// NewJaro... | finder/algorithm.go | 0.751557 | 0.424949 | algorithm.go | starcoder |
package msgraph
// RatingUnitedStatesMoviesType undocumented
type RatingUnitedStatesMoviesType int
const (
// RatingUnitedStatesMoviesTypeVAllAllowed undocumented
RatingUnitedStatesMoviesTypeVAllAllowed RatingUnitedStatesMoviesType = 0
// RatingUnitedStatesMoviesTypeVAllBlocked undocumented
RatingUnitedStatesMov... | v1.0/RatingUnitedStatesMoviesTypeEnum.go | 0.602179 | 0.561215 | RatingUnitedStatesMoviesTypeEnum.go | starcoder |
package value
import (
"errors"
"fmt"
"math/big"
"github.com/nkanaev/numb/pkg/ratutils"
"github.com/nkanaev/numb/pkg/token"
"github.com/nkanaev/numb/pkg/unit"
)
type ConformanceError struct {
a, b unit.UnitList
}
func (c ConformanceError) Error() string {
dim1, _ := c.a.Dimension().Measure()
dim2, _ := c.b... | pkg/value/unit.go | 0.560253 | 0.435121 | unit.go | starcoder |
package lib
import (
"encoding/binary"
"github.com/dunelang/dune"
)
func init() {
dune.RegisterLib(Binary, `
declare namespace binary {
export function putInt16LittleEndian(v: byte[], n: number): void
export function putInt32LittleEndian(v: byte[], n: number): void
export function putInt64LittleEndi... | lib/binary.go | 0.545044 | 0.476641 | binary.go | starcoder |
package disjoint
import "fmt"
//Set is a simple implementation of the disjoint set structure as in https://en.wikipedia.org/wiki/Disjoint-set_data_structure.
//This is a efficient way of storing disjoint subsets of {0,...,n-1} when the only operations are checking if two elements are in same subet and taking the unio... | disjoint/disjoint_set.go | 0.755637 | 0.597989 | disjoint_set.go | starcoder |
package testing
import (
"reflect"
"runtime"
"testing"
"time"
)
func AssertTrue(t *testing.T, cond bool, desc string) {
if !cond {
Fatalf(t, "Expected %s to be true", desc)
}
}
func AssertFalse(t *testing.T, cond bool, desc string) {
if cond {
Fatalf(t, "Expected %s to be false", desc)
}
}
func AssertNo... | testing/util.go | 0.539226 | 0.421433 | util.go | starcoder |
package fielder
import (
"fmt"
"strings"
)
//Position is a type that describes a field position
type Position int
//List of valid field positions and the bench positions
const (
Bench Position = iota
Pitcher
Catcher
First
Second
Third
LShort
RShort
LField
LCenter
RCenter
RField
NumFieldPositions int =... | scheduling/position.go | 0.666822 | 0.443902 | position.go | starcoder |
package template
import (
"fmt"
"math"
"reflect"
"strconv"
"strings"
"github.com/coveooss/gotemplate/v3/utils"
)
func add(a interface{}, args ...interface{}) (r interface{}, err error) {
if a == nil {
return
}
defer func() { err = trapError(err, recover()) }()
arguments := convertArgs(a, args...)
args =... | template/math_base.go | 0.604282 | 0.405508 | math_base.go | starcoder |
package holidays
import (
"time"
"github.com/vjeantet/eastertime"
)
func Observed(holiday time.Time) time.Time {
wd := holiday.Weekday()
if wd == time.Saturday {
return holiday.AddDate(0, 0, -1)
}
if wd == time.Sunday {
return holiday.AddDate(0, 0, 1)
}
return holiday
}
func NthDayOfMonth(year int, mont... | holidays.go | 0.61855 | 0.546617 | holidays.go | starcoder |
package neuralnetwork
import (
"github.com/timothy102/matrix"
)
//Network defines the neural network.
type Network struct {
inputNodes, hiddenNodes, outputNodes int
weightsIh, weightsHo, biasO, biasH matrix.Matrix
learningRate float64
}
//Package network implements the simp... | nn/neuralnetwork.go | 0.811489 | 0.613873 | neuralnetwork.go | starcoder |
Package protocol implements ntp packet and basic functions to work with.
It provides quick and transparent translation between 48 bytes and
simply accessible struct in the most efficient way.
*/
package protocol
import (
"time"
)
// NanosecondsToUnix is the difference between the start of NTP Era 0 and the Unix epoc... | ntp/protocol/ntp.go | 0.801548 | 0.710515 | ntp.go | starcoder |
package gotorch
// #cgo CFLAGS: -I ${SRCDIR}
// #cgo LDFLAGS: -L ${SRCDIR}/cgotorch -Wl,-rpath ${SRCDIR}/cgotorch -lcgotorch
// #cgo LDFLAGS: -L ${SRCDIR}/cgotorch/libtorch/lib -Wl,-rpath ${SRCDIR}/cgotorch/libtorch/lib -lc10 -ltorch -ltorch_cpu
// #include "cgotorch/cgotorch.h"
import "C"
import (
"log"
"reflect"
... | tensor_ops.go | 0.7324 | 0.488954 | tensor_ops.go | starcoder |
package mazes
import (
"bytes"
"image"
"image/color"
"image/draw"
"image/png"
"io"
"log"
"math/rand"
"time"
)
const cellSize = 10
type ContentsOfCell func(cell *Cell) string
func DefaultContentsOfCell(cell *Cell) string {
return " "
}
type Grid struct {
Random *rand.Rand
ContentsOfCell Conten... | mazes/grid.go | 0.618204 | 0.492066 | grid.go | starcoder |
package retry
import (
"fmt"
"net/http"
"strings"
"time"
)
// Func is a function with return error type that will be executed and evaluated by Executor
type Func func() error
// FuncHTTP is a function with return httpResponse and error(i.e: http status code). The httpResponse status code will be executed and eva... | executor.go | 0.621541 | 0.403332 | executor.go | starcoder |
package schedule
import "time"
const secondsPerDay int64 = 24 * 60 * 60
const firstWeekDay = secondsPerDay * 4
const secondsBeforeUnix = (1969*365 + 1969/4 - 1969/100 + 1969/400) * secondsPerDay
var daysPerMonth = [...]int{
0,
31,
31 + 28,
31 + 28 + 31,
31 + 28 + 31 + 30,
31 + 28 + 31 + 30 + 31,
31 + 28 + 31 ... | attuned_month.go | 0.662687 | 0.406391 | attuned_month.go | starcoder |
package yurit
import (
"bytes"
"errors"
"fmt"
)
type mp4mp4a map[string]interface{}
func processMP4AAtom(mp4aAtom Mp4Atom) (mp4mp4a, mp4esds, error) {
//mp4a atom is a sample description stored as a child of a sample
//description atom (stsd) and it contains channel and sample rate info and
//also likely has a... | mp4mp4a.go | 0.554953 | 0.556159 | mp4mp4a.go | starcoder |
package weather
import "time"
// DateTime represents a point in time specified in the response
type DateTime struct {
Name string `xml:"name,attr"` // Name is the title of what the DateTime object represents.
Zone string `xml:"zone,attr"` // Zone is the name of the timezone that the DateTime o... | forecast.go | 0.805364 | 0.458712 | forecast.go | starcoder |
package geombuilder
import geom "github.com/twpayne/go-geom"
const near0 = 1.0/256.0
const mnear0 = -near0
func isEq(a,b float64) bool {
c := a-b
return mnear0<c && c<near0
}
func isEqC(a,b geom.Coord) bool {
return isEq(a[0],b[0])||isEq(a[1],b[1])
}
func concat(coords ...[]geom.Coord) []float64 {
i := 0
for _... | geombuild/geombuilder.go | 0.713531 | 0.444685 | geombuilder.go | starcoder |
package ml
import (
"github.com/cpmech/gosl/fun"
"github.com/cpmech/gosl/io"
"github.com/cpmech/gosl/la"
"github.com/cpmech/gosl/plt"
"github.com/cpmech/gosl/utl"
)
// Plotter plots results from Machine Learning models
type Plotter struct {
// input
data *Data // data
mapper DataMapper // mapper
//... | ml/plotter.go | 0.591487 | 0.482673 | plotter.go | starcoder |
package address
import (
"crypto/rand"
"fmt"
"github.com/iotaledger/hive.go/crypto/ed25519"
"github.com/mr-tron/base58"
"golang.org/x/crypto/blake2b"
"github.com/iotaledger/hive.go/marshalutil"
)
// Version represents the version of the address. Different versions are associated to different signature schemes... | dapps/valuetransfers/packages/address/address.go | 0.848439 | 0.433682 | address.go | starcoder |
// Package cfg is an implementation of cfg(2) in Go: http://man.postnix.pw/purgatorio/2/cfg.
package cfg
import (
"bufio"
"errors"
"fmt"
"io"
"log"
"strings"
"unicode"
)
// Quotation specifies the output quoting mode
type Quotation int
const (
// Double quote output
Double Quotation = iota
// Single quote... | cfg.go | 0.712932 | 0.408749 | cfg.go | starcoder |
package stats
import (
"fmt"
"math"
"sort"
)
func MeanVariance(list []float64) (mean float64, variance float64) {
n := float64(len(list))
switch n {
case 0:
return math.NaN(), math.NaN()
case 1:
return list[0], math.NaN()
}
var sum1, sum2 float64
for _, x := range list {
sum1 += x
sum2 += x * x
}
... | gmath/stats/stats.go | 0.66769 | 0.428174 | stats.go | starcoder |
package semantic
import "github.com/influxdata/platform/query/ast"
type binarySignature struct {
operator ast.OperatorKind
left, right Kind
}
var binaryTypesLookup = map[binarySignature]Kind{
//---------------
// Math Operators
//---------------
{operator: ast.AdditionOperator, left: Int, right: Int}: ... | query/semantic/binary_types.go | 0.708918 | 0.748789 | binary_types.go | starcoder |
package util
import "math"
const (
// PositiveInfinity indicates value is positively infinite
PositiveInfinity int = iota
// NegativeInfinity indicates value is negatively infinite.
NegativeInfinity
// NaN not a number
NaN
// IsNumber is numerical value
IsNumber
)
// Numerical can be either an integer or a f... | util/float_parser.go | 0.658308 | 0.485905 | float_parser.go | starcoder |
package labradar
import (
"fmt"
"opgenorth.net/mylittlerangebook/pkg/util"
)
// BallisticCoefficient captures the ballistics data about a specific projectile.
type BallisticCoefficient struct {
DragModel string `json:"dragModel"`
Value float32 `json:"value"`
}
func (t BallisticCoefficient) String() string {... | code/cli/pkg/labradar/models.go | 0.847873 | 0.424651 | models.go | starcoder |
package main
import (
"os"
"fmt"
"sort"
"math/rand"
"image"
"image/png"
"image/color"
"time"
)
type Vector struct {
dim int
ones []int
}
func NewVector(dim int) Vector {
return Vector{dim, make([]int, 0)}
}
func (p Vector) Clone() Vector {
ones := make([]int, len(p.ones))
copy(ones, p.ones)
return Vect... | sparse.go | 0.68763 | 0.537527 | sparse.go | starcoder |
package windigo
type Point struct {
X, Y int
}
type TopLeft Point
type NexusType Point
type nexusType int
const (
nexusTopLeft nexusType = iota
nexusTopRight
nexusBottomLeft
nexusBottomRight
_
_
nexusLeftT
nexusRightT
nexusTopT
nexusBottomT
nexusCross
nexusNone
)
type WidthHeight struct {
W, H int
}
... | regions.go | 0.827201 | 0.442877 | regions.go | starcoder |
package main
import (
"fmt"
"reflect"
shmeh "shmensor/shmensor"
)
func main() {
table := []struct {
t shmeh.Tensor
desc string
}{
{col1, "Column Vector (1, 0)."},
{row1, "Row Vector (0, 1)."},
{mat1, "Matrix (1, 1)."},
{bivec1, "Bivector (2, 0.)"},
{shmeh.Eval(s1.U(""), x1.U("i").D("j"), x2.U("k... | demo.go | 0.580828 | 0.459986 | demo.go | starcoder |
package strings
// Nodes are managed by slice(vector).
const (
// assume words consisting of only lower case or upper case
_TRIE_CHAR_SIZE = 26
)
// Operate do something in a trie node while traversing automaton.
type Operate func(curNodeID int, c int)
// NewTrie returns a trie managing words starting from base c... | lib/strings/trie.go | 0.793146 | 0.521776 | trie.go | starcoder |
package quantize
import (
"github.com/fileformats/graphics/jt/codec"
"github.com/fileformats/graphics/jt/model"
"fmt"
)
// The Quantized Vertex Normal Array data collection contains the quantization data/representation for a set of
// vertex normals. Quantized Vertex Normal Array data collection is only present if... | jt/segments/quantize/QuantizedVertexNormalArray.go | 0.662796 | 0.647227 | QuantizedVertexNormalArray.go | starcoder |
package resolver
import (
"github.com/google/gapid/gapil/ast"
"github.com/google/gapid/gapil/semantic"
)
func unaryOp(rv *resolver, in *ast.UnaryOp) *semantic.UnaryOp {
out := &semantic.UnaryOp{AST: in}
out.Operator = in.Operator
out.Expression = expression(rv, in.Expression)
et := out.Expression.ExpressionTyp... | gapil/resolver/operator.go | 0.617859 | 0.444866 | operator.go | starcoder |
package continuous
import (
gsl "github.com/jtejido/ggsl"
"github.com/jtejido/ggsl/specfunc"
"github.com/jtejido/linear"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Weibull distribution
// https://en.wikipedia.org/wiki/Weibull_distribution
type Weibull struct {
scale, sha... | dist/continuous/weibull.go | 0.753104 | 0.448668 | weibull.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.