Example #1
0
def test_echo():
    """
    Testing successful uses of echo
    """
    assert echo.echo("1") == "1", "1 == 1"
    assert echo.echo("abc") == "abc", "abc == abc"
    assert echo.echo("trump") == "trump", "trump == trump"
Example #2
0
def test_echo():
    """
    Basic echo tests.
    """
    assert echo.echo("1") == "1", "1 == 1"
    assert echo.echo("abc") == "abc", "abc == abc"
    assert echo.echo("trump") == "trump", "trump == trump"
Example #3
0
def wav_echo_sim(ifn,
                 ofn,
                 stereo=True,
                 cosim=True,
                 sample_rng=None,
                 feedback_gain=0.6,
                 delay=0.25):
    """Applies echo effect on a WAV file using Verilator cosimulation

    ifn - Input WAV file name
    ofn - Output WAV file name
    """

    samples_all, params = wav_utils.load_wav(ifn, stereo=stereo)
    samples = samples_all[:sample_rng]

    sample_bit_width = 8 * params.sampwidth
    sample_type = Fixp[1, sample_bit_width]

    if stereo:
        stream_type = Tuple[sample_type, sample_type]

        def decode_sample(seq):
            for s in seq:
                yield stream_type(
                    (sample_type.decode(s[0]), sample_type.decode(s[1])))
    else:
        stream_type = sample_type

        def decode_sample(seq):
            for s in seq:
                yield sample_type.decode(s)

    result = []
    drv(t=stream_type, seq=decode_sample(samples)) \
        | echo(feedback_gain=feedback_gain,
               sample_rate=params.framerate,
               delay=delay,
               sim_cls=SimVerilated if cosim else None) \
        | collect(result=result, samples_num=len(samples))

    sim(resdir='./build')

    wav_utils.dump_wav(ofn, result, params, stereo=stereo)

    try:
        wav_utils.plot_wavs(samples, result, stereo=stereo)
    except:
        pass
Example #4
0
def scope_test():
    def local_scope():
        span = "local scope"

    def do_nonlocal():
        nonlocal span
        span = "nonlocal scope"

    def globe_scope():
        global span
        span = "global scope"

    span = "test scpoe"
    local_scope()
    echo("call local_scope:", span)
    do_nonlocal()
    echo("call nonlocal:", span)
    globe_scope()
    echo("call global:", span)
def test_given_empty_string_then_prints_newline(output):
    echo("")
    assert output.out == "\n"
Example #6
0
#-*- coding:utf-8 -*-
from echo import echo
import sys

try:
    with open("./hahah.txt", "a") as f:
        # f.readline()
        f.write(2)
        # 1/0
except:
    echo("exception error:{}".format(sys.exc_info()))
    raise
Example #7
0
def test_echo_except():
    """
    Trigger exception.
    """
    with pytest.raises(InputError):
        assert echo.echo("echo")
Example #8
0
 def Response(self, request, context):
     response = echo_pb2.Set()
     response.value = echo.echo(request.value)
     response.number = echo.echo(request.number)
     return response
def test_given_option_newline_disabled_then_does_not_print_new_line(output):
    echo("a", newline=False)
    assert output.out == "a"
Example #10
0
 def printxx(self):
     echo("ff")
Example #11
0
 def a(self):
     echo("second method")
Example #12
0
def test_echo_except():
    """
    Testing unsuccessful uses of echo
    """
    with pytest.raises(InputError):
        assert echo.echo("echo")
def test_given_one_character_then_prints_character_and_newline(output):
    echo("a")
    assert output.out == "a\n"
Example #14
0
def f(event, context):
    return echo.echo(event)
# -*-coding:utf-8-*-
from echo import echo
import reprlib

echo(reprlib.repr(set("hsfhhrumbsdbsjhgkhfjkhvba")))

import threading, zipfile


class AsyncZip(threading.Thread):
    def __init__(self, infile, outfile):
        threading.Thread.__init__(self)
        self.infile = infile
        self.outfile = outfile

    def run(self):
        f = zipfile.ZipFile(self.outfile, 'w', zipfile.ZIP_DEFLATED)
        f.write(self.infile)
        f.close()
        print('Finished background zip of:', self.infile)


background = AsyncZip('mydata.txt', 'myarchive.zip')
background.start()
print('The main program continues to run in foreground.')

background.join()  # Wait for the background task to finish
print('Main program waited until background was done.')

import logging
Example #16
0
import os
import shutil

from echo import echo
from pygears import Intf
from pygears.definitions import LIB_SVLIB_DIR
from pygears.hdl.sv import svgen
from pygears.typing import Int
from pygears.util.print_hier import print_hier

Intf(Int[16]) | echo(feedback_gain=0.6, sample_rate=48000, delay=0.25)
svgen('/echo', outdir='build/echo', wrapper=True)

print(f'Generated SystemVerilog files inside {os.path.abspath("build/echo")}')

print()
print_hier()
print()

print(f'Creating Vivado project inside {os.path.abspath("build/echo/vivado")}')

shutil.rmtree('build/echo/vivado', ignore_errors=True)

viv_cmd = (f'vivado -mode batch -source echo_synth.tcl -nolog -nojournal'
           f' -tclargs {LIB_SVLIB_DIR}')

if os.system(viv_cmd) == 0:
    with open('build/echo/echo_utilization.txt') as f:
        print(f.read())
Example #17
0
def main(args):
    return echo(args)
Example #18
0
def test_echo_except():
    """Testing a failed echo"""
    with pytest.raises(InputError):
        assert echo.echo("echo")
Example #19
0
 def printx(self):
     echo("base class")
Example #20
0
 def a(self):
     echo("first method")
