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 lmq
import (
"github.com/fiwippi/go-quantise/internal/quantisers"
"image"
"image/color"
)
const (
xMax = 255
xMin = 0
)
// Returns "m" greyscale colours to best recreate the colour palette of the original image
func QuantiseGreyscale(img image.Image, m int) color.Palette {
// Create the histogram
hist... | pkg/quantisers/lmq/lmq.go | 0.745861 | 0.41834 | lmq.go | starcoder |
package parser
import (
"fmt"
)
// TypeNode is an interface for different ways of creating new types or referring to existing ones
type TypeNode interface {
Node() // must also implement the Node interface
Type() string
String() string
Variadic() bool
SetName(string)
GetName() string
}
// SingleTypeNode refer... | compiler/parser/node_types.go | 0.679179 | 0.441553 | node_types.go | starcoder |
package typ
import (
"fmt"
"github.com/mb0/xelf/bfr"
)
// Kind is a bit-set describing a type. It represents all type information except reference names
// and type parameters. It is a handy implementation detail, but not part of the xelf specification.
type Kind uint64
func (Kind) Bits() map[string]int64 { retur... | typ/kind.go | 0.581184 | 0.51879 | kind.go | starcoder |
package action
import (
"sync/atomic"
"time"
"github.com/aamcrae/gpio"
)
const stepperQueueSize = 20 // Size of queue for requests
type msg struct {
speed float64 // RPM
steps int
sync chan bool
}
// Stepper represents a stepper motor.
// All actual stepping is done in a background goroutine, so requests c... | action/stepper.go | 0.67822 | 0.423875 | stepper.go | starcoder |
package iso20022
// Order to invest the investor's principal in an investment fund.
type SubscriptionOrder4 struct {
// Unique and unambiguous identifier for an order, as assigned by the instructing party.
OrderReference *Max35Text `xml:"OrdrRef"`
// Specifies the category of the investment fund order.
OrderType... | SubscriptionOrder4.go | 0.776284 | 0.434401 | SubscriptionOrder4.go | starcoder |
package string
import (
"bytes"
"fmt"
)
// EditDist computes distance between strings
// Levenshtein algorithm
func EditDist(a, b string) int {
len1, len2 := len(a), len(b)
if len1 < len2 {
return EditDist(b, a)
}
row1, row2 := make([]int, len2+1), make([]int, len2+1)
for i := 0; i < len2+1; i++ {
row2[i]... | string/string.go | 0.551091 | 0.431824 | string.go | starcoder |
package nn
import (
"fmt"
"math"
"sync"
)
type relu struct {
inputShape Shape
outputShape Shape
mask [][]bool
}
// ReLU is an activation function layer.
func ReLU() Layer {
return &relu{}
}
func (r *relu) Init(inputShape Shape, _ OptimizerFactory) error {
r.inputShape = inputShape
r.outputShape = i... | nn/activation.go | 0.656548 | 0.513729 | activation.go | starcoder |
package prayertime
import (
"fmt"
m "math"
"time"
)
const (
radToDeg = 180 / m.Pi
degToRad = m.Pi / 180
)
type coordinate struct {
longitude float64
latitude float64
zone float64
}
type Prayertime struct {
date time.Time
coordinate *coordinate
CalculationMethod int
DST ... | prayertime/prayertime.go | 0.765593 | 0.525125 | prayertime.go | starcoder |
package translator
import (
"fmt"
"strings"
)
/*
The definitive grammar guide on English to Gopherish translation:
1. If a word starts with a vowel letter, add prefix “g” to the word (ex. apple => gapple)
2. If a word starts with the consonant letters “xr”, add the prefix “ge” to the begging of the word.
Such word... | pkg/translator/translator.go | 0.661704 | 0.47792 | translator.go | starcoder |
package dag
import (
"fmt"
"sync"
"github.com/goombaio/orderedmap"
)
// DAG type implements a Directed Acyclic Graph data structure.
type DAG struct {
mu sync.Mutex
vertices orderedmap.OrderedMap
}
// NewDAG creates a new Directed Acyclic Graph instance.
func NewDAG() *DAG {
d := &DAG{
vertices: *ord... | dag.go | 0.845815 | 0.609263 | dag.go | starcoder |
package helper
import (
"regexp"
"time"
"github.com/onsi/gomega"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
// DevSession represents a session running `odo dev`
/*
It can be used in different ways:
# Starting a session for a series of tests and stopping the session after the tests:
This fo... | tests/helper/helper_dev.go | 0.588653 | 0.71049 | helper_dev.go | starcoder |
package schema
import (
"crypto/sha256"
"github.com/codenotary/immudb/embedded/htree"
"github.com/codenotary/immudb/embedded/store"
)
func TxTo(tx *store.Tx) *Tx {
entries := make([]*TxEntry, len(tx.Entries()))
for i, e := range tx.Entries() {
hValue := e.HVal()
entries[i] = &TxEntry{
Key: e.Key(),
... | pkg/api/schema/database_protoconv.go | 0.619817 | 0.401805 | database_protoconv.go | starcoder |
package breeze
import (
"github.com/pkg/errors"
"math"
"reflect"
)
// WriteFieldsFunc is a func interface of how to write all fields of a breeze message to the buffer.
type WriteFieldsFunc func(buf *Buffer)
// WriteElemFunc write map or array elements
type WriteElemFunc func(buf *Buffer)
// WriteBool write a boo... | breezeWriter.go | 0.553023 | 0.45847 | breezeWriter.go | starcoder |
package evaluator
import (
"github.com/manishmeganathan/tunalang/object"
"github.com/manishmeganathan/tunalang/syntaxtree"
)
// A function that evaluates a Syntax tree program into an evaluated object
func evalProgram(program *syntaxtree.Program, env *object.Environment) object.Object {
// Declare an object
var r... | evaluator/evaluators.go | 0.772144 | 0.583559 | evaluators.go | starcoder |
package evdb
import (
"time"
)
// TimeRange is a range of time with a specific step
type TimeRange struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
Step time.Duration `json:"step"`
}
// TimeRel is a relation between two time ranges
type TimeRel int
// TimeRel enum
const (
TimeRelNo... | timerange.go | 0.802826 | 0.445771 | timerange.go | starcoder |
package main
import (
"fmt"
"text/template"
)
type templateData struct {
Datetime string
System systemInfo
Tests []*Test
}
var (
rootTmpl *template.Template
)
func init() {
rootTmpl = template.New("")
template.Must(rootTmpl.New("results").Funcs(template.FuncMap{
"formatTimeUs": formatTimeUs,
"form... | template.go | 0.779154 | 0.778313 | template.go | starcoder |
package doltcore
import (
"errors"
"math"
"strconv"
"strings"
"github.com/google/uuid"
"github.com/liquidata-inc/dolt/go/store/types"
)
// StringToValue takes a string and a NomsKind and tries to convert the string to a noms Value.
func StringToValue(s string, kind types.NomsKind) (types.Value, error) {
if ... | go/libraries/doltcore/str_to_noms.go | 0.69451 | 0.450118 | str_to_noms.go | starcoder |
package index
import (
"bufio"
"bytes"
"encoding/binary"
"fmt"
"io"
"os"
"sync"
"github.com/ipld/go-storethehash/store/primary"
"github.com/ipld/go-storethehash/store/types"
)
/* An append-only log [`recordlist`]s.
The format of that append only log is:
```text
| Once | ... | store/index/index.go | 0.660829 | 0.499634 | index.go | starcoder |
package marketplace
import (
"sort"
"strings"
"time"
)
// Subscription is either an Annual or a Monthly subscription
type Subscription string
func (s Subscription) Abbrev() string {
if s == AnnualSubscription {
return "y"
}
if s == MonthlySubscription {
return "m"
}
return "?"
}
// AccountType is either... | marketplace/sales.go | 0.790247 | 0.496338 | sales.go | starcoder |
package cnns
import (
"fmt"
"github.com/LdDl/cnns/tensor"
"gonum.org/v1/gonum/mat"
)
// ReLULayer Rectified Linear Unit layer (activation: max(0, x))
/*
Oj - Input data
Ok - Output data
LocalDelta - Incoming gradients*weights (backpropagation)
*/
type ReLULayer struct {
Oj *mat.Dense
Ok *mat.... | relu_layer.go | 0.738858 | 0.419588 | relu_layer.go | starcoder |
package drawing
import (
"math"
)
// Matrix represents an affine transformation
type Matrix [6]float64
const (
epsilon = 1e-6
)
// Determinant compute the determinant of the matrix
func (tr Matrix) Determinant() float64 {
return tr[0]*tr[3] - tr[1]*tr[2]
}
// Transform applies the transformation matrix to point... | vendor/github.com/wcharczuk/go-chart/v2/drawing/matrix.go | 0.905795 | 0.838151 | matrix.go | starcoder |
package energy
import (
"fmt"
"os"
"sort"
pb "github.com/openthread/ot-ns/visualize/grpc/pb"
"github.com/simonlingoogle/go-simplelogger"
)
type EnergyAnalyser struct {
nodes map[int]*NodeEnergy
networkHistory []NetworkConsumption
energyHistoryByNodes [][]*pb.NodeEnergy
title ... | energy/core.go | 0.595257 | 0.412412 | core.go | starcoder |
package main
import (
"errors"
"math"
"math/rand"
)
type point struct {
x, y float32
}
type population struct {
nodes []point
current [][]int
currentFitnesses []float32
fittest []int
dnaLength int
crossoverProbability float32
mutationProbability flo... | nodepath.go | 0.550849 | 0.447279 | nodepath.go | starcoder |
package rgb8
// Conversion of natively non-D50 RGB colorspaces with D50 illuminator to CIE XYZ and back.
// Bradford adaptation was used to calculate D50 matrices from colorspaces' native illuminators.
// RGB values must be linear and in the nominal range [0, 255].
// XYZ values are usually in [0, 255] but may be ... | i8/rgb8/rgb_d50.go | 0.754373 | 0.425187 | rgb_d50.go | starcoder |
package main
import (
"log"
"regexp"
"strings"
redis "github.com/xuyu/goredis"
)
//Extract set expressions from the query (virtual index builders)
func extractSetExpressions(q string) []string {
re := regexp.MustCompile("\\[([^]]+)\\]")
return re.FindAllString(q, -1)
}
//Is token operator
func isOp(o string)... | queryparse.go | 0.536556 | 0.483892 | queryparse.go | starcoder |
package entity
import (
"github.com/lquesada/cavernal/model"
"github.com/lquesada/cavernal/lib/g3n/engine/math32"
)
type IEntity interface {
model.IDrawable
ITickable
Name() string
ShadowNode() model.INode
Colision() []*Cylinder
Radius() float32
OuterRadius() float32
ClimbRadius() float32
ClimbReach()... | entity/entity.go | 0.750553 | 0.481332 | entity.go | starcoder |
package container
import (
"fmt"
"math/rand"
"time"
)
/*
https://cp-algorithms.com/data_structures/treap.html
https://zh.wikipedia.org/wiki/%E6%A0%91%E5%A0%86
简述:
treap = tree + heap
其Node.Value符合tree(二叉查找树)的特性(左≤根≤右)
再给每个Node一个随机的权重(或称优先级),Node.randWeight 来使其姿态符合二叉堆的特性,所以保证了操作(期望)都是O(log(n))的
logN的证明:
不是特别“显然”,... | src/gostd/container/treap.go | 0.527803 | 0.588239 | treap.go | starcoder |
package main
import (
"errors"
"fmt"
)
//TreeNode data structure represents a typical binary tree
type TreeNode struct {
val int
left *TreeNode
right *TreeNode
}
func main() {
t := &TreeNode{val: 8}
t.Insert(1)
t.Insert(2)
t.Insert(3)
t.Insert(4)
t.Insert(5)
t.Insert(6)
t.Insert(7)
t.Find(11)
t... | binarysearchtree/binarysearchtree.go | 0.734881 | 0.616186 | binarysearchtree.go | starcoder |
package openapi
import "encoding/json"
// An OrderedMap is a set of key-value pairs that preserves the order in which
// items were added. It marshals to JSON as an object.
type OrderedMap struct {
kvs []KeyValue
}
// KeyValue associates a value with a key.
type KeyValue struct {
Key string
Value interface{}
}... | encoding/openapi/orderedmap.go | 0.679285 | 0.408572 | orderedmap.go | starcoder |
package shimesaba
import (
"fmt"
"log"
"math"
"time"
"github.com/mashiike/shimesaba/internal/timeutils"
)
// Metric handles aggregated Mackerel metrics
type Metric struct {
id string
values map[time.Time][]float64
aggregationInterval time.Duration
aggregationMethod func([]flo... | metric.go | 0.754644 | 0.420421 | metric.go | starcoder |
package aep
import (
"bytes"
"encoding/binary"
"fmt"
"strings"
"github.com/rioam2/rifx"
)
// PropertyTypeName enumerates the value/type of a property
type PropertyTypeName uint16
const (
// PropertyTypeBoolean denotes a boolean checkbox property
PropertyTypeBoolean PropertyTypeName = 0x04
// PropertyTypeOne... | property.go | 0.629547 | 0.432363 | property.go | starcoder |
package config
import (
"encoding/csv"
"fmt"
"io"
"os"
"strconv"
"github.com/pkg/errors"
"github.com/google/simhospital/pkg/ir"
"github.com/google/simhospital/pkg/sample"
)
// nilKey is a keyword to use in CSV files that are loaded with loadCSVWithFrequency.
// Rows for which all items (except the frequency... | pkg/config/csv.go | 0.658198 | 0.471041 | csv.go | starcoder |
package dxf
// AcadVersion represents the minimum version of AutoCAD that is expected to be able to read the file.
type AcadVersion int
const (
// Version1_0 corresponds to the value "MC0.0"
Version1_0 AcadVersion = iota
// Version1_2 corresponds to the value "AC1.2"
Version1_2
// Version1_40 corresponds to th... | acadVersion.go | 0.561816 | 0.521532 | acadVersion.go | starcoder |
Create 2d/3d panels.
*/
//-----------------------------------------------------------------------------
package obj
import "github.com/deadsy/sdfx/sdf"
//-----------------------------------------------------------------------------
/*
2D Panel with rounded corners and edge holes.
Note: The hole pattern is used t... | obj/panel.go | 0.776114 | 0.546738 | panel.go | starcoder |
package ent
import (
"context"
"errors"
"fmt"
"github.com/facebookincubator/ent/dialect/sql/sqlgraph"
"github.com/facebookincubator/ent/schema/field"
"github.com/google/uuid"
"github.com/minskylab/asclepius/ent/epidemiologicresults"
"github.com/minskylab/asclepius/ent/test"
)
// EpidemiologicResultsCreate i... | ent/epidemiologicresults_create.go | 0.509764 | 0.4016 | epidemiologicresults_create.go | starcoder |
package types
import (
"fmt"
"sort"
"time"
"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/x"
)
type sortBase struct {
values [][]Val // Each uid could have multiple values which we need to sort it by.
desc []bool // Sort orders for different values.
ul *pb.List
o []*pb.Face... | types/sort.go | 0.648021 | 0.40116 | sort.go | starcoder |
package tsm1
// bool encoding uses 1 bit per value. Each compressed byte slice contains a 1 byte header
// indicating the compression type, followed by a variable byte encoded length indicating
// how many booleans are packed in the slice. The remaining bytes contains 1 byte for every
// 8 boolean values encoded.
i... | tsdb/engine/tsm1/bool.go | 0.834508 | 0.554772 | bool.go | starcoder |
package main
import (
"fmt"
"math"
"math/rand"
"time"
)
// Fade function as defined by <NAME>. This will smooth out the result.
func Fade(t float64) float64 {
t = math.Abs(t)
return t * t * t * (t*(t*6-15) + 10)
}
// Generates a randomly arranged array of 512 values ranging between 0-255 inclusive
func Generat... | generator.go | 0.713432 | 0.474996 | generator.go | starcoder |
package binarytrie
import (
"net"
)
type NaiveTrie struct {
root *naiveTrieNode
mutable bool
}
type naiveTrieNode struct {
skipValue uint8
skippedBits uint32
branchingFactor uint8
parent *naiveTrieNode
children []*naiveTrieNode
value uint32
}
// NewNaiveTrie creates a... | pkg/binarytrie/naive.go | 0.617513 | 0.469034 | naive.go | starcoder |
package chart
import "fmt"
const (
// DefaultMACDPeriodPrimary is the long window.
DefaultMACDPeriodPrimary = 26
// DefaultMACDPeriodSecondary is the short window.
DefaultMACDPeriodSecondary = 12
// DefaultMACDSignalPeriod is the signal period to compute for the MACD.
DefaultMACDSignalPeriod = 9
)
// MACDSerie... | vendor/github.com/wcharczuk/go-chart/v2/macd_series.go | 0.803868 | 0.594904 | macd_series.go | starcoder |
package anns
import (
"math/big"
"sync"
"github.com/ncw/gmp"
"github.com/sachaservan/argsort"
"github.com/sachaservan/vec"
)
// DistanceMetric specifies the distance LSH should be sensitive to
type DistanceMetric int
const (
// HammingDistance specifies a hamming weight distance metric
HammingDistance Distan... | anns/lsh_nn.go | 0.716219 | 0.45048 | lsh_nn.go | starcoder |
package spogoto
import (
"math"
"strconv"
)
// NewFloatStack generates a float DataStack.
func NewFloatStack(floats []float64) *datastack {
elements := Elements{}
for _, v := range floats {
elements = append(elements, float64(v))
}
d := NewDataStack(elements, FunctionMap{}, func(str string) (Element, bool) {
... | float_stack.go | 0.601477 | 0.489381 | float_stack.go | starcoder |
package prism
// DecoratedString is a string with methods for coloring
type DecoratedString string
// InBlack returns this DecoratedString with black text
func (ds DecoratedString) InBlack() DecoratedString {
return InBlack(string(ds))
}
// InRed returns this DecoratedString with red text
func (ds DecoratedString) ... | ds.go | 0.911458 | 0.442516 | ds.go | starcoder |
package metadata
// https://media.kingston.com/support/downloads/MKP_521.6_SMART-DCP1000_attribute.pdf
// https://www.percona.com/blog/2017/02/09/using-nvme-command-line-tools-to-check-nvme-flash-health/
// https://nvmexpress.org/resources/nvm-express-technology-features/nvme-features-for-error-reporting-smart-log-pag... | webapp/backend/pkg/metadata/nvme_attribute_metadata.go | 0.753104 | 0.412767 | nvme_attribute_metadata.go | starcoder |
package spriter
import "fmt"
type Pixel int8
const (
PixelBorder = Pixel(-1)
PixelEmpty = iota
PixelEmptyOrBody = iota
PixelBorderOrBody = iota
PixelBody = iota
p_ = PixelBorder
p0 = PixelEmpty
p1 = PixelEmptyOrBody
p2 = PixelBorderOrBody
)
type Mask struct {
Bitmap []Pixel
Mas... | mask.go | 0.506347 | 0.49585 | mask.go | starcoder |
package config
const deploymentConfigSchema = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Deployment configuration",
"description": "URLs and instructions for how to install and run the application.",
"type": "object",
"definitions": {
"TargetPlatformsArray": {
"type": "array",
"... | pkg/launcher/config/schemas.go | 0.504639 | 0.42662 | schemas.go | starcoder |
package modular32
import (
mgl "github.com/go-gl/mathgl/mgl32"
)
// NewVec2Modulus creates a new 2d Vector Modulus
func NewVec2Modulus(vec mgl.Vec2) Vec2Modulus {
return Vec2Modulus{
x: NewModulus(vec[0]),
y: NewModulus(vec[1]),
}
}
// Vec2Modulus defines a modulus for 2d vectors
type Vec2Modulus struct {
x ... | modular32/vec.go | 0.854415 | 0.59131 | vec.go | starcoder |
package utl
import (
"math"
"math/rand"
"github.com/cpmech/gosl/chk"
)
// ParetoMin compares two vectors using Pareto's optimal criterion
// Note: minimum dominates (is better)
func ParetoMin(u, v []float64) (uDominates, vDominates bool) {
chk.IntAssert(len(u), len(v))
uHasAllLeq := true // all u values are l... | utl/pareto.go | 0.595493 | 0.434941 | pareto.go | starcoder |
package crypto
import (
"crypto/cipher"
"crypto/des"
"github.com/pkg/errors"
)
// Pad80 takes a []byte and a block size which must be a multiple of 8 and appends '80' and zero bytes until
// the length of the resulting []byte reaches a multiple of the block size and returns the padded []byte.
// If force is false... | internal/crypto/crypto.go | 0.654232 | 0.496277 | crypto.go | starcoder |
package scheme
import (
"fmt"
"strings"
)
func areEqual(a Object, b Object) bool {
if a == nil {
return true
}
if typeName(a) != typeName(b) {
return false
} else if areIdentical(a, b) {
return true
}
switch a.(type) {
case *Pair:
return areEqual(a.(*Pair).Car, b.(*Pair).Car) && areEqual(a.(*Pair).C... | scheme/misc.go | 0.625095 | 0.446796 | misc.go | starcoder |
package main
var schemas = `
{
"API": {
"createContainerLogistics": {
"description": "Create an asset. One argument, a JSON encoded event. Container No is required with zero or more writable properties. Establishes an initial asset state.",
"properties": {
"args": {
... | contracts/industry/LogisticsSplit.0.6/Container/schemas.go | 0.862901 | 0.60092 | schemas.go | starcoder |
package calc
import (
"math"
"strconv"
"strings"
"unicode"
)
var oprData = map[string]struct {
prec int
rAsoc bool // true = right // false = left
fx func(x, y float64) float64
}{
"^": {4, true, func(x, y float64) float64 { return math.Pow(x, y) }},
"*": {3, false, func(x, y float64) float64 { return x *... | calc/solver.go | 0.599368 | 0.57684 | solver.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"strconv"
"strings"
)
/*
--- Day 1: Report Repair ---
After saving Christmas five years in a row, you've decided to take a vacation at a nice resort on a tropical island. Surely, Christmas will go on without you.
The tropical island has its own currency and is entirely cas... | 2020/day-01/main.go | 0.532182 | 0.493042 | main.go | starcoder |
package sample
import (
"crypto/rand"
"encoding/binary"
"math/big"
)
// cdtTable consists of a precomputed table of values
// using which one can create a constant time half-Gaussian
// sampler with sigma = sqrt(1/2ln(2))
var cdtTable = [][2]uint64{{2200310400551559144, 3327841033070651387},
{7912151619254726620,... | sample/normal_cdt.go | 0.708011 | 0.402979 | normal_cdt.go | starcoder |
package tree
import (
"github.com/efreitasn/go-datas/graph"
"github.com/efreitasn/go-datas/linkedlist"
)
// Tree is a tree of ints.
type Tree struct {
g *graph.Graph
root int
}
// New create a tree of ints.
func New(root int) *Tree {
g := graph.New(true)
g.AddVertex(root)
return &Tree{
g,
root,
}
}
... | tree/tree.go | 0.823825 | 0.424054 | tree.go | starcoder |
package ent
import (
"context"
"errors"
"fmt"
"time"
"github.com/empiricaly/recruitment/internal/ent/project"
"github.com/empiricaly/recruitment/internal/ent/run"
"github.com/empiricaly/recruitment/internal/ent/steprun"
"github.com/empiricaly/recruitment/internal/ent/template"
"github.com/facebook/ent/diale... | internal/ent/run_create.go | 0.57678 | 0.434521 | run_create.go | starcoder |
package rotate
import (
"math"
"math/rand"
"github.com/paulwrubel/photolum/config/geometry"
"github.com/paulwrubel/photolum/config/geometry/primitive"
"github.com/paulwrubel/photolum/config/geometry/primitive/aabb"
"github.com/paulwrubel/photolum/config/shading/material"
)
// RotationZ is a primiti... | config/geometry/primitive/transform/rotate/rotatez.go | 0.825695 | 0.444444 | rotatez.go | starcoder |
package cnns
import (
"fmt"
"math/rand"
"github.com/LdDl/cnns/tensor"
"github.com/pkg/errors"
"gonum.org/v1/gonum/mat"
)
// FullyConnectedLayer FC is simple layer structure (so this layer can be used for simple neural networks like XOR problem)
/*
Oj - O{j}, activated output from previous layer for j-th neuron... | fully_connected_layer.go | 0.689306 | 0.563198 | fully_connected_layer.go | starcoder |
package packed
import "io"
const wordSize = 8
// Special case tags.
const (
zeroTag byte = 0x00
unpackedTag byte = 0xff
)
// Pack appends the packed version of src to dst and returns the
// resulting slice. len(src) must be a multiple of 8 or Pack panics.
func Pack(dst, src []byte) []byte {
if len(src)%word... | internal/packed/packed.go | 0.602412 | 0.408218 | packed.go | starcoder |
package accounting
import (
"encoding/json"
)
// AccountingFeatures Outlines the features that are supported by the external accounting system.
type AccountingFeatures struct {
CreateInvoice CreateInvoiceFeature `json:"createInvoice"`
ImportInvoice ImportInvoiceFeature `json:"importInvoice"`
// Indicates if sync... | generated/accounting/model_accounting_features.go | 0.758421 | 0.433862 | model_accounting_features.go | starcoder |
package main
import "github.com/jakecoffman/cp/examples"
import . "github.com/jakecoffman/cp"
func main() {
space := NewSpace()
body1 := addBar(space, Vector{-240, 160}, Vector{-160, 80}, 1)
body2 := addBar(space, Vector{-160, 80}, Vector{-80, 160}, 1)
body3 := addBar(space, Vector{0, 160}, Vector{80, 0}, 1)
bo... | examples/springies/springies.go | 0.651687 | 0.416797 | springies.go | starcoder |
package edge_compute
import (
"encoding/json"
)
// V1MatchExpression An expression to match selectors against a set of values
type V1MatchExpression struct {
// The name of the selector to perform a match against
Key *string `json:"key,omitempty"`
// The operation to perform to match a selector Valid values are ... | pkg/edge_compute/model_v1_match_expression.go | 0.809878 | 0.478163 | model_v1_match_expression.go | starcoder |
package fauxgl
import (
"fmt"
"image/color"
"math"
"strings"
)
var (
Discard = Color{}
Transparent = Color{}
Black = Color{0, 0, 0, 1}
White = Color{1, 1, 1, 1}
)
type Color struct {
R, G, B, A float64
}
func Gray(x float64) Color {
return Color{x, x, x, 1}
}
func MakeColor(c color.Color)... | color.go | 0.84124 | 0.401981 | color.go | starcoder |
package assert
import (
"encoding/json"
"testing"
"github.com/google/go-cmp/cmp"
)
func JsonObjResponseMatchExpected(t *testing.T, expected interface{}, jsonResponse []byte) {
t.Run("JsonObjResponseMatchExpected", func(t *testing.T) {
response := make(map[string]interface{})
if err := json.Unmarshal(jsonRes... | service/src/assert/assertions.go | 0.615435 | 0.552057 | assertions.go | starcoder |
package nifi
import (
"encoding/json"
)
// VersionedFlowCoordinates struct for VersionedFlowCoordinates
type VersionedFlowCoordinates struct {
// The URL of the Flow Registry that contains the flow
RegistryUrl *string `json:"registryUrl,omitempty"`
// The UUID of the bucket that the flow resides in
BucketId *st... | model_versioned_flow_coordinates.go | 0.770292 | 0.427456 | model_versioned_flow_coordinates.go | starcoder |
package finnhub
import (
"encoding/json"
)
// EarningResult struct for EarningResult
type EarningResult struct {
// Actual earning result.
Actual *float32 `json:"actual,omitempty"`
// Estimated earning.
Estimate *float32 `json:"estimate,omitempty"`
// Surprise - The difference between actual and estimate.
Sur... | model_earning_result.go | 0.785103 | 0.411643 | model_earning_result.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"math"
"os"
"strconv"
"strings"
)
type Coordinate struct {
X, Y, Z int
}
type Position Coordinate
type Velocity Coordinate
type Acceleration Coordinate
type Particle struct {
Position
Velocity
Acceleration
}
func (self *Particle) Step() *Particle {
velocity := Velo... | 20/main.go | 0.577019 | 0.518424 | main.go | starcoder |
package collections
import (
"context"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
type (
Iterator interface {
HasNext() bool
Next() (value core.Value, key core.Value, err error)
}
Iterable interface {
Iterate() Iterator
}
IterableExpression inte... | pkg/runtime/collections/iterator.go | 0.663342 | 0.421314 | iterator.go | starcoder |
package csmt
import (
"fmt"
"github.com/phoreproject/synapse/chainhash"
)
// Compact Sparse Merkle Trees
// Paper: https://eprint.iacr.org/2018/955.pdf
// Key is the key type of a CSMT
type Key = chainhash.Hash
// Hash is the hash type of a CSMT
type Hash = Key
// NodeHashFunction computes the hash for the chil... | csmt/csmt.go | 0.799912 | 0.441492 | csmt.go | starcoder |
package common
import (
"fmt"
"math/big"
"math/rand"
"reflect"
"github.com/ethereum/go-ethereum/common/hexutil"
)
const (
HashLength = 32
AddressLength = 20
)
type (
// Hash represents the 32 byte Keccak256 hash of arbitrary data.
Hash [HashLength]byte
// Address represents the 20 byte address of an ... | vendor/github.com/ethereum/go-ethereum/common/types.go | 0.802942 | 0.49408 | types.go | starcoder |
package dtruncate
import (
"github.com/lawrencewoodman/ddataset"
"github.com/lawrencewoodman/ddataset/internal"
)
// DTruncate represents a truncated Dataset
type DTruncate struct {
dataset ddataset.Dataset
numRecords int64
isReleased bool
}
// DTruncateConn represents a connection to a DTruncate Dataset
typ... | dtruncate/dtruncate.go | 0.744842 | 0.496216 | dtruncate.go | starcoder |
package rgb8
// Conversion of different RGB colorspaces with their native illuminators (reference whites) to CIE XYZ scaled to 256 and back.
// RGB values must be linear and in the nominal range [0, 255].
// XYZ values are usually in [0, 1e9] but may slightly outside.
// To get quick and dirty XYZ approximations, ... | i8/rgb8/rgb.go | 0.72086 | 0.441011 | rgb.go | starcoder |
package batchnorm
import (
"encoding/gob"
"github.com/nlpodyssey/spago/ag"
"github.com/nlpodyssey/spago/mat"
"github.com/nlpodyssey/spago/nn"
)
var _ nn.Model[float32] = &Model[float32]{}
// Model contains the serializable parameters.
type Model[T mat.DType] struct {
nn.BaseModel[T]
W nn.Param[T] `spa... | nn/normalization/batchnorm/batchnorm.go | 0.865295 | 0.602471 | batchnorm.go | starcoder |
package mcs
import "mcs/games/samegame"
// (╯°□°)╯︵ ┻━┻ poor mans's generic:
// GameState can be anything that describes accurately the state of a game.
// In samegame it's a board.
type GameState samegame.State
// Clone returns a memory-independent copy.
func (g GameState) Clone() GameState {
return GameState(sa... | pkg/mcs/iface.go | 0.830147 | 0.713054 | iface.go | starcoder |
package hindley_milner
import "fmt"
type FunctionType struct {
a, b Type
context CodeContext
}
func NewFnType(ts ...Type) *FunctionType {
if len(ts) < 2 {
panic("Expected at least 2 input types")
}
retVal := borrowFnType()
retVal.a = ts[0]
if len(ts) > 2 {
retVal.b = NewFnType(ts[1:]...)
} else {
... | src/type_checker/hindley_milner/functionType.go | 0.518302 | 0.467818 | functionType.go | starcoder |
package ast
import (
"fmt"
"regexp"
"time"
"github.com/influxdata/influxql"
)
// NodeTypeOf is used by all Node to identify the node duration Marshal and Unmarshal
const NodeTypeOf = "typeOf"
// JSONNode is the intermediate type between Node and JSON serialization
type JSONNode map[string]interface{}
// Type a... | tick/ast/json.go | 0.740644 | 0.567637 | json.go | starcoder |
package contracts
import (
"context"
"reflect"
"testing"
"github.com/adamluzsi/frameless"
"github.com/adamluzsi/frameless/contracts/assert"
"github.com/adamluzsi/frameless/extid"
"github.com/adamluzsi/testcase"
"github.com/stretchr/testify/require"
)
type Publisher struct {
T
Subject func(testing.TB... | contracts/Publisher.go | 0.617167 | 0.592961 | Publisher.go | starcoder |
package slice
import "reflect"
// Interface type for an iterator
type Iterator interface {
// Returns whether there is a next element
HasNext() bool
// Goes to the next element, then returns false if the end of the slice
// was reached
Next() bool
// Returns whether there is a previous element
HasPrev() bool... | slice.go | 0.846229 | 0.448487 | slice.go | starcoder |
package checks
import (
"github.com/pkg/errors"
"time"
)
// Status represents the status of a Consul health check match.
type Status string
const (
// StatusPassing represents a Consul health check status match that is passing.
StatusPassing Status = "passing"
// StatusWarning represents a Consul check status... | checks/check.go | 0.712232 | 0.529628 | check.go | starcoder |
package sort
import "sync"
// Sort the given `slice` in-place (non-decreasing order) using the merge sort algorithm
// Runs in O(NlgN) time with O(N) memory
func MergeSort(slice []int) {
if len(slice) < 2 {
return
}
q := (len(slice) + 1) / 2
left, right := slice[:q], slice[q:]
MergeSort(left)
MergeSo... | Algorithms/Sort/go/mergesort.go | 0.801897 | 0.564639 | mergesort.go | starcoder |
package formatters
import (
"fmt"
"github.com/kdelwat/recipaliser"
"github.com/olekukonko/tablewriter"
"os"
)
type ingredientField struct {
field string
value float64
}
func selectIngredientFields(ingredient recipaliser.Ingredient, selections ...string) []ingredientField {
selectionSets := map[string][]ingred... | formatters/print_ingredients.go | 0.597256 | 0.480296 | print_ingredients.go | starcoder |
package carving
import (
"log"
"math"
"alvin.com/GoCarver/geom"
g "alvin.com/GoCarver/geom"
"alvin.com/GoCarver/hmap"
)
type oneRun interface {
isDone() bool
setEnableCarvingAtFulldepth(enable bool)
doOnePass(delta float64)
}
var maxDepth = 0.0
// carvingRun represent a single rectilinear run of the carvin... | carving/carving_run.go | 0.686055 | 0.542863 | carving_run.go | starcoder |
package api
func init() {
Swagger.Add("auth_tokens_tokens", `{
"swagger": "2.0",
"info": {
"title": "components/automate-gateway/api/auth/tokens/tokens.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"app... | components/automate-gateway/api/auth_tokens_tokens.pb.swagger.go | 0.623721 | 0.413181 | auth_tokens_tokens.pb.swagger.go | starcoder |
package copier
import (
"fmt"
"reflect"
)
func Copy(toValue interface{}, fromValue interface{}) (err error) {
var (
isSlice bool
fromType reflect.Type
isFromPtr bool
toType reflect.Type
amount int
)
var accumulatedError error
from := reflect.Indirect(reflect.ValueOf(fromValue))
to := refle... | copier.go | 0.531939 | 0.503357 | copier.go | starcoder |
package utils
import (
"fmt"
"time"
)
// TimeSecondAt returns the result of rounding t down to the nearest multiple of a second
func TimeSecondAt(t time.Time) time.Time {
return t.Local().Truncate(time.Second)
}
// TimeMinuteAt returns the result of rounding t down to the nearest multiple of a minute
func TimeMin... | utils/datetime.go | 0.844697 | 0.799403 | datetime.go | starcoder |
package main
// MapToInt is a right-bias mapping function and an alias for MapRightToInt
func (e *EitherStringOrString) MapToInt(f func(string) int) *EitherStringOrInt {
if e.isLeft {
return &EitherStringOrInt{
left: e.left,
isLeft: true,
}
}
return &EitherStringOrInt{
right: f(e.right),
isLeft: f... | examples/gen_either_compose_1.go | 0.820541 | 0.556821 | gen_either_compose_1.go | starcoder |
package geometry
import (
"fmt"
"math"
)
func Degree2Radian(degree float64) float64 { return math.Pi * degree / 180 }
func Radian2Degree(radian float64) float64 { return radian * 180 / math.Pi }
type Point complex128
func P(x, y float64) Point { return Point(complex(x, y)) }
func Float(f float64) Point { return ... | math/geometry/geometry.go | 0.770983 | 0.643343 | geometry.go | starcoder |
package lz77
import (
"bytes"
"fmt"
"log"
)
// Compress takes a slice of bytes and returns a compressed version of
// it. Compression is done in 4096 byte blocks for historical reasons.
func Compress(data []byte) ([]byte, error) {
// Is our input less than one block? If so just compress it and be
// done. No nee... | lz77/lz77.go | 0.647241 | 0.470615 | lz77.go | starcoder |
package unit
import (
"math"
"github.com/brettbuddin/shaden/dsp"
)
func newSlope(io *IO, c Config) (*Unit, error) {
return NewUnit(io, &slope{
state: &slopeState{
lastTrigger: -1,
},
stateFunc: slopeIdle,
trigger: io.NewIn("trigger", dsp.Float64(-1)),
gate: io.NewIn("gate", dsp.Float64(-1)),
... | unit/slope.go | 0.720368 | 0.46035 | slope.go | starcoder |
package geom
import (
"github.com/ctessum/geom/proj"
)
// Transform shifts the coordinates of p according to t.
func (p Point) Transform(t proj.Transformer) (Geom, error) {
if t == nil {
return p, nil
}
var err error
p2 := Point{}
p2.X, p2.Y, err = t(p.X, p.Y)
return p2, err
}
// Transform shifts the coordi... | transform.go | 0.759761 | 0.452354 | transform.go | starcoder |
package tda
import (
"image"
"sort"
)
// Persistence constructs object persistence trajectories for an
// image.
type Persistence struct {
// The dimensions of the image
rows int
cols int
// The current step, 1 plus the number of times that Next was
// called.
step int
// The persistence trajectories
tra... | persistence.go | 0.691706 | 0.563438 | persistence.go | starcoder |
package cartridge
// MBC1 represents memory bank controller for MBC1 type.
type MBC1 struct {
rom []byte
romBankNumber byte
ram []byte
ramBankNumber byte
romBanking bool
ramEnabled bool
}
// NewMBC1 is a constructor for MBC1 type memory banking controller.
func NewMBC1(rom []byte) *MBC1 {
... | pkg/cartridge/mbc1.go | 0.669961 | 0.457076 | mbc1.go | starcoder |
package helper
import (
"errors"
"github.com/guregu/null"
"strconv"
)
// Convert the val int a float64, return value and null/nill status
func ConvertToFloat64(val interface{}, nullable bool) (float64, bool, error) {
if nullable && val == nil {
return 0, true, nil
}
switch v := val.(type) {
case null.String... | helper/Conversion.go | 0.684264 | 0.421552 | Conversion.go | starcoder |
package pflag
import (
"fmt"
"strconv"
)
// optional interface to indicate boolean flags that can be
// supplied without "=value" text
type boolFlag interface {
Value
IsBoolFlag() bool
}
// -- bool Value
type boolValue bool
func newBoolValue(val bool, p *bool) *boolValue {
*p = val
return (*boolValue)(p)
}
f... | Godeps/_workspace/src/github.com/spf13/pflag/bool.go | 0.755005 | 0.404625 | bool.go | starcoder |
package meta
// ConditionStatus represents a condition's status.
type ConditionStatus string
// These are valid condition statuses. "ConditionTrue" means a resource is in
// the condition; "ConditionFalse" means a resource is not in the condition;
// "ConditionUnknown" means kubernetes can't decide if a resource is i... | internal/apis/meta/types.go | 0.714728 | 0.437703 | types.go | starcoder |
package v1beta1
func (DataVolume) SwaggerDoc() map[string]string {
return map[string]string{
"": "DataVolume is an abstraction on top of PersistentVolumeClaims to allow easy population of those PersistentVolumeClaims with relation to VirtualMachines\n+genclient\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg... | pkg/apis/core/v1beta1/types_swagger_generated.go | 0.777596 | 0.422803 | types_swagger_generated.go | starcoder |
package ring
import (
"encoding/binary"
"errors"
"math/bits"
"github.com/tuneinsight/lattigo/v3/utils"
)
// Poly is the structure that contains the coefficients of a polynomial.
type Poly struct {
Coeffs [][]uint64 // Coefficients in CRT representation
IsNTT bool
IsMForm bool
}
// NewPoly creates a new po... | ring/ring_poly.go | 0.800419 | 0.562477 | ring_poly.go | starcoder |
package untrusted_deserialization
import (
"github.com/threagile/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "untrusted-deserialization",
Title: "Untrusted Deserialization",
Description: "When a technical asset accepts data in a specific serialized form (like Java... | risks/built-in/untrusted-deserialization/untrusted-deserialization-rule.go | 0.743168 | 0.451387 | untrusted-deserialization-rule.go | starcoder |
package value
import (
"errors"
"strings"
"github.com/mithrandie/ternary"
)
type ComparisonResult int
const (
IsEqual ComparisonResult = iota
IsBoolEqual
IsNotEqual
IsLess
IsGreater
IsIncommensurable
)
var comparisonResultLiterals = map[ComparisonResult]string{
IsEqual: "IsEqual",
IsBoolEqual:... | lib/value/comparison.go | 0.60778 | 0.517266 | comparison.go | starcoder |
package types
import (
"encoding/binary"
"fmt"
"regexp"
"strings"
"sync"
)
// BitArray is a thread-safe implementation of a bit array.
type BitArray struct {
mtx sync.Mutex
Bits uint `json:"bits"` // NOTE: persisted via reflect, must be exported
Elems []uint64 `json:"elems"` // NOTE: persisted via ref... | core/types/bitarray.go | 0.690037 | 0.413714 | bitarray.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.