本文整理汇总了Python中parameters.Parameters.load方法的典型用法代码示例。如果您正苦于以下问题:Python Parameters.load方法的具体用法?Python Parameters.load怎么用?Python Parameters.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parameters.Parameters
的用法示例。
在下文中一共展示了Parameters.load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from parameters import Parameters [as 别名]
# 或者: from parameters.Parameters import load [as 别名]
def __init__(self, parameters=None, **kwargs):
self.__H = None
self.__derivative_ops = {}
self.__derivative_ops_default = ['evolution']
self.__named_states = {} # A dictionary of named states for easy recollection
self.__named_ensembles = {} # A dictionary of named ensembles for density states
self.__named_subspaces = {} # A dictionary of named subspaces for easy identification
self.__named_bases = {} # A dictionary of named bases for state representation
self.__basis_default = None
self.init(**kwargs)
# Initialise parameters instance
if isinstance(parameters, str):
self.p = Parameters.load(parameters, constants=True)
elif isinstance(parameters, Parameters):
self.p = parameters
else:
self.p = Parameters(constants=True)
if isinstance(parameters, dict):
self.p << parameters
params = self.init_parameters()
if isinstance(params, dict):
self.p << params
# Initialise Hamiltonian
H = self.init_hamiltonian()
if isinstance(H, (Operator, OperatorSet)):
self.hamiltonian = H
# Initialise Bases
bases = self.init_bases()
if isinstance(bases, dict):
for name, basis in bases.items():
self.add_basis(name, basis)
# Initialise named states
states = self.init_states()
if isinstance(states, dict):
for name, state in states.items():
self.add_state(name, state)
# Initialise derivative operators
derivatives = self.init_derivative_ops()
if isinstance(derivatives, dict):
for name, derivative in derivatives.items():
self.add_derivative_op(name, derivative)
# Initialise measurements
self.measure = Measurements(self)
measurements = self.init_measurements()
if isinstance(measurements, dict):
for name, measurement in measurements:
self.add_measurement(name, measurement)
示例2: Flask
# 需要导入模块: from parameters import Parameters [as 别名]
# 或者: from parameters.Parameters import load [as 别名]
# -*- coding: utf-8 -*-
import webbrowser
from flask import Flask, render_template
from threading import Timer
import json
app = Flask(__name__)
from snapshots import Snapshot
from parameters import Parameters
P = Parameters()
S = Snapshot(parameters=P)
P.load('capture.config.json')
profile = 'default'
@app.route('/hello')
@app.route('/hello/<name>')
def hello_world(name=None):
return render_template('main.html',name=name)
@app.route('/action/<name>')
def action(name):
if name=='start':
S.start()
elif name=='stop':
S.stop()
elif name=='save':
S.saveTimeline()
return json.dumps('done')