text:
package key

import (
	"fmt"

	cli "github.com/jawher/mow.cli"
	"github.com/zarbchain/zarb-go/cmd"
	"github.com/zarbchain/zarb-go/keystore/key"
)

//Inspect displays various information of the keyfile
func Inspect() func(c *cli.Cmd) {
	return func(c *cli.Cmd) {
		keyFileArg := c.String(cli.StringArg{
			Name: "KEYFILE",
			Desc: "Path to the encrypted key file",
		})
		showPrivateOpt := c.Bool(cli.BoolOpt{
			Name: "e expose-private-key",
			Desc: "expose the private key in the output",
		})
		authOpt := c.String(cli.StringOpt{
			Name: "a auth",
			Desc: "Passphrase of the key file",
		})
		c.Before = func() { fmt.Println(cmd.ZARB) }
		c.Action = func() {

			ek, err := key.NewEncryptedKey(*keyFileArg)
			if err != nil {
				cmd.PrintErrorMsg("Failed to read the key file: %v", err)
				return
			}
			var auth string
			if *authOpt == "" {
				auth = cmd.PromptPassphrase("Passphrase: ", false)
			} else {
				auth = *authOpt
			}
			// Decrypt key with passphrase.
			keyObj, err := ek.Decrypt(auth)
			if err != nil {
				cmd.PrintErrorMsg("Failed to decrypt: %v", err)
				return
			}

			cmd.PrintLine()
			cmd.PrintInfoMsg("Label: %v", ek.Label)
			cmd.PrintInfoMsg("Address: %v", keyObj.Address())
			cmd.PrintInfoMsg("Public key: %v", keyObj.PublicKey())
			if *showPrivateOpt {
				cmd.PrintDangerMsg("Private key: %v", keyObj.PrivateKey())
			}
		}
	}
}

license: MIT

repository: FarhadGhE/zarb-go

repo_name: FarhadGhE/zarb-go

branch_name: refs/heads/main

gha_license_id: MIT


text:
package main

import (
	"log"
	"time"

	joysticks "github.com/Nick-Zuchlewski/joysticks"
)

type Region struct {
	minX, minY, maxX, maxY float32
}

type RegionEvent struct {
	time  time.Duration
	Index int
}

func (b RegionEvent) Moment() time.Duration {
	return b.time
}

func OnRegionChanged(trigger, position chan joysticks.Event, regions []Region) (chan RegionEvent, chan RegionEvent) {
	in := make(chan RegionEvent)
	out := make(chan RegionEvent)
	states := make([]bool, len(regions))
	var pevt joysticks.CoordsEvent
	go func() {
		for e := range position {
			switch v := e.(type) {
			case joysticks.CoordsEvent:
				pevt = v
			}
		}
	}()
	go func() {
		for e := range trigger {
			for ri, r := range regions {
				if pevt.X >= r.minX && pevt.X <= r.maxX && pevt.Y >= r.minY && pevt.Y <= r.maxY {
					if !states[ri] {
						in <- RegionEvent{e.Moment(), ri}
						states[ri] = true
					}
				} else {
					if states[ri] {
						out <- RegionEvent{e.Moment(), ri}
						states[ri] = false
					}
				}
			}
		}
		close(in)
		close(out)
	}()
	return in, out
}

func main() {
	device, _ := joysticks.Connect(1)
	if device == nil {
		log.Println("no HIDs")
		return
	}
	log.Printf("HID#1:- Buttons:%d, Hats:%d\n", len(device.Buttons), len(device.HatAxes)/2)

	// make channels for specific events
	regionEntering, regionExiting := OnRegionChanged(device.OnHat(1), device.OnMove(1), []Region{Region{.5, .5, 1, 1}, Region{-1, -1, -.5, -.5}})

	// feed OS events onto the event channels.
	go device.ParcelOutEvents()

	// handle event channels
	go func() {
		for {
			select {
			case r := <-regionEntering:
				log.Println("enter region:", r.Index)
			case r := <-regionExiting:
				log.Println("leave region:", r.Index)
			}
		}
	}()

	log.Println("Timeout in 10 secs.")
	<-time.After(time.Second * 10)
	log.Println("Shutting down due to timeout.")
}

license: Unlicense

repository: Nick-Zuchlewski/joysticks

license_type: permissive

repo_name: Nick-Zuchlewski/joysticks

branch_name: refs/heads/master

gha_license_id: Unlicense

extension: go


text:
file(REMOVE_RECURSE
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/aligngivenpath.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/aligngivenpathsw.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/aligntwomsas.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/aligntwoprofs.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/aln.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/alpha.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/anchoredpp.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/anchors.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/bittraceback.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/blosum62.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/blosumla.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/clust.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/cluster.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/clwwt.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/color.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/cons.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/diaglist.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/diffobjscore.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/diffpaths.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/difftrees.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/difftreese.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/distcalc.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/distfunc.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/distpwkimura.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/domuscle.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/dosp.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/dpreglist.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/drawtree.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/edgelist.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/enumopts.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/enumtostr.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/estring.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/fasta.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/fasta2.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/fastclust.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/fastdist.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/fastdistjones.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/fastdistkbit.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/fastdistkmer.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/fastdistmafft.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/fastdistnuc.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/fastscorepath2.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/finddiags.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/finddiagsn.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/glbalign.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/glbalign352.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/glbaligndiag.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/glbalignle.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/glbalignsimple.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/glbalignsp.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/glbalignspn.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/glbalignss.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/glbalndimer.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/globals.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/globalslinux.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/globalsother.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/globalswin32.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/gonnet.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/gotowt.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/henikoffweight.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/henikoffweightpb.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/html.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/hydro.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/intmath.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/local.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/main.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/makerootmsa.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/makerootmsab.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/maketree.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/mhack.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/mpam200.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/msa.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/msa2.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/msadistkimura.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/msf.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/muscle.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/muscleout.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/nucmx.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/nwdasimple.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/nwdasimple2.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/nwdasmall.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/nwrec.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/nwsmall.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/objscore.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/objscore2.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/objscoreda.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/onexception.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/options.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/outweights.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/pam200mafft.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/params.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/phy.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/phy2.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/phy3.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/phy4.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/phyfromclust.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/phyfromfile.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/physeq.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/phytofile.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/posgap.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/ppscore.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/profdb.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/profile.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/profilefrommsa.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/progalign.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/progress.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/progressivealign.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/pwpath.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/readmx.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/realigndiffs.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/realigndiffse.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/refine.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/refinehoriz.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/refinesubfams.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/refinetree.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/refinetreee.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/refinevert.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/refinew.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/savebest.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/scoredist.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/scoregaps.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/scorehistory.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/scorepp.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/seq.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/seqvect.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/setblosumweights.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/setgscweights.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/setnewhandler.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/spfast.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/sptest.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/stabilize.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/subfam.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/subfams.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/sw.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/termgaps.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/textfile.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/threewaywt.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/tomhydro.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/traceback.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/tracebackopt.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/tracebacksw.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/treefrommsa.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/typetostr.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/upgma2.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/usage.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/validateids.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/vtml2.cpp.o"
  "CMakeFiles/parsnp.dir/muscle/libMUSCLE/writescorefile.cpp.o"
  "CMakeFiles/parsnp.dir/src/csgmum/csg.c.o"
  "CMakeFiles/parsnp.dir/src/csgmum/fastaread.c.o"
  "CMakeFiles/parsnp.dir/src/csgmum/mum.c.o"
  "CMakeFiles/parsnp.dir/src/ext/iniFile.cpp.o"
  "CMakeFiles/parsnp.dir/src/Converter.cpp.o"
  "CMakeFiles/parsnp.dir/src/LCB.cpp.o"
  "CMakeFiles/parsnp.dir/src/LCR.cpp.o"
  "CMakeFiles/parsnp.dir/src/MuscleInterface.cpp.o"
  "CMakeFiles/parsnp.dir/src/parsnp.cpp.o"
  "CMakeFiles/parsnp.dir/src/TMum.cpp.o"
  "parsnp.pdb"
  "parsnp"
)

