Skip to content

Commit bed9b82

Browse files
committed
Print statement fix
1 parent a8b936e commit bed9b82

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Diff for: src/diffpy/pdfmorph/pdfmorph_io.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -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)

Diff for: src/diffpy/pdfmorph/pdfmorphapp.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -732,12 +732,13 @@ def multiple_morphs(parser, opts, pargs, stdout_flag=True):
732732
morph_results,
733733
morph_file_names,
734734
save_directory=save_directory,
735-
morph_directory=morph_directory,
736-
target_file=target_file,
735+
morph_file=target_file,
736+
target_directory=morph_directory,
737737
field=field,
738738
field_list=field_list,
739739
verbose=opts.verbose,
740740
stdout_flag=stdout_flag,
741+
mm=True,
741742
)
742743
except (FileNotFoundError, RuntimeError):
743744
save_fail_message = "Unable to save summary to directory."

0 commit comments

Comments
 (0)