Skip to content

Commit 02d19e3

Browse files
committed
Return r, gr from python frunction
1 parent 511435a commit 02d19e3

File tree

2 files changed

+9
-63
lines changed

2 files changed

+9
-63
lines changed

src/diffpy/pdfmorph/pdfmorphapp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def custom_error(self, msg):
299299
return parser
300300

301301

302-
def single_morph(parser, opts, pargs, stdout_flag=True):
302+
def single_morph(parser, opts, pargs, stdout_flag=True, return_morph=False):
303303
if len(pargs) < 2:
304304
parser.error("You must supply FILE1 and FILE2.")
305305
elif len(pargs) > 2:
@@ -482,6 +482,8 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
482482
l_width=l_width,
483483
)
484484

485+
if return_morph:
486+
return morph_results, chain.x_morph_out, chain.y_morph_out
485487
return morph_results
486488

487489

src/diffpy/pdfmorph/pdfmorphpy.py

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ def pdfmorph(file1, file2, **kwargs):
2727
file2: str
2828
Path-like object to the target file.
2929
kwargs: dict
30-
See the PDFmorph manual for options.
30+
See the PDFmorph manual for options. Multiple morphs not supported.
3131
3232
Returns
3333
-------
3434
dict:
3535
Summary of morphs.
36+
x: array-like
37+
The r grid after the morph is applied.
38+
y: array-like
39+
The g(r) values after the morph is applied.
3640
"""
3741

3842
parser = create_option_parser()
@@ -44,64 +48,4 @@ def pdfmorph(file1, file2, **kwargs):
4448
(opts, pargs) = parser.parse_args(inputs)
4549
pargs = [file1, file2]
4650

47-
return single_morph(parser, opts, pargs)
48-
49-
50-
def pdfmorph_multiple_targets(file, dir, **kwargs):
51-
"""Run PDFmorph with multiple targets at Python level.
52-
53-
Parameters
54-
----------
55-
file1: str
56-
Path-like object to the file to be morphed.
57-
file2: str
58-
Path-like object to the target file.
59-
kwargs: dict
60-
See the PDFmorph manual for options.
61-
62-
Returns
63-
-------
64-
dict:
65-
Summary of morphs.
66-
"""
67-
68-
parser = create_option_parser()
69-
70-
inputs = []
71-
for key, value in kwargs.items():
72-
inputs.append(f"--{key}")
73-
inputs.append(f"{value}")
74-
(opts, pargs) = parser.parse_args(inputs)
75-
pargs = [file, dir]
76-
77-
return multiple_targets(parser, opts, pargs)
78-
79-
80-
def pdfmorph_multiple_morphs(dir, file, **kwargs):
81-
"""Run PDFmorph for multiple morphs at Python level.
82-
83-
Parameters
84-
----------
85-
file1: str
86-
Path-like object to the file to be morphed.
87-
file2: str
88-
Path-like object to the target file.
89-
kwargs: dict
90-
See the PDFmorph manual for options.
91-
92-
Returns
93-
-------
94-
dict:
95-
Summary of morphs.
96-
"""
97-
98-
parser = create_option_parser()
99-
100-
inputs = []
101-
for key, value in kwargs.items():
102-
inputs.append(f"--{key}")
103-
inputs.append(f"{value}")
104-
(opts, pargs) = parser.parse_args(inputs)
105-
pargs = [dir, file]
106-
107-
return multiple_morphs(parser, opts, pargs)
51+
return single_morph(parser, opts, pargs, return_morph=True)

0 commit comments

Comments
 (0)