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 sheetfile
import (
"github.com/fourstring/sheetfs/master/config"
"github.com/fourstring/sheetfs/master/model"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
/*
Chunk
Represent a fixed-size block of data stored on some DataNode.
The size of a Chunk is given by config.BytesPerChunk.
A Version is maintained by Mast... | master/sheetfile/chunk.go | 0.61832 | 0.540136 | chunk.go | starcoder |
package datadog
import (
"encoding/json"
)
// SLOBulkDeleteResponseData An array of service level objective objects.
type SLOBulkDeleteResponseData struct {
// An array of service level objective object IDs that indicates which objects that were completely deleted.
Deleted *[]string `json:"deleted,omitempty"`
//... | api/v1/datadog/model_slo_bulk_delete_response_data.go | 0.736211 | 0.406332 | model_slo_bulk_delete_response_data.go | starcoder |
package types
import (
"errors"
"fmt"
"math/rand"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// Has check if an input is between double weight range
func (wr DoubleWeightRange) Has(number sdk.Dec) bool {
return wr.Lower.GTE(number) && wr.Upper.LTE(number)
}... | database/types/recipe_weight_table.go | 0.743354 | 0.495484 | recipe_weight_table.go | starcoder |
package mat
import (
"github.com/angelsolaorbaiceta/inkmath/vec"
)
// A SparseMat is a matrix where the zeroes aren't stored.
type SparseMat struct {
rows, cols int
data map[int]map[int]float64
}
// MakeSquareSparse creates a new square sparse matrix with the given number of rows and columns.
func MakeSquar... | mat/sparse_matrix.go | 0.872619 | 0.796094 | sparse_matrix.go | starcoder |
package document
import (
"bytes"
"strings"
"time"
)
type operator uint8
const (
operatorEq operator = iota + 1
operatorGt
operatorGte
operatorLt
operatorLte
)
func (op operator) String() string {
switch op {
case operatorEq:
return "="
case operatorGt:
return ">"
case operatorGte:
return ">="
ca... | document/compare.go | 0.743354 | 0.52007 | compare.go | starcoder |
package world
import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/go-gl/mathgl/mgl64"
"math"
)
// blockPosFromNBT returns a position from the X, Y and Z components stored in the NBT data map passed. The
// map is assumed to have an 'x', 'y' and 'z' key.
//noinspection GoCommentLeadingSpace
func blo... | server/world/position.go | 0.820649 | 0.45532 | position.go | starcoder |
package plaid
import (
"encoding/json"
)
// AccountAssets struct for AccountAssets
type AccountAssets struct {
// Plaid’s unique identifier for the account. This value will not change unless Plaid can't reconcile the account with the data returned by the financial institution. This may occur, for example, when the... | plaid/model_account_assets.go | 0.792865 | 0.51251 | model_account_assets.go | starcoder |
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test that we restrict inlining into very large functions.
// See issue #26546.
package foo
func small(a []int) int { // ERROR "can inline small as:.*" "sm... | test/inline_big.go | 0.532547 | 0.44553 | inline_big.go | starcoder |
package datasets
import (
"math"
"math/rand"
"runtime"
"sort"
"github.com/pa-m/sklearn/base"
"github.com/pa-m/sklearn/preprocessing"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/stat/distmv"
)
// MakeRegression Generate a random regression problem
// n_samples : int, optional (de... | datasets/samples_generator.go | 0.590307 | 0.484868 | samples_generator.go | starcoder |
package dicom
import (
"bytes"
"compress/flate"
"fmt"
"io"
)
// DataElementIterator represents an iterator over a DataSet's DataElements
type DataElementIterator interface {
// Next returns the next DataElement in the DataSet. If there is no next DataElement, the
// error io.EOF is returned. In Addition, if an... | dicom/iterator.go | 0.76454 | 0.412116 | iterator.go | starcoder |
package main
import (
"log"
)
func parseFlashMap(data []string) HeightMap {
heightMap := HeightMap{[][]int{}}
for _, line := range data {
energies := []int{}
for _, energy := range line {
energies = append(energies, int(energy-'0'))
}
heightMap.points = append(heightMap.points, energies)
}
return h... | 2021/11.go | 0.577495 | 0.429489 | 11.go | starcoder |
package coinharness
import (
"fmt"
"github.com/jfixby/pin"
"github.com/jfixby/pin/commandline"
"strconv"
"strings"
)
// DeploySimpleChain defines harness setup sequence for this package:
// 1. obtains a new mining wallet address
// 2. restart harness node and wallet with the new mining address
// 3. builds a new... | simplechainbuilder.go | 0.529507 | 0.433742 | simplechainbuilder.go | starcoder |
package gamescene
import (
"image"
"image/color"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/ebitenutil"
"github.com/hajimehoshi/gopherwalk/internal/scene"
)
type Dir int
const (
DirLeft Dir = iota
DirRight
DirUp
DirDown
)
const (
tileWidth = 16
tileHeight = 16
)
func shift(area i... | internal/gamescene/object.go | 0.621541 | 0.427337 | object.go | starcoder |
package grouping
import (
"fmt"
"log"
)
/*
* grouping implements an algorithm that grouping data points that are practically a rank and an
* associated value. In this software package, the value is the amount of data
* that a rank is sending or receiving.
* The grouping algorithm is quite simple:
* - We comp... | tools/internal/pkg/grouping/grouping.go | 0.692122 | 0.610831 | grouping.go | starcoder |
package sqlx
import (
"fmt"
"reflect"
"strings"
"time"
)
type Updater struct {
Where interface{}
Updater interface{}
}
func (u *Updater) TableName() string {
if u.Updater == nil {
return ""
}
if table, ok := u.Updater.(Table); ok && len(table.TableName()) > 0 {
return table.TableName()
}
if t := r... | updater.go | 0.532182 | 0.403831 | updater.go | starcoder |
package api
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderMainPage() string {
figs := A{
"FigHierarchy": RenderFigurePngSvg(
"Virtual anchor hierarchy, depicting elements attached to some of the anchors.", "hierarchy", "600px"),
"FigResidence": RenderFigurePngSvg(
"Except for... | gocircuit.org/api/api.go | 0.80525 | 0.755502 | api.go | starcoder |
package Set1
func hexToBase64(hexString string) string {
return byteArrayToBase64(hexToByteArray(hexString))
}
func hexToByteArray(hexString string) []byte {
bytes := make([]byte, len(hexString)/2)
hexCharToByte := map[byte]byte{
'0': 0,
'1': 1,
'2': 2,
'3': 3,
'4': 4,
'5': 5,
'6': 6,
'7': 7,
'8... | Set1/Chall1.go | 0.72526 | 0.46563 | Chall1.go | starcoder |
package model
import (
"bytes"
"strings"
"time"
"github.com/d3ce1t/areyouin-server/api"
"github.com/d3ce1t/areyouin-server/utils"
)
type Event struct {
id int64
authorID int64
authorName string
description string
pictureDigest []byte
createdDate time.Time // Seconds precision
modif... | model/event.go | 0.621541 | 0.402862 | event.go | starcoder |
package dateparser
import (
"time"
"strings"
)
type HandleFn func(d *Date, ts []*Token) bool
type Pattern struct {
children []*Pattern
Matchers []*Matcher
HandleFn HandleFn
}
func NewPattern() *Pattern {
return &Pattern{}
}
func (p *Pattern) Add() *Pattern {
if p.children == nil {
... | patterns.go | 0.576184 | 0.417628 | patterns.go | starcoder |
package findfirstandlastpositionofelementinsortedarray
// binary search
// time complexity: O(logn)
// space complexity: O(1)
func searchRange(nums []int, target int) []int {
lowerIndex := firstOccurance(nums, target)
first := -1
if lowerIndex != len(nums) && target == nums[lowerIndex] {
first = lowerIndex
}
... | src/0034_find_first_and_last_position_of_element_in_sorted_array/find_first_and_last_position_of_element_in_sorted_array.go | 0.513425 | 0.437223 | find_first_and_last_position_of_element_in_sorted_array.go | starcoder |
package value
import (
"errors"
"fmt"
"reflect"
"time"
"google.golang.org/protobuf/types/known/timestamppb"
)
var errNotSlice = errors.New("not a slice type")
var errUnsupportedSliceType = errors.New("unsupported slice type")
// getTypeOfSlice returns the type of the elements of the slice
func getTypeOfSlice(i... | types/value/valueBuilder.go | 0.610453 | 0.423696 | valueBuilder.go | starcoder |
package mercury
import (
"path/filepath"
"strings"
)
// NamespaceSpec implements a parsed namespace search
type NamespaceSpec interface {
Type() string
Value() string
String() string
Raw() string
Match(string) bool
}
// Namespace Spec types
const (
TypeNamespaceNode = "node"
TypeNamespaceStar = "star"
Ty... | mercury/search.go | 0.744563 | 0.512632 | search.go | starcoder |
package sandbox
import (
"encoding/json"
)
// SandboxInsertBeamStatsRequest struct for SandboxInsertBeamStatsRequest
type SandboxInsertBeamStatsRequest struct {
BeamStatsMap *SandboxInsertBeamStatsRequestBeamStatsMap `json:"beamStatsMap,omitempty"`
// UNIX time (in milliseconds)
Unixtime *int64 `json:"unixtime,o... | openapi/sandbox/model_sandbox_insert_beam_stats_request.go | 0.705582 | 0.50708 | model_sandbox_insert_beam_stats_request.go | starcoder |
package sweetiebot
import (
"fmt"
"strings"
"github.com/bwmarrin/discordgo"
)
type GroupsModule struct {
}
func (w *GroupsModule) Name() string {
return "Groups"
}
func (w *GroupsModule) Register(info *GuildInfo) {}
func (w *GroupsModule) Commands() []Command {
return []Command{
&AddGroupCommand{},
&Join... | sweetiebot/groups_command.go | 0.61659 | 0.429609 | groups_command.go | starcoder |
package list
const ListMapToParamFunctions = `
//-------------------------------------------------------------------------------------------------
// List:MapTo[{{.TypeParameter}}]
{{if .TypeParameter.IsBasic}}
// MapTo{{.TypeParameter.LongName}} transforms {{.TName}}List to []{{.TypeParameter.Name}}.
func (list {{.T... | internal/list/mapToT.go | 0.751375 | 0.61855 | mapToT.go | starcoder |
package pathThroughMap
import (
"fmt"
e "github.com/daniloanp/IA/environment"
"math"
)
var currentDistance float64
//The math definition of distance
func distanceBetweenTwoPoints(p1, p2 e.Point) float64 {
var (
dX = float64(p1.Row - p2.Row)
dY = float64(p1.Column - p2.Column)
distance = math.Sq... | pathThroughMap/aStar.go | 0.766731 | 0.541227 | aStar.go | starcoder |
package gofft
import (
"math"
"math/bits"
)
// IsPow2 returns true if N is a perfect power of 2 (1, 2, 4, 8, ...) and false otherwise.
// Algorithm from: https://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
func IsPow2(N int) bool {
if N == 0 {
return false
}
return (uint64(N) & uint64(N-1)... | utils.go | 0.808786 | 0.592283 | utils.go | starcoder |
package compositor
import (
"github.com/mattkimber/cargopositor/internal/utils"
"github.com/mattkimber/gandalf/geometry"
"github.com/mattkimber/gandalf/magica"
"log"
"math"
"strings"
)
func getBounds(v *magica.VoxelObject, ignoreMask bool) geometry.Bounds {
min := geometry.Point{X: v.Size.X, Y: v.Size.Y, Z: v... | internal/compositor/compositor.go | 0.754373 | 0.540681 | compositor.go | starcoder |
package poc
import (
"encoding/binary"
"math/big"
"github.com/massnetorg/mass-core/poc/chiapos"
"github.com/massnetorg/mass-core/poc/pocutil"
)
func ChiaPlotSize(k int) uint64 {
return uint64(2*k+1) * (uint64(1) << (uint(k) - 1))
}
type ChiaProof struct {
pos *chiapos.ProofOfSpace
}
func NewChiaProof(pos *ch... | poc/proof_chia.go | 0.6508 | 0.481393 | proof_chia.go | starcoder |
package diff
import (
"fmt"
"strings"
"github.com/circl-dev/spec"
)
// CompareEnums returns added, deleted enum values
func CompareEnums(left, right []interface{}) []TypeDiff {
diffs := []TypeDiff{}
leftStrs := []string{}
rightStrs := []string{}
for _, eachLeft := range left {
leftStrs = append(leftStrs, f... | cmd/swagger/commands/diff/checks.go | 0.639849 | 0.439988 | checks.go | starcoder |
package rsmt2d
import (
"errors"
"math"
)
// dataSquare stores all data for an original data square (ODS) or extended
// data square (EDS). Data is duplicated in both row-major and column-major
// order in order to be able to provide zero-allocation column slices.
type dataSquare struct {
squareRow [][][]byte /... | datasquare.go | 0.712032 | 0.51013 | datasquare.go | starcoder |
package caf
import (
"encoding/binary"
"fmt"
"io"
"time"
)
type AudioDescChunk struct {
}
/*
Decoder
CAF files begin with a file header, which identifies the file type and the CAF version,
followed by a series of chunks. A chunk consists of a header, which defines the type of the chunk and
indicates the size of ... | caf/decoder.go | 0.683736 | 0.745838 | decoder.go | starcoder |
package main
import (
"fmt"
"strings"
"github.com/andreaskoch/togglapi/date"
"github.com/andreaskoch/togglcsv/toggl"
)
// The TimeRecordMapper interface provides functions for mapping CSV records to time records and vice versa.
type TimeRecordMapper interface {
// GetTimeRecords returns a list of time records f... | csvmapper.go | 0.692954 | 0.470311 | csvmapper.go | starcoder |
package time
import (
"errors"
"sync"
"time"
)
// Ceil returns the result of rounding t up to a multiple of d (since the zero time).
// If d <= 0, Ceil returns t unchanged.
func Ceil(t time.Time, d time.Duration) time.Time {
if d <= 0 {
return t
}
return t.Add(d).Truncate(d)
}
// Prev returns the nearest mul... | pkg/time/multiple.go | 0.775307 | 0.45847 | multiple.go | starcoder |
package hbook
import (
"errors"
"sort"
)
// Indices for the under- and over-flow 1-dim bins.
const (
UnderflowBin = -1
OverflowBin = -2
)
var (
errInvalidXAxis = errors.New("hbook: invalid X-axis limits")
errEmptyXAxis = errors.New("hbook: X-axis with zero bins")
errShortXAxis = errors.New("hbook:... | hbook/binning1d.go | 0.62601 | 0.473109 | binning1d.go | starcoder |
package linearModel
import (
"fmt"
"log"
"math"
"runtime"
// use dot import for lisibility
//"github.com/gcla/sklearn/base"
"github.com/gcla/sklearn/base"
"gonum.org/v1/gonum/mat"
gg "gorgonia.org/gorgonia"
"gorgonia.org/tensor"
)
// Float is gorgonia's Float64
var Float = gg.Float64
// LinearRegressionGor... | linear_model/gorgonia.go | 0.566978 | 0.443781 | gorgonia.go | starcoder |
package matrix
import (
"fmt"
"math/rand"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/stat"
)
// ColsMax returns a slice of max values of first cols number of matrix columns
// It returns error if passed in matrix is nil, has zero size or requested number
// of columns exceeds the number of columns in the matri... | pkg/matrix/matrix.go | 0.883381 | 0.776072 | matrix.go | starcoder |
package gozmo
import (
"fmt"
"github.com/go-gl/mathgl/mgl32"
)
// A Rendered is an accelerated sprite drawer component. It supports color
// addition and multiplication
type Renderer struct {
mesh *Mesh
texture *Texture
textureName string
pixelsPerUnit uint32
index uint32
forceHeight... | renderer.go | 0.755817 | 0.488161 | renderer.go | starcoder |
package utils
import (
"bytes"
"fmt"
"math"
"gonum.org/v1/gonum/mat"
)
type BlockMatrix struct {
M [][]Matrix // First slice points to rows of matrices - Note, the Matrix type allows for scalar matrices
Nr, Nc int // number of rows, columns in the square block matrix consisting of a sub-matrix in e... | utils/blockMatrix.go | 0.70619 | 0.573768 | blockMatrix.go | starcoder |
package grinder
import (
"go/ast"
"go/token"
"golang.org/x/tools/go/types"
"rsc.io/grind/block"
)
func Unlabel(x ast.Stmt) ast.Stmt {
for {
y, ok := x.(*ast.LabeledStmt)
if !ok {
return x
}
x = y.Stmt
}
}
func IsGotoTarget(blocks *block.Graph, x ast.Stmt) bool {
for {
y, ok := x.(*ast.LabeledS... | grinder/ast.go | 0.511229 | 0.406037 | ast.go | starcoder |
package int_tree
import (
"github.com/joeyciechanowicz/letter-combinations/pkg/reader"
"sort"
)
func ToAlphabetIndex(letter rune) int {
return int(letter) - int(ToRune("a"))
}
func ToRune(letter string) rune {
return []rune(letter)[0]
}
var RuneToLetters = map[rune]int {
ToRune("a"): ToAlphabetIndex(ToRune("a"... | pkg/int-tree/int-tree.go | 0.518546 | 0.425963 | int-tree.go | starcoder |
package mathf
import (
"fmt"
"math"
)
// A Quaternion describes a rotation in 3D space.
// The Quaternion is mathematically defined as Q = x*i + y*j + z*k + w, where (i,j,k) are imaginary basis vectors.
// (x,y,z) can be seen as a vector related to the axis of rotation, while the real multiplier, w, is related to t... | server/mathf/quaternion.go | 0.909203 | 0.826537 | quaternion.go | starcoder |
package plaid
import (
"encoding/json"
)
// IncomeBreakdown An object representing a breakdown of the different income types on the paystub.
type IncomeBreakdown struct {
// The type of income. Possible values include: `\"regular\"`: regular income `\"overtime\"`: overtime income `\"bonus\"`: bonus income
T... | plaid/model_income_breakdown.go | 0.79053 | 0.538012 | model_income_breakdown.go | starcoder |
package money
import (
"fmt"
"math"
"strings"
)
const (
decimalDefault = "."
)
// Money represents an amount ot a specific currency
type Money struct {
amount float64
currency Currency
}
// New creates a new Money object
func New(f float64, c Currency) *Money {
m := &Money{currency: c}
m.amount = m.round(... | money.go | 0.835986 | 0.405508 | money.go | starcoder |
package metrics
type Exporter struct {
podMetric *podMetric
nodeMetric *nodeMetric
gpuMetric *gpuMetric
}
func NewExporter() *Exporter {
return &Exporter{
podMetric: newPodMetric(),
nodeMetric: newNodeMetric(),
gpuMetric: newGPUMetric(),
}
}
func (exporter *Exporter) ExportPodMetricModelTime(
podNS, ... | ai-dispatcher/pkg/metrics/exporter.go | 0.748995 | 0.407982 | exporter.go | starcoder |
package regressiontest
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.skia.org/infra/perf/go/clustering2"
"go.skia.org/infra/perf/go/dataframe"
"go.skia.org/infra/perf/go/regression"
"go.skia.org/infra/perf/go/types"
)
var (
// timestamps is a lis... | perf/go/regression/regressiontest/regressiontest.go | 0.534127 | 0.62631 | regressiontest.go | starcoder |
package gomonochromebitmap
import (
"fmt"
"image"
"image/color"
"math"
)
type MonoBitmap struct {
Pix []uint32 //using byte vs uint16 vs uint32 vs uint64... 32bit shoud suit well for raspi1/2
W int
H int
}
//Initializes empty bitmap
//fill is default value
func NewMonoBitmap(w int, h int, fill bool) Mono... | gomonochromebitmap.go | 0.501709 | 0.481271 | gomonochromebitmap.go | starcoder |
package main
/* Day 7 part A:
Determine a tree structure given an ascii representation:
pbga (66)
xhth (57)
ebii (61)
havc (66)
ktlj (57)
fwft (72) -> ktlj, cntj, xhth
qoyq (66)
padx (45) -> pbga, havc, qoyq
tknk (41) -> ugml, padx, fwft
jptl (61)
ugml (68) -> gyxo, ebii, jptl
gyxo (61)
cntj (57)
tknk is at the bot... | 2017/day07.go | 0.76145 | 0.461199 | day07.go | starcoder |
package pair
import (
"image"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"os"
"time"
)
// Pair is a construct of 2 images to be compared, along with Score and time taken for comparison
// Score is a value between 0 to 1 indicating similarity of images.
// 0 indicates the images are identical, 1 indicates images... | pkg/pair/pair.go | 0.778102 | 0.560493 | pair.go | starcoder |
package iso20022
// Details of the closing of the securities financing transaction.
type SecuritiesFinancingTransactionDetails34 struct {
// Unambiguous identification of the underlying securities financing trade as assigned by the instructing party. The identification is common to all collateral pieces (one or many... | SecuritiesFinancingTransactionDetails34.go | 0.823399 | 0.407805 | SecuritiesFinancingTransactionDetails34.go | starcoder |
package ocr
import (
"image"
"image/color"
"math"
"sort"
"github.com/LKKlein/gocv"
"github.com/PaddlePaddle/PaddleOCR/thirdparty/paddleocr-go/paddle"
clipper "github.com/ctessum/go.clipper"
)
type xFloatSortBy [][]float32
func (a xFloatSortBy) Len() int { return len(a) }
func (a xFloatSortBy) Swap(... | thirdparty/paddleocr-go/ocr/postprocess.go | 0.536799 | 0.515864 | postprocess.go | starcoder |
package logic
// Node represents a game tree node.
type Node struct {
// Value contains the value of this node.
Value [3][3]int
// Weight represents the weight of a move.
Weight int64
// Children is a slice containing children of this node.
Children []*Node
}
// Constants defined for assigning weights to posi... | src/logic/tree.go | 0.746416 | 0.501282 | tree.go | starcoder |
package event
func isPowerOfTwo(v uint64) bool {
if v == 0 {
return false
}
return (v & (v - 1)) == 0
}
// BaseEventDataRing is a ring of EventData
type BaseEventDataRing struct {
datas []BaseEventData
writePos uint64
readPos uint64
}
func BaseEventDataRingCreate(cap int) (self BaseEventDataRing) {
if ... | event/baseeventdataring.go | 0.736401 | 0.45181 | baseeventdataring.go | starcoder |
package core
import (
"fmt"
"strconv"
"strings"
colorful "github.com/lucasb-eyer/go-colorful"
tiled "github.com/zaklaus/go-tiled"
rl "github.com/zaklaus/raylib-go/raylib"
"github.com/zaklaus/raylib-go/raymath"
"github.com/zaklaus/resolv/resolv"
"github.com/zaklaus/rurik/src/system"
)
const (
... | src/core/helpers.go | 0.675122 | 0.469824 | helpers.go | starcoder |
package networking
import "encoding/binary"
// Output represents a connection output (i.e. what's written to the connection). It wraps several helpers to write to this output.
type Output struct {
buf []byte
}
// NewOutput returns a well-formed Output.
func NewOutput() Output {
return Output{
buf: make([]byte, 0... | pkg/networking/output.go | 0.770983 | 0.409221 | output.go | starcoder |
package bisect_squares_lcci
import "math"
/*
面试题 16.13. 平分正方形 https://leetcode-cn.com/problems/bisect-squares-lcci/
给定两个正方形及一个二维平面。请找出将这两个正方形分割成两半的一条直线。假设正方形顶边和底边与 x 轴平行。
每个正方形的数据square包含3个数值,正方形的左下顶点坐标[X,Y] = [square[0],square[1]],以及正方形的边长square[2]。
所求直线穿过两个正方形会形成4个交点,请返回4个交点形成线段的两端点坐标
(两个端点即为4个交点中距离最远的2个点,这2个点所连成的... | solutions/bisect-squares-lcci/d.go | 0.54698 | 0.434941 | d.go | starcoder |
package unsafe
import (
"reflect"
"unsafe"
)
// UintptrToSlice returns a slice with len and cap of sz.
func UintptrToSlice(ptr uintptr, sz uint64) []byte {
return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
Data: uintptr(ptr),
Len: int(sz),
Cap: int(sz),
}))
}
// UnsafeToSlice returns a slice with le... | unsafe/unsafe.go | 0.646795 | 0.494263 | unsafe.go | starcoder |
package geom
// Grid provides an interface for reasoning over a 1D slice as if it were a
// 3D grid.
type Grid struct {
CellBounds
Length, Area, Volume int
uBounds [3]int
}
// GridLocation is a Grid which also specifies a physical location within
// a periodic super-grid.
type GridLocation struct {
Grid
Cells in... | render/geom/grid.go | 0.880528 | 0.640664 | grid.go | starcoder |
package morph
import "fmt"
// Table represents a mapping between an entity and a database table.
type Table struct {
typeName string
name string
alias string
columnsByName map[string]Column
columnsByField map[string]Column
}
// SetType associates the entity type to the table.
func (t *... | table.go | 0.700588 | 0.411406 | table.go | starcoder |
package terminal
// https://github.com/cli/cli/blob/trunk/utils/table_printer.go
import (
"fmt"
"io"
"strings"
"github.com/cli/cli/pkg/text"
)
// TablePrinter prints table formatted output.
type TablePrinter interface {
// AddField adds a field with the given string to the row. If given, the
// ColorFunc will... | pkg/terminal/table_printer.go | 0.759671 | 0.445891 | table_printer.go | starcoder |
package grid2d
import (
"github.com/maxfish/go-libs/pkg/geom"
)
//cellEdges is only used during the construction phase of the edges.
type cellEdges struct {
top, bottom, left, right *geom.Segment
}
type ComputeEdgesCallback func(x int, y int) bool
//ComputeEdges creates a list of segments covering all edges of th... | pkg/grid2d/edges.go | 0.678966 | 0.725065 | edges.go | starcoder |
package cu
import (
"log"
"gitlab.com/akita/akita"
"gitlab.com/akita/mgpusim/insts"
"gitlab.com/akita/mgpusim/timing/wavefront"
"gitlab.com/akita/util"
"gitlab.com/akita/util/pipelining"
"gitlab.com/akita/util/tracing"
)
type vectorMemInst struct {
wavefront *wavefront.Wavefront
}
func (i vectorMemInst) Tas... | timing/cu/vectormemoryunit.go | 0.659405 | 0.481454 | vectormemoryunit.go | starcoder |
package monitoring
import (
"fmt"
"github.com/chr-ras/advent-of-code-2019/util/calc"
g "github.com/chr-ras/advent-of-code-2019/util/geometry"
)
// BestAsteroidForMonitoringStation determines the best (== from where one can see the most asteroids) asteroid on the asteroid map to build a monitoring station on.
func... | 10-monitoring-station/monitoring/monitoring.go | 0.75183 | 0.61286 | monitoring.go | starcoder |
package vida
import (
"fmt"
)
// PrintError shows a given error in the terminal.
func PrintError(err error) {
fmt.Printf("\n\n\n %v:\n %v\n\n", runTimeError, err.Error())
}
// Error messages for type errors in binary operations.
func TypeErrorInBinaryOperator(op string, lhs, rhs Value) error {
return fmt.Erro... | vida/errors.go | 0.746046 | 0.433412 | errors.go | starcoder |
package types
import (
"fmt"
"math"
)
// Value is an arbitrary value that can be represented as Watson.
type Value struct {
Kind Kind
Int int64
Uint uint64
Float float64
String []byte
Object map[string]*Value
Array []*Value
Bool bool
}
// NewIntValue creates a new Value that contains an integer.... | pkg/types/types.go | 0.726426 | 0.426441 | types.go | starcoder |
package keeper
import (
"sort"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/liquidity/x/liquidity/types"
)
// Execute Swap of the pool batch, Collect swap messages in batch for transact the same price for each batch and run them on endblock.
func (k Keeper) SwapExecution(ctx sdk.Context, liqui... | x/liquidity/keeper/swap.go | 0.638046 | 0.404096 | swap.go | starcoder |
package transform
import (
"context"
"log"
"github.com/turbot/steampipe-plugin-sdk/plugin/quals"
)
// TransformData is the input to a transform function.
type TransformData struct {
// an optional parameter
Param interface{}
// the value to be transformed
Value interface{}
// a data object containing the sou... | plugin/transform/column_transforms.go | 0.660501 | 0.403391 | column_transforms.go | starcoder |
// Package stroke converts complex strokes to gioui.org/op/clip operations.
package stroke
import (
"gioui.org/f32"
"gioui.org/op"
"gioui.org/op/clip"
)
// Path defines the shape of a Stroke.
type Path struct {
Segments []Segment
}
type Segment struct {
// op is the operator.
op segmentOp
// args is up to th... | stroke/stroke.go | 0.67854 | 0.603056 | stroke.go | starcoder |
package convert
// A statute mile is 5,280 feet, as defined in 14 CFR Part 298.2 and mentioned in the
// Pilot's Handbook of Aeronautical Knowledge (http://www.faa.gov/regulations_policies/handbooks_manuals/aviation/pilot_handbook/media/PHAK%20-%20Chapter%2015.pdf).
const StatuteMileInFeet = 5280
// A nautical mile i... | aviation/convert/convert.go | 0.708112 | 0.62157 | convert.go | starcoder |
package selector
import (
"github.com/llir/ll"
)
type Selector func(nt ll.NodeType) bool
var (
Any = func(t ll.NodeType) bool { return true }
APINotesField = func(t ll.NodeType) bool { return t == ll.APINotesField }
AShrExpr = func(t ll.NodeTy... | selector/selector.go | 0.515376 | 0.5901 | selector.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// AccessPackageAssignment
type AccessPackageAssignment struct {
Entity
// Re... | models/access_package_assignment.go | 0.685739 | 0.497498 | access_package_assignment.go | starcoder |
package graphql
import (
"fmt"
"strings"
"time"
"github.com/skydive-project/skydive/graffiti/graph"
"github.com/skydive-project/skydive/graffiti/graph/traversal"
)
const (
// PrefixOriginName defines the prefix set in nodes/edges Origin field
PrefixOriginName = "graphql."
)
// newNode create a new node in Sk... | topology/probes/graphql/skydive_helpers.go | 0.735737 | 0.438064 | skydive_helpers.go | starcoder |
package main
import (
"fmt"
cz "github.com/CloudNativeDataPlane/cndp/lang/go/tools/pkgs/colorize"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
type chartData struct {
points []float64
name string
}
// TitleColor - Set the title color to the windows
func TitleColor(msg string) string {
return f... | lang/go/tools/cmon/helpers_tview.go | 0.73848 | 0.42471 | helpers_tview.go | starcoder |
package parser
import (
"strings"
)
const ParserNameOs = "os"
const FixtureFileOs = "oss.yml"
type OsReg struct {
Regular `yaml:",inline" json:",inline"`
Name string `yaml:"name" json:"name"`
Version string `yaml:"version" json:"version"`
}
// Known operating systems mapped to their internal short codes
var ... | parser/os.go | 0.559531 | 0.607081 | os.go | starcoder |
package cbor
import (
"fmt"
"math"
log "github.com/sirupsen/logrus"
)
// PositiveInteger8 wraps a positive integer with 8 bits
type PositiveInteger8 struct {
basePositiveInteger
}
// PositiveInteger16 wraps a positive integer with 16 bits
type PositiveInteger16 struct {
basePositiveInteger
}
// PositiveIntege... | cbor/positive.go | 0.860222 | 0.410284 | positive.go | starcoder |
package network
import (
"math"
"fmt"
"errors"
"github.com/elmware/goNEAT/neat/utils"
)
var (
// The error to be raised when maximal number of network activation attempts exceeded
NetErrExceededMaxActivationAttempts = errors.New("maximal network activation attempts exceeded.")
// The error to be raised when un... | neat/network/common.go | 0.724091 | 0.555073 | common.go | starcoder |
package ez
import (
"reflect"
"runtime"
"testing"
)
// A Unit is a specification that can be used for testing and/or benchmarking.
type Unit struct {
gfn interface{}
rs []runner
T *testing.T
B *testing.B
tr bool
br bool
}
// A half is an incomplete case.
type half struct {
in in
u *Unit
}
// A r... | unit.go | 0.616012 | 0.400515 | unit.go | starcoder |
package matchers
import (
"fmt"
"reflect"
"runtime"
"github.com/onsi/gomega/format"
"k8s.io/utils/semantic"
)
// EqualitiesEqualMatcher is a matcher that matches the Expected value using the given Equalities
// and semantic.Equalities.DeepEqual.
type EqualitiesEqualMatcher struct {
Equalities semantic.Equaliti... | testutils/matchers/matchers.go | 0.843992 | 0.619788 | matchers.go | starcoder |
package transpiler
// MapVisitor visit the Tree and return a map[string]interface{}, this map can be serialized
// to a YAML document.
type MapVisitor struct {
Content interface{}
}
// OnStr is called when we visit a StrVal.
func (m *MapVisitor) OnStr(v string) {
m.Content = v
}
// OnInt is called when we visit a... | x-pack/elastic-agent/pkg/agent/transpiler/map_visitor.go | 0.699152 | 0.424591 | map_visitor.go | starcoder |
package gaia
import (
"fmt"
"github.com/globalsign/mgo/bson"
"github.com/mitchellh/copystructure"
"go.aporeto.io/elemental"
)
// PolicyGraphPolicyTypeValue represents the possible values for attribute "policyType".
type PolicyGraphPolicyTypeValue string
const (
// PolicyGraphPolicyTypeAuthorization represents ... | policygraph.go | 0.796886 | 0.404331 | policygraph.go | starcoder |
package platformsnotificationevents
import (
"encoding/json"
)
// ViasPersonalData struct for ViasPersonalData
type ViasPersonalData struct {
// The date of birth of the person. The date should be in ISO-8601 format yyyy-mm-dd (e.g. 2000-01-31).
DateOfBirth *string `json:"dateOfBirth,omitempty"`
// Key value pai... | src/platformsnotificationevents/model_vias_personal_data.go | 0.763396 | 0.525795 | model_vias_personal_data.go | starcoder |
package mmr
type leafIndex uint64
func LeafIndex(value uint64) (res *leafIndex) {
v := leafIndex(value)
return &v
}
func (x *leafIndex) GetLeftBranch() IBlockIndex {
value := uint64(*x)
if value&1 == 0 && value > 1 {
return NodeIndex(uint64(*x) - 1)
}
return nil
}
func (x *leafIndex) GetSibling() IBlockInde... | utils/mmr/mmr.nodes.leaf.go | 0.651244 | 0.532668 | mmr.nodes.leaf.go | starcoder |
package suffix_array
import "sort"
// Suffix represents a single suffix item which holds a reference to the
// initial string index and the last range of sort indices.
type Suffix struct {
nr []int
idx int
}
// SuffixResult is the group of Suffix objects
type SuffixResult []*Suffix
// ToSuffixArray gets the sort... | data-structures/suffix-array/suffix_array.go | 0.867612 | 0.495239 | suffix_array.go | starcoder |
package poly
import (
"image"
"math/rand"
)
type Polygon struct {
// Order represents the number of vertices in the polygon
Order int
ColorRGBA Color
// Vertices represents the list of coordinates for the vertices of the polygon
Vertices []Point
// Rectangle represents the minimum rectangle that contains ... | poly/polygon.go | 0.794823 | 0.593845 | polygon.go | starcoder |
package tsuro
import "math/rand"
// Deck definition - the deck of tiles that players draw from
type Deck struct {
Tiles []Tile `json:"tiles"`
}
func (deck *Deck) Shuffle() {
for i := 0; i < len(deck.Tiles); i++ {
r := rand.Intn(len(deck.Tiles))
if i != r {
deck.Tiles[r], deck.Tiles[i] = deck.Tiles[i], deck.... | backend/game/deck.go | 0.533641 | 0.7214 | deck.go | starcoder |
package date
import (
"encoding/json"
"fmt"
"regexp"
"strconv"
"time"
)
// Date represents a date without time information; it may represent only a year
// (month and day may be zero, comparisons work correctly in this case).
type Date struct {
Year int
Month int
Day int
}
// Build creates a Date from yea... | pkg/date/date.go | 0.751375 | 0.638201 | date.go | starcoder |
package feign
import (
"errors"
"reflect"
"time"
)
var typeTime = reflect.TypeOf((*time.Time)(nil)).Elem()
// ErrUnhandledType is an error returned when the type is not fillable.
// Unfillable types include funcs, chans, and interfaces. When filling structs,
// maps, or slices, these types will be ignored.
var Er... | fill.go | 0.519278 | 0.409221 | fill.go | starcoder |
package bloomtree
import (
"errors"
"math"
"sort"
"github.com/willf/bitset"
)
type CompactMultiProof struct {
// Chunks are the leaves of the bloom tree, i.e. the bloom filter values for given parts of the bloom filter.
Chunks [][32]byte
// Proof are the hashes needed to reconstruct the bloom tree root.
Proo... | proof.go | 0.617167 | 0.513425 | proof.go | starcoder |
// Attribs package offers up a flexible approach to attaching Attribs that then be used to avoid
// the brittle parameter problem.
package attributes
// Attributes is an array of name-value pairs.
type Attributes []NameValuePair
func (a *Attributes) Value(name string) interface{} {
for _, attribute := range *a {
... | pkg/attributes/Attributes.go | 0.723895 | 0.454714 | Attributes.go | starcoder |
package poisson
//Option is function to update required setting
type Option func(*options)
type options struct {
//tries is a number of attempts to generate a new point
tries int
//minDistance is a minimum distance between two points
minDistance float64
//generator to use for random numbers
generator RandomGe... | options.go | 0.774498 | 0.495911 | options.go | starcoder |
package journal
import (
"math/big"
"sort"
"strings"
)
// An Amount is an amount of a certain unit, e.g., currency or commodity.
type Amount struct {
Number big.Int
Unit Unit
}
// Zero returns whether the amount is zero.
func (a *Amount) Zero() bool {
return isZero(&a.Number)
}
// Neg flips the sign of the... | journal/amount.go | 0.828245 | 0.488832 | amount.go | starcoder |
package automata
const (
MinSize = 12
Steps = 20
)
type Automata struct {
gridCount int
walls []*Wall
currentStep int
particlesByStep [Steps][]*Particle
}
func New(gridRowCount int, walls []*Wall, particles []*Particle) *Automata {
particlesByStep := [Steps][]*Particle{}
for i := 0; i < Steps-1; i... | _drafts/01/automata/automata.go | 0.603932 | 0.47993 | automata.go | starcoder |
package sample
import (
"math/rand"
"github.com/tendermint/spn/pkg/types"
monitoringc "github.com/tendermint/spn/x/monitoringc/types"
monitoringp "github.com/tendermint/spn/x/monitoringp/types"
)
const ConsensusStateNb = 2
// ConsensusState returns a sample ConsensusState
// nb allows to select a consensus stat... | testutil/sample/monitoring.go | 0.696268 | 0.412471 | monitoring.go | starcoder |
package srg
import (
"fmt"
"strings"
"bytes"
"github.com/serulian/compiler/compilercommon"
"github.com/serulian/compiler/compilergraph"
"github.com/serulian/compiler/compilerutil"
"github.com/serulian/compiler/sourceshape"
)
// SRGTypeRef represents a type reference defined in the SRG.
type SRGTypeRef struc... | graphs/srg/typeref.go | 0.682468 | 0.472562 | typeref.go | starcoder |
package iterator
import q "github.com/janderland/fdbq/keyval"
// Bool asserts the current element of the tuple is of type Bool.
// If the type assertion fails a ConversionError is returned. If the
// iterator points beyond the end of the tuple, a ShortTupleError is
// returned. Otherwise, the element is returned and ... | keyval/iterator/iterator.g.go | 0.720467 | 0.491578 | iterator.g.go | starcoder |
// Package geomfn contains functions that are used for geometry-based builtins.
package geomfn
import "github.com/twpayne/go-geom"
// applyCoordFunc applies a function on src to copy onto dst.
// Both slices represent a single Coord within the FlatCoord array.
type applyCoordFunc func(l geom.Layout, dst []float64, s... | pkg/geo/geomfn/geomfn.go | 0.857156 | 0.515925 | geomfn.go | starcoder |
package design
import (
"fmt"
"math"
"regexp"
"time"
regen "github.com/zach-klippenstein/goregen"
)
// exampleGenerator generates a random example based on the given validations on the definition.
type exampleGenerator struct {
a *AttributeDefinition
r *RandomGenerator
}
// newExampleGenerator returns an exa... | design/example.go | 0.673943 | 0.408336 | example.go | starcoder |
package gtime
import (
"bytes"
"strconv"
"strings"
"github.com/gogf/gf/text/gregex"
)
var (
// Refer: http://php.net/manual/en/function.date.php
formats = map[byte]string{
'd': "02", // Day: Day of the month, 2 digits with leading zeros. Eg: 01 to 31.
'D': "Mon", ... | os/gtime/gtime_format.go | 0.550607 | 0.46478 | gtime_format.go | starcoder |
package timeseries
import (
"errors"
"math"
)
// FirstObs returns the first Observation of a DataSeries, whether it is NaN() or not. See FirstValidObs
func FirstObs(data *DataSeries) (lst Observation, err error) {
data.SortChronAsc()
if len(*data) > 0 {
lst = (*data)[0]
} else {
//err = errors.New("DataSerie... | internalfunctions.go | 0.746324 | 0.497376 | internalfunctions.go | starcoder |
package meshdata
import (
"encoding/json"
"fmt"
"strings"
)
const (
// FlagsNone resets all mesh data flags.
FlagsNone = 0
// FlagObsolete flags the mesh data for removal.
FlagObsolete = 0x0001
)
// MeshData holds the entire mesh data managed by Mentix.
type MeshData struct {
Sites []*Site
ServiceT... | pkg/mentix/meshdata/meshdata.go | 0.70028 | 0.500122 | meshdata.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.