From 238da5775bcfd3b39bd245aa1bec8399dd0de2a1 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 23 Mar 2026 15:30:01 -0400 Subject: [PATCH 1/8] checkpoint commit --- src/diffpy/labpdfproc/labpdfprocapp.py | 37 +++++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/diffpy/labpdfproc/labpdfprocapp.py b/src/diffpy/labpdfproc/labpdfprocapp.py index e5dd808..118f098 100644 --- a/src/diffpy/labpdfproc/labpdfprocapp.py +++ b/src/diffpy/labpdfproc/labpdfprocapp.py @@ -132,9 +132,6 @@ def _add_credit_args(parser, use_gui=False): def _save_corrected(corrected, input_path, args): outfile = args.output_directory / (input_path.stem + "_corrected.chi") - if outfile.exists() and not args.force: - print(f"WARNING: {outfile} exists. Use --force to overwrite.") - return corrected.metadata = corrected.metadata or {} corrected.dump(str(outfile), xtype=args.xtype) print(f"Saved corrected data to {outfile}") @@ -142,9 +139,6 @@ def _save_corrected(corrected, input_path, args): def _save_correction(correction, input_path, args): corrfile = args.output_directory / (input_path.stem + "_cve.chi") - if corrfile.exists() and not args.force: - print(f"WARNING: {corrfile} exists. Use --force to overwrite.") - return correction.metadata = correction.metadata or {} correction.dump(str(corrfile), xtype=args.xtype) print(f"Saved correction data to {corrfile}") @@ -310,9 +304,37 @@ def get_args_gui(): return parser.parse_args() +# def get_args_cli(override=None): +# parser = create_parser(use_gui=False) +# return parser.parse_args(override) + + def get_args_cli(override=None): parser = create_parser(use_gui=False) - return parser.parse_args(override) + argv = override if override is not None else sys.argv[1:] + argv = [arg for arg in argv if arg != "--ignore-gooey"] + return parser.parse_args(argv) + + +def _check_saved_file_exists(args): + """Check if the output files already exist based on the input paths + and output directory.""" + existing_files = [] + for path in args.input_paths: + outfile = args.output_directory / (path.stem + "_corrected.chi") + if outfile.exists() and not args.force: + existing_files.append(outfile) + if args.output_correction: + corrfile = args.output_directory / (path.stem + "_cve.chi") + if corrfile.exists() and not args.force: + existing_files.append(corrfile) + if existing_files: + existing_files_str = "\n".join(str(f) for f in existing_files) + raise FileExistsError( + "The following output files already exist:" + f"\n{existing_files_str}\n" + "Use --force to overwrite them." + ) def main(): @@ -320,6 +342,7 @@ def main(): args = get_args_gui() if use_gui else get_args_cli() args = _handle_old_api_conversion(args) args = preprocessing_args(args) + _check_saved_file_exists(args) apply_absorption_correction(args) From 75b02ba8264482c44598e89861e2ca2f574d971f Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 1 Apr 2026 12:19:51 -0400 Subject: [PATCH 2/8] checkpoint 2 --- tests/conftest.py | 4 ++++ tests/test_labpdfprocapp.py | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/test_labpdfprocapp.py diff --git a/tests/conftest.py b/tests/conftest.py index 63d4646..015b64b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -24,6 +24,10 @@ def user_filesystem(tmp_path): ) binary_data = b"\x00\x01\x02\x03\x04" + with open(base_dir / "data.chi", "w") as f: + f.write(chi_data) + with open(base_dir / "data_corrected.chi", "w") as f: + f.write(chi_data) with open(base_dir / "good_data.chi", "w") as f: f.write(chi_data) with open(base_dir / "good_data.xy", "w") as f: diff --git a/tests/test_labpdfprocapp.py b/tests/test_labpdfprocapp.py new file mode 100644 index 0000000..cecfc0d --- /dev/null +++ b/tests/test_labpdfprocapp.py @@ -0,0 +1,27 @@ +import pytest + +from diffpy.labpdfproc.labpdfprocapp import ( + apply_absorption_correction, + get_args_cli, +) + + +# Case: user tries to run absorption correction, but the output +# filename already exists. +# expected: the function should raise a FileExistsError, telling the +# user that the output +# file already exists and asking if they want to overwrite it. +def test_file_exists_error(user_filesystem): + input_data_file = str(user_filesystem / "data.chi") + existing_corrected_file = str(user_filesystem / "data_corrected.chi") + + cli_inputs = ["mud"] + [input_data_file] + ["2.5"] + args = get_args_cli(cli_inputs) + # assert args == [] + msg = ( + "The following output files already exist:" + f"\n{existing_corrected_file}\n" + "Use --force to overwrite them." + ) + with pytest.raises(FileExistsError, match=msg): + apply_absorption_correction(args) From b9be468a20967024a1b86a996ba4fb59b5b48ee5 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 1 Apr 2026 15:08:43 -0400 Subject: [PATCH 3/8] add function that raises an error if output file(s) already exist, and add a test for this --- src/diffpy/labpdfproc/labpdfprocapp.py | 22 ------------------- src/diffpy/labpdfproc/tools.py | 27 ++++++++++++++++++++++++ tests/conftest.py | 11 +++++----- tests/test_labpdfprocapp.py | 27 ------------------------ tests/test_tools.py | 29 ++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 54 deletions(-) delete mode 100644 tests/test_labpdfprocapp.py diff --git a/src/diffpy/labpdfproc/labpdfprocapp.py b/src/diffpy/labpdfproc/labpdfprocapp.py index 118f098..34ab7b9 100644 --- a/src/diffpy/labpdfproc/labpdfprocapp.py +++ b/src/diffpy/labpdfproc/labpdfprocapp.py @@ -316,33 +316,11 @@ def get_args_cli(override=None): return parser.parse_args(argv) -def _check_saved_file_exists(args): - """Check if the output files already exist based on the input paths - and output directory.""" - existing_files = [] - for path in args.input_paths: - outfile = args.output_directory / (path.stem + "_corrected.chi") - if outfile.exists() and not args.force: - existing_files.append(outfile) - if args.output_correction: - corrfile = args.output_directory / (path.stem + "_cve.chi") - if corrfile.exists() and not args.force: - existing_files.append(corrfile) - if existing_files: - existing_files_str = "\n".join(str(f) for f in existing_files) - raise FileExistsError( - "The following output files already exist:" - f"\n{existing_files_str}\n" - "Use --force to overwrite them." - ) - - def main(): use_gui = len(sys.argv) == 1 or "--gui" in sys.argv args = get_args_gui() if use_gui else get_args_cli() args = _handle_old_api_conversion(args) args = preprocessing_args(args) - _check_saved_file_exists(args) apply_absorption_correction(args) diff --git a/src/diffpy/labpdfproc/tools.py b/src/diffpy/labpdfproc/tools.py index 2aa6754..4e35381 100644 --- a/src/diffpy/labpdfproc/tools.py +++ b/src/diffpy/labpdfproc/tools.py @@ -528,6 +528,27 @@ def load_package_info(args): return args +def _check_saved_file_exists(args): + """Check if the output files already exist based on the input paths + and output directory.""" + existing_files = [] + for path in args.input_paths: + outfile = args.output_directory / (path.stem + "_corrected.chi") + if outfile.exists() and not args.force: + existing_files.append(outfile) + if args.output_correction: + corrfile = args.output_directory / (path.stem + "_cve.chi") + if corrfile.exists() and not args.force: + existing_files.append(corrfile) + if existing_files: + existing_files_str = "\n".join(str(f) for f in existing_files) + raise FileExistsError( + "The following output files already exist:" + f"\n{existing_files_str}\n" + "Use --force to overwrite them." + ) + + def preprocessing_args(args): """Perform preprocessing on the provided args. The process includes loading package and user information, setting input, output, @@ -542,6 +563,11 @@ def preprocessing_args(args): ------- args : argparse.Namespace The updated argparse Namespace with arguments preprocessed. + + Raises + ------ + FileExistsError + If the output files already exist and --force is not used. """ args = load_wavelength_from_config_file(args) args = set_mud(args) @@ -552,6 +578,7 @@ def preprocessing_args(args): args = load_user_metadata(args) args = load_user_info(args) args = load_package_info(args) + _check_saved_file_exists(args) return args diff --git a/tests/conftest.py b/tests/conftest.py index 015b64b..d6eb523 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,7 +13,8 @@ def user_filesystem(tmp_path): home_dir.mkdir(parents=True, exist_ok=True) test_dir = base_dir / "test_dir" test_dir.mkdir(parents=True, exist_ok=True) - + output_dir = base_dir / "output_dir" + output_dir.mkdir(parents=True, exist_ok=True) chi_data = ( "dataformat = twotheta\n mode = " "xray\n # chi_Q chi_I\n 1 2\n 3 4\n 5 6\n 7 8\n" @@ -24,10 +25,6 @@ def user_filesystem(tmp_path): ) binary_data = b"\x00\x01\x02\x03\x04" - with open(base_dir / "data.chi", "w") as f: - f.write(chi_data) - with open(base_dir / "data_corrected.chi", "w") as f: - f.write(chi_data) with open(base_dir / "good_data.chi", "w") as f: f.write(chi_data) with open(base_dir / "good_data.xy", "w") as f: @@ -63,6 +60,10 @@ def user_filesystem(tmp_path): f.write("good_data.xy \n") f.write(f"{str(input_dir.resolve() / 'good_data.txt')}\n") + with open(output_dir / "good_data_corrected.chi", "w") as f: + f.write(chi_data) + with open(output_dir / "good_data_cve.chi", "w") as f: + f.write(chi_data) home_config_data = { "wavelength": 0.3, "owner_name": "home_username", diff --git a/tests/test_labpdfprocapp.py b/tests/test_labpdfprocapp.py deleted file mode 100644 index cecfc0d..0000000 --- a/tests/test_labpdfprocapp.py +++ /dev/null @@ -1,27 +0,0 @@ -import pytest - -from diffpy.labpdfproc.labpdfprocapp import ( - apply_absorption_correction, - get_args_cli, -) - - -# Case: user tries to run absorption correction, but the output -# filename already exists. -# expected: the function should raise a FileExistsError, telling the -# user that the output -# file already exists and asking if they want to overwrite it. -def test_file_exists_error(user_filesystem): - input_data_file = str(user_filesystem / "data.chi") - existing_corrected_file = str(user_filesystem / "data_corrected.chi") - - cli_inputs = ["mud"] + [input_data_file] + ["2.5"] - args = get_args_cli(cli_inputs) - # assert args == [] - msg = ( - "The following output files already exist:" - f"\n{existing_corrected_file}\n" - "Use --force to overwrite them." - ) - with pytest.raises(FileExistsError, match=msg): - apply_absorption_correction(args) diff --git a/tests/test_tools.py b/tests/test_tools.py index e7a137e..3307eba 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -847,3 +847,32 @@ def test_load_metadata(mocker, user_filesystem, inputs, expected): **expected, } assert actual_metadata == expected_metadata + + +def test_preprocess_args_bad(user_filesystem): + # Case: user tries to run absorption correction, but the output + # filenames already for *_corrected.chi and *_cve.chi exists. + # expected: preprocess_args catches this early and raises an Error + input_data_file = str(user_filesystem / "good_data.chi") + existing_corrected_file = str( + user_filesystem / "output_dir" / "good_data_corrected.chi" + ) + existing_corrected_cve_file = str( + user_filesystem / "output_dir" / "good_data_cve.chi" + ) + cli_inputs = ( + ["mud"] + + [input_data_file] + + ["2.5", "-w", "Mo", "-o", str(user_filesystem / "output_dir")] + + ["-c"] # -c flag saves the cve file + ) + args = get_args_cli(cli_inputs) + args = set_input_lists(args) + msg = ( + "The following output files already exist:" + f"\n{existing_corrected_file}\n" + f"{existing_corrected_cve_file}\n" + "Use --force to overwrite them." + ) + with pytest.raises(FileExistsError, match=re.escape(msg)): + preprocessing_args(args) From cc422c7baa7da8d687447daff88b7f2ceb27393c Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 1 Apr 2026 15:09:45 -0400 Subject: [PATCH 4/8] rm unnecessary comment --- src/diffpy/labpdfproc/labpdfprocapp.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/diffpy/labpdfproc/labpdfprocapp.py b/src/diffpy/labpdfproc/labpdfprocapp.py index 34ab7b9..37e92ab 100644 --- a/src/diffpy/labpdfproc/labpdfprocapp.py +++ b/src/diffpy/labpdfproc/labpdfprocapp.py @@ -304,11 +304,6 @@ def get_args_gui(): return parser.parse_args() -# def get_args_cli(override=None): -# parser = create_parser(use_gui=False) -# return parser.parse_args(override) - - def get_args_cli(override=None): parser = create_parser(use_gui=False) argv = override if override is not None else sys.argv[1:] From fc68ff761956ced5cf93065c70e903bedc3a16eb Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 1 Apr 2026 15:17:24 -0400 Subject: [PATCH 5/8] changed _corrected to -mud-corrected --- .../source/examples/labpdfprocapp-example.rst | 2 +- news/check-saved-files.rst | 23 +++++++++++++++++++ src/diffpy/labpdfproc/labpdfprocapp.py | 2 +- src/diffpy/labpdfproc/tools.py | 2 +- tests/conftest.py | 2 +- tests/test_tools.py | 4 ++-- 6 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 news/check-saved-files.rst diff --git a/docs/source/examples/labpdfprocapp-example.rst b/docs/source/examples/labpdfprocapp-example.rst index c33cadf..cc9b79d 100644 --- a/docs/source/examples/labpdfprocapp-example.rst +++ b/docs/source/examples/labpdfprocapp-example.rst @@ -79,7 +79,7 @@ For example, labpdfproc mud zro2_mo.xy 2.5 -w 0.71303 labpdfproc mud zro2_mo.xy 2.5 -w Mo -This will then save the corrected file in the same directory as the input file with the name ``zro2_mo_corrected.chi``. +This will then save the corrected file in the same directory as the input file with the name ``zro2_mo-mud-corrected.chi``. To save the correction file, specify the ``-c`` or ``--output-correction`` flag, diff --git a/news/check-saved-files.rst b/news/check-saved-files.rst new file mode 100644 index 0000000..699c696 --- /dev/null +++ b/news/check-saved-files.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Changed output file behavior to raise an error early if the saved file exists. + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/labpdfproc/labpdfprocapp.py b/src/diffpy/labpdfproc/labpdfprocapp.py index 37e92ab..c8c9829 100644 --- a/src/diffpy/labpdfproc/labpdfprocapp.py +++ b/src/diffpy/labpdfproc/labpdfprocapp.py @@ -131,7 +131,7 @@ def _add_credit_args(parser, use_gui=False): def _save_corrected(corrected, input_path, args): - outfile = args.output_directory / (input_path.stem + "_corrected.chi") + outfile = args.output_directory / (input_path.stem + "-mud-corrected.chi") corrected.metadata = corrected.metadata or {} corrected.dump(str(outfile), xtype=args.xtype) print(f"Saved corrected data to {outfile}") diff --git a/src/diffpy/labpdfproc/tools.py b/src/diffpy/labpdfproc/tools.py index 4e35381..2a0bfc7 100644 --- a/src/diffpy/labpdfproc/tools.py +++ b/src/diffpy/labpdfproc/tools.py @@ -533,7 +533,7 @@ def _check_saved_file_exists(args): and output directory.""" existing_files = [] for path in args.input_paths: - outfile = args.output_directory / (path.stem + "_corrected.chi") + outfile = args.output_directory / (path.stem + "-mud-corrected.chi") if outfile.exists() and not args.force: existing_files.append(outfile) if args.output_correction: diff --git a/tests/conftest.py b/tests/conftest.py index d6eb523..629020a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -60,7 +60,7 @@ def user_filesystem(tmp_path): f.write("good_data.xy \n") f.write(f"{str(input_dir.resolve() / 'good_data.txt')}\n") - with open(output_dir / "good_data_corrected.chi", "w") as f: + with open(output_dir / "good_data-mud-corrected.chi", "w") as f: f.write(chi_data) with open(output_dir / "good_data_cve.chi", "w") as f: f.write(chi_data) diff --git a/tests/test_tools.py b/tests/test_tools.py index 3307eba..9c818ab 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -851,11 +851,11 @@ def test_load_metadata(mocker, user_filesystem, inputs, expected): def test_preprocess_args_bad(user_filesystem): # Case: user tries to run absorption correction, but the output - # filenames already for *_corrected.chi and *_cve.chi exists. + # filenames already for *-mud-corrected.chi and *_cve.chi exists. # expected: preprocess_args catches this early and raises an Error input_data_file = str(user_filesystem / "good_data.chi") existing_corrected_file = str( - user_filesystem / "output_dir" / "good_data_corrected.chi" + user_filesystem / "output_dir" / "good_data-mud-corrected.chi" ) existing_corrected_cve_file = str( user_filesystem / "output_dir" / "good_data_cve.chi" From 9f10e112c202096b1d71011c107233379b448346 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 1 Apr 2026 15:18:03 -0400 Subject: [PATCH 6/8] news --- news/check-saved-files.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/news/check-saved-files.rst b/news/check-saved-files.rst index 699c696..519174e 100644 --- a/news/check-saved-files.rst +++ b/news/check-saved-files.rst @@ -5,6 +5,7 @@ **Changed:** * Changed output file behavior to raise an error early if the saved file exists. +* Changed saved file name from ``_corrected.chi`` to ``-mud-corrected.chi``. **Deprecated:** From ce7ca2d4b6f9c4cddf75773bf5009d13ffd59aa4 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Thu, 2 Apr 2026 11:50:25 -0400 Subject: [PATCH 7/8] set cwd in test so config file can be found --- .../source/examples/labpdfprocapp-example.rst | 6 ++--- news/check-saved-files.rst | 1 + src/diffpy/labpdfproc/labpdfprocapp.py | 2 +- src/diffpy/labpdfproc/tools.py | 2 +- tests/conftest.py | 2 +- tests/test_tools.py | 24 ++++++++++++------- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/docs/source/examples/labpdfprocapp-example.rst b/docs/source/examples/labpdfprocapp-example.rst index cc9b79d..249c5de 100644 --- a/docs/source/examples/labpdfprocapp-example.rst +++ b/docs/source/examples/labpdfprocapp-example.rst @@ -87,7 +87,7 @@ To save the correction file, specify the ``-c`` or ``--output-correction`` flag, labpdfproc mud zro2_mo.xy 2.5 -w 0.71303 -c -This will then save the correction file in the same directory as the input file with the name ``zro2_mo_cve.chi``. +This will then save the correction file in the same directory as the input file with the name ``zro2_mo-cve.chi``. ``labpdfproc zscan`` Command ---------------------------- @@ -125,7 +125,7 @@ To save the correction file, specify the ``-c`` or ``--output-correction`` flag, labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy -w 0.71303 -c -This will then save the correction file in the same directory as the input file with the name ``CeO2_635um_accum_0_cve.chi``. +This will then save the correction file in the same directory as the input file with the name ``CeO2_635um_accum_0-cve.chi``. ``labpdfproc sample`` Command ----------------------------- @@ -165,7 +165,7 @@ To save the correction file, specify the ``-c`` or ``--output-correction`` flag, labpdfproc sample zro2_mo.xy ZrO2 17.45 1.2 -w 0.71303 -c -This will then save the correction file in the same directory as the input file with the name ``zro2_mo_cve.chi``. +This will then save the correction file in the same directory as the input file with the name ``zro2_mo-cve.chi``. Additional CLI options ---------------------- diff --git a/news/check-saved-files.rst b/news/check-saved-files.rst index 519174e..514ba98 100644 --- a/news/check-saved-files.rst +++ b/news/check-saved-files.rst @@ -6,6 +6,7 @@ * Changed output file behavior to raise an error early if the saved file exists. * Changed saved file name from ``_corrected.chi`` to ``-mud-corrected.chi``. +* Changed saved file name from ``_cve.chi`` to ``-cve.chi``. **Deprecated:** diff --git a/src/diffpy/labpdfproc/labpdfprocapp.py b/src/diffpy/labpdfproc/labpdfprocapp.py index c8c9829..f8ec7e7 100644 --- a/src/diffpy/labpdfproc/labpdfprocapp.py +++ b/src/diffpy/labpdfproc/labpdfprocapp.py @@ -138,7 +138,7 @@ def _save_corrected(corrected, input_path, args): def _save_correction(correction, input_path, args): - corrfile = args.output_directory / (input_path.stem + "_cve.chi") + corrfile = args.output_directory / (input_path.stem + "-cve.chi") correction.metadata = correction.metadata or {} correction.dump(str(corrfile), xtype=args.xtype) print(f"Saved correction data to {corrfile}") diff --git a/src/diffpy/labpdfproc/tools.py b/src/diffpy/labpdfproc/tools.py index 2a0bfc7..6945f20 100644 --- a/src/diffpy/labpdfproc/tools.py +++ b/src/diffpy/labpdfproc/tools.py @@ -537,7 +537,7 @@ def _check_saved_file_exists(args): if outfile.exists() and not args.force: existing_files.append(outfile) if args.output_correction: - corrfile = args.output_directory / (path.stem + "_cve.chi") + corrfile = args.output_directory / (path.stem + "-cve.chi") if corrfile.exists() and not args.force: existing_files.append(corrfile) if existing_files: diff --git a/tests/conftest.py b/tests/conftest.py index 629020a..cda2974 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -62,7 +62,7 @@ def user_filesystem(tmp_path): with open(output_dir / "good_data-mud-corrected.chi", "w") as f: f.write(chi_data) - with open(output_dir / "good_data_cve.chi", "w") as f: + with open(output_dir / "good_data-cve.chi", "w") as f: f.write(chi_data) home_config_data = { "wavelength": 0.3, diff --git a/tests/test_tools.py b/tests/test_tools.py index 9c818ab..9112699 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -849,23 +849,29 @@ def test_load_metadata(mocker, user_filesystem, inputs, expected): assert actual_metadata == expected_metadata -def test_preprocess_args_bad(user_filesystem): +def test_preprocess_args_bad(user_filesystem, monkeypatch): # Case: user tries to run absorption correction, but the output - # filenames already for *-mud-corrected.chi and *_cve.chi exists. + # filenames already for *-mud-corrected.chi and *-cve.chi exists. # expected: preprocess_args catches this early and raises an Error + cwd = Path(user_filesystem) + home_dir = cwd / "home_dir" + # set cwd so program can find diffpyconfig.json + monkeypatch.setattr("pathlib.Path.home", lambda _: home_dir) input_data_file = str(user_filesystem / "good_data.chi") existing_corrected_file = str( user_filesystem / "output_dir" / "good_data-mud-corrected.chi" ) existing_corrected_cve_file = str( - user_filesystem / "output_dir" / "good_data_cve.chi" - ) - cli_inputs = ( - ["mud"] - + [input_data_file] - + ["2.5", "-w", "Mo", "-o", str(user_filesystem / "output_dir")] - + ["-c"] # -c flag saves the cve file + user_filesystem / "output_dir" / "good_data-cve.chi" ) + cli_inputs = [ + "mud", + input_data_file, + "2.5", + "-o", + str(user_filesystem / "output_dir"), + "-c", # -c flag saves the cve file + ] args = get_args_cli(cli_inputs) args = set_input_lists(args) msg = ( From 5125fa96d018c06d8f0b9b78c396d5f5e57b0aa8 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Thu, 2 Apr 2026 11:52:02 -0400 Subject: [PATCH 8/8] use f-strings instead of + --- src/diffpy/labpdfproc/labpdfprocapp.py | 4 ++-- src/diffpy/labpdfproc/tools.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/diffpy/labpdfproc/labpdfprocapp.py b/src/diffpy/labpdfproc/labpdfprocapp.py index f8ec7e7..db7f873 100644 --- a/src/diffpy/labpdfproc/labpdfprocapp.py +++ b/src/diffpy/labpdfproc/labpdfprocapp.py @@ -131,14 +131,14 @@ def _add_credit_args(parser, use_gui=False): def _save_corrected(corrected, input_path, args): - outfile = args.output_directory / (input_path.stem + "-mud-corrected.chi") + outfile = args.output_directory / (f"{input_path.stem}-mud-corrected.chi") corrected.metadata = corrected.metadata or {} corrected.dump(str(outfile), xtype=args.xtype) print(f"Saved corrected data to {outfile}") def _save_correction(correction, input_path, args): - corrfile = args.output_directory / (input_path.stem + "-cve.chi") + corrfile = args.output_directory / (f"{input_path.stem}-cve.chi") correction.metadata = correction.metadata or {} correction.dump(str(corrfile), xtype=args.xtype) print(f"Saved correction data to {corrfile}") diff --git a/src/diffpy/labpdfproc/tools.py b/src/diffpy/labpdfproc/tools.py index 6945f20..305291e 100644 --- a/src/diffpy/labpdfproc/tools.py +++ b/src/diffpy/labpdfproc/tools.py @@ -533,11 +533,11 @@ def _check_saved_file_exists(args): and output directory.""" existing_files = [] for path in args.input_paths: - outfile = args.output_directory / (path.stem + "-mud-corrected.chi") + outfile = args.output_directory / (f"{path.stem}-mud-corrected.chi") if outfile.exists() and not args.force: existing_files.append(outfile) if args.output_correction: - corrfile = args.output_directory / (path.stem + "-cve.chi") + corrfile = args.output_directory / (f"{path.stem}-cve.chi") if corrfile.exists() and not args.force: existing_files.append(corrfile) if existing_files: