import os, syssys.path.append(os.path.split(os.path.realpath(__file__))[0] + "/../lib")from cnstream import *from cnstream_cpptest import *# in order to determine whether the python function is called by cppinit_called = Falseexecute_called = Falsepreproc_params = Noneclass CustomPreproc(Preproc):def __init__(self):Preproc.__init__(self)def init(self, params):global init_calledglobal preproc_paramsinit_called = Truepreproc_params = paramsreturn Truedef execute(self, input_shapes, finfo):global execute_calledexecute_called = Trueresults = []# the shape of return value must be equal to input_shapesfor sp in input_shapes:data_count = 1for i in range(len(sp) - 1):data_count *= sp[i]results.append(range(data_count))return resultsclass TestPreproc:def test_init(self):params = {'pyclass_name' : 'test.preproc_test.CustomPreproc', 'param' : 'value'}assert cpptest_pypreproc(params)# test cpp call python init function successassert init_called# test custom parameters from cpp pass to python successassert preproc_params['param'] == 'value'# test cpp call python execute function successassert execute_called
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。