Skip to content

Commit 080e8bd

Browse files
committed
Fix for multiple subdirectories
1 parent 641b5e7 commit 080e8bd

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/diffpy/pdfmorph/pdfmorphapp.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,14 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
487487
parser.custom_error(save_fail_message)
488488

489489
if opts.plot:
490-
pairlist = [chain.xy_morph_out, chain.xy_target_out]
491-
labels = [pargs[0], pargs[1]] # Default is to use file names
490+
pairlist = [chain.xy_target_out, chain.xy_morph_out]
491+
labels = [pargs[1], pargs[0]] # Default is to use file names
492492

493493
# If user chooses labels
494494
if opts.mlabel is not None:
495-
labels[0] = opts.mlabel
495+
labels[1] = opts.mlabel
496496
if opts.tlabel is not None:
497-
labels[1] = opts.tlabel
497+
labels[0] = opts.tlabel
498498

499499
# Plot extent defaults to calculation extent
500500
pmin = opts.pmin if opts.pmin is not None else opts.rmin
@@ -536,6 +536,8 @@ def multiple_targets(parser, opts, pargs, stdout_flag=True):
536536
for target in target_list:
537537
if target.is_dir():
538538
target_list.remove(target)
539+
for morph in to_remove:
540+
morph_list.remove(morph)
539541

540542
# Do not morph morph_file against itself if it is in the same directory
541543
if morph_file in target_list:
@@ -678,9 +680,12 @@ def multiple_morphs(parser, opts, pargs, stdout_flag=True):
678680

679681
# Get list of files from morph directory
680682
morph_list = list(morph_directory.iterdir())
683+
to_remove = []
681684
for morph in morph_list:
682685
if morph.is_dir():
683-
morph_list.remove(morph)
686+
to_remove.append(morph)
687+
for morph in to_remove:
688+
morph_list.remove(morph)
684689

685690
# Do not morph target_file against itself if it is in the same directory
686691
if target_file in morph_list:

0 commit comments

Comments
 (0)