Beispiel #1
0
    def test_multiple_arguments(self):
        options = [
            "@0:1:backprop=yes", "@0:2:backprop=no", "@0:3:backprop=heh"
        ]
        res = parse_options.parse_options(options)

        self.assertEqual(res.strip(), "--backprop=yes,no,heh")

        # args with extra syntactic sugar
        options = [
            "@0:1:backprop=yes", "@0:2:sugar:backprop=no",
            "@0:4:somemoresugar:backprop=heh"
        ]
        res = parse_options.parse_options(options)

        self.assertEqual(res.strip(), "--backprop=yes,no,heh")
Beispiel #2
0
    def test_skip(self):
        options = [
            "@0:F:backprop=yes", "@1:S:deletion=yes", "@1:S:Geo:aryrestarts=2"
        ]
        res = parse_options.parse_options(options)

        self.assertEqual(res.strip(), "--backprop")
Beispiel #3
0
    def __init__(self, predicate, callback, pause=5.):
	"""

	"""
        super(ClipboardWatcher, self).__init__()
        self._predicate = predicate
        self._callback = callback
        self._pause = 5
        self._stopping = False
	self.options = parse_options.parse_options()
	print self.options
Beispiel #4
0
from call_cmd import call_cmd, make_call_in_dst
import os, o_p


def add_options(parser):
    parser.add_option("--bcp",
                      action="store",
                      dest="bcp",
                      metavar='bcp_path',
                      help="path to bcp utility",
                      default='bcp')


if __name__ == '__main__':
    from parse_options import parse_options
    options, (boost_src, boost_dst) = parse_options(
        "usage: %prog [options] boost_src boost_dst", add_options, num_args=2)
    bcp = options.bcp

    # политика: вроде как bcp сам не удаляет boost_dst, поэтому работаем по месту
    if os.path.exists(boost_dst):
        # удаляем все кроме своего
        lst = ['LICENSE_1_0.txt', 'README', 'SConscript', 'test_include']
        for fname in os.listdir(boost_dst):
            if not fname in lst:
                fpath = os.path.join(boost_dst, fname)
                print 'rm', fpath
                o_p.del_any_fpath(fpath)

    cmd = '''%(bcp)s --boost=%(boost_src)s boost/smart_ptr.hpp boost/test boost/function.hpp boost/lambda boost/bind \
boost/filesystem system boost/regex format boost/foreach.hpp boost/iterator boost/cast.hpp boost/range/reference.hpp \
boost/assign/list_of.hpp boost/assign.hpp boost/mpl/print.hpp %(boost_dst)s''' % locals(
Beispiel #5
0
#
# Скопировать часть библиотеки Boost для проекта Atom
#
# Пример: BCP=bcp tools/scripts/copy_boost.py /home/ilya/opt/programming/atom-project/boost_1_44_0 libs/boost-lib/
#

from call_cmd import call_cmd, make_call_in_dst
import os, o_p

def add_options(parser):
    parser.add_option("--bcp", action="store", dest="bcp", metavar='bcp_path', 
                      help="path to bcp utility", default='bcp')

if __name__ == '__main__':
    from parse_options import parse_options
    options, (boost_src, boost_dst) = parse_options("usage: %prog [options] boost_src boost_dst", add_options, num_args=2)
    bcp = options.bcp

    # политика: вроде как bcp сам не удаляет boost_dst, поэтому работаем по месту
    if os.path.exists(boost_dst):
        # удаляем все кроме своего
        lst = ['LICENSE_1_0.txt', 'README', 'SConscript', 'test_include']
        for fname in os.listdir(boost_dst):
            if not fname in lst:
                fpath = os.path.join(boost_dst, fname)
                print 'rm', fpath
                o_p.del_any_fpath(fpath)
    
    cmd = '''%(bcp)s --boost=%(boost_src)s boost/smart_ptr.hpp boost/test boost/function.hpp boost/lambda boost/bind \
boost/filesystem system boost/regex format boost/foreach.hpp boost/iterator boost/cast.hpp boost/range/reference.hpp \
boost/assign/list_of.hpp boost/assign.hpp boost/mpl/print.hpp %(boost_dst)s''' % locals()
Beispiel #6
0
    def test_flag(self):
        options = ["@0:F:backprop=yes"]
        res = parse_options.parse_options(options)

        self.assertEqual(res.strip(), "--backprop")
Beispiel #7
0
    def test_special_cases(self):
        options = ["@0:No:vsids-progress=no"]
        res = parse_options.parse_options(options)

        self.assertEqual(res.strip(), "--vsids-progress=no")
Beispiel #8
0
    def test_special_no_arguments(self):
        options = ["@0:no:eq=0", "@1:No:contraction=no"]
        res = parse_options.parse_options(options)

        self.assertEqual(res.strip(), "--eq=0 --no-contraction")
Beispiel #9
0
    def test_argument(self):
        options = ["@0:backprop=yes", "@1:deletion=yes", "@1:aryrestarts=2"]
        res = parse_options.parse_options(options)

        self.assertEqual(res.strip(),
                         "--backprop=yes --deletion=yes --aryrestarts=2")
Beispiel #10
0
import numpy as np
from keras.preprocessing import image
from keras import layers
from keras import models
from keras import optimizers
from keras.applications import inception_v3, imagenet_utils
from keras.preprocessing import image
from keras import backend as K
import parse_options
options = parse_options.parse_options()


def crop2square(img):
    short_side = min(img.size)
    x0 = (img.size[0] - short_side) / 2
    y0 = (img.size[1] - short_side) / 2
    x1 = img.size[0] - x0
    y1 = img.size[1] - y0
    return img.crop((x0, y0, x1, y1))


def dummy(value):
    if value == 1:
        return [0, 0]
    elif value == 2:
        return [1, 0]
    elif value == 3:
        return [1, 1]


img = np.random.rand(224, 224, 3)