Skip to content

Commit 9c2433e

Browse files
set cwd to tmp_path to avoid confusion and fixed grammar for help statements
1 parent 75b6f6c commit 9c2433e

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/diffpy/labpdfproc/labpdfprocapp.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,52 @@
1111
def get_args():
1212
p = ArgumentParser()
1313
p.add_argument("mud", help="Value of mu*D for your " "sample. Required.", type=float)
14-
p.add_argument("-i", "--input-file", help="The filename of the " "datafile to load")
14+
p.add_argument("-i", "--input-file", help="The filename of the " "datafile to load.")
1515
p.add_argument(
1616
"-a",
1717
"--anode-type",
1818
help=f"The type of the x-ray source. Allowed values are "
19-
f"{*[known_sources], }. Either specify a known x-ray source or specify wavelength",
19+
f"{*[known_sources], }. Either specify a known x-ray source or specify wavelength.",
2020
default="Mo",
2121
)
2222
p.add_argument(
2323
"-w",
2424
"--wavelength",
2525
help="X-ray source wavelength in angstroms. Not needed if the anode-type "
26-
"is specified. This wavelength will override the anode wavelength if both are specified",
26+
"is specified. This wavelength will override the anode wavelength if both are specified.",
2727
default=None,
2828
type=float,
2929
)
3030
p.add_argument(
3131
"-o",
3232
"--output-directory",
33-
help="the name of the output directory. If not specified "
33+
help="The name of the output directory. If not specified "
3434
"then corrected files will be written to the current directory."
3535
"If the specified directory doesn't exist it will be created.",
3636
default=None,
3737
)
3838
p.add_argument(
3939
"-x",
4040
"--xtype",
41-
help=f"the quantity on the independent variable axis. allowed "
41+
help=f"The quantity on the independent variable axis. Allowed "
4242
f"values: {*XQUANTITIES, }. If not specified then two-theta "
4343
f"is assumed for the independent variable. Only implemented for "
44-
f"tth currently",
44+
f"tth currently.",
4545
default="tth",
4646
)
4747
p.add_argument(
4848
"-c",
4949
"--output-correction",
5050
action="store_true",
51-
help="the absorption correction will be output to a file if this "
52-
"flag is set. Default is that it is not output",
51+
help="The absorption correction will be output to a file if this "
52+
"flag is set. Default is that it is not output.",
5353
default="tth",
5454
)
5555
p.add_argument(
5656
"-f",
5757
"--force-overwrite",
5858
action="store_true",
59-
help="outputs will not overwrite existing file unless --force is specified",
59+
help="Outputs will not overwrite existing file unless --force is specified.",
6060
)
6161
args = p.parse_args()
6262
return args
@@ -75,13 +75,13 @@ def main():
7575

7676
if outfile.exists() and not args.force_overwrite:
7777
sys.exit(
78-
f"output file {str(outfile)} already exists. Please rerun "
79-
f"specifying -f if you want to overwrite it"
78+
f"Output file {str(outfile)} already exists. Please rerun "
79+
f"specifying -f if you want to overwrite it."
8080
)
8181
if corrfile.exists() and args.output_correction and not args.force_overwrite:
8282
sys.exit(
83-
f"corrections file {str(corrfile)} was requested and already "
84-
f"exists. Please rerun specifying -f if you want to overwrite it"
83+
f"Corrections file {str(corrfile)} was requested and already "
84+
f"exists. Please rerun specifying -f if you want to overwrite it."
8585
)
8686

8787
input_pattern = Diffraction_object(wavelength=args.wavelength)

src/diffpy/labpdfproc/tests/test_tools.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def test_set_output_directory(inputs, expected, tmp_path):
2020
directory = Path(tmp_path)
2121
os.chdir(directory)
2222

23-
existing_dir = Path().cwd().resolve() / "existing_dir"
23+
existing_dir = Path(tmp_path).resolve() / "existing_dir"
2424
existing_dir.mkdir(parents=True, exist_ok=True)
2525

26-
expected_output_directory = Path.cwd().resolve() / expected[0]
26+
expected_output_directory = Path(tmp_path).resolve() / expected[0]
2727
actual_args = argparse.Namespace(output_directory=inputs[0])
2828
actual_args.output_directory = set_output_directory(actual_args)
2929
assert actual_args.output_directory == expected_output_directory
@@ -35,7 +35,7 @@ def test_set_output_directory_bad(tmp_path):
3535
directory = Path(tmp_path)
3636
os.chdir(directory)
3737

38-
existing_file = Path().cwd().resolve() / "existing_file.py"
38+
existing_file = Path(tmp_path).resolve() / "existing_file.py"
3939
existing_file.touch()
4040

4141
actual_args = argparse.Namespace(output_directory="existing_file.py")
@@ -64,10 +64,10 @@ def test_set_wavelength(inputs, expected):
6464
params3 = [
6565
(
6666
[None, "invalid"],
67-
[f"Anode type not recognized. please rerun specifying an anode_type from {*known_sources, }"],
67+
[f"Anode type not recognized. Please rerun specifying an anode_type from {*known_sources, }."],
6868
),
69-
([0, None], ["No valid wavelength. Please rerun specifying a known anode_type or a positive wavelength"]),
70-
([-1, "Mo"], ["No valid wavelength. Please rerun specifying a known anode_type or a positive wavelength"]),
69+
([0, None], ["No valid wavelength. Please rerun specifying a known anode_type or a positive wavelength."]),
70+
([-1, "Mo"], ["No valid wavelength. Please rerun specifying a known anode_type or a positive wavelength."]),
7171
]
7272

7373

src/diffpy/labpdfproc/tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ def set_wavelength(args):
4747
"""
4848
if args.wavelength is not None and args.wavelength <= 0:
4949
raise ValueError(
50-
"No valid wavelength. Please rerun specifying a known anode_type or a positive wavelength"
50+
"No valid wavelength. Please rerun specifying a known anode_type or a positive wavelength."
5151
)
5252
if not args.wavelength and args.anode_type and args.anode_type not in WAVELENGTHS:
5353
raise ValueError(
54-
f"Anode type not recognized. please rerun specifying an anode_type from {*known_sources, }"
54+
f"Anode type not recognized. Please rerun specifying an anode_type from {*known_sources, }."
5555
)
5656

5757
if args.wavelength:

0 commit comments

Comments
 (0)