Skip to content

Commit

Permalink
fix: removed mu*D requirement for one of the error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
yucongalicechen committed Feb 5, 2025
1 parent 468f436 commit 1dc6972
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
10 changes: 4 additions & 6 deletions src/diffpy/labpdfproc/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ def set_wavelength(args):
ValueError
Raised if:
(1) neither wavelength or anode type is provided,
and either mu*D needs to be looked up or
xtype is not the two-theta grid,
and xtype is not the two-theta grid,
(2) both are provided,
(3) anode_type is not one of the known sources,
(4) wavelength is non-positive.
Expand All @@ -188,11 +187,10 @@ def set_wavelength(args):
"""
# first load values from config file
if args.wavelength is None and args.anode_type is None:
# either mu*D needs to be looked up or
# xtype is not the two-theta grid
if args.mud is None or args.xtype not in ANGLEQUANTITIES:
if args.xtype not in ANGLEQUANTITIES:
raise ValueError(
f"Please provide a wavelength or anode type. "
f"Please provide a wavelength or anode type "
f"because the independent variable axis is not on two-theta. "
f"Allowed anode types are {*known_sources, }."
)
elif args.wavelength is not None and args.anode_type is not None:
Expand Down
7 changes: 3 additions & 4 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,13 @@ def test_set_wavelength(inputs, expected):
@pytest.mark.parametrize(
"inputs, expected_error_msg",
[
( # C1.1: nothing passed in, xtype is not on tth
( # C1: nothing passed in, xtype is not on tth
# expect error asking for either wavelength or anode type
["--xtype", "q"],
f"Please provide a wavelength or anode type. "
f"Please provide a wavelength or anode type "
f"because the independent variable axis is not on two-theta. "
f"Allowed anode types are {*known_sources, }.",
),
# C1.2: nothing passed in, need to look up mu*D
# expect error asking for either wavelength or anode type
( # C2: both wavelength and anode type were specified
# expect error asking not to specify both
["--wavelength", "0.7", "--anode-type", "Mo"],
Expand Down

0 comments on commit 1dc6972

Please sign in to comment.