def __str__(self): sb = StringBuilder() if (self.key != None and self.key != ""): sb.Append("\tkey: " + self.key + "\n") if (self.value != None and self.value != ""): sb.Append("\tvalue: " + self.value + "\n") return str(sb)
def __str__(self): sb = StringBuilder() if (self.href != None): sb.Append("\thref: " + self.href + "\n") if (self.writtenCount != None): sb.Append("\twrittenCount: " + str(self.writtenCount) + "\n") return str(sb)
def __str__(self): sb = StringBuilder() if (self.v != None and self.v != 0): sb.Append("\tv: " + str(self.v) + "\n") if (self.ts != None and self.ts != 0): sb.Append("\tts: " + str(self.ts) + "\n") return str(sb)
def print_most_selected_path(self, delimiter='->'): """ Returns a string that visualizes the path in the tree that has been taken most frequently. This can be useful for debugging. """ sb = StringBuilder() most_selections = 0.0 best_child = None best_action = None for action in self.children: if self.children[action].value is not None: if most_selections < self.children[action].observations: most_selections = self.children[action].observations best_child = self.children[action] best_val = best_child.value best_action = action if best_child is not None: sb.append("(a={action},v={val}){d}".format(action=best_action, val=best_val, d=delimiter)) sb.append(best_child.print_most_selected_path(delimiter=delimiter)) else: sb.append("Leaf decision node" + delimiter) return sb.to_string()
def print_most_selected_path(self, delimiter='->'): """ Returns a string that visualizes the path in the tree that has been taken most frequently. This can be useful for debugging. """ sb = StringBuilder() best_val = np.inf best_child = None best_action = None best_prob = 0.0 most_observations = 0 for state in self.children: child = self.children[state] prob = self.successor_state_distribution[state] if most_observations < child.observations: most_observations = child.observations best_child = self.children[state] best_val = best_child.value best_prob = prob if best_val == -np.inf: best_val = 0.0 sb.append("(p={prob},v={val}){d}".format(prob=best_prob, val=best_val, d=delimiter)) if best_child is not None: sb.append(best_child.print_most_selected_path(delimiter=delimiter)) return sb.to_string()
def __str__(self): sb = StringBuilder() if (self.name != None and self.name != ""): sb.Append("\tname: " + self.name + "\n") if (self.unit != None and self.unit != ""): sb.Append("\tunit: " + self.unit + "\n") if (self.dataType != None and self.dataType != ""): sb.Append("\tdataType: " + self.dataType + "\n") if (self.href != None and self.href != ""): sb.Append("\thref: " + self.href + "\n") if (self.path != None and self.path != ""): sb.Append("\tpath: " + self.path + "\n") if (self.valueslist != None and len(self.valueslist) > 0): sb.Append("values: \n") for da in self.valueslist: sb.Append(str(da)) sb.Append("\n") return str(sb)
def __str__(self): sb = StringBuilder() if (self.totalWritten != None): sb.Append("totalWritten: ") sb.Append(str(self.totalWritten)) sb.Append("\n") if (self.resultlist != None and len(self.resultlist) > 0): sb.Append("writeResults: \n") for da in self.resultlist: sb.Append(str(da)) sb.Append("\n") return str(sb)
def __str__(self): sb = StringBuilder() if (self.href != None and self.href != ""): sb.Append("href: ") sb.Append(self.href) sb.Append("\n") if (self.datanodeslist != None and len(self.datanodeslist) > 0): sb.Append("datanodeslist: \n") for da in self.datanodeslist: sb.Append(str(da)) sb.Append("\n") return str(sb)
def __str__(self): sb = StringBuilder() if (self.name != None and self.name != ""): sb.Append("\tname: " + self.name + "\n") if (self.unit != None and self.unit != ""): sb.Append("\tunit: " + self.unit + "\n") if (self.dataType != None and self.dataType != ""): sb.Append("\tdataType: " + self.dataType + "\n") if (self.href != None and self.href != ""): sb.Append("\thref: " + self.href + "\n") if (self.path != None and self.path != ""): sb.Append("\tpath: " + self.path + "\n") return str(sb)
def __str__(self): sb = StringBuilder() if (self.totalDevices != None): sb.Append("totalDevices: " + str(self.totalDevices) + "\n") if (self.maxNumberOfDevices != None): if (self.maxNumberOfDevices > 0): sb.Append("maxNumberOfDevices: " + str(self.maxNumberOfDevices) + "\n") else: sb.Append("maxNumberOfDevices: " + "Unlimit" + "\n") if (self.maxDataNodePerDevice != None): if (self.maxDataNodePerDevice > 0): sb.Append("maxDataNodePerDevice: " + str(self.maxDataNodePerDevice) + "\n") else: sb.Append("maxDataNodePerDevice: " + "Unlimit" + "\n") if (self.usedStorageSize != None): sb.Append("usedStorageSize: " + str(self.usedStorageSize) + "\n") if (self.maxStorageSize != None): if (self.maxStorageSize > 0): sb.Append("maxStorageSize: " + str(self.maxStorageSize) + "\n") else: sb.Append("maxStorageSize: " + "Unlimit" + "\n") return str(sb)
def __str__(self): sb = StringBuilder() if (self.totalRequestToday != None): sb.Append("totalRequestToday: " + str(self.totalRequestToday) + "\n") if (self.maxReadRequestPerDay != None): if (self.maxReadRequestPerDay > 0): sb.Append("maxReadRequestPerDay: " + str(self.maxReadRequestPerDay) + "\n") else: sb.Append("maxReadRequestPerDay: " + "Unlimit" + "\n") if (self.deviceId != None): sb.Append("deviceId: " + self.deviceId + "\n") if (self.numberOfDataNodes != None): sb.Append("numberOfDataNodes: " + str(self.numberOfDataNodes) + "\n") if (self.storageSize != None): sb.Append("storageSize: " + str(self.storageSize) + "\n") return str(sb)
def pretty_print(self): """ Returns a pretty string describing the environment """ sb = StringBuilder() cell_width = int(np.floor(np.log10(self.max_treasure))) + 1 row_delimiter = '+' + (('-'*cell_width) + '+') * self.num_cols + '\n' for row in range(self.num_rows): sb.append(row_delimiter) for col in range(self.num_cols): sb.append('|') if row < self.depths[col]: sb.append(' '*cell_width) elif row > self.depths[col]: sb.append(' ' + 'x'*(cell_width-2) + ' ') else: sb.append(str(self.treasure[col]).zfill(cell_width)) sb.append('|\n') sb.append(row_delimiter) sb.append("Transition Noise: {tn}\n\n".format(tn=self.transition_noise)) return sb.to_string()
def __str__(self): sb = StringBuilder() if (self.description != None and self.description != ""): sb.Append("ERROR:\n") sb.Append("\tdescription: ") sb.Append(self.description) sb.Append("\n") if (self.code != None and self.code != 0): sb.Append("\tcode: ") sb.Append(str(self.code)) sb.Append("\n") if (self.moreInfo != None and self.moreInfo != ""): sb.Append("\tmoreInfo: ") sb.Append(self.moreInfo) sb.Append("\n") if (self.apiver != None and self.apiver != 0): sb.Append("\tapiver: ") sb.Append(str(self.apiver)) sb.Append("\n") return str(sb)
def __str__(self): sb = StringBuilder() if (self.fullSize != None and self.fullSize != 0): sb.Append("fullSize: ") sb.Append(str(self.fullSize)) sb.Append("\n") if (self.limit != None and self.limit != 0): sb.Append("limit: ") sb.Append(str(self.limit)) sb.Append("\n") if (self.offset != None and self.offset != 0): sb.Append("offset: ") sb.Append(str(self.offset)) sb.Append("\n") if (self.datanodelist != None and len(self.datanodelist) > 0): sb.Append("datanodelist: \n") for dn in self.datanodelist: sb.Append(str(dn)) sb.Append("\n") sb.Append("\n") return str(sb)
def pretty_print(self, depth, num_tabs=0, new_lines=False): """ Returns a string that pretty prints the tree rooted from this node and values to a certain depth. This can be useful for debugging. Args: depth: the depth of the search tree to print out num_tabs: the amount of indentation use when printing this level new_lines: if we should add new lines to try make it more readable Returns: String, a pretty printed tree, using D for decision nodes and C for chance nodes. We use parenthesis '()' to denote children and use square parenthesis '[]' to denote the value of a node and how many times it has been selected. """ sb = StringBuilder() indent = '\t' * num_tabs sb.append("D[") if isinstance(self.value, float): sb.append("{val:.3f}".format(val=self.value)) else: sb.append("{val}".format(val=self.value)) sb.append(",") sb.append(str(self.observations)) sb.append("](") if depth == 0: sb.append("...)") return sb.to_string() first_iter = True for action in self.children: if not first_iter: sb.append(", ") else: first_iter = False if new_lines: sb.append("\n") sb.append(indent) sb.append(action) sb.append("->") child_node_string = self.children[action].pretty_print( depth=depth - 1, num_tabs=num_tabs + 1, new_lines=new_lines) sb.append(child_node_string) sb.append(")") return sb.to_string()
def join_words_builder(words: List[str]) -> str: """Joins words using a StringBuilder""" builder = StringBuilder() for word in words: builder.append(word) return builder.to_string()
def __str__(self): sb = StringBuilder() if (self.name != None and self.name != ""): sb.Append("name: ") sb.Append(self.name) sb.Append("\n") if (self.manufacturer != None and self.manufacturer != ""): sb.Append("manufacturer: ") sb.Append(self.manufacturer) sb.Append("\n") if (self.type != None and self.type != ""): sb.Append("type: ") sb.Append(self.type) sb.Append("\n") if (self.description != None and self.description != ""): sb.Append("description: ") sb.Append(self.description) sb.Append("\n") if (self.createdAt != None and self.createdAt != ""): sb.Append("createdAt: ") sb.Append(self.createdAt) sb.Append("\n") if (self.deviceId != None and self.deviceId != ""): sb.Append("deviceId: ") sb.Append(self.deviceId) sb.Append("\n") if (self.href != None and self.href != ""): sb.Append("href: ") sb.Append(self.href) sb.Append("\n") if (self.attributeslist != None and len(self.attributeslist) > 0): sb.Append("attributes: \n") for da in self.attributeslist: sb.Append(str(da)) sb.Append("\n") return str(sb)