@@ -174,6 +174,7 @@ def multiple_morph_output(
174174 target_directory = None ,
175175 verbose = False ,
176176 stdout_flag = False ,
177+ mm = False ,
177178):
178179 """Helper function for printing details about a series of multiple morphs.
179180 Handles both printing to terminal and printing to a file.
@@ -201,6 +202,9 @@ def multiple_morph_output(
201202 Print additional summary details when True (default False).
202203 stdout_flag: bool
203204 Print to terminal when True (default False).
205+ mm: bool
206+ Multiple morphs done with a single target rather than multiple targets for a single morphed file.
207+ Swaps morph and target in the code.
204208 """
205209
206210 # Input parameters used for every morph
@@ -212,7 +216,10 @@ def multiple_morph_output(
212216 if verbose :
213217 # Output for every morph (information repeated in a succinct table below)
214218 for target in morph_results .keys ():
215- output = f"\n # Target: { target } \n "
219+ if not mm :
220+ output = f"\n # Target: { target } \n "
221+ else :
222+ output = f"\n # Morph: { target } \n "
216223 output += "# Optimized morphing parameters:\n "
217224 output += "\n " .join (
218225 f"# { param } = { morph_results [target ][param ]:.6f} " for param in morph_results [target ]
@@ -223,7 +230,10 @@ def multiple_morph_output(
223230 tabulated_results = tabulate_results (morph_results )
224231
225232 # Table labels
226- labels = "\n # Labels: [Target]"
233+ if not mm :
234+ labels = "\n # Labels: [Target]"
235+ else :
236+ labels = "\n # Labels: [Morph]"
227237 if field is not None :
228238 labels += f" [{ field } ]"
229239 for param in tabulated_results .keys ():
@@ -252,8 +262,12 @@ def multiple_morph_output(
252262 target_path_name = str (Path (target_directory ).resolve ())
253263
254264 header = "# Data generated by pdfmorph\n "
255- header += f"# from morphing { morph_path_name } \n "
256- header += f"# with target directory { target_path_name } "
265+ if not mm :
266+ header += f"# from morphing { morph_path_name } \n "
267+ header += f"# with target directory { target_path_name } "
268+ else :
269+ header += f"# from morphing directory { target_path_name } \n "
270+ header += f"# with target { morph_path_name } "
257271 reference_table = Path (save_directory ).joinpath ("Morph_Reference_Table.txt" )
258272 with open (reference_table , "w" ) as reference :
259273 print (f"{ header } \n { inputs } \n { verbose_outputs } { table } " , file = reference )
0 commit comments