代码拉取完成,页面将自动刷新
# import models.modulator_models
# import models.demodulator_models
# print(models.modulator_models)
from importlib import import_module
from models.demodulator import Demodulator
from models.modulator import Modulator
# def my_import(name):
# components = name.split('.')
# mod = __import__(components[0])
# for comp in components[1:]:
# mod = getattr(mod, comp)
# return mod
class Agent():
def __init__(self, *, agent_dict, name, verbose=False):
self.name = name
self.to_echo = None
self.actions = None
for function in ['mod', 'demod']:
model = agent_dict['%s_model'%function]
params = agent_dict.get('%s_params'%function, False)
assert params, "agent %s %s_params not defined"%(name, function)
assert params.get('bits_per_symbol', False), "agent %s %s_params['bits_per_symbol'] not defined"%(name, function)
assert params['bits_per_symbol'] in [1,2,3,4], "agent %s %s_params['bits_per_symbol'] is not 1,2,3, or 4"%(name, function)
#### LOAD MODEL
module_name = 'models.%sulator_models.%s'%(function, model.capitalize())
model_class = getattr(import_module(module_name), model.capitalize())
if function == 'demod':
self.demod = Demodulator(model=model_class, verbose=verbose, **params)
else: # function == 'mod'
self.mod = Modulator(model=model_class, verbose=verbose, **params)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。