# Per-language clean rules from dependency scanning.
foreach(lang C CXX)
  include(CMakeFiles/parsnp.dir/cmake_clean_${lang}.cmake OPTIONAL)
endforeach()

repository: sebasso/parsnp

repo_name: sebasso/parsnp

extension: cmake


text:
// Copyright 2016 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package grumpy

import (
	"testing"
)

func TestXxx(t *testing.T) {
}

func TestNewCodeKeywordsCheck(t *testing.T) {
	oldLogFatal := logFatal
	defer func() { logFatal = oldLogFatal }()
	var got string
	logFatal = func(msg string) {
		got = msg
	}
	NewCode("foo", "foo.py", []Param{{"bar", None}, {"baz", nil}}, 0, nil)
	if want := "foo() non-keyword arg baz after keyword arg"; got != want {
		t.Errorf("NewCode logged %q, want %q", got, want)
	}
}

func TestNewCode(t *testing.T) {
	testFunc := newBuiltinFunction("TestNewCode", func(f *Frame, args Args, kwargs KWArgs) (*Object, *BaseException) {
		if raised := checkFunctionVarArgs(f, "TestNewCode", args, CodeType); raised != nil {
			return nil, raised
		}
		return toCodeUnsafe(args[0]).Eval(f, nil, args[1:], kwargs)
	})
	fn := func(f *Frame, args []*Object) (*Object, *BaseException) {
		return NewTuple(Args(args).makeCopy()...).ToObject(), nil
	}
	nilFn := func(*Frame, []*Object) (*Object, *BaseException) {
		return nil, nil
	}
	cases := []invokeTestCase{
		invokeTestCase{args: wrapArgs(NewCode("f1", "foo.py", nil, 0, fn)), want: NewTuple().ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f2", "foo.py", []Param{{"a", nil}}, 0, fn), 123), want: newTestTuple(123).ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f2", "foo.py", []Param{{"a", nil}}, 0, fn)), kwargs: wrapKWArgs("a", "apple"), want: newTestTuple("apple").ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f2", "foo.py", []Param{{"a", nil}}, 0, fn)), kwargs: wrapKWArgs("b", "bear"), wantExc: mustCreateException(TypeErrorType, "f2() got an unexpected keyword argument 'b'")},
		invokeTestCase{args: wrapArgs(NewCode("f2", "foo.py", []Param{{"a", nil}}, 0, fn)), wantExc: mustCreateException(TypeErrorType, "f2() takes at least 1 arguments (0 given)")},
		invokeTestCase{args: wrapArgs(NewCode("f2", "foo.py", []Param{{"a", nil}}, 0, fn), 1, 2, 3), wantExc: mustCreateException(TypeErrorType, "f2() takes 1 arguments (3 given)")},
		invokeTestCase{args: wrapArgs(NewCode("f3", "foo.py", []Param{{"a", nil}, {"b", nil}}, 0, fn), 1, 2), want: newTestTuple(1, 2).ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f3", "foo.py", []Param{{"a", nil}, {"b", nil}}, 0, fn), 1), kwargs: wrapKWArgs("b", "bear"), want: newTestTuple(1, "bear").ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f3", "foo.py", []Param{{"a", nil}, {"b", nil}}, 0, fn)), kwargs: wrapKWArgs("b", "bear", "a", "apple"), want: newTestTuple("apple", "bear").ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f3", "foo.py", []Param{{"a", nil}, {"b", nil}}, 0, fn), 1), kwargs: wrapKWArgs("a", "alpha"), wantExc: mustCreateException(TypeErrorType, "f3() got multiple values for keyword argument 'a'")},
		invokeTestCase{args: wrapArgs(NewCode("f4", "foo.py", []Param{{"a", nil}, {"b", None}}, 0, fn), 123), want: newTestTuple(123, None).ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f4", "foo.py", []Param{{"a", nil}, {"b", None}}, 0, fn), 123, "bar"), want: newTestTuple(123, "bar").ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f4", "foo.py", []Param{{"a", nil}, {"b", None}}, 0, fn)), kwargs: wrapKWArgs("a", 123, "b", "bar"), want: newTestTuple(123, "bar").ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f5", "foo.py", []Param{{"a", nil}}, CodeFlagVarArg, fn), 1), want: newTestTuple(1, NewTuple()).ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f5", "foo.py", []Param{{"a", nil}}, CodeFlagVarArg, fn), 1, 2, 3), want: newTestTuple(1, newTestTuple(2, 3)).ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f6", "foo.py", []Param{{"a", nil}}, CodeFlagKWArg, fn), "bar"), want: newTestTuple("bar", NewDict()).ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f6", "foo.py", []Param{{"a", nil}}, CodeFlagKWArg, fn)), kwargs: wrapKWArgs("a", "apple", "b", "bear"), want: newTestTuple("apple", newTestDict("b", "bear")).ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f6", "foo.py", []Param{{"a", nil}}, CodeFlagKWArg, fn), "bar"), kwargs: wrapKWArgs("b", "baz", "c", "qux"), want: newTestTuple("bar", newTestDict("b", "baz", "c", "qux")).ToObject()},
		invokeTestCase{args: wrapArgs(NewCode("f7", "foo.py", nil, 0, nilFn)), want: None},
	}
	for _, cas := range cases {
		if err := runInvokeTestCase(testFunc.ToObject(), &cas); err != "" {
			t.Error(err)
		}
	}
}

func TestCodeEvalRestoreExc(t *testing.T) {
	e := mustCreateException(RuntimeErrorType, "uh oh")
	ranC1, ranC2 := false, false
	globals := NewDict()
	c1 := NewCode("<c1>", "foo.py", nil, 0, func(f *Frame, _ []*Object) (*Object, *BaseException) {
		if got, _ := f.ExcInfo(); got != e {
			t.Errorf("ExcInfo() = %v, want %v", got, e)
		}
		f.RestoreExc(nil, nil)
		ranC1 = true
		return None, nil
	})
	c2 := NewCode("<c2>", "foo.py", nil, 0, func(f *Frame, _ []*Object) (*Object, *BaseException) {
		f.RestoreExc(e, newTraceback(f, nil))
		c1.Eval(f, globals, nil, nil)
		// The exception was cleared by c1 but when returning to c2, it
		// should have been restored.
		if got, _ := f.ExcInfo(); got != e {
			t.Errorf("ExcInfo() = %v, want <nil>", got)
		}
		f.RestoreExc(nil, nil)
		ranC2 = true
		return None, nil
	})
	c2.Eval(NewRootFrame(), globals, nil, nil)
	if !ranC1 {
		t.Error("c1 did not run")
	}
	if !ranC2 {
		t.Error("c2 did not run")
	}
}

repository: alanjds/grumpy

repo_name: alanjds/grumpy

gha_language: Go


text:
DESCRIPTION = "RDM Zway Stick Updater"
HOMEPAGE = "http://www.rademacher.de"

LICENSE = "Proprietary"
LIC_FILES_CHKSUM = "file://${THISDIR}/files/license.txt;md5=3ebe3464e841ddbf115af1f7019017c5"

FILESEXTRAPATHS_prepend := "${THISDIR}/z-way-stick-updater:"

PV = "0.4"

SRC_URI = "\
    git://git@bitbucket.org/rdm-dev/z-way-stick-updater.git;protocol=ssh;branch=import \
"
SRCREV = "031474999a20ee7b2199536700ef5eaf34afdbc6"

