11export  log_header, log_row
22
3- const  formats =  Dict {DataType, String} (Signed =>  " %6d"  ,
4-                                        AbstractFloat =>  " %8.1e"  ,
5-                                        AbstractString =>  " %15s"  ,
6-                                        Symbol =>  " %15s"  ,
7-                                        Missing =>  " %15s" 
8-                                       )
9- 
10- const  default_headers =  Dict {Symbol, String} (:name  =>  " Name"  ,
11-                                              :elapsed_time  =>  " Time"  ,
12-                                              :objective  =>  " f(x)"  ,
13-                                              :dual_feas  =>  " Dual"  ,
14-                                              :primal_feas  =>  " Primal"  )
3+ const  formats =  Dict {DataType, String} (
4+   Signed =>  " %6d"  ,
5+   AbstractFloat =>  " %8.1e"  ,
6+   AbstractString =>  " %15s"  ,
7+   Symbol =>  " %15s"  ,
8+   Missing =>  " %15s"  ,
9+ )
10+ 
11+ const  default_headers =  Dict {Symbol, String} (
12+   :name  =>  " Name"  ,
13+   :elapsed_time  =>  " Time"  ,
14+   :objective  =>  " f(x)"  ,
15+   :dual_feas  =>  " Dual"  ,
16+   :primal_feas  =>  " Primal"  ,
17+ )
1518
1619for  (typ, fmt) in  formats
1720  hdr_fmt_foo =  Symbol (" header_formatter_$typ "  )
1821  len =  match (r" \% ([0-9]*)"  , fmt)[1 ]
1922  fmt2 =  " %$(len) s" 
2023
2124  @eval  begin 
22-     row_formatter (x  ::   $typ ) =  @sprintf ($ fmt, x)
23-     row_formatter (::   Type{<:$typ} ) =  @sprintf ($ fmt2, " -"  )
25+     row_formatter (x:: $typ ) =  @sprintf ($ fmt, x)
26+     row_formatter (:: Type{<:$typ} ) =  @sprintf ($ fmt2, " -"  )
2427
2528    $ hdr_fmt_foo (x) =  @sprintf ($ fmt2, x)
26-     header_formatter (x  ::   Union{Symbol,String} , ::   Type{<:$typ} ) =  $ hdr_fmt_foo (x)
29+     header_formatter (x:: Union{Symbol,  String} , :: Type{<:$typ} ) =  $ hdr_fmt_foo (x)
2730  end 
2831end 
2932
@@ -44,10 +47,12 @@ Keyword arguments:
4447
4548See also [`log_row`](@ref). 
4649""" 
47- function  log_header (colnames ::  AbstractVector{Symbol} , coltypes ::  AbstractVector{DataType} ;
48-                     hdr_override ::  Dict{Symbol,String}  =  Dict {Symbol,String} (),
49-                     colsep ::  Int  =  2 ,
50-                    )
50+ function  log_header (
51+   colnames:: AbstractVector{Symbol} ,
52+   coltypes:: AbstractVector{DataType} ;
53+   hdr_override:: Dict{Symbol, String}  =  Dict {Symbol, String} (),
54+   colsep:: Int  =  2 ,
55+ )
5156  out_vec =  String[]
5257  for  (name, typ) in  zip (colnames, coltypes)
5358    x =  if  haskey (hdr_override, name)
@@ -59,7 +64,7 @@ function log_header(colnames :: AbstractVector{Symbol}, coltypes :: AbstractVect
5964    end 
6065    push! (out_vec, header_formatter (x, typ))
6166  end 
62-   return  join (out_vec,   "  " ^ colsep)
67+   return  join (out_vec, "  " ^ colsep)
6368end 
6469
6570""" 
8287Keyword arguments: 
8388- `colsep::Int`: Number of spaces between columns (Default: 2) 
8489""" 
85- function  log_row (vals; colsep  ::   Int  =  2 )
90+ function  log_row (vals; colsep:: Int  =  2 )
8691  string_cols =  (row_formatter (val) for  val in  vals)
8792  return  join (string_cols, "  " ^ colsep)
8893end 
0 commit comments