@@ -174,6 +174,7 @@ def multiple_morph_output(
174
174
target_directory = None ,
175
175
verbose = False ,
176
176
stdout_flag = False ,
177
+ mm = False ,
177
178
):
178
179
"""Helper function for printing details about a series of multiple morphs.
179
180
Handles both printing to terminal and printing to a file.
@@ -201,6 +202,9 @@ def multiple_morph_output(
201
202
Print additional summary details when True (default False).
202
203
stdout_flag: bool
203
204
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.
204
208
"""
205
209
206
210
# Input parameters used for every morph
@@ -212,7 +216,10 @@ def multiple_morph_output(
212
216
if verbose :
213
217
# Output for every morph (information repeated in a succinct table below)
214
218
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 "
216
223
output += "# Optimized morphing parameters:\n "
217
224
output += "\n " .join (
218
225
f"# { param } = { morph_results [target ][param ]:.6f} " for param in morph_results [target ]
@@ -223,7 +230,10 @@ def multiple_morph_output(
223
230
tabulated_results = tabulate_results (morph_results )
224
231
225
232
# Table labels
226
- labels = "\n # Labels: [Target]"
233
+ if not mm :
234
+ labels = "\n # Labels: [Target]"
235
+ else :
236
+ labels = "\n # Labels: [Morph]"
227
237
if field is not None :
228
238
labels += f" [{ field } ]"
229
239
for param in tabulated_results .keys ():
@@ -252,8 +262,12 @@ def multiple_morph_output(
252
262
target_path_name = str (Path (target_directory ).resolve ())
253
263
254
264
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 } "
257
271
reference_table = Path (save_directory ).joinpath ("Morph_Reference_Table.txt" )
258
272
with open (reference_table , "w" ) as reference :
259
273
print (f"{ header } \n { inputs } \n { verbose_outputs } { table } " , file = reference )
0 commit comments