DEPENDS = "hp2-base"
RDEPENDS_${PN} += "hp2-base"
RDEPENDS_${PN} += "perl"
RDEPENDS_${PN} += "python-fcntl"
RDEPENDS_${PN} += "python-logging"
RDEPENDS_${PN} += "python-pyserial"

S = "${WORKDIR}/git"
INST_DEST_PREFIX="/opt/z-way-stick-updater"

do_install() {
    install -d ${D}${INST_DEST_PREFIX}
    install -d ${D}${INST_DEST_PREFIX}/ZStickUpdater
    install -m 755 zwave_update.pl ${D}${INST_DEST_PREFIX}
    install -m 755 ZStickUpdater/ZStickUpdater.py ${D}${INST_DEST_PREFIX}/ZStickUpdater
    install -m 644 ZStickUpdater/IntelHex.py ZStickUpdater/SerialAPI.py \
                   ZStickUpdater/ZLogging.py \
                   ZStickUpdater/Rademacher4.ehex ZStickUpdater/Rademacher5.ehex \
                   ${D}${INST_DEST_PREFIX}/ZStickUpdater
}

FILES_${PN} += "${INST_DEST_PREFIX}"

repository: rdm-dev/meta-jens

repo_name: rdm-dev/meta-jens

branch_name: refs/heads/jethro-kiebitzsee

extension: bb


text:
package main

import (
	"github.com/trasa/watchmud-message"
	"github.com/trasa/watchmud-message/direction"
)

func (c *Client) handleMoveResponse(resp *message.MoveResponse) {
	if resp.GetSuccess() {
		UIPrintRoom(resp.RoomDescription)
	} else if resp.GetResultCode() == "CANT_GO_THAT_WAY" {
		UIPrintln("There's no exit that way.")
	} else if resp.GetResultCode() == "IN_A_FIGHT" {
		UIPrintln("Your fighting for your life!")
	} else {
		UIPrintResponseError(resp, resp.GetResultCode())
	}
}

func (c *Client) handleEnterRoomNotification(note *message.EnterRoomNotification) {
	if !note.GetSuccess() {
		UIPrintResponseError(note, note.GetResultCode())
	} else {
		UIPrintln(note.Name, "enters.")
	}
}

func (c *Client) handleLeaveRoomNotification(note *message.LeaveRoomNotification) {
	if !note.GetSuccess() {
		UIPrintResponseError(note, note.GetResultCode())
	} else {
		dirName, err := direction.DirectionToString(direction.Direction(note.Direction))
		if err != nil {
			UIPrintln("Error figuring out direction string for", note.Direction)
		}
		UIPrintln(note.Name, "departs", dirName+".")
	}
}

repository: trasa/watchmud-client

repo_name: trasa/watchmud-client


text:
package aedatastore

import (
	"context"

	w "go.mercari.io/datastore/v2"
	"google.golang.org/appengine/v2/datastore"
)

var _ w.Key = (*keyImpl)(nil)
var _ w.PendingKey = (*pendingKeyImpl)(nil)

type keyImpl struct {
	ctx       context.Context
	kind      string
	id        int64
	name      string
	parent    *keyImpl
	namespace string
}

type pendingKeyImpl struct {
	ctx context.Context
	key *datastore.Key
}

type contextPendingKey struct{}

func (k *keyImpl) Kind() string {
	if k == nil {
		panic("k is nil")
	}
	return k.kind
}

func (k *keyImpl) ID() int64 {
	return k.id
}

func (k *keyImpl) Name() string {
	return k.name
}

func (k *keyImpl) ParentKey() w.Key {
	if k.parent == nil {
		return nil
	}
	return k.parent
}

func (k *keyImpl) Namespace() string {
	return k.namespace
}

func (k *keyImpl) SetNamespace(namespace string) {
	k.namespace = namespace
}

func (k *keyImpl) String() string {
	return toOriginalKey(k).String()
}

func (k *keyImpl) GobEncode() ([]byte, error) {
	return toOriginalKey(k).GobEncode()
}

func (k *keyImpl) GobDecode(buf []byte) error {
	origKey := &datastore.Key{}
	err := origKey.GobDecode(buf)
	if err != nil {
		return err
	}

	k.kind = origKey.Kind()
	k.id = origKey.IntID()
	k.name = origKey.StringID()
	k.parent = toWrapperKey(k.ctx, origKey.Parent())
	k.namespace = origKey.Namespace()

	return nil
}

func (k *keyImpl) MarshalJSON() ([]byte, error) {
	return toOriginalKey(k).MarshalJSON()
}

func (k *keyImpl) UnmarshalJSON(buf []byte) error {
	origKey := &datastore.Key{}
	err := origKey.UnmarshalJSON(buf)
	if err != nil {
		return err
	}

	k.kind = origKey.Kind()
	k.id = origKey.IntID()
	k.name = origKey.StringID()
	k.parent = toWrapperKey(k.ctx, origKey.Parent())
	k.namespace = origKey.Namespace()

	return nil
}

func (k *keyImpl) Encode() string {
	return toOriginalKey(k).Encode()
}

func (k *keyImpl) Equal(o w.Key) bool {
	var a w.Key = k
	var b = o
	for {
		if a == nil && b == nil {
			return true
		} else if a != nil && b == nil {
			return false
		} else if a == nil && b != nil {
			return false
		}
		if a.Kind() != b.Kind() || a.Name() != b.Name() || a.ID() != b.ID() || a.Namespace() != b.Namespace() {
			return false
		}

		// NOTE Don't checking appID. align to Cloud Datastore API.

		a = a.ParentKey()
		b = b.ParentKey()
	}
}

func (k *keyImpl) Incomplete() bool {
	return k.Name() == "" && k.ID() == 0
}

func (p *pendingKeyImpl) StoredContext() context.Context {
	return context.WithValue(p.ctx, contextPendingKey{}, p)
}

repository: mercari/datastore

repo_name: mercari/datastore


text:
require linux-omap3.inc

COMPATIBLE_MACHINE = "ti814x"

KVER = "2.6.37"
PSPREL = "04.01.00.04"

BRANCH = "ti81xx-master"
# Use literal tags in SRCREV, when available, instead of commit IDs
SRCREV = "v2.6.37_TI814XPSP_04.01.00.04"


text:
@misc{cython,
	title="Cython: C-Extensions for Python",
	url="https://cython.org/",
	journal="Cython: C-Extensions for Python"
}
@misc{source_code,
	title="Github repository with source code",
	url="https://github.com/zivkovic/natural_neighbour_interpolation_FRI_NRG",
}
@article{algorithm,
	title = "Parallel algorithm for natural neighbor interpolation",
	keywords = "CUDA, Geo-physics, Interpolation, Natural neighbor, OpenMP, Parallel algorithm",
	author = "Alexander Tsidaev",
	year = "2016",
	language = "English",
	volume = "1729",
	pages = "78--83",
	journal = "CEUR Workshop Proceedings",
	issn = "1613-0073",
	publisher = "CEUR-WS",
}

extension: bib


text:
SUMMARY = "Terminal utilities"
DESCRIPTION = "Small utilities for dealing with terminals"
HOMEPAGE = "https://github.com/madisongh/termutils"
SECTION = "console/utils"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=7d039b9a48908f094d9d93578290517f"

SRC_URI = "https://github.com/madisongh/termutils/releases/download/v${PV}/${BPN}-${PV}.tar.gz \
	   file://00checkwinsize \
"

SRC_URI[md5sum] = "d23fa05a8ebdb9890b3a4600b4fbf718"
SRC_URI[sha256sum] = "a31184d820c8108c7ad83940c03f1ac529d385f3ee6ed961dd94759d6bf608fb"

S = "${WORKDIR}/${BPN}-${PV}"

inherit autotools

do_install_append() {
    install -d ${D}${sysconfdir}/profile.d
    install -m 644 ${WORKDIR}/00checkwinsize ${D}${sysconfdir}/profile.d
}

