Skip to content

Commit 6dc86f5

Browse files
authored
Merge pull request #83 from yucongalicechen/anodetype
Check Anode type
2 parents 8a9627e + 7324351 commit 6dc86f5

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/diffpy/labpdfproc/labpdfprocapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def main():
116116
args = load_user_info(args)
117117
args = set_input_lists(args)
118118
args.output_directory = set_output_directory(args)
119-
args.wavelength = set_wavelength(args)
119+
args = set_wavelength(args)
120120
args = load_user_metadata(args)
121121

122122
for filepath in args.input_paths:

src/diffpy/labpdfproc/tests/test_tools.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,21 @@ def test_set_output_directory_bad(user_filesystem):
145145

146146

147147
params2 = [
148-
([], [0.71]),
149-
(["--anode-type", "Ag"], [0.59]),
150-
(["--wavelength", "0.25"], [0.25]),
151-
(["--wavelength", "0.25", "--anode-type", "Ag"], [0.25]),
148+
([], [0.71, "Mo"]),
149+
(["--anode-type", "Ag"], [0.59, "Ag"]),
150+
(["--wavelength", "0.25"], [0.25, None]),
151+
(["--wavelength", "0.25", "--anode-type", "Ag"], [0.25, None]),
152152
]
153153

154154

155155
@pytest.mark.parametrize("inputs, expected", params2)
156156
def test_set_wavelength(inputs, expected):
157-
expected_wavelength = expected[0]
157+
expected_wavelength, expected_anode_type = expected[0], expected[1]
158158
cli_inputs = ["2.5", "data.xy"] + inputs
159159
actual_args = get_args(cli_inputs)
160-
actual_args.wavelength = set_wavelength(actual_args)
160+
actual_args = set_wavelength(actual_args)
161161
assert actual_args.wavelength == expected_wavelength
162+
assert getattr(actual_args, "anode_type", None) == expected_anode_type
162163

163164

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

187188

188189
params5 = [

src/diffpy/labpdfproc/tools.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,12 @@ def set_wavelength(args):
126126
)
127127

128128
if args.wavelength:
129-
return args.wavelength
129+
delattr(args, "anode_type")
130130
elif args.anode_type:
131-
return WAVELENGTHS[args.anode_type]
131+
args.wavelength = WAVELENGTHS[args.anode_type]
132132
else:
133-
return WAVELENGTHS["Mo"]
133+
args.wavelength = WAVELENGTHS["Mo"]
134+
return args
134135

135136

136137
def _load_key_value_pair(s):

0 commit comments

Comments
 (0)