本文整理汇总了Python中module.Module类的典型用法代码示例。如果您正苦于以下问题:Python Module类的具体用法?Python Module怎么用?Python Module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Module类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, probability=0.5, scaled=False):
assert probability < 1 and probability > 0, 'probability must be (0,1)'
Module.__init__(self)
self.prob = probability
self.train = True
self.scaled = scaled
self.noise = torch.Tensor()
示例2: __init__
def __init__(self,args):
Module.__init__(self,args)
self.log_request = args.log_request
self.log_response = args.log_response
self.log = args.log
self.data = args.data
self.headers = args.headers
示例3: __init__
def __init__(self, dim, peepholes = False, name = None):
"""
:arg dim: number of cells
:key peepholes: enable peephole connections (from state to gates)? """
self.setArgs(dim = dim, peepholes = peepholes)
# Internal buffers, created dynamically:
self.bufferlist = [
('ingate', dim),
('outgate', dim),
('forgetgate', dim),
('ingatex', dim),
('outgatex', dim),
('forgetgatex', dim),
('state', dim),
('ingateError', dim),
('outgateError', dim),
('forgetgateError', dim),
('stateError', dim),
]
Module.__init__(self, 4*dim, dim, name)
if self.peepholes:
ParameterContainer.__init__(self, dim*3)
self._setParameters(self.params)
self._setDerivatives(self.derivs)
示例4: __init__
def __init__(self, input_size, output_size):
Module.__init__(self)
self.weight = Tensor(output_size, input_size)
self.bias = Tensor(output_size)
self.grad_weight = Tensor(output_size, input_size)
self.grad_bias = Tensor(output_size)
self.reset()
示例5: __init__
def __init__(self, dim, nNeurons, name=None, outputFullMap=False):
if outputFullMap:
outdim = nNeurons ** 2
else:
outdim = 2
Module.__init__(self, dim, outdim, name)
# switch modes
self.outputFullMap = outputFullMap
# create neurons
self.neurons = random.random((nNeurons, nNeurons, dim))
self.difference = zeros(self.neurons.shape)
self.winner = zeros(2)
self.nInput = dim
self.nNeurons = nNeurons
self.neighbours = nNeurons
self.learningrate = 0.01
self.neighbourdecay = 0.9999
# distance matrix
distx, disty = mgrid[0:self.nNeurons, 0:self.nNeurons]
self.distmatrix = zeros((self.nNeurons, self.nNeurons, 2))
self.distmatrix[:, :, 0] = distx
self.distmatrix[:, :, 1] = disty
示例6: dropEvent
def dropEvent(self, e):
# Establecer el widget en una nueva posición
# aqui tengo que separar entre modulos nuevos y ya existentes.
# la cadena que transmito es "posx,posy" si es mover uno existe
# posx y posy es la posicion relativa al modulo del cursor
# los ya existentes, muevo el modulo que paso con el drag a
# la posicion del click menos el punto (posx,posy)
# los modulos nuevos, hago una copia de ese tipo de modulo
# de una base que no se este mostrando, y lo muestro
# y no solo eso, sino que ademas mantengo
# la numeracion de cada tipo de modulos para generar siguientes
# obtiene la posicion relativa de los datos mime (mimeData)
if e.mimeData().hasText():
x, y = map(int, e.mimeData().text().split(','))
e.source().move(e.pos()-QtCore.QPoint(x, y))
e.setDropAction(QtCore.Qt.MoveAction)
for l in e.source().lines:
l.repaint()
else:
name=self.newName(e.source().name)
m = Module(name, e.source().code, self)
m.move(e.pos()-QtCore.QPoint(100,50))
m.show()
self.addModule(m)
if m.type == Module.Input:
self.update_composite()
e.setDropAction(QtCore.Qt.CopyAction)
e.accept()
示例7: LoadEntered
def LoadEntered(self):
name = self.e.get()
self.loadPopup.destroy()
tempDict = {}
with open("./Patches/patches.json",'r') as json_file:
patchDictionary = json.load(json_file)
print "ALL MODULES"
print self.AllModules
while len(self.AllModules) != 0:
m = self.AllModules.pop()
print "DELETING" + str(m.name)
m.delete()
patch = patchDictionary[name]
self.PureData.reset()
#Load all modules
for n, module in patch['modules'].iteritems():
newM = Module(self.canvas, module['Name'], module['x'] * scalar , module['y'] * scalar, self, self.osc)
newM.setValues(module['Values'])
tempDict[n] = newM
self.AllModules.append(newM)
#Load all connections
for cable in patch['cables'].values():
print cable
inputModule = tempDict[cable[0]]
inputJack = inputModule.InputJacks[cable[1]]
outputModule = tempDict[cable[2]]
outputJack = outputModule.OutputJacks[cable[3]]
inputModule.connectCable(inputJack, outputJack)
示例8: write_london
def write_london(template, scf, molecule):
printable = ''
wave_function = scf.contains(template.wave_function.name)
if wave_function:
scf_submodule = wave_function.submodules.get(template.scf.name)
if scf_submodule:
atomst = scf_submodule.properties.pop(template.atomst.name)
for module in scf.modules:
if module.name != template.visual.name:
printable += module.__str__()
nmr = SubModule('*NMR')
nmr.add_property(template, '.LONDON')
nmr.add_property(template, '.DOEPRN')
nmr.add_property(template, '.INTFLG', ['1 1 0'])#calculating just large-large large-small
newModule = Module('**PROPERTIES')
newModule.add_property(template, '.' + molecule.magnetic_field)
newModule.submodules.update({'*NMR':nmr})
printable += newModule.__str__()
printable += '*END OF\n'
if atomst:
scf_submodule.properties.update({atomst.name:atomst})
return printable
示例9: configure
def configure(self, config):
Module.configure(self, config)
if not self.version:
self.version = m.ReadModuleName()
# Import appropriate the ADAM module (or package).
module = 'mpx.ion.adam.adam' + self.version
command = compile('import ' + module,
'mpx.ion.adam.unknown.configure()', 'exec')
eval(command)
# Get the module's factory and instanciate the "real" class.
command = module + '.factory'
adam_factory = eval(command, globals(), locals())
self.instance = adam_factory()
# Scary stuff. Detach this ion from our parent, configure the real
# instance (thus attaching it to the parent) and then morph this
# instance to behave like the real instance (in case anyone has a
# handle to this instance).
try:
self.parent._del_child(self.name)
self.instance.configure(config)
attributes = vars(self.instance.__class__)
attributes.update(vars(self.instance))
for attrribute in attributes:
setattr(self, attrribute, getattr(self.instance, attrribute))
except:
msglog.exception()
# The scary stuff failed, reattach to the parent.
try:
self.parent._del_child(self.instance.name)
except:
pass
self.parent._add_child(self)
示例10: ModuleTestCase
class ModuleTestCase(TestCase):
def setUp(self):
print '-' * 200
print 'testing Module'
self.module = Module(1)
self.module.fill('dcg', 'DCG', 1)
obj = self.module.get_object()
print obj
示例11: GenerateBldMod
def GenerateBldMod (self):
# ugly hack for create a module for the bld file
bldMod = Module('bld_' + self.name, '** autogenerated **')
bldMod.resolvedFiles.append(self.bldFile)
bldMod.putInPkg = False
self.buildSys.modules[bldMod.name] = bldMod
if bldMod.name not in self.modules:
self.modules.append(bldMod.name)
示例12: __init__
def __init__(self, context):
Module.__init__(self, context)
self.monitor_is_on = True
self.status_label = render.OutlinedTextImg(color="#8888ff", outlinesize=2, size=20)
self.bluetooth_address = context.get_config("bluetooth")
if len(self.bluetooth_address) == 0:
self.bluetooth_address = None
# -1=scan failed, 0=not scanned, 1=not found, 2=found
self.bluetooth_status = 0
示例13: scan
def scan(self):
for addr in range(0,0x100):
try:
m = Module()
m.configure({'name':'adamXXXX', 'parent':self,
'line_handler':self, 'address':addr})
print '0x%02X' % addr, '(%3d)' % addr, m.ReadModuleName()
except EIOError:
print "."
del m
示例14: list_bin
def list_bin(args):
"""
List the programs provided by the module.
"""
db = ModuleDb()
for moduleid in args.module:
name,version = splitid(moduleid)
try:
Module.list_bin(db.lookup(name),version)
except ModuleError as e:
e.warn()
示例15: __init__
def __init__(self, context):
Module.__init__(self, context)
self.img = None
self._next_index = 0
self.img_rect = None
self._files = []
slideshow_dir = context.get_config("slideshow_dir")
for filename in os.listdir(slideshow_dir):
full_path = os.path.join(slideshow_dir, filename)
if os.path.isfile(full_path):
self._files.append(full_path)
random.shuffle(self._files)