2 Unit tests for optimization that logs to comet.ml. 
    3 Author: Jing Wu and Frank Dellaert 
    8 if sys.version_info.major >= 3:
 
    9     from io 
import StringIO
 
   11     from cStringIO 
import StringIO
 
   14 from datetime 
import datetime
 
   18 from gtsam 
import Rot3
 
   28     """Check correct logging to comet.ml.""" 
   31         """Set up a small Karcher mean optimization example.""" 
   33         R = Rot3.Expmap(np.array([0.1, 0, 0]))
 
   34         rotations = {R, R.inverse()}  
 
   48             self.
graph.
add(gtsam.PriorFactorRot3(KEY, R, MODEL))
 
   57         """Reset print capture.""" 
   58         sys.stdout = sys.__stdout__
 
   61         """Test with a simple hook.""" 
   78         """Make sure we are properly terminating LM""" 
   91     @unittest.skip(
"Not a test we want run every time, as needs comet.ml account")
 
   93         """Test with a comet hook.""" 
   94         from comet_ml 
import Experiment
 
   96                            auto_output_logging=
"native")
 
   97         comet.log_dataset_info(name=
"Karcher", path=
"shonan")
 
   98         comet.add_tag(
"GaussNewton")
 
   99         comet.log_parameter(
"method", 
"GaussNewton")
 
  100         time = datetime.now()
 
  101         comet.set_name(
"GaussNewton-" + 
str(time.month) + 
"/" + 
str(time.day) + 
" " 
  102                        + 
str(time.hour)+
":"+
str(time.minute)+
":"+
str(time.second))
 
  105         def hook(optimizer, error):
 
  106             comet.log_metric(
"Karcher error",
 
  107                              error, optimizer.iterations())
 
  112         actual = self.optimizer.
values()
 
  115 if __name__ == 
"__main__":