Skip to content

Commit f224f3c

Browse files
docs: edit input + mud help messages; replace test example with Mo energy
1 parent 66cbc0c commit f224f3c

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

src/diffpy/labpdfproc/labpdfprocapp.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
from diffpy.utils.diffraction_objects import XQUANTITIES, DiffractionObject
1313
from diffpy.utils.parsers.loaddata import loadData
1414

15+
theoretical_mud_hmsg_suffix = (
16+
"in that exact order, "
17+
"separated by commas (e.g., ZrO2,17.45,0.5). "
18+
"If you add whitespaces, "
19+
"enclose it in quotes (e.g., 'ZrO2, 17.45, 0.5'). "
20+
)
21+
1522

1623
def _define_arguments():
1724
args = [
@@ -21,7 +28,8 @@ def _define_arguments():
2128
"The filename(s) or folder(s) of the datafile(s) to load. "
2229
"Required.\n"
2330
"Supply a space-separated list of files or directories. "
24-
"If a filename contains whitespace, enclose it in quotes. "
31+
"Avoid spaces in filenames when possible; "
32+
"if present, enclose the name in quotes. "
2533
"Long lists can be supplied, one per line, "
2634
"in a file with name file_list.txt. "
2735
"If one or more directory is provided, all valid "
@@ -183,10 +191,8 @@ def _add_mud_selection_group(p, is_gui=False):
183191
help=(
184192
"Estimate mu*D theoretically using sample mass density. "
185193
"Specify the chemical formula, incident x-ray energy (in keV), "
186-
"and sample mass density (in g/cm^3), in that exact order, "
187-
"separated by commas (e.g., ZrO2,20,1.5). "
188-
"If you add whitespaces, "
189-
"enclose it in quotes (e.g., 'ZrO2, 20, 1.5'). "
194+
"and sample mass density (in g/cm^3), "
195+
+ theoretical_mud_hmsg_suffix
190196
),
191197
)
192198
g.add_argument(
@@ -195,10 +201,7 @@ def _add_mud_selection_group(p, is_gui=False):
195201
help=(
196202
"Estimate mu*D theoretically using packing fraction. "
197203
"Specify the chemical formula, incident x-ray energy (in keV), "
198-
"and packing fraction (0 to 1), in that exact order, "
199-
"separated by commas (e.g., ZrO2,20,0.5). "
200-
"If you add whitespaces, "
201-
"enclose it in quotes (e.g., 'ZrO2, 20, 0.5'). "
204+
"and packing fraction (0 to 1), " + theoretical_mud_hmsg_suffix
202205
),
203206
)
204207
return p

src/diffpy/labpdfproc/tools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def _parse_theoretical_input(input_str):
325325
f"Invalid mu*D input '{input_str}'. "
326326
"Expected format is 'sample composition, energy, "
327327
"sample mass density or packing fraction' "
328-
"(e.g., 'ZrO2,20,0.8').",
328+
"(e.g., 'ZrO2,17.45,0.5').",
329329
)
330330
sample_composition = parts[0]
331331
energy = float(parts[1])

tests/test_tools.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def test_set_mud(user_filesystem, inputs, expected_mud):
502502
"Invalid mu*D input 'ZrO2,0.5'. "
503503
"Expected format is 'sample composition, energy, "
504504
"sample mass density or packing fraction' "
505-
"(e.g., 'ZrO2,20,0.8').",
505+
"(e.g., 'ZrO2,17.45,0.5').",
506506
],
507507
),
508508
# C2.2: (packing fraction option)
@@ -515,33 +515,33 @@ def test_set_mud(user_filesystem, inputs, expected_mud):
515515
"Invalid mu*D input 'ZrO2,0.5'. "
516516
"Expected format is 'sample composition, energy, "
517517
"sample mass density or packing fraction' "
518-
"(e.g., 'ZrO2,20,0.8').",
518+
"(e.g., 'ZrO2,17.45,0.5').",
519519
],
520520
),
521521
# C3.1: (sample mass density option)
522522
# user provides more than 3 input values
523523
# expect ValueError with a message indicating the correct format
524524
(
525-
["--theoretical-from-density", "ZrO2,1.5,1.5,0.5"],
525+
["--theoretical-from-density", "ZrO2,17.45,1.5,0.5"],
526526
[
527527
ValueError,
528-
"Invalid mu*D input 'ZrO2,1.5,1.5,0.5'. "
528+
"Invalid mu*D input 'ZrO2,17.45,1.5,0.5'. "
529529
"Expected format is 'sample composition, energy, "
530530
"sample mass density or packing fraction' "
531-
"(e.g., 'ZrO2,20,0.8').",
531+
"(e.g., 'ZrO2,17.45,0.5').",
532532
],
533533
),
534534
# C3.2: (packing fraction option)
535535
# user provides more than 3 input values
536536
# expect ValueError with a message indicating the correct format
537537
(
538-
["--theoretical-from-packing", "ZrO2,1.5,1.5,0.5"],
538+
["--theoretical-from-packing", "ZrO2,17.45,1.5,0.5"],
539539
[
540540
ValueError,
541-
"Invalid mu*D input 'ZrO2,1.5,1.5,0.5'. "
541+
"Invalid mu*D input 'ZrO2,17.45,1.5,0.5'. "
542542
"Expected format is 'sample composition, energy, "
543543
"sample mass density or packing fraction' "
544-
"(e.g., 'ZrO2,20,0.8').",
544+
"(e.g., 'ZrO2,17.45,0.5').",
545545
],
546546
),
547547
],

0 commit comments

Comments
 (0)