Example #21
0
 def test_echo(self):
     self.assertEqual("echoing: yy", echo ("yy"))
Example #22
0
 def __init__(self):
     echo("sub class is invoked")
     echo("base class attribute", self.kind)
Example #23
0
# -*- coding:utf8 -*-

from echo import echo

list = [1, 2, 3, "ff"]

echo(list)

a, b, c = 1, 2, 3
echo(c)

# try:
#     x = int(input("请输入int类型数据\n"))
#     echo(x)
# except:
#     echo("输入错误")

pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]

# key=lambda pair: pair[1]
pairs.sort(key=lambda pair: pair[1])


def fun():
    """Do you know the function

The function is a demo.
    """


echo(fun.__doc__)
Example #24
0
def f(event):
    return echo.echo(event)
def test_given_multiple_arguments_then_prints_them_seperated_by_spaces(output):
    echo("a", "b", "c")
    assert output.out == "a b c\n"
Example #26
0
 def testEcho(self):
     expected = "TEST MESSAGE"
     result = echo.echo(expected)
     self.assertEqual(expected, result)
Example #27
0
def lambda_handler(event, context):
    return echo.echo(event)
Example #28
0
#-*-coding:utf-8-*-

import math
from echo import echo

import json

echo("asahj{0:.3f}".format(math.pi))

table = {"orange": 3234, "pear": 123, "apple": 77879}

for key, value in table.items():
    # pass
    echo("{0:10}=>{1:10d}".format(key, value))

echo("pear:{0[pear]};orange:{0[orange]:d};apple:{0[apple]:d}".format(table))

echo("pear:{pear};orange:{orange};apple:{apple}".format(**table))

with open("json.json", "r+") as f:
    x = json.dumps(table)
    # f.write("ffff")
    echo(type(x))
    echo(table)
    # echo(type(f.readline()))
    x = f.readline()
    echo(x)
Example #29
0
def test_echo_except():
    with pytest.raises(InputError):
        assert echo.echo("echo")
Example #30
0
# -*-coding:utf-8-*-
from echo import echo
import os
import shutil
import glob
import sys

echo(os.getcwd())

# a = os.chdir("/Users/deyinliu/Desktop")
# os.system("rm i.py")

# shutil.copyfile("./standard_lib.py","./standard_lib1.py")
# echo(help(glob.glob))
echo(glob.glob("*.py"))
echo(sys.argv)
# print("  \bdd\nfsaf")
from timeit import Timer
echo(Timer("a = 1;b = 2").timeit())


def average(values):
    """Computes the arithmetic mean of a list of numbers.

    >>> print(average([20, 30, 70]))
    40.0
    """
    return sum(values) / len(values)


import doctest
Example #31
0
def test_echo():
    assert echo.echo("1") == "1", "1 == 1"
    assert echo.echo("abc") == "abc", "abc == abc"
    assert echo.echo("trump") == "trump", "trump == trump"
Example #32
0
from echo import echo, MORSE, ALPHABET, full_expand

# Silly alfa lima foxtrot alfa.

S = 'The quick brown fox jumps over the lazy dogs'

print(echo(S))
print()
print(echo(echo(S)))
print()
print(echo(echo('Hi')))
print()
print()

# Prosigns

EQUIVALENT_PROSIGNS = []

for a1 in range(26):
    for a2 in range(26):
        for b1 in range(26):
            for b2 in range(26):
                if a1 == b1 and a2 == b2:
                    continue
                prosign_1 = MORSE[a1] + MORSE[a2]
                prosign_2 = MORSE[b1] + MORSE[b2]
                if prosign_1 == prosign_2:
                    text1 = ALPHABET[a1] + ALPHABET[a2]
                    text2 = ALPHABET[b1] + ALPHABET[b2]
                    EQUIVALENT_PROSIGNS.append(text1 + " = " + text2)
Example #33
0
from sys import argv
import cat
import echo
import head
import sort
import tail

if argv[1] == '-c':
    cat.cat(argv[2])
elif argv[1] == '-e':
    echo.echo(argv[2])
elif argv[1] == '-h':
    head.head(argv[2])
elif argv[1] == '-s':
    sort.sort(argv[2])
elif argv[1] == '-t':
    tail.tail(argv[2])
Example #34
0

class Reverse():
    def __init__(self, data):
        self.data = data
        self.index = len(data)

    def __iter__(self):
        return self

    def __next__(self):
        if self.index == 0:
            raise StopIteration
        self.index = self.index - 1
        return self.data[-self.index - 1]


if __name__ == '__main__':

    # x = subtest()
    # echo(x.kind)
    # x.a()
    # a = Reverse("index")
    # echo(a)
    def reserve(data):
        for index in range(len(data)):
            yield data[index]

    for i in reserve("index"):
        echo(i)
Example #35
0
 def __init__(self, data):
     echo("base class is invoked")
     self.data = data
     # mutable object
     self.trick = []
Example #36
0
# -*- coding: cp936 -*-
from echo import echo
echo(__file__)
from math import sqrt
#for
def ForSqrt(List):
   temp =[]
   if type(List) == list:
      for x in List:
         temp.append(sqrt(x))
   return temp
#map
def MapSqrt(List):
   if type(List) == list:
      return map(lambda x:sqrt(x),L)
#列表解析
def ListSqrt(List):
   if type(List) == list:
      return [sqrt(x) for x in L]

#列表解析会更方便
   #1.直观
   #2.比起用for会更快
   #3.map当function部分不是内置的时候,性能表现甚至会连for都不如

L = [2,4,9,16,25]

print ForSqrt(L)
print MapSqrt(L)
print ListSqrt(L)
def test_given_no_arguments_then_prints_newline(output):
    echo()
    assert output.out == "\n"