repository: Trellis-Logic/test-distro

repo_name: Trellis-Logic/test-distro


text:
///
/// Main for CPU Simulation
///
/// Molecular Dynamics Simulation on GPU
///
/// Written by Vadim Kuras. 2009-2010.
///

#define APPEXE "cpumd.exe"

#include "..\..\common\global.h"
#include "..\..\common\loader.h"
#include "host.h"

///
/// Main function.
///
int main(int argc, char ** argv)
{
	configuration config; //simulation configuration structure
	Loader(argc, argv, APPEXE, config); //load configuration

	//output logo...
	cout << "Molecular::Dynamics\n";

	return hostMain(&config); //begin
}

repository: vakuras/moleculardynamics

repo_name: vakuras/moleculardynamics

extension: cpp


text:
SUMMARY = "Platform-independent Qt API for storing passwords securely"
HOMEPAGE = "https://github.com/frankosterfeld/qtkeychain"
LICENSE = "BSD-2-Clause"
LIC_FILES_CHKSUM = "file://COPYING;md5=5c262c13b60ebefe3060aed37d334ab6"

DEPENDS = " \
    qttools-native \
    qttools \
    qtbase \
"

QT_TRANSLATION_FILES = "${datadir}/qt5keychain/translations/*.qm"

inherit cmake_qt5_extra qt5-translation

SRC_URI = "git://github.com/frankosterfeld/${BPN}.git;protocol=https"
SRCREV = "815fe610353ff8ad7e2f1121c368a74df8db5eb7"
PV = "0.12.0"
S = "${WORKDIR}/git"

do_install_append() {
    # mkspecs are installed at the wrong place. So as long as there are no
    # consumers building with qmake, delete mkspecs
    rm -rf ${D}${prefix}/mkspecs
}

branch_name: refs/heads/nilrt/master/hardknott

gha_language: BitBake


text:
package microphones

import (
	"encoding/csv"
	"errors"
	"fmt"
	"strconv"
)

type MicrophoneFileReader struct {
	filename       string
	microphoneList []Microphone
}

func (mfr *MicrophoneFileReader) LoadMicrophones(reader *csv.Reader) (bool, error) {
	records, err := reader.ReadAll()

	if err != nil {
		fmt.Println(err)
		return false, err
	}

	for i := 0; i < len(records); i++ {
		price, err := strconv.ParseFloat(records[i][3], 64)

		if err != nil {
			return false, errors.New("Not able to parse price to float")
		}

		mic := Microphone{
			name:        records[i][0],
			brand:       records[i][1],
			description: records[i][2],
			price:       price,
			url:         records[i][4],
			micType:     records[i][5],
			micStyle:    records[i][6],
		}
		mfr.microphoneList = append(mfr.microphoneList, mic)
	}

	return true, nil
}

func (mfr *MicrophoneFileReader) GetMicrophones() []Microphone {
	return mfr.microphoneList
}

type Microphone struct {
	name, brand, description, url, micType, micStyle string
	price                                            float64
}

repository: settermjd/microphones

repo_name: settermjd/microphones


text:
# ----------------------------------------------------------------------------
# (c) 2005-2023 - CROWN OWNED COPYRIGHT. All rights reserved.
# The copyright of this Software is vested in the Crown
# and the Software is the property of the Crown.
# ----------------------------------------------------------------------------
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------
# Classification: UK OFFICIAL
# ----------------------------------------------------------------------------

macro(_simple_handle_common_args)
    if (DEFINED ARGS_SRCDIR)
        set(SRCDIR "${ARGS_SRCDIR}/")
    else ()
        if (${ARGC} GREATER 0)
            set(SRCDIR "${CMAKE_CURRENT_LIST_DIR}/${ARGV0}/")
        else ()
            set(SRCDIR "${CMAKE_CURRENT_LIST_DIR}/src/")
        endif ()
    endif ()

    foreach (src ${ARGS_SOURCES})
        list(APPEND sourceFiles "${SRCDIR}${src}")
    endforeach ()

    foreach (src ${ARGS_DEPENDS})
        list(APPEND dependFiles "${SRCDIR}${src}")
    endforeach ()

    if (DEFINED ARGS_INCDIR)
        set(INCDIR "${ARGS_INCDIR}")
    else ()
        set(INCDIR "include")
    endif ()
endmacro()

macro(_simple_handle_common_install)
    if (DEFINED ARGS_EXPORT OR ARGS_INSTALL)

        if (DEFINED ARGS_EXPORT)
            install(
                TARGETS ${ARGS_NAME}
                EXPORT ${ARGS_EXPORT}Targets
                RUNTIME DESTINATION ${INSTALL_BIN_DIR}
                LIBRARY DESTINATION ${INSTALL_LIB_DIR}
                ARCHIVE DESTINATION ${INSTALL_LIB_DIR}
                INCLUDES DESTINATION ${INSTALL_INCLUDE_DIR}
            )
        else ()
            install(
                TARGETS ${ARGS_NAME}
                RUNTIME DESTINATION ${INSTALL_BIN_DIR}
                LIBRARY DESTINATION ${INSTALL_LIB_DIR}
                ARCHIVE DESTINATION ${INSTALL_LIB_DIR}
                INCLUDES DESTINATION ${INSTALL_INCLUDE_DIR}
            )
        endif ()

        if (DEFINED ARGS_INCLUDES AND NOT ARGS_FIXPROTOINC)
            if ("${ARGS_INCLUDES}" STREQUAL "ALL")
                install(
                    DIRECTORY ${INCDIR}/
                    DESTINATION ${INSTALL_INCLUDE_DIR}
                )
            else ()
                foreach (file ${ARGS_INCLUDES})
                    get_filename_component(dir ${file} DIRECTORY)
                    install(
                        FILES ${INCDIR}/${file}
                        DESTINATION ${INSTALL_INCLUDE_DIR}/${dir}
                    )
                endforeach ()
            endif ()
        elseif(DEFINED ARGS_INCLUDES AND ARGS_FIXPROTOINC)
            foreach (file ${ARGS_INCLUDES})
                get_filename_component(filename ${file} NAME)
                get_filename_component(dir ${file} DIRECTORY)
                install(
                    FILES "${GENERATED_TARGET_DIR}/${filename}"
                    DESTINATION ${INSTALL_INCLUDE_DIR}/${dir}
                )
            endforeach ()
        endif ()
    endif ()
endmacro()

macro(simple_print_cmake_vars)
    get_cmake_property(_variableNames VARIABLES)
    list (SORT _variableNames)
    foreach (_variableName ${_variableNames})
        message(STATUS "${_variableName}=${${_variableName}}")
    endforeach()
endmacro()

repository: xtuml/masl

repo_name: xtuml/masl

gha_language: Java


text:
/*************************************************************************/
/*  symantic_analysier.h                                                 */
/*************************************************************************/
/*                       The MIT License (MIT)                           */
/*************************************************************************/
/* Copyright (c) 2018 Paul Batty.                                        */
/*                                                                       */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the       */
/* "Software"), to deal in the Software without restriction, including   */
/* without limitation the rights to use, copy, modify, merge, publish,   */
/* distribute, sublicense, and/or sell copies of the Software, and to    */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions:                                             */
/*                                                                       */
/* The above copyright notice and this permission notice shall be        */
/* included in all copies or substantial portions of the Software.       */
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/

#ifndef SYMANTIC_ANALYSIER_H
#define SYMANTIC_ANALYSIER_H

#include <string>
#include <memory>
#include <vector>

#include "parser.h"
#include "tokens.h"
#include "./data_structures/tree_node.h"

class SymanticAnalysier
{
public:

	struct Node
	{
		unsigned parent_id;
		unsigned int id;
		Token type;
		std::string value;
	};
private:

