@@ -62,13 +62,13 @@ def define_arguments(argparser):
6262 )
6363
6464
65- def get_cell_formatter (sig_digits ):
65+ def get_cell_formatter (sig_digits , zero_cutoff ):
6666 sig_digits_formatter = "{0:." + str (sig_digits ) + "g}"
6767
6868 def format_cell (c ):
6969 if not isinstance (c , float ):
7070 return c
71- if abs (c ) < 1e-8 :
71+ if abs (c ) < zero_cutoff :
7272 return 0
7373 else :
7474 return sig_digits_formatter .format (c )
@@ -86,7 +86,9 @@ def write_table(instance, *indexes, output_file=None, **kwargs):
8686 # don't know what that is.
8787 if output_file is None :
8888 raise Exception ("Must specify output_file in write_table()" )
89- cell_formatter = get_cell_formatter (instance .options .sig_figs_output )
89+ cell_formatter = get_cell_formatter (
90+ instance .options .sig_figs_output , instance .options .zero_cutoff_output
91+ )
9092
9193 if "df" in kwargs :
9294 df = kwargs .pop ("df" )
@@ -153,7 +155,9 @@ def post_solve(instance, outdir):
153155
154156
155157def save_generic_results (instance , outdir , sorted_output ):
156- cell_formatter = get_cell_formatter (instance .options .sig_figs_output )
158+ cell_formatter = get_cell_formatter (
159+ instance .options .sig_figs_output , instance .options .zero_cutoff_output
160+ )
157161
158162 components = list (instance .component_objects (Var ))
159163 # add Expression objects that should be saved, if any
0 commit comments