Skip to content

Check Anode type #83

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

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/diffpy/labpdfproc/labpdfprocapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def main():
args = load_user_info(args)
args = set_input_lists(args)
args.output_directory = set_output_directory(args)
args.wavelength = set_wavelength(args)
args = set_wavelength(args)
args = load_user_metadata(args)

for filepath in args.input_paths:
Expand Down
15 changes: 8 additions & 7 deletions src/diffpy/labpdfproc/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,21 @@ def test_set_output_directory_bad(user_filesystem):


params2 = [
([], [0.71]),
(["--anode-type", "Ag"], [0.59]),
(["--wavelength", "0.25"], [0.25]),
(["--wavelength", "0.25", "--anode-type", "Ag"], [0.25]),
([], [0.71, "Mo"]),
(["--anode-type", "Ag"], [0.59, "Ag"]),
(["--wavelength", "0.25"], [0.25, None]),
(["--wavelength", "0.25", "--anode-type", "Ag"], [0.25, None]),
]


@pytest.mark.parametrize("inputs, expected", params2)
def test_set_wavelength(inputs, expected):
expected_wavelength = expected[0]
expected_wavelength, expected_anode_type = expected[0], expected[1]
cli_inputs = ["2.5", "data.xy"] + inputs
actual_args = get_args(cli_inputs)
actual_args.wavelength = set_wavelength(actual_args)
actual_args = set_wavelength(actual_args)
assert actual_args.wavelength == expected_wavelength
assert getattr(actual_args, "anode_type", None) == expected_anode_type


params3 = [
Expand All @@ -182,7 +183,7 @@ def test_set_wavelength_bad(inputs, msg):
cli_inputs = ["2.5", "data.xy"] + inputs
actual_args = get_args(cli_inputs)
with pytest.raises(ValueError, match=re.escape(msg[0])):
actual_args.wavelength = set_wavelength(actual_args)
actual_args = set_wavelength(actual_args)


params5 = [
Expand Down
7 changes: 4 additions & 3 deletions src/diffpy/labpdfproc/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ def set_wavelength(args):
)

if args.wavelength:
return args.wavelength
delattr(args, "anode_type")
elif args.anode_type:
return WAVELENGTHS[args.anode_type]
args.wavelength = WAVELENGTHS[args.anode_type]
else:
return WAVELENGTHS["Mo"]
args.wavelength = WAVELENGTHS["Mo"]
return args


def _load_key_value_pair(s):
Expand Down
Loading