	std::vector<Parser::Node> _create_list(
			const std::unique_ptr<TreeNode<Parser::Node>> &p_root
	);

	std::unique_ptr<TreeNode<Node>> _make_node(
			Token p_type,
			std::string p_value
	);

	void _update_node(
			std::unique_ptr<TreeNode<Node>> &p_node,
			Token p_type,
			std::string p_value
	);

	void _error(std::string p_error);

	void _print_tree(
			const std::unique_ptr<TreeNode<Node>> &p_current_node,
			bool p_last_child = true,
			std::string p_indent = ""
	);

	std::vector<std::string> function_declarations;

	unsigned int current_node_offset;
	unsigned int node_count;
	std::vector<Parser::Node> tree_vector;
	Parser::Node current_node;

	void _advance();

	void _analyse_function_declaration(
			std::unique_ptr<TreeNode<Node>> &p_parent
	);

	void _analyse_code_block(
			std::unique_ptr<TreeNode<Node>> &p_parent
	);

	void _analyse_declaration(
			std::unique_ptr<TreeNode<Node>> &p_parent
	);

	void _analyse_statement(
	        std::unique_ptr<TreeNode<Node>> &p_parent
	);

	void _analyse_expression(
			std::unique_ptr<TreeNode<Node>> &p_parent
	);

public:
	std::unique_ptr<TreeNode<Node>> analyise(
			const std::unique_ptr<TreeNode<Parser::Node>> &parse_tree
	);

	SymanticAnalysier();
};

#endif // SYMANTIC_ANALYSIER_H

extension: h


text:
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bigquery

import (
	"reflect"
	"testing"

	bq "google.golang.org/api/bigquery/v2"
)

func bqTableFieldSchema(desc, name, typ, mode string) *bq.TableFieldSchema {
	return &bq.TableFieldSchema{
		Description: desc,
		Name:        name,
		Mode:        mode,
		Type:        typ,
	}
}

func fieldSchema(desc, name, typ string, repeated, required bool) *FieldSchema {
	return &FieldSchema{
		Description: desc,
		Name:        name,
		Repeated:    repeated,
		Required:    required,
		Type:        FieldType(typ),
	}
}

func TestSchemaConversion(t *testing.T) {
	testCases := []struct {
		schema   *Schema
		bqSchema *bq.TableSchema
	}{
		{
			// required
			bqSchema: &bq.TableSchema{
				Fields: []*bq.TableFieldSchema{
					bqTableFieldSchema("desc", "name", "STRING", "REQUIRED"),
				},
			},
			schema: &Schema{
				fieldSchema("desc", "name", "STRING", false, true),
			},
		},
		{
			// repeated
			bqSchema: &bq.TableSchema{
				Fields: []*bq.TableFieldSchema{
					bqTableFieldSchema("desc", "name", "STRING", "REPEATED"),
				},
			},
			schema: &Schema{
				fieldSchema("desc", "name", "STRING", true, false),
			},
		},
		{
			// nullable, string
			bqSchema: &bq.TableSchema{
				Fields: []*bq.TableFieldSchema{
					bqTableFieldSchema("desc", "name", "STRING", ""),
				},
			},
			schema: &Schema{
				fieldSchema("desc", "name", "STRING", false, false),
			},
		},
		{
			// integer
			bqSchema: &bq.TableSchema{
				Fields: []*bq.TableFieldSchema{
					bqTableFieldSchema("desc", "name", "INTEGER", ""),
				},
			},
			schema: &Schema{
				fieldSchema("desc", "name", "INTEGER", false, false),
			},
		},
		{
			// float
			bqSchema: &bq.TableSchema{
				Fields: []*bq.TableFieldSchema{
					bqTableFieldSchema("desc", "name", "FLOAT", ""),
				},
			},
			schema: &Schema{
				fieldSchema("desc", "name", "FLOAT", false, false),
			},
		},
		{
			// boolean
			bqSchema: &bq.TableSchema{
				Fields: []*bq.TableFieldSchema{
					bqTableFieldSchema("desc", "name", "BOOLEAN", ""),
				},
			},
			schema: &Schema{
				fieldSchema("desc", "name", "BOOLEAN", false, false),
			},
		},
		{
			// timestamp
			bqSchema: &bq.TableSchema{
				Fields: []*bq.TableFieldSchema{
					bqTableFieldSchema("desc", "name", "TIMESTAMP", ""),
				},
			},
			schema: &Schema{
				fieldSchema("desc", "name", "TIMESTAMP", false, false),
			},
		},
		{
			// nested
			bqSchema: &bq.TableSchema{
				Fields: []*bq.TableFieldSchema{
					&bq.TableFieldSchema{
						Description: "An outer schema wrapping a nested schema",
						Name:        "outer",
						Mode:        "REQUIRED",
						Type:        "RECORD",
						Fields: []*bq.TableFieldSchema{
							bqTableFieldSchema("inner field", "inner", "STRING", ""),
						},
					},
				},
			},
			schema: &Schema{
				&FieldSchema{
					Description: "An outer schema wrapping a nested schema",
					Name:        "outer",
					Required:    true,
					Type:        "RECORD",
					Schema: []*FieldSchema{
						&FieldSchema{
							Description: "inner field",
							Name:        "inner",
							Type:        "STRING",
						},
					},
				},
			},
		},
	}

	for _, tc := range testCases {
		bqSchema := tc.schema.asTableSchema()
		if !reflect.DeepEqual(bqSchema, tc.bqSchema) {
			t.Errorf("converting to TableSchema: got:\n%v\nwant:\n%v", bqSchema, tc.bqSchema)
		}
		schema := convertTableSchema(tc.bqSchema)
		if !reflect.DeepEqual(schema, tc.schema) {
			t.Errorf("converting to Schema: got:\n%v\nwant:\n%v", schema, tc.schema)
		}
	}
}

repository: kykl/goapi

repo_name: kykl/goapi


text:
cmake_minimum_required(VERSION 3.10)

@PACKAGE_INIT@

# https://cmake.org/cmake/help/v3.5/module/CMakePackageConfigHelpers.html#module:CMakePackageConfigHelpers
# seems to indicate that I need to pre-pend PACKAGE_ to the variable names after the @PACKAGE_INIT@ macro
# but this doesn't seem to work, not sure if this is a "relocatable package" (low concern)
include("@Tasmanian_final_install_path@/lib/@CMAKE_PROJECT_NAME@/@CMAKE_PROJECT_NAME@.cmake")

add_executable(Tasmanian::tasgrid IMPORTED)
set_property(TARGET Tasmanian::tasgrid PROPERTY IMPORTED_LOCATION "@Tasmanian_final_install_path@/bin/tasgrid${CMAKE_EXECUTABLE_SUFFIX_CXX}")

add_library(Tasmanian::Tasmanian INTERFACE IMPORTED GLOBAL)

add_library(Tasmanian_libsparsegrid INTERFACE) # for backwards compatibility
add_library(Tasmanian_libdream INTERFACE)

if (TARGET Tasmanian_shared)
    add_library(Tasmanian::shared INTERFACE IMPORTED GLOBAL)
    set_target_properties(Tasmanian::shared PROPERTIES INTERFACE_LINK_LIBRARIES Tasmanian_shared)
    set(Tasmanian_SHARED_FOUND "ON")
endif()

