Skip to content

Commit 3089e1b

Browse files
authored
Merge pull request #40 from yucongalicechen/wavelength2
closes #25: update wavelength function
2 parents bc138c0 + 68840bc commit 3089e1b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/diffpy/labpdfproc/tests/test_tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import re
23

34
import pytest
45

@@ -33,5 +34,5 @@ def test_set_wavelength(inputs, expected):
3334
@pytest.mark.parametrize("inputs, msg", params3)
3435
def test_set_wavelength_bad(inputs, msg):
3536
actual_args = argparse.Namespace(wavelength=inputs[0], anode_type=inputs[1])
36-
with pytest.raises(ValueError, match=msg[0]):
37+
with pytest.raises(ValueError, match=re.escape(msg[0])):
3738
actual_args.wavelength = set_wavelength(actual_args)

src/diffpy/labpdfproc/tools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ def set_wavelength(args):
2020
2121
"""
2222
if args.wavelength is not None and args.wavelength <= 0:
23-
raise ValueError("Please rerun the program specifying a positive float number.")
23+
raise ValueError(
24+
"No valid wavelength. Please rerun specifying a known anode_type or a positive wavelength"
25+
)
2426
if not args.wavelength and args.anode_type and args.anode_type not in WAVELENGTHS:
2527
raise ValueError(
26-
f"Invalid anode type {args.anode_type}. "
27-
f"Please rerun the program to either specify a wavelength as a positive float number "
28-
f"or specify anode_type as one of {known_sources}."
28+
f"Anode type not recognized. please rerun specifying an anode_type from {*known_sources, }"
2929
)
3030

3131
if args.wavelength:

0 commit comments

Comments
 (0)