迭代历史打印机
iterprinter的Python项目详细描述
迭代打印机:一个简单的迭代历史打印机
当使用迭代数值算法时,这是很常见的
在每次迭代后打印一条消息,以便用户
可以监视聚合并捕获任何错误。
例如,demo.py
实现了一个简单的对分算法
计算二的平方根。
以下是使用此库的输出:
使用
fromiterprinterimportIterationPrinter# Initialize the printer by passing formatting information each columnprinter=IterationPrinter(it='4d',obj='16.6e')# Print a header for the tableprinter.print_header(it='iter',obj='objective')# Print a normal line of historyprinter.print_iter(it=0,obj=5e3)# If a particular field is not provided, the column is left emptyprinter.print_iter(it=1)
有关更完整的示例,请参见demo.py
。在
- 项目
标签: