Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for multiple morphs #157

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions news/hotfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Multiple morphs/targets used to break given multiple subdirectories.

**Security:**

* <news item>
18 changes: 12 additions & 6 deletions src/diffpy/pdfmorph/pdfmorphapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,14 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
parser.custom_error(save_fail_message)

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

# If user chooses labels
if opts.mlabel is not None:
labels[0] = opts.mlabel
labels[1] = opts.mlabel
if opts.tlabel is not None:
labels[1] = opts.tlabel
labels[0] = opts.tlabel

# Plot extent defaults to calculation extent
pmin = opts.pmin if opts.pmin is not None else opts.rmin
Expand Down Expand Up @@ -533,9 +533,12 @@ def multiple_targets(parser, opts, pargs, stdout_flag=True):

# Get list of files from target directory
target_list = list(target_directory.iterdir())
to_remove = []
for target in target_list:
if target.is_dir():
target_list.remove(target)
to_remove.append(target)
for target in to_remove:
target_list.remove(target)

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

# Get list of files from morph directory
morph_list = list(morph_directory.iterdir())
to_remove = []
for morph in morph_list:
if morph.is_dir():
morph_list.remove(morph)
to_remove.append(morph)
for morph in to_remove:
morph_list.remove(morph)

# Do not morph target_file against itself if it is in the same directory
if target_file in morph_list:
Expand Down
Loading