def test_basic_convert(self):
        """ Tests conversion with no tokens are macros. """
        template = convert.get_template(resource(FREEMARKER_BASIC_HTML_NAME))
        output = convert.freemarker_to_django(template)

        expected = read_file(DJANGO_BASIC_HTML_NAME)
        self.assertEqualsStr(expected, output.replace('\r', ''))
 def test_convert_basic_variable(self):
     """ Tests conversion of variable to something that Django can understand. """
     template = convert.get_template(resource(FREEMARKER_BASIC_VARIABLE_NAME))
     output = convert.freemarker_to_django(template)
     expected = read_file(DJANGO_BASIC_VARIABLE_NAME)
     self.assertEqualsStr(expected, output)
    def test_basic_generator(self):
        """ Tests conversion with no tokens are macros. """
        generator = templatetags.generator.Generator('example', EXAMPLE_TEMPLATE_TAGS_PARAMS_MAP)

        expected = read_file(EXAMPLE_TEMPLATE_TAGS_NAME)
        self.assertEqualsStr(expected, generator.render())
#!/usr/bin/env python

##
# SPDX-License-Identifier: LGPL-2.1-only
#
# Copyright (C) 2018 Samsung Electronics
#
# @file checkScaledTensor.py
# @brief Check if the scaled results are correct
# @author MyungJoo Ham <*****@*****.**>

import os
import sys

sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from test_utils import read_file, compare_scaled_tensor


if len(sys.argv) != 8:
    exit(9)

# (data, width, height)
data1 = (read_file(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]))
data2 = (read_file(sys.argv[4]), int(sys.argv[5]), int(sys.argv[6]))
innerdim = int(sys.argv[7])

exit(compare_scaled_tensor(data1, data2, innerdim))
Example #5
0
#!/usr/bin/env python

##
# SPDX-License-Identifier: LGPL-2.1-only
#
# Copyright (C) 2019 Samsung Electronics
#
# @file checkLabel.py
# @brief Check the result label of pytorch model
# @author Parichay Kapoor <*****@*****.**>

import sys
import os
import string

sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from test_utils import convert_to_bytes, read_file


# Verify that the output of test case verifies the filename of the input
onehot = read_file(sys.argv[1])
onehot = [convert_to_bytes(x) for x in onehot]
idx = onehot.index(max(onehot))

label = str(idx)

answer = sys.argv[2].split('/')[-1].split('.')[0].strip()
exit(label != answer)
Example #6
0
##
# SPDX-License-Identifier: LGPL-2.1-only
#
# Copyright (C) 2018 Samsung Electronics
#
# @file checkLabel.py
# @brief Check the result label of tensorflow-lite model
# @author HyoungJoo Ahn <*****@*****.**>

import sys
import os
import struct
import string

sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from test_utils import convert_to_bytes, read_file

bytearr = read_file(sys.argv[1])
softmax = []
for i in range(10):
    byte = b''
    byte += convert_to_bytes(bytearr[i * 4])
    byte += convert_to_bytes(bytearr[i * 4 + 1])
    byte += convert_to_bytes(bytearr[i * 4 + 2])
    byte += convert_to_bytes(bytearr[i * 4 + 3])
    softmax.append(struct.unpack('f', byte))

pred = softmax.index(max(softmax))
answer = int(sys.argv[2].strip())
exit(pred != answer)
Example #7
0
    for x in range(0, num):
        vala = struct.unpack(typeapack,
                             fna[x * typeasize:x * typeasize + typeasize])[0]
        valb = struct.unpack(typebpack,
                             fnb[x * typebsize:x * typebsize + typebsize])[0]
        diff = vala - valb
        if diff > 0.00001 or diff < -0.00001:
            return 20
    return 0


if len(sys.argv) < 2:
    exit(5)

if sys.argv[1] == 'standardization':
    if len(sys.argv) < 8:
        exit(5)
    fna = read_file(sys.argv[2])
    fnb = read_file(sys.argv[3])
    typeasize = int(sys.argv[4])
    typebsize = int(sys.argv[5])
    typeapack = (sys.argv[6])
    typebpack = (sys.argv[7])

    exit(
        test_standardization(fna, fnb, typeasize, typebsize, typeapack,
                             typebpack))

exit(5)
Example #8
0
 def setUp(self):
     self.test1 = read_file('markdown/test1.md')
Example #9
0
 def setUp(self):
     self.test1 = read_file('rst/test1.rst')
     self.test2 = read_file('rst/test2.rst')
     self.table = read_file('rst/table.rst')
Example #10
0
    num = lena // typeasize
    limitb = 2**(8 * typebsize)
    maskb = limitb - 1

    for x in range(0, num):
        astart = x * typeasize
        bstart = x * typebsize
        vala = struct.unpack(typeapack, fna[astart:astart + typeasize])[0]
        valb = struct.unpack(typebpack, fnb[bstart:bstart + typebsize])[0]
        if not _compare(vala, valb, typeb, maskb):
            return 21
    return 0


if len(sys.argv) < 2:
    exit(5)

if sys.argv[1] == 'typecast':
    if len(sys.argv) < 10:
        exit(5)

    # (data, type, type-size, type-pack)
    data1 = (read_file(sys.argv[2]), sys.argv[4], int(sys.argv[5]),
             sys.argv[6])
    data2 = (read_file(sys.argv[3]), sys.argv[7], int(sys.argv[8]),
             sys.argv[9])

    exit(test_typecast(data1, data2))

exit(5)
Example #11
0
        astart = x * typeasize
        bstart = x * typebsize
        vala = struct.unpack(typeapack, fna[astart: astart + typeasize])[0]
        valb = struct.unpack(typebpack, fnb[bstart: bstart + typebsize])[0]
        if not _check_diff(mode, vala, valb, val1, val2):
            return 20
    return 0


if len(sys.argv) < 2:
    exit(5)

if sys.argv[1] == 'arithmetic':
    if len(sys.argv) < 11:
        exit(5)

    packa = (sys.argv[6])
    packb = (sys.argv[7])
    arith_mode = sys.argv[8]

    # (data, type-size, type-pack)
    data1 = (read_file(sys.argv[2]), int(sys.argv[4]), packa)
    data2 = (read_file(sys.argv[3]), int(sys.argv[5]), packb)
    # (value, type-pack)
    value1 = (sys.argv[9], packa)
    value2 = (sys.argv[10], packb)

    exit(test_arithmetic(data1, data2, arith_mode, value1, value2))

exit(5)