本文整理汇总了Python中state.State方法的典型用法代码示例。如果您正苦于以下问题:Python state.State方法的具体用法?Python state.State怎么用?Python state.State使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类state
的用法示例。
在下文中一共展示了state.State方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import state [as 别名]
# 或者: from state import State [as 别名]
def __init__(self, session, authProvider, accessToken, location):
self.session = session
self.authProvider = authProvider
self.accessToken = accessToken
self.location = location
if self.location.noop:
logging.info("Limited functionality. No location provided")
self._state = State()
self.authTicket = None
self.endpoint = None
self.endpoint = 'https://{0}{1}'.format(
self.createApiEndpoint(),
'/rpc'
)
# Set up Inventory
self.getInventory()
示例2: __reset_model
# 需要导入模块: import state [as 别名]
# 或者: from state import State [as 别名]
def __reset_model(self):
"""
Loads the model / resets it if it's loaded.
"""
if self.fmu == None:
self.fmu = load_fmu(self.fmu_path)
else:
self.fmu.reset()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# State set/get
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
示例3: __get_state
# 需要导入模块: import state [as 别名]
# 或者: from state import State [as 别名]
def __get_state(self):
var_values = {}
for v in self.state_vars:
var_values[v] = self.__get(v)
state = State(var_values)
return state
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Variable/input set/get
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
示例4: get_initial_state
# 需要导入模块: import state [as 别名]
# 或者: from state import State [as 别名]
def get_initial_state(self):
"""
Returns the initial state of the model.
"""
self.__reset_model()
var_values = {}
for v in self.state_vars:
var_values[v] = self.fmu.get(self.var_map[v])[0]
state = State(var_values)
return state
示例5: parse
# 需要导入模块: import state [as 别名]
# 或者: from state import State [as 别名]
def parse(inFileName):
with open(inFileName, "r") as inFile:
header = inFile.readline()
rows, columns, nr_drones, nr_turns, max_payload = list(map(int, header.strip().split(" ")))
# read product types
nr_products = int(inFile.readline())
products = list(map(int, inFile.readline().strip().split(" ")))
assert len(products) == nr_products
# read warehouses
nr_warehouses = int(inFile.readline())
warehouses = []
for i in range(nr_warehouses):
pos = tuple(map(int, inFile.readline().strip().split(" ")))
items = list(map(int, inFile.readline().strip().split(" ")))
assert len(items) == nr_products
warehouses.append(Warehouse(i, pos, items))
assert len(warehouses) == nr_warehouses
# read orders
nr_orders = int(inFile.readline())
orders = []
lines = inFile.readlines()
for i, (pos, nr_items, items) in enumerate(zip(lines[::3], lines[1::3], lines[2::3])):
pos = tuple(map(int, pos.split(" ")))
items = list(map(int, items.strip().split(" ")))
assert int(nr_items) == len(items)
orders.append(Order(id=i, pos=pos, items=items))
assert len(orders) == nr_orders
# init drones to simulate
drones = []
first_warehouse = warehouses[0]
for i in range(nr_drones):
drone = Drone(pos=first_warehouse.pos, id=i, max_payload=max_payload)
drones.append(drone)
return State(
rows = rows,
columns = columns,
nr_turns = nr_turns,
max_payload = max_payload,
products = products,
warehouses = warehouses,
orders = orders,
drones = drones
)