# define _static/_shared independent libraries, default to static if both types are present
if (TARGET Tasmanian_static)
    target_link_libraries(Tasmanian_libsparsegrid INTERFACE Tasmanian_libsparsegrid_static)
    target_link_libraries(Tasmanian_libdream INTERFACE Tasmanian_libdream_static)

    add_library(Tasmanian::static INTERFACE IMPORTED GLOBAL)
    set_target_properties(Tasmanian::static PROPERTIES INTERFACE_LINK_LIBRARIES Tasmanian_static)
    set(Tasmanian_STATIC_FOUND "ON")

    if (@Tasmanian_ENABLE_CUDA@)
    # Since Tasmanian does not transitively include <cuda.h> and since all CUDA calls are wrapped in CXX API,
    # projects do not require cuda language to link to Tasmanian; however, CMake adds the extraneous dependence.
    # If Tasmanian was build with CUDA and if the user has not explicitly enabled the CUDA language,
    # then overwrite the CMake generated extraneous CUDA requirements and link with the CXX compiler only.
    # This hack is not necessary when building shared libraries.
        if (NOT CMAKE_CUDA_COMPILER)
            set_target_properties(Tasmanian_libsparsegrid_static PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX")
            set_target_properties(Tasmanian_libsparsegrid_static PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX")
            get_target_property(TasLibs Tasmanian_libsparsegrid_static INTERFACE_LINK_LIBRARIES)
            if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
                set_target_properties(Tasmanian_libsparsegrid_static PROPERTIES INTERFACE_LINK_LIBRARIES "${TasLibs};@Tasmanian_cudaruntime@")
            else()
                set_target_properties(Tasmanian_libsparsegrid_static PROPERTIES INTERFACE_LINK_LIBRARIES "${TasLibs};@Tasmanian_cudaruntime@;dl")
            endif()
        endif()
    endif()
else()
    target_link_libraries(Tasmanian_libsparsegrid INTERFACE Tasmanian_libsparsegrid_shared)
    target_link_libraries(Tasmanian_libdream INTERFACE Tasmanian_libdream_shared)
endif()

if (@Tasmanian_ENABLE_FORTRAN@)
    add_library(Tasmanian_libfortran90 INTERFACE)
    if (TARGET Tasmanian_libfortran90_static)
        target_link_libraries(Tasmanian_libfortran90 INTERFACE Tasmanian_libfortran90_static)
    else()
        target_link_libraries(Tasmanian_libfortran90 INTERFACE Tasmanian_libfortran90_shared)
    endif()
    set(Tasmanian_FORTRAN_FOUND "ON")

    add_library(Tasmanian::Fortran INTERFACE IMPORTED GLOBAL)
    set_target_properties(Tasmanian::Fortran PROPERTIES INTERFACE_LINK_LIBRARIES Tasmanian::Tasmanian)
endif()

# export the python path so other projects can configure python scripts
if (@Tasmanian_ENABLE_PYTHON@)
    set_and_check(Tasmanian_PYTHONPATH "@Tasmanian_final_install_path@/share/Tasmanian/python/")
    set(Tasmanian_PYTHON_FOUND "ON")
endif()

# export the MATLAB paths so other projects can write files directly to MATLAB
if (NOT "@Tasmanian_MATLAB_WORK_FOLDER@" STREQUAL "")
    set_and_check(Tasmanian_MATLAB_WORK_FOLDER "@Tasmanian_MATLAB_WORK_FOLDER@")
    set_and_check(Tasmanian_MATLABPATH "@Tasmanian_final_install_path@/share/Tasmanian/matlab/")
    set(Tasmanian_MATLAB_FOUND "ON")
endif()

set(Tasmanian_OPENMP_FOUND "@Tasmanian_ENABLE_OPENMP@")
set(Tasmanian_BLAS_FOUND   "@Tasmanian_ENABLE_BLAS@")
set(Tasmanian_MPI_FOUND    "@Tasmanian_ENABLE_MPI@")
set(Tasmanian_CUDA_FOUND   "@Tasmanian_ENABLE_CUDA@")
set(Tasmanian_MAGMA_FOUND  "@Tasmanian_ENABLE_MAGMA@")

# write component info
foreach(_comp ${Tasmanian_FIND_COMPONENTS})
    if (Tasmanian_${_comp}_FOUND)
        message(STATUS "Tasmanian component ${_comp}: found")
    else()
        if (Tasmanian_FIND_REQUIRED_${_comp})
            message(WARNING "Tasmanian rerquired component ${_comp}: missing (error)")
        else()
            message(STATUS "Tasmanian optional component ${_comp}: missing")
        endif()
    endif()
endforeach()
unset(_comp)

check_required_components(Tasmanian)

# if find_package(Tasmanian REQUIRED SHARED) is called without STATIC then default to shared libraries
if ((SHARED IN_LIST Tasmanian_FIND_COMPONENTS) AND (NOT STATIC IN_LIST Tasmanian_FIND_COMPONENTS) AND (TARGET Tasmanian_shared))
    set_target_properties(Tasmanian::Tasmanian PROPERTIES INTERFACE_LINK_LIBRARIES Tasmanian_shared)
else() # otherwise use the default (static if existing, else shared)
    set_target_properties(Tasmanian::Tasmanian PROPERTIES INTERFACE_LINK_LIBRARIES Tasmanian_master)
endif()


text:
package main

import (
	"log"
	"os"
)

const (
	OINC = iota
	OSHIFT
	OINPUT
	OOUTPUT
	OJMP
	OCLEAR
	OMULADD
)

type Instruction struct {
	op, arg1 uint8
	arg2     int
}

// ooo11111 11122222 22222222 22222222
//  op     arg1                   arg2
type PackedInstruction uint32

type Program []PackedInstruction

func (inst Instruction) Pack() PackedInstruction {
	return PackedInstruction((uint32(inst.op)&0x7)<<29 | (uint32(inst.arg1)&0xff)<<21 | uint32(inst.arg2)&0x1fffff)
}

func (packed PackedInstruction) Unpack() (inst Instruction) {
	inst.arg2 = int(packed & 0xfffff)
	if packed&0x100000 != 0 {
		inst.arg2 |= ^0xfffff
	}
	packed >>= 21
	inst.arg1 = uint8(packed & 0xff)
	packed >>= 8
	inst.op = uint8(packed)
	return
}

func (p *Program) Append(inst Instruction) {
	*p = append(*p, inst.Pack())
}

func (p *Program) Extend(p1 Program) {
	*p = append(*p, p1...)
}

func (p *Program) Len() int {
	return len(*p)
}

func checkError(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func VMRun(p Program) {
	var (
		memory [65536]uint8
		cursor uint16
		pc     int
	)
	for pc = 0; pc < len(p); pc++ {
		switch inst := p[pc].Unpack(); inst.op {
		case OINC:
			memory[cursor] += inst.arg1
		case OSHIFT:
			cursor += uint16(inst.arg2)
		case OINPUT:
			_, err := os.Stdin.Read(memory[cursor : cursor+1])
			checkError(err)
		case OOUTPUT:
			_, err := os.Stdout.Write(memory[cursor : cursor+1])
			checkError(err)
		case OJMP:
			if (memory[cursor] == 0) == (inst.arg1 == 0) {
				// should jump
				pc += inst.arg2
			}
		case OCLEAR:
			memory[cursor] = 0
		case OMULADD:
			memory[cursor+uint16(inst.arg2)] += inst.arg1 * memory[cursor]
		default:
			panic("unreached")
		}
	}
}

repository: z-rui/bfgo

repo_name: z-rui/bfgo


text:
@inproceedings{
dhingra2020differentiable,
title={Differentiable Reasoning over a Virtual Knowledge Base},
author={Bhuwan Dhingra and Manzil Zaheer and Vidhisha Balachandran and Graham Neubig and Ruslan Salakhutdinov and William W. Cohen},
booktitle={International Conference on Learning Representations},
year={2020},
url={https://openreview.net/forum?id=SJxstlHFPH}
}

repository: vidhishanair/academic-kickstart

repo_name: vidhishanair/academic-kickstart


text:
#pragma once

#include <functional>
#include <unordered_map>

#include <core/common/nonstd/type_index.hpp>
#include <core/string_utils/string_utils.h>
#include <core/tasks/task_system.h>

#include "asset_handle.h"
#include <cassert>

namespace runtime
{

struct basic_storage
{
	//-----------------------------------------------------------------------------
	//  Name : ~base_storage (virtual )
	/// <summary>
	///
	///
	///
	/// </summary>
	//-----------------------------------------------------------------------------
	virtual ~basic_storage() = default;

	//-----------------------------------------------------------------------------
	//  Name : clear (virtual )
	/// <summary>
	///
	///
	///
	/// </summary>
	//-----------------------------------------------------------------------------
	virtual void clear() = 0;

	//-----------------------------------------------------------------------------
	//  Name : clear (virtual )
	/// <summary>
	///
	///
	///
	/// </summary>
	//-----------------------------------------------------------------------------
	virtual void clear(const std::string& group) = 0;
};

template <typename T>
struct asset_storage : public basic_storage
{
	/// aliases
	using request_container_t = std::unordered_map<std::string, core::task_future<asset_handle<T>>>;
	template <typename F>
	using callable = std::function<F>;
	using load_from_file_t = callable<bool(core::task_future<asset_handle<T>>&, const std::string&)>;
	using load_from_instance_t =
		callable<bool(core::task_future<asset_handle<T>>&, const std::string&, std::shared_ptr<T>)>;

	using predicate_t = callable<bool(const typename request_container_t::value_type&)>;
	//-----------------------------------------------------------------------------
	//  Name : ~storage ()
	/// <summary>
	///
	///
	///
	/// </summary>
	//-----------------------------------------------------------------------------
	~asset_storage() override = default;

	void clear_with_condition(const predicate_t& predicate)
	{
		std::lock_guard<std::recursive_mutex> lock(container_mutex);
		for(auto it = container.cbegin(); it != container.cend();)
		{
			if(predicate(*it))
			{
				it = container.erase(it);
			}
			else
			{
				++it;
			}
		}
	}
	//-----------------------------------------------------------------------------
	//  Name : clear ()
	/// <summary>
	///
	///
	///
	/// </summary>
	//-----------------------------------------------------------------------------
	void clear() final
	{
		clear_with_condition([](const auto& it) {
			const auto& task = it.second;
			task.cancel();
			return true;
		});
	}

	//-----------------------------------------------------------------------------
	//  Name : clear ()
	/// <summary>
	///
	///
	///
	/// </summary>
	//-----------------------------------------------------------------------------
	void clear(const std::string& group) final
	{
		clear_with_condition([&group](const auto& it) {
			const auto& id = it.first;
			const auto& task = it.second;

			if(string_utils::begins_with(id, group))
			{
				task.cancel();
				return true;
			}
			return false;
		});
	}

	/// key, mode
	load_from_file_t load_from_file;

	/// key, mode
	load_from_instance_t load_from_instance;

	/// Storage container
	request_container_t container;

	/// Mutex
	std::recursive_mutex container_mutex;
};
}

repository: pgruenbacher/EtherealEngine

repo_name: pgruenbacher/EtherealEngine


text:
package auth

import (
	"encoding/json"
	"fmt"
	"golang.org/x/oauth2"
	"golang.org/x/oauth2/microsoft"
	"io"
	"net/http"
	"net/url"
	"os"
	"time"
)

// TokenSource holds an oauth2.TokenSource which uses device auth to get a code. The user authenticates using
// a code. TokenSource prints the authentication code and URL to os.Stdout. To use a different io.Writer, use
// WriterTokenSource. TokenSource automatically refreshes tokens.
var TokenSource oauth2.TokenSource = &tokenSource{w: os.Stdout}

// WriterTokenSource returns a new oauth2.TokenSource which, like TokenSource, uses device auth to get a code.
// Unlike TokenSource, WriterTokenSource allows passing an io.Writer to which information on the auth URL and
// code are printed. WriterTokenSource automatically refreshes tokens.
func WriterTokenSource(w io.Writer) oauth2.TokenSource {
	return &tokenSource{w: w}
}

// tokenSource implements the oauth2.TokenSource interface. It provides a method to get an oauth2.Token using
// device auth through a call to RequestLiveToken.
type tokenSource struct {
	w io.Writer
	t *oauth2.Token
}

// Token attempts to return a Live Connect token using the RequestLiveToken function.
func (src *tokenSource) Token() (*oauth2.Token, error) {
	if src.t == nil {
		t, err := RequestLiveTokenWriter(src.w)
		src.t = t
		return t, err
	}
	tok, err := refreshToken(src.t)
	if err != nil {
		return nil, err
	}
	// Update the token to use to refresh for the next time Token is called.
	src.t = tok
	return tok, nil
}

// RefreshTokenSource returns a new oauth2.TokenSource using the oauth2.Token passed that automatically
// refreshes the token everytime it expires. Note that this function must be used over oauth2.ReuseTokenSource
// due to that function not refreshing with the correct scopes.
func RefreshTokenSource(t *oauth2.Token) oauth2.TokenSource {
	return RefreshTokenSourceWriter(t, os.Stdout)
}

// RefreshTokenSourceWriter returns a new oauth2.TokenSource using the oauth2.Token passed that automatically
// refreshes the token everytime it expires. It requests from io.Writer if the oauth2.Token is invalid.
// Note that this function must be used over oauth2.ReuseTokenSource due to that
// function not refreshing with the correct scopes.
func RefreshTokenSourceWriter(t *oauth2.Token, w io.Writer) oauth2.TokenSource {
	return oauth2.ReuseTokenSource(t, &tokenSource{w: w, t: t})
}

// RequestLiveToken does a login request for Microsoft Live Connect using device auth. A login URL will be
// printed to the stdout with a user code which the user must use to submit.
// RequestLiveToken is the equivalent of RequestLiveTokenWriter(os.Stdout).
func RequestLiveToken() (*oauth2.Token, error) {
	return RequestLiveTokenWriter(os.Stdout)
}

// RequestLiveTokenWriter does a login request for Microsoft Live Connect using device auth. A login URL will
// be printed to the io.Writer passed with a user code which the user must use to submit.
// Once fully authenticated, an oauth2 token is returned which may be used to login to XBOX Live.
func RequestLiveTokenWriter(w io.Writer) (*oauth2.Token, error) {
	d, err := startDeviceAuth()
	if err != nil {
		return nil, err
	}
	_, _ = w.Write([]byte(fmt.Sprintf("Authenticate at %v using the code %v.\n", d.VerificationURI, d.UserCode)))
	ticker := time.NewTicker(time.Second * time.Duration(d.Interval))
	defer ticker.Stop()

	for range ticker.C {
		t, err := pollDeviceAuth(d.DeviceCode)
		if err != nil {
			return nil, fmt.Errorf("error polling for device auth: %w", err)
		}
		// If the token could not be obtained yet (authentication wasn't finished yet), the token is nil.
		// We just retry if this is the case.
		if t != nil {
			_, _ = w.Write([]byte("Authentication successful.\n"))
			return t, nil
		}
	}
	panic("unreachable")
}

// startDeviceAuth starts the device auth, retrieving a login URI for the user and a code the user needs to
// enter.
func startDeviceAuth() (*deviceAuthConnect, error) {
	resp, err := http.PostForm("https://login.live.com/oauth20_connect.srf", url.Values{
		"client_id":     {"0000000048183522"},
		"scope":         {"service::user.auth.xboxlive.com::MBI_SSL"},
		"response_type": {"device_code"},
	})
	if err != nil {
		return nil, fmt.Errorf("POST https://login.live.com/oauth20_connect.srf: %w", err)
	}
	defer func() {
		_ = resp.Body.Close()
	}()
	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("POST https://login.live.com/oauth20_connect.srf: %v", resp.Status)
	}
	data := new(deviceAuthConnect)
	return data, json.NewDecoder(resp.Body).Decode(data)
}

// pollDeviceAuth polls the token endpoint for the device code. A token is returned if the user authenticated
// successfully. If the user has not yet authenticated, err is nil but the token is nil too.
func pollDeviceAuth(deviceCode string) (t *oauth2.Token, err error) {
	resp, err := http.PostForm(microsoft.LiveConnectEndpoint.TokenURL, url.Values{
		"client_id":   {"0000000048183522"},
		"grant_type":  {"urn:ietf:params:oauth:grant-type:device_code"},
		"device_code": {deviceCode},
	})
	if err != nil {
		return nil, fmt.Errorf("POST https://login.live.com/oauth20_token.srf: %w", err)
	}
	poll := new(deviceAuthPoll)
	if err := json.NewDecoder(resp.Body).Decode(poll); err != nil {
		return nil, fmt.Errorf("POST https://login.live.com/oauth20_token.srf: json decode: %w", err)
	}
	_ = resp.Body.Close()
	if poll.Error == "authorization_pending" {
		return nil, nil
	} else if poll.Error == "" {
		return &oauth2.Token{
			AccessToken:  poll.AccessToken,
			TokenType:    poll.TokenType,
			RefreshToken: poll.RefreshToken,
			Expiry:       time.Now().Add(time.Duration(poll.ExpiresIn) * time.Second),
		}, nil
	}
	return nil, fmt.Errorf("non-empty unknown poll error: %v", poll.Error)
}

// refreshToken refreshes the oauth2.Token passed and returns a new oauth2.Token. An error is returned if
// refreshing was not successful.
func refreshToken(t *oauth2.Token) (*oauth2.Token, error) {
	// This function unfortunately needs to exist because golang.org/x/oauth2 does not pass the scope to this
	// request, which Microsoft Connect enforces.
	resp, err := http.PostForm(microsoft.LiveConnectEndpoint.TokenURL, url.Values{
		"client_id":     {"0000000048183522"},
		"scope":         {"service::user.auth.xboxlive.com::MBI_SSL"},
		"grant_type":    {"refresh_token"},
		"refresh_token": {t.RefreshToken},
	})
	if err != nil {
		return nil, fmt.Errorf("POST https://login.live.com/oauth20_token.srf: %w", err)
	}
	poll := new(deviceAuthPoll)
	if err := json.NewDecoder(resp.Body).Decode(poll); err != nil {
		return nil, fmt.Errorf("POST https://login.live.com/oauth20_token.srf: json decode: %w", err)
	}
	_ = resp.Body.Close()
	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("POST https://login.live.com/oauth20_token.srf: refresh error: %v", poll.Error)
	}
	return &oauth2.Token{
		AccessToken:  poll.AccessToken,
		TokenType:    poll.TokenType,
		RefreshToken: poll.RefreshToken,
		Expiry:       time.Now().Add(time.Duration(poll.ExpiresIn) * time.Second),
	}, nil
}

type deviceAuthConnect struct {
	UserCode        string `json:"user_code"`
	DeviceCode      string `json:"device_code"`
	VerificationURI string `json:"verification_uri"`
	Interval        int    `json:"interval"`
	ExpiresIn       int    `json:"expiresIn"`
}

type deviceAuthPoll struct {
	Error        string `json:"error"`
	UserID       string `json:"user_id"`
	TokenType    string `json:"token_type"`
	Scope        string `json:"scope"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
}

repository: Sandertv/gophertunnel

repo_name: Sandertv/gophertunnel


text:
PR = "r1"

MAP_NAME = "low levels"
require om-maps.inc

MAP_FN = "om-maps-low-levels-${PV}.eet"
MAP_VER = "${PV}"


text:
#include "test.h"

#include "taco/lower/lower.h"
#include "taco/error/error_messages.h"

using namespace taco;

static const Dimension n, m, o;
static const Type vectype(Float64, {n});
static const Type mattype(Float64, {n,m});
static const Type tentype(Float64, {n,m,o});

static TensorVar alpha("alpha", Float64);
static TensorVar beta("beta",   Float64);
static TensorVar delta("delta", Float64);
static TensorVar  zeta("zeta",  Float64);
static TensorVar   eta("eta",   Float64);

static TensorVar a("a", vectype, Format());
static TensorVar b("b", vectype, Format());
static TensorVar c("c", vectype, Format());
static TensorVar d("d", vectype, Format());

static TensorVar w("w", vectype, dense);

static TensorVar A("A", mattype, Format());
static TensorVar B("B", mattype, Format());
static TensorVar C("C", mattype, Format());
static TensorVar D("D", mattype, Format());

static TensorVar S("S", tentype, Format());
static TensorVar T("T", tentype, Format());
static TensorVar U("U", tentype, Format());
static TensorVar V("V", tentype, Format());

const IndexVar i("i"), iw("iw");
const IndexVar j("j"), jw("jw");
const IndexVar k("k"), kw("kw");

TEST(DISABLED_lower, transpose) {
  TensorVar A(mattype, Format({sparse,sparse}, {0,1}));
  TensorVar B(mattype, Format({sparse,sparse}, {0,1}));
  TensorVar C(mattype, Format({sparse,sparse}, {1,0}));
  string reason;
  ASSERT_FALSE(isLowerable(forall(i,
                                  forall(j,
                                         A(i,j) = B(i,j) + C(i,j)
                                         )),
                           &reason));
  ASSERT_EQ(error::expr_transposition, reason);
}

TEST(DISABLED_lower, transpose2) {
  TensorVar A(mattype, Format({sparse,sparse}, {0,1}));
  TensorVar B(mattype, Format({sparse,sparse}, {0,1}));
  TensorVar C(mattype, Format({sparse,sparse}, {0,1}));
  string reason;
  ASSERT_FALSE(isLowerable(forall(i,
                                  forall(j,
                                         A(i,j) = B(i,j) + C(j,i)
                                         )),
                           &reason));
  ASSERT_EQ(error::expr_transposition, reason);
}

TEST(DISABLED_lower, transpose3) {
  TensorVar A(tentype, Format({sparse,sparse,sparse}, {0,1,2}));
  TensorVar B(tentype, Format({sparse,sparse,sparse}, {0,1,2}));
  TensorVar C(tentype, Format({sparse,sparse,sparse}, {0,1,2}));
  string reason;
  ASSERT_FALSE(isLowerable(forall(i,
                                  forall(j,
                                         forall(k,
                                                A(i,j,k) = B(i,j,k) + C(k,i,j)
                                                ))),
                           &reason));
  ASSERT_EQ(error::expr_transposition, reason);
}

// denseIterationTranspose tests a dense iteration that contain a transposition
// of one of the tensors.
TEST(lower, denseIterationTranspose) {
  auto dim = 4;
  Tensor<int> A("A", {dim, dim, dim}, {Dense, Dense, Dense});
  Tensor<int> B("B", {dim, dim, dim}, {Dense, Dense, Dense});
  Tensor<int> C("C", {dim, dim, dim}, {Dense, Dense, Dense});
  Tensor<int> expected("expected", {dim, dim, dim}, {Dense, Dense, Dense});
  for (int i = 0; i < dim; i++) {
    for (int j = 0; j < dim; j++) {
      for (int k = 0; k < dim; k++) {
        A.insert({i, j, k}, i + j + k);
        B.insert({i, j, k}, i + j + k);
        expected.insert({i, j, k}, 2 * (i + j + k));
      }
    }
  }
  A.pack(); B.pack(); expected.pack();
  C(i, j, k) = A(i, j, k) + B(k, j, i);
  C.evaluate();
  ASSERT_TRUE(equals(C, expected));
}

repository: tensor-compiler/taco

repo_name: tensor-compiler/taco

gha_license_id: NOASSERTION