From f064217187ece84eb10dd57e130112cf3ea19cef Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Sun, 22 Dec 2024 07:13:13 -0500 Subject: [PATCH 01/16] initial commit of tests for the config updater. I need to get the updated user_filesystem fixture so merging main next --- news/configupdate.rst | 23 +++++++++++++++++++++++ src/diffpy/utils/tools.py | 5 ++++- tests/test_tools.py | 32 +++++++++++++++++++++++++++++++- 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 news/configupdate.rst diff --git a/news/configupdate.rst b/news/configupdate.rst new file mode 100644 index 00000000..0bc3ffa9 --- /dev/null +++ b/news/configupdate.rst @@ -0,0 +1,23 @@ +**Added:** + +* no news added: covered in the news from the get_user_info work + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index 3fc10031..98db017e 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -130,10 +130,13 @@ def get_user_info(args=None): if config_bool is False: os.remove(Path().home() / "diffpyconfig.json") config = {"username": "", "email": ""} - return config +def check_and_build_global_config(): + return + + def get_package_info(package_names, metadata=None): """ Fetches package version and updates it into (given) metadata. diff --git a/tests/test_tools.py b/tests/test_tools.py index 0a42332f..117a8565 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -5,7 +5,7 @@ import pytest -from diffpy.utils.tools import get_package_info, get_user_info +from diffpy.utils.tools import check_and_build_global_config, get_package_info, get_user_info def _setup_dirs(monkeypatch, user_filesystem): @@ -123,6 +123,36 @@ def test_get_user_info_no_conf_file_no_inputs(monkeypatch, inputsa, inputsb, exp assert confile.exists() is False +@pytest.mark.parametrize( + "test_inputs,expected", + [ # Check check_and_build_global_config() builds correct config when config is found missing + ( # C1: user inputs valid name, email and orcid + {"user_inputs": ["input_name", "input@email.com", "input_orcid"]}, + {"owner_email": "input@email.com", "owner_orcid": "input_orcid", "owner_name": "input_name"}, + ), + # ( # C2: empty strings passed in, expect uname, email, orcid from home_config + # {"owner_name": "", "owner_email": "", "owner_orcid": ""}, + # {"owner_name": "home_ownername", "owner_email": "home@email.com", "owner_orcid": "home_orcid"}, + # ), + ], +) +def test_check_and_build_global_config(test_inputs, expected, user_filesystem, mocker): + # user_filesystem[0] is tmp_dir/home_dir with the global config file in it, user_filesystem[1] + # is tmp_dir/cwd_dir + mocker.patch.object(Path, "home", return_value=user_filesystem[0]) + os.chdir(user_filesystem[1]) + # remove the config file from home that came with user_filesystem + old_confile = user_filesystem[0] / "diffpyconfig.json" + os.remove(old_confile) + check_and_build_global_config() + inp_iter = iter(test_inputs["user_inputs"]) + mocker.patch("builtins.input", lambda _: next(inp_iter)) + with open(old_confile, "r") as f: + actual = json.load(f) + print(actual) + assert actual == expected + + params_package_info = [ (["diffpy.utils", None], {"package_info": {"diffpy.utils": "3.3.0"}}), (["package1", None], {"package_info": {"package1": "1.2.3", "diffpy.utils": "3.3.0"}}), From ad05e37e7c0c9707d6270ff6c1c77734aee913eb Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Sun, 22 Dec 2024 09:18:48 -0500 Subject: [PATCH 02/16] check_and_build_global_config added wih tests --- src/diffpy/utils/tools.py | 70 +++++++++++++++++++++++---------------- tests/test_tools.py | 66 ++++++++++++++++++------------------ 2 files changed, 74 insertions(+), 62 deletions(-) diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index 1fd0ed70..59c5d31d 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -74,22 +74,6 @@ def _sorted_merge(*dicts): return merged -def _create_global_config(args): - username = input( - f"Please enter the name you would want future work to be credited to " f"[{args.get('username', '')}]: " - ).strip() or args.get("username", "") - email = input(f"Please enter the your email " f"[{args.get('email', '')}]: ").strip() or args.get("email", "") - return_bool = False if username is None or email is None else True - with open(Path().home() / "diffpyconfig.json", "w") as f: - f.write(json.dumps({"username": stringify(username), "email": stringify(email)})) - print( - f"You can manually edit the config file at {Path().home() / 'diffpyconfig.json'} using any text editor.\n" - f"Or you can update the config file by passing new values to get_user_info(), " - f"see examples here: https://www.diffpy.org/diffpy.utils/examples/toolsexample.html" - ) - return return_bool - - def get_user_info(owner_name=None, owner_email=None, owner_orcid=None): """ Get name, email and orcid of the owner/user from various sources and return it as a metadata dictionary @@ -107,7 +91,7 @@ def get_user_info(owner_name=None, owner_email=None, owner_orcid=None): "owner_email": ">@email.com", "owner_orcid": ">" } - You may also store any other gloabl-level information that you would like associated with your + You may also store any other global-level information that you would like associated with your diffraction data in this file Parameters @@ -132,24 +116,52 @@ def get_user_info(owner_name=None, owner_email=None, owner_orcid=None): del runtime_info[key] global_config = load_config(Path().home() / "diffpyconfig.json") local_config = load_config(Path().cwd() / "diffpyconfig.json") - # if global_config is None and local_config is None: - # print( - # "No global configuration file was found containing " - # "information about the user to associate with the data.\n" - # "By following the prompts below you can add your name and email to this file on the current " - # "computer and your name will be automatically associated with subsequent diffpy data by default.\n" - # "This is not recommended on a shared or public computer. " - # "You will only have to do that once.\n" - # "For more information, please refer to www.diffpy.org/diffpy.utils/examples/toolsexample.html" - # ) user_info = global_config user_info.update(local_config) user_info.update(runtime_info) return user_info -def check_and_build_global_config(): - return +def _get_value(mystring): + return mystring.strip() + + +def check_and_build_global_config(skip_config_creation=False): + config_path = Path().home() / "diffpyconfig.json" + if skip_config_creation: + return + if config_path.is_file(): + return + intro_text = ( + "No global configuration file was found containing information about the user to " + "associate with the data.\n By following the prompts below you can add your name " + "and email to this file on the current " + "computer and your name will be automatically associated with subsequent diffpy data by default.\n" + "This is not recommended on a shared or public computer. " + "You will only have to do that once.\n" + "For more information, please refer to www.diffpy.org/diffpy.utils/examples/toolsexample.html" + ) + print(intro_text) + username = input("Please enter the name you would want future work to be credited to: ").strip() + email = input("Please enter your email: ").strip() + orcid = input("Please enter your orcid ID if you know it: ").strip() + config = {"owner_name": stringify(username), "owner_email": stringify(email), "owner_orcid": stringify(orcid)} + if email != "" or orcid != "" or username != "": + config["owner_orcid"] = stringify(orcid) + with open(config_path, "w") as f: + f.write(json.dumps(config)) + outro_text = ( + f"The config file at {Path().home() / 'diffpyconfig.json'} has been created. " + f"The values {config} were entered.\n" + f"These values will be inserted as metadata with your data in apps that use " + f"diffpy.get_user_info(). If you would like to update these values, either " + f"delete the config file and this workflow will rerun next time you run this " + f"program. Or you may open the config file in a text editor and manually edit the" + f"entries. For more information, see: " + f"https://diffpy.githu.io/diffpy.utils/examples/tools_example.html" + ) + print(outro_text) + return def get_package_info(package_names, metadata=None): diff --git a/tests/test_tools.py b/tests/test_tools.py index 3169f01f..88e81566 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -149,29 +149,6 @@ def test_get_user_info_with_local_conf_file(runtime_inputs, expected, user_files assert actual == expected -# @pytest.mark.parametrize("inputsa, inputsb, expected", params_user_info_with_no_home_conf_file) -# def test_get_user_info_with_no_home_conf_file(monkeypatch, inputsa, inputsb, expected, user_filesystem): -# _setup_dirs(monkeypatch, user_filesystem) -# os.remove(Path().home() / "diffpyconfig.json") -# inp_iter = iter(inputsb) -# monkeypatch.setattr("builtins.input", lambda _: next(inp_iter)) -# _run_tests(inputsa, expected) -# confile = Path().home() / "diffpyconfig.json" -# assert confile.is_file() -# -# -# @pytest.mark.parametrize("inputsa, inputsb, expected", params_user_info_no_conf_file_no_inputs) -# def test_get_user_info_no_conf_file_no_inputs(monkeypatch, inputsa, inputsb, expected, user_filesystem): -# _setup_dirs(monkeypatch, user_filesystem) -# os.remove(Path().home() / "diffpyconfig.json") -# inp_iter = iter(inputsb) -# monkeypatch.setattr("builtins.input", lambda _: next(inp_iter)) -# _run_tests(inputsa, expected) -# confile = Path().home() / "diffpyconfig.json" -# assert confile.exists() is False -# - - @pytest.mark.parametrize( "test_inputs,expected", [ # Check check_and_build_global_config() builds correct config when config is found missing @@ -179,10 +156,11 @@ def test_get_user_info_with_local_conf_file(runtime_inputs, expected, user_files {"user_inputs": ["input_name", "input@email.com", "input_orcid"]}, {"owner_email": "input@email.com", "owner_orcid": "input_orcid", "owner_name": "input_name"}, ), - # ( # C2: empty strings passed in, expect uname, email, orcid from home_config - # {"owner_name": "", "owner_email": "", "owner_orcid": ""}, - # {"owner_name": "home_ownername", "owner_email": "home@email.com", "owner_orcid": "home_orcid"}, - # ), + ({"user_inputs": ["", "", ""]}, None), # C2: empty strings passed in, expect no config file created + ( # C3: just username input, expect config file but with some empty values + {"user_inputs": ["input_name", "", ""]}, + {"owner_email": "", "owner_orcid": "", "owner_name": "input_name"}, + ), ], ) def test_check_and_build_global_config(test_inputs, expected, user_filesystem, mocker): @@ -190,18 +168,40 @@ def test_check_and_build_global_config(test_inputs, expected, user_filesystem, m # is tmp_dir/cwd_dir mocker.patch.object(Path, "home", return_value=user_filesystem[0]) os.chdir(user_filesystem[1]) + confile = user_filesystem[0] / "diffpyconfig.json" # remove the config file from home that came with user_filesystem - old_confile = user_filesystem[0] / "diffpyconfig.json" - os.remove(old_confile) + os.remove(confile) + mocker.patch("builtins.input", side_effect=test_inputs["user_inputs"]) check_and_build_global_config() - inp_iter = iter(test_inputs["user_inputs"]) - mocker.patch("builtins.input", lambda _: next(inp_iter)) - with open(old_confile, "r") as f: + try: + with open(confile, "r") as f: + actual = json.load(f) + except FileNotFoundError: + actual = None + assert actual == expected + + +def test_check_and_build_global_config_file_exists(user_filesystem, mocker): + mocker.patch.object(Path, "home", return_value=user_filesystem[0]) + os.chdir(user_filesystem[1]) + confile = user_filesystem[0] / "diffpyconfig.json" + expected = {"owner_name": "home_ownername", "owner_email": "home@email.com", "owner_orcid": "home_orcid"} + check_and_build_global_config() + with open(confile, "r") as f: actual = json.load(f) - print(actual) assert actual == expected +def test_check_and_build_global_config_skipped(user_filesystem, mocker): + mocker.patch.object(Path, "home", return_value=user_filesystem[0]) + os.chdir(user_filesystem[1]) + confile = user_filesystem[0] / "diffpyconfig.json" + # remove the config file from home that came with user_filesystem + os.remove(confile) + check_and_build_global_config(skip_config_creation=True) + assert not confile.exists() + + params_package_info = [ (["diffpy.utils", None], {"package_info": {"diffpy.utils": "3.3.0"}}), (["package1", None], {"package_info": {"package1": "1.2.3", "diffpy.utils": "3.3.0"}}), From 552dd32f8b516577e6dfd3040a26b242c56c0eed Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Sun, 22 Dec 2024 09:25:15 -0500 Subject: [PATCH 03/16] delete unneeded _get_value() function and unneeded test parms --- src/diffpy/utils/tools.py | 4 --- tests/test_tools.py | 65 --------------------------------------- 2 files changed, 69 deletions(-) diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index 59c5d31d..27e49ff8 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -122,10 +122,6 @@ def get_user_info(owner_name=None, owner_email=None, owner_orcid=None): return user_info -def _get_value(mystring): - return mystring.strip() - - def check_and_build_global_config(skip_config_creation=False): config_path = Path().home() / "diffpyconfig.json" if skip_config_creation: diff --git a/tests/test_tools.py b/tests/test_tools.py index 88e81566..d364feb9 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -7,71 +7,6 @@ from diffpy.utils.tools import check_and_build_global_config, get_package_info, get_user_info -# def _setup_dirs(monkeypatch, user_filesystem): -# home_dir, cwd_dir = user_filesystem.home_dir, user_filesystem.cwd_dir -# os.chdir(cwd_dir) -# return home_dir -# - - -def _run_tests(inputs, expected): - args = {"username": inputs[0], "email": inputs[1]} - expected_username, expected_email = expected - config = get_user_info(args) - assert config.get("username") == expected_username - assert config.get("email") == expected_email - - -params_user_info_with_local_conf_file = [ - (["", ""], ["cwd_username", "cwd@email.com"]), - (["cli_username", ""], ["cli_username", "cwd@email.com"]), - (["", "cli@email.com"], ["cwd_username", "cli@email.com"]), - ([None, None], ["cwd_username", "cwd@email.com"]), - (["cli_username", None], ["cli_username", "cwd@email.com"]), - ([None, "cli@email.com"], ["cwd_username", "cli@email.com"]), - (["cli_username", "cli@email.com"], ["cli_username", "cli@email.com"]), -] -params_user_info_with_no_home_conf_file = [ - ( - [None, None], - ["input_username", "input@email.com"], - ["input_username", "input@email.com"], - ), - ( - ["cli_username", None], - ["", "input@email.com"], - ["cli_username", "input@email.com"], - ), - ( - [None, "cli@email.com"], - ["input_username", ""], - ["input_username", "cli@email.com"], - ), - ( - ["", ""], - ["input_username", "input@email.com"], - ["input_username", "input@email.com"], - ), - ( - ["cli_username", ""], - ["", "input@email.com"], - ["cli_username", "input@email.com"], - ), - ( - ["", "cli@email.com"], - ["input_username", ""], - ["input_username", "cli@email.com"], - ), - ( - ["cli_username", "cli@email.com"], - ["input_username", "input@email.com"], - ["cli_username", "cli@email.com"], - ), -] -params_user_info_no_conf_file_no_inputs = [ - ([None, None], ["", ""], ["", ""]), -] - @pytest.mark.parametrize( "runtime_inputs, expected", From 1a2214fc14916eef8f1737ca70bd4ff38f82980d Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 23 Dec 2024 14:03:55 -0500 Subject: [PATCH 04/16] Rename id to uuid in DiffractionObjet --- news/uuid-rename.rst | 23 +++++++++++++++++++++++ src/diffpy/utils/diffraction_objects.py | 14 +++++++------- tests/test_diffraction_objects.py | 24 +++++++++++++----------- 3 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 news/uuid-rename.rst diff --git a/news/uuid-rename.rst b/news/uuid-rename.rst new file mode 100644 index 00000000..ecd7f22d --- /dev/null +++ b/news/uuid-rename.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* DiffractionObject's "id" property renamed to "uuid" + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/utils/diffraction_objects.py b/src/diffpy/utils/diffraction_objects.py index 92ad17dc..2922cdbd 100644 --- a/src/diffpy/utils/diffraction_objects.py +++ b/src/diffpy/utils/diffraction_objects.py @@ -50,7 +50,7 @@ class DiffractionObject: The array containing the quantity of q, tth, d values. input_xtype : str The type of the independent variable in `xarray`. Must be one of {*XQUANTITIES} - id : uuid + _uuid : uuid The unique identifier for the diffraction object. scat_quantity : str The type of scattering experiment (e.g., "x-ray", "neutron"). Default is an empty string "". @@ -127,7 +127,7 @@ def __init__( >>> print(do.metadata) """ - self._id = uuid.uuid4() + self._uuid = uuid.uuid4() self._input_data(xarray, yarray, xtype, wavelength, scat_quantity, name, metadata) def _input_data(self, xarray, yarray, xtype, wavelength, scat_quantity, name, metadata): @@ -299,12 +299,12 @@ def input_xtype(self, _): raise AttributeError(_setter_wmsg("input_xtype")) @property - def id(self): - return self._id + def uuid(self): + return self._uuid - @id.setter - def id(self, _): - raise AttributeError(_setter_wmsg("id")) + @uuid.setter + def uuid(self, _): + raise AttributeError(_setter_wmsg("uuid")) def get_array_index(self, value, xtype=None): """Return the index of the closest value in the array associated with diff --git a/tests/test_diffraction_objects.py b/tests/test_diffraction_objects.py index 63f349eb..33675b9e 100644 --- a/tests/test_diffraction_objects.py +++ b/tests/test_diffraction_objects.py @@ -479,7 +479,7 @@ def test_init_valid(do_init_args, expected_do_dict, divide_by_zero_warning_expec else: actual_do_dict = DiffractionObject(**do_init_args).__dict__ diff = DeepDiff( - actual_do_dict, expected_do_dict, ignore_order=True, significant_digits=13, exclude_paths="root['_id']" + actual_do_dict, expected_do_dict, ignore_order=True, significant_digits=13, exclude_paths="root['_uuid']" ) assert diff == {} @@ -523,27 +523,29 @@ def test_all_array_setter(do_minimal): do.all_arrays = np.empty((4, 4)) -def test_id_getter(do_minimal): +def test_uuid_getter(do_minimal): do = do_minimal - assert hasattr(do, "id") - assert isinstance(do.id, UUID) - assert len(str(do.id)) == 36 + assert hasattr(do, "uuid") + assert isinstance(do.uuid, UUID) + assert len(str(do.uuid)) == 36 -def test_id_getter_with_mock(mocker, do_minimal): - mocker.patch.object(DiffractionObject, "id", new_callable=lambda: UUID("d67b19c6-3016-439f-81f7-cf20a04bee87")) +def test_uuid_getter_with_mock(mocker, do_minimal): + mocker.patch.object( + DiffractionObject, "uuid", new_callable=lambda: UUID("d67b19c6-3016-439f-81f7-cf20a04bee87") + ) do = do_minimal - assert do.id == UUID("d67b19c6-3016-439f-81f7-cf20a04bee87") + assert do.uuid == UUID("d67b19c6-3016-439f-81f7-cf20a04bee87") -def test_id_setter_error(do_minimal): +def test_uuid_setter_error(do_minimal): do = do_minimal with pytest.raises( AttributeError, - match="Direct modification of attribute 'id' is not allowed. Please use 'input_data' to modify 'id'.", + match="Direct modification of attribute 'uuid' is not allowed. Please use 'input_data' to modify 'uuid'.", ): - do.id = uuid.uuid4() + do.uuid = uuid.uuid4() def test_xarray_yarray_length_mismatch(): From 576afb2b35a5a1e79d191f1b655f9e766e633d3e Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 23 Dec 2024 14:28:16 -0500 Subject: [PATCH 05/16] No manual edits made to reformat docstrings --- .pre-commit-config.yaml | 7 +++++++ src/diffpy/__init__.py | 1 - src/diffpy/utils/__init__.py | 3 +-- src/diffpy/utils/parsers/__init__.py | 4 +--- src/diffpy/utils/parsers/serialization.py | 4 ++-- src/diffpy/utils/resampler.py | 4 ++-- src/diffpy/utils/tools.py | 20 ++++++------------ src/diffpy/utils/transforms.py | 20 +++++++----------- src/diffpy/utils/version.py | 1 - src/diffpy/utils/wx/__init__.py | 4 +--- src/diffpy/utils/wx/gridutils.py | 25 ++++++++++++----------- tests/test_loaddata.py | 9 ++++---- tests/test_version.py | 6 +++--- 13 files changed, 47 insertions(+), 61 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b7fb3631..6dca6f1e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,3 +58,10 @@ repos: - id: prettier additional_dependencies: - "prettier@^3.2.4" + # docformatter - formats docstrings using PEP 257 + - repo: https://github.com/s-weigand/docformatter + rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c + hooks: + - id: docformatter + additional_dependencies: [tomli] + args: [--in-place, --config, ./pyproject.toml] diff --git a/src/diffpy/__init__.py b/src/diffpy/__init__.py index 11a4204c..00208e23 100644 --- a/src/diffpy/__init__.py +++ b/src/diffpy/__init__.py @@ -16,7 +16,6 @@ # See LICENSE.rst for license information. # ############################################################################## - """diffpy - tools for structure analysis by diffraction. Blank namespace package. diff --git a/src/diffpy/utils/__init__.py b/src/diffpy/utils/__init__.py index c9909a8a..12f4a49d 100644 --- a/src/diffpy/utils/__init__.py +++ b/src/diffpy/utils/__init__.py @@ -12,8 +12,7 @@ # See LICENSE.rst for license information. # ############################################################################## - -"""Shared utilities for diffpy packages""" +"""Shared utilities for diffpy packages.""" # package version from diffpy.utils.version import __version__ diff --git a/src/diffpy/utils/parsers/__init__.py b/src/diffpy/utils/parsers/__init__.py index bab9943c..a0278e27 100644 --- a/src/diffpy/utils/parsers/__init__.py +++ b/src/diffpy/utils/parsers/__init__.py @@ -12,6 +12,4 @@ # See LICENSE_DANSE.txt for license information. # ############################################################################## - -"""Various utilities related to data parsing and manipulation. -""" +"""Various utilities related to data parsing and manipulation.""" diff --git a/src/diffpy/utils/parsers/serialization.py b/src/diffpy/utils/parsers/serialization.py index 46d4b8ff..20b34b31 100644 --- a/src/diffpy/utils/parsers/serialization.py +++ b/src/diffpy/utils/parsers/serialization.py @@ -33,8 +33,8 @@ def serialize_data( show_path=True, serial_file=None, ): - """Serialize file data into a dictionary. Can also save dictionary into a serial language file. Dictionary is - formatted as {filename: data}. + """Serialize file data into a dictionary. Can also save dictionary into a + serial language file. Dictionary is formatted as {filename: data}. Requires hdata and data_table (can be generated by loadData). diff --git a/src/diffpy/utils/resampler.py b/src/diffpy/utils/resampler.py index 21fabf56..115087a2 100644 --- a/src/diffpy/utils/resampler.py +++ b/src/diffpy/utils/resampler.py @@ -12,7 +12,6 @@ # See LICENSE_DANSE.txt for license information. # ############################################################################## - """Various utilities related to data parsing and manipulation.""" import warnings @@ -80,7 +79,8 @@ def wsinterp(x, xp, fp, left=None, right=None): def nsinterp(xp, fp, qmin=0, qmax=25, left=None, right=None): - """One-dimensional Whittaker-Shannon interpolation onto the Nyquist-Shannon grid. + """One-dimensional Whittaker-Shannon interpolation onto the Nyquist-Shannon + grid. Takes a band-limited function fp and original grid xp and resamples fp on the NS grid. Uses the minimum number of points N required by the Nyquist sampling theorem. diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index 91505e6f..8b021ad1 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -5,8 +5,7 @@ def clean_dict(obj): - """ - Remove keys from the dictionary where the corresponding value is None. + """Remove keys from the dictionary where the corresponding value is None. Parameters ---------- @@ -17,7 +16,6 @@ def clean_dict(obj): ------- dict: The cleaned dictionary with keys removed where the value is None. - """ obj = obj if obj is not None else {} for key, value in copy(obj).items(): @@ -27,8 +25,7 @@ def clean_dict(obj): def stringify(obj): - """ - Convert None to an empty string. + """Convert None to an empty string. Parameters ---------- @@ -44,8 +41,7 @@ def stringify(obj): def load_config(file_path): - """ - Load configuration from a .json file. + """Load configuration from a .json file. Parameters ---------- @@ -56,7 +52,6 @@ def load_config(file_path): ------- dict: The configuration dictionary or {} if the config file does not exist. - """ config_file = Path(file_path).resolve() if config_file.is_file(): @@ -91,8 +86,8 @@ def _create_global_config(args): def get_user_info(owner_name=None, owner_email=None, owner_orcid=None): - """ - Get name, email and orcid of the owner/user from various sources and return it as a metadata dictionary + """Get name, email and orcid of the owner/user from various sources and + return it as a metadata dictionary. The function looks for the information in json format configuration files with the name 'diffpyconfig.json'. These can be in the user's home directory and in the current working directory. The information in the @@ -124,7 +119,6 @@ def get_user_info(owner_name=None, owner_email=None, owner_orcid=None): dict: The dictionary containing username, email and orcid of the user/owner, and any other information stored in the global or local config files. - """ runtime_info = {"owner_name": owner_name, "owner_email": owner_email, "owner_orcid": owner_orcid} for key, value in copy(runtime_info).items(): @@ -149,8 +143,7 @@ def get_user_info(owner_name=None, owner_email=None, owner_orcid=None): def get_package_info(package_names, metadata=None): - """ - Fetches package version and updates it into (given) metadata. + """Fetches package version and updates it into (given) metadata. Package info stored in metadata as {'package_info': {'package_name': 'version_number'}}. @@ -164,7 +157,6 @@ def get_package_info(package_names, metadata=None): ------- dict: The updated metadata dict with package info inserted. - """ if metadata is None: metadata = {} diff --git a/src/diffpy/utils/transforms.py b/src/diffpy/utils/transforms.py index 1d50aeab..f2956879 100644 --- a/src/diffpy/utils/transforms.py +++ b/src/diffpy/utils/transforms.py @@ -29,8 +29,7 @@ def _validate_inputs(q, wavelength): def q_to_tth(q, wavelength): - r""" - Helper function to convert q to two-theta. + r"""Helper function to convert q to two-theta. If wavelength is missing, returns x-values that are integer indexes @@ -72,9 +71,7 @@ def q_to_tth(q, wavelength): def tth_to_q(tth, wavelength): - r""" - - Helper function to convert two-theta to q on independent variable axis. + r"""Helper function to convert two-theta to q on independent variable axis. If wavelength is missing, returns independent variable axis as integer indexes. @@ -120,8 +117,8 @@ def tth_to_q(tth, wavelength): def q_to_d(q): - r""" - Helper function to convert q to d on independent variable axis, using :math:`d = \frac{2 \pi}{q}`. + r"""Helper function to convert q to d on independent variable axis, using + :math:`d = \frac{2 \pi}{q}`. Parameters ---------- @@ -140,8 +137,7 @@ def q_to_d(q): def tth_to_d(tth, wavelength): - r""" - Helper function to convert two-theta to d on independent variable axis. + r"""Helper function to convert two-theta to d on independent variable axis. The formula is .. math:: d = \frac{\lambda}{2 \sin\left(\frac{2\theta}{2}\right)}. @@ -174,8 +170,7 @@ def tth_to_d(tth, wavelength): def d_to_q(d): - r""" - Helper function to convert q to d using :math:`d = \frac{2 \pi}{q}`. + r"""Helper function to convert q to d using :math:`d = \frac{2 \pi}{q}`. Parameters ---------- @@ -194,8 +189,7 @@ def d_to_q(d): def d_to_tth(d, wavelength): - r""" - Helper function to convert d to two-theta on independent variable axis. + r"""Helper function to convert d to two-theta on independent variable axis. The formula is .. math:: 2\theta = 2 \arcsin\left(\frac{\lambda}{2d}\right). diff --git a/src/diffpy/utils/version.py b/src/diffpy/utils/version.py index 0bc397e4..e74c47bd 100644 --- a/src/diffpy/utils/version.py +++ b/src/diffpy/utils/version.py @@ -12,7 +12,6 @@ # See LICENSE.rst for license information. # ############################################################################## - """Definition of __version__.""" # We do not use the other three variables, but can be added back if needed. diff --git a/src/diffpy/utils/wx/__init__.py b/src/diffpy/utils/wx/__init__.py index 3f7417ef..e2f08735 100644 --- a/src/diffpy/utils/wx/__init__.py +++ b/src/diffpy/utils/wx/__init__.py @@ -12,6 +12,4 @@ # See LICENSE_DANSE.txt for license information. # ############################################################################## - -"""Utilities related wx Python GUIs. -""" +"""Utilities related wx Python GUIs.""" diff --git a/src/diffpy/utils/wx/gridutils.py b/src/diffpy/utils/wx/gridutils.py index c459ac30..a01e8f92 100644 --- a/src/diffpy/utils/wx/gridutils.py +++ b/src/diffpy/utils/wx/gridutils.py @@ -12,9 +12,7 @@ # See LICENSE_DANSE.txt for license information. # ############################################################################## - -"""Common functions for manipulating wx.grid.Grid. -""" +"""Common functions for manipulating wx.grid.Grid.""" import wx @@ -53,7 +51,9 @@ def getSelectionColumns(grid): def getSelectedCells(grid): """Get list of (row, col) pairs of all selected cells. - Unlike grid.GetSelectedCells this returns them all no matter how they were selected. + + Unlike grid.GetSelectedCells this returns them all no matter how + they were selected. """ rows = grid.GetNumberRows() cols = grid.GetNumberCols() @@ -75,8 +75,8 @@ def getSelectedCells(grid): def limitSelectionToRows(grid, indices): - """Limit selection to the specified row indices. - No action for empty indices. + """Limit selection to the specified row indices. No action for empty + indices. Parameters ---------- @@ -112,10 +112,10 @@ def limitSelectionToRows(grid, indices): def quickResizeColumns(grid, indices): """Resize the columns that were recently affected by cell changes. - This is faster than the normal grid AutoSizeColumns, since the latter loops - over the entire grid. In addition, this will not cause a - EVT_GRID_CMD_CELL_CHANGE event to be thrown, which can cause recursion. - This method will only increase column size. + This is faster than the normal grid AutoSizeColumns, since the + latter loops over the entire grid. In addition, this will not cause + a EVT_GRID_CMD_CELL_CHANGE event to be thrown, which can cause + recursion. This method will only increase column size. """ # Get the columns and maximum text width in each one dc = wx.ScreenDC() @@ -140,8 +140,9 @@ def quickResizeColumns(grid, indices): def _indicesToBlocks(indices): - """Convert a list of integer indices to a list of (start, stop) tuples. - The (start, stop) tuple defines a continuous block, where the stop index is included in the block. + """Convert a list of integer indices to a list of (start, stop) tuples. The + (start, stop) tuple defines a continuous block, where the stop index is + included in the block. Parameters ---------- diff --git a/tests/test_loaddata.py b/tests/test_loaddata.py index a7e273e7..f825139c 100644 --- a/tests/test_loaddata.py +++ b/tests/test_loaddata.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -"""Unit tests for diffpy.utils.parsers.loaddata -""" +"""Unit tests for diffpy.utils.parsers.loaddata.""" import numpy as np import pytest @@ -10,7 +9,7 @@ def test_loadData_default(datafile): - """check loadData() with default options""" + """Check loadData() with default options.""" loaddata01 = datafile("loaddata01.txt") d2c = np.array([[3, 31], [4, 32], [5, 33]]) @@ -38,7 +37,7 @@ def test_loadData_default(datafile): def test_loadData_1column(datafile): - """check loading of one-column data.""" + """Check loading of one-column data.""" loaddata01 = datafile("loaddata01.txt") d1c = np.arange(1, 6) @@ -54,7 +53,7 @@ def test_loadData_1column(datafile): def test_loadData_headers(datafile): - """check loadData() with headers options enabled""" + """Check loadData() with headers options enabled.""" expected = { "wavelength": 0.1, "dataformat": "Qnm", diff --git a/tests/test_version.py b/tests/test_version.py index 421a96e4..4152a197 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -1,10 +1,10 @@ -"""Unit tests for __version__.py -""" +"""Unit tests for __version__.py.""" import diffpy.utils def test_package_version(): - """Ensure the package version is defined and not set to the initial placeholder.""" + """Ensure the package version is defined and not set to the initial + placeholder.""" assert hasattr(diffpy.utils, "__version__") assert diffpy.utils.__version__ != "0.0.0" From 660f8a1987298c19f001c5c2e265566aef9f4f3a Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 23 Dec 2024 14:31:15 -0500 Subject: [PATCH 06/16] Add news for docformatt --- news/docformatter.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/docformatter.rst diff --git a/news/docformatter.rst b/news/docformatter.rst new file mode 100644 index 00000000..56368125 --- /dev/null +++ b/news/docformatter.rst @@ -0,0 +1,23 @@ +**Added:** + +* docforamtter in pre-commit for automatic formatting of docstrings to PEP 257 + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From f498a0740d26627175ffa8c073311ca3db0c2969 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 25 Dec 2024 07:18:22 -0500 Subject: [PATCH 07/16] docstring for create global config and have it return a bool --- src/diffpy/utils/tools.py | 40 ++++++++++++++++++++++++++++++++++----- tests/test_tools.py | 11 ++++++++--- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index 27e49ff8..e7d44d12 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -123,11 +123,40 @@ def get_user_info(owner_name=None, owner_email=None, owner_orcid=None): def check_and_build_global_config(skip_config_creation=False): + """ + Checks for a global diffpu config file in user's home directory and creates one if it is missing + + The file it looks for is called diffpyconfig.json. This can contain anything in json format, but + minimally contains information about the computer owner. The information is used + when diffpy objects are created and saved to files or databases to retain ownership information + of datasets. For example, it is used by diffpy.utils.tools.get_user_info(). + + If the function finds no config file in the user's home directory it interrupts execution + and prompts the user for name, email, and orcid information. It then creates the config file + with this information inside it. + + The function returns True if the file exists and False otherwise. + + If you would like to check for a file but not run the file creation workflow you can set + the optional argument skip_config_creation to True. + + Parameters + ---------- + skip_config_creation: bool, optional, Default is False + The bool that will override the creation workflow even if no config file exists. + + Returns + ------- + bool: True if the file exists and False otherwise. + + """ + config_exists = False config_path = Path().home() / "diffpyconfig.json" - if skip_config_creation: - return if config_path.is_file(): - return + config_exists = True + return config_exists + if skip_config_creation: + return config_exists intro_text = ( "No global configuration file was found containing information about the user to " "associate with the data.\n By following the prompts below you can add your name " @@ -154,10 +183,11 @@ def check_and_build_global_config(skip_config_creation=False): f"delete the config file and this workflow will rerun next time you run this " f"program. Or you may open the config file in a text editor and manually edit the" f"entries. For more information, see: " - f"https://diffpy.githu.io/diffpy.utils/examples/tools_example.html" + f"https://diffpy.github.io/diffpy.utils/examples/tools_example.html" ) print(outro_text) - return + config_exists = True + return config_exists def get_package_info(package_names, metadata=None): diff --git a/tests/test_tools.py b/tests/test_tools.py index d364feb9..3808537d 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -107,13 +107,16 @@ def test_check_and_build_global_config(test_inputs, expected, user_filesystem, m # remove the config file from home that came with user_filesystem os.remove(confile) mocker.patch("builtins.input", side_effect=test_inputs["user_inputs"]) - check_and_build_global_config() + actual_bool = check_and_build_global_config() try: with open(confile, "r") as f: actual = json.load(f) + expected_bool = True except FileNotFoundError: + expected_bool = False actual = None assert actual == expected + assert actual_bool == expected_bool def test_check_and_build_global_config_file_exists(user_filesystem, mocker): @@ -121,7 +124,8 @@ def test_check_and_build_global_config_file_exists(user_filesystem, mocker): os.chdir(user_filesystem[1]) confile = user_filesystem[0] / "diffpyconfig.json" expected = {"owner_name": "home_ownername", "owner_email": "home@email.com", "owner_orcid": "home_orcid"} - check_and_build_global_config() + actual_bool = check_and_build_global_config() + assert actual_bool is True with open(confile, "r") as f: actual = json.load(f) assert actual == expected @@ -133,7 +137,8 @@ def test_check_and_build_global_config_skipped(user_filesystem, mocker): confile = user_filesystem[0] / "diffpyconfig.json" # remove the config file from home that came with user_filesystem os.remove(confile) - check_and_build_global_config(skip_config_creation=True) + actual_bool = check_and_build_global_config(skip_config_creation=True) + assert actual_bool is False assert not confile.exists() From 7b99d258409ab4c21e64235a1fc822ecedfd7c95 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 25 Dec 2024 08:26:19 -0500 Subject: [PATCH 08/16] update docs with new return value for create_config --- doc/source/examples/tools_example.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/source/examples/tools_example.rst b/doc/source/examples/tools_example.rst index 60746e6f..27de73b5 100644 --- a/doc/source/examples/tools_example.rst +++ b/doc/source/examples/tools_example.rst @@ -95,6 +95,10 @@ it will only run once. However, if you want to bypass this behavior, ``check_and_build_global_config()`` takes an optional boolean ``skip_config_creation`` parameter that could be set to ``True`` at runtime to override the config creation. +``check_and_build_global_config()`` returns ``True`` if the config file exists (whether it created it or not) +and ``False`` if the config file does not exist in the user's home allowing you to develop your own +workflow for handling missing config files after running it with ``skip_config_creation=True``. + I entered the wrong information in my config file so it always loads incorrect information, how do I fix that? -------------------------------------------------------------------------------------------------------------- From 2a9e1c34dc414fc1572047724a8e595f004833ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Dec 2024 22:16:45 +0000 Subject: [PATCH 09/16] [pre-commit.ci] auto fixes from pre-commit hooks --- src/diffpy/utils/tools.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index 248230eb..b7c89b4c 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -4,7 +4,6 @@ from pathlib import Path - def clean_dict(obj): """Remove keys from the dictionary where the corresponding value is None. @@ -26,9 +25,7 @@ def clean_dict(obj): def _stringify(obj): - """ - Convert None to an empty string. - + """Convert None to an empty string. Parameters ---------- @@ -44,9 +41,8 @@ def _stringify(obj): def _load_config(file_path): - """ - Load configuration from a .json file. ->>>>>>> de55560eb525ef412c38bb31d21d43d9b170d3f6 + """Load configuration from a .json file. >>>>>>> + de55560eb525ef412c38bb31d21d43d9b170d3f6. Parameters ---------- From 32c00188343d035dd4625541adf4d338cfd38141 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Dec 2024 17:19:37 -0500 Subject: [PATCH 10/16] Remove >>>> extra due to merge conflict in tools --- src/diffpy/utils/tools.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index b7c89b4c..f2f4e136 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -41,8 +41,7 @@ def _stringify(obj): def _load_config(file_path): - """Load configuration from a .json file. >>>>>>> - de55560eb525ef412c38bb31d21d43d9b170d3f6. + """Load configuration from a .json file. Parameters ---------- From 209a1945c33950ddfff1d1eaf8e086c16695995a Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Dec 2024 23:10:38 -0500 Subject: [PATCH 11/16] Add separate docstring for @property methods --- src/diffpy/utils/diffraction_objects.py | 37 ++++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/diffpy/utils/diffraction_objects.py b/src/diffpy/utils/diffraction_objects.py index 2922cdbd..a1b1bd13 100644 --- a/src/diffpy/utils/diffraction_objects.py +++ b/src/diffpy/utils/diffraction_objects.py @@ -46,12 +46,6 @@ class DiffractionObject: Attributes ---------- - all_arrays : ndarray - The array containing the quantity of q, tth, d values. - input_xtype : str - The type of the independent variable in `xarray`. Must be one of {*XQUANTITIES} - _uuid : uuid - The unique identifier for the diffraction object. scat_quantity : str The type of scattering experiment (e.g., "x-ray", "neutron"). Default is an empty string "". wavelength : float @@ -284,6 +278,20 @@ def __rtruediv__(self, other): @property def all_arrays(self): + """The array containing `xarray` values in q, d, tth, and `yarray`. + + Returns + ------- + ndarray + The 2D matrix containing the `xarray` objects values and `yarray`. + + Examples + -------- + >>> my_do.all_arrays[:, 0] # yarray + >>> my_do.all_arrays[:, 1] # `xarray` in q + >>> my_do.all_arrays[:, 2] # `xarray` in tth + >>> my_do.all_arrays[:, 3] # `xarray` in d + """ return self._all_arrays @all_arrays.setter @@ -292,6 +300,13 @@ def all_arrays(self, _): @property def input_xtype(self): + """The type of the independent variable in `xarray`. + + Returns + ------- + str + The type of `xarray`, which must be one of {*XQUANTITIES}. + """ return self._input_xtype @input_xtype.setter @@ -300,6 +315,13 @@ def input_xtype(self, _): @property def uuid(self): + """The unique identifier for the DiffractionObject instance. + + Returns + ------- + uuid + The unique identifier of the DiffractionObject instance. + """ return self._uuid @uuid.setter @@ -319,7 +341,8 @@ def get_array_index(self, value, xtype=None): Returns ------- - the index of the value in the array + list + The list containing the index of the closest value in the array. """ xtype = self._input_xtype From 5824250c02fca1e067598615b48418eb24a48504 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Dec 2024 23:15:40 -0500 Subject: [PATCH 12/16] Improve docstring for all_arrays --- src/diffpy/utils/diffraction_objects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/utils/diffraction_objects.py b/src/diffpy/utils/diffraction_objects.py index a1b1bd13..684c71b7 100644 --- a/src/diffpy/utils/diffraction_objects.py +++ b/src/diffpy/utils/diffraction_objects.py @@ -278,12 +278,12 @@ def __rtruediv__(self, other): @property def all_arrays(self): - """The array containing `xarray` values in q, d, tth, and `yarray`. + """The 2D array containing `xarray` and `yarray` values. Returns ------- ndarray - The 2D matrix containing the `xarray` objects values and `yarray`. + The 2D array containing the `xarray` values in q, tth, d, and `yarray`. Examples -------- From 2f293c09999cc1b8617cd39b2c9a0b07f1b2add3 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Dec 2024 23:16:53 -0500 Subject: [PATCH 13/16] Remove extra singl quote around comment --- src/diffpy/utils/diffraction_objects.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffpy/utils/diffraction_objects.py b/src/diffpy/utils/diffraction_objects.py index 684c71b7..286154d7 100644 --- a/src/diffpy/utils/diffraction_objects.py +++ b/src/diffpy/utils/diffraction_objects.py @@ -288,9 +288,9 @@ def all_arrays(self): Examples -------- >>> my_do.all_arrays[:, 0] # yarray - >>> my_do.all_arrays[:, 1] # `xarray` in q - >>> my_do.all_arrays[:, 2] # `xarray` in tth - >>> my_do.all_arrays[:, 3] # `xarray` in d + >>> my_do.all_arrays[:, 1] # xarray in q + >>> my_do.all_arrays[:, 2] # xarray in tth + >>> my_do.all_arrays[:, 3] # xarray in d """ return self._all_arrays From ceba7f9dead7867476bdba5482caacfe77810de0 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Thu, 26 Dec 2024 14:49:52 -0500 Subject: [PATCH 14/16] Fix docstring for all_arrays per sbilling pr review --- src/diffpy/utils/diffraction_objects.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/diffpy/utils/diffraction_objects.py b/src/diffpy/utils/diffraction_objects.py index 286154d7..83d7f1cf 100644 --- a/src/diffpy/utils/diffraction_objects.py +++ b/src/diffpy/utils/diffraction_objects.py @@ -283,10 +283,13 @@ def all_arrays(self): Returns ------- ndarray - The 2D array containing the `xarray` values in q, tth, d, and `yarray`. + The shape (len(data), 4) 2D array with columns containing the `yarray` (intensity) + and the `xarray` values in q, tth, d, and `yarray`. Examples -------- + To access specific arrays individually, use these slices: + >>> my_do.all_arrays[:, 0] # yarray >>> my_do.all_arrays[:, 1] # xarray in q >>> my_do.all_arrays[:, 2] # xarray in tth From 2d1c104b4197b20c94c21d5fef6683f65f876d00 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 26 Dec 2024 19:50:06 +0000 Subject: [PATCH 15/16] [pre-commit.ci] auto fixes from pre-commit hooks --- src/diffpy/utils/diffraction_objects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffpy/utils/diffraction_objects.py b/src/diffpy/utils/diffraction_objects.py index 83d7f1cf..87ed9d13 100644 --- a/src/diffpy/utils/diffraction_objects.py +++ b/src/diffpy/utils/diffraction_objects.py @@ -289,7 +289,7 @@ def all_arrays(self): Examples -------- To access specific arrays individually, use these slices: - + >>> my_do.all_arrays[:, 0] # yarray >>> my_do.all_arrays[:, 1] # xarray in q >>> my_do.all_arrays[:, 2] # xarray in tth From b198d66ae05bce8d6e01a5223e625bc58fafc0fb Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Thu, 26 Dec 2024 15:33:56 -0500 Subject: [PATCH 16/16] Remove extra mention of yarray --- src/diffpy/utils/diffraction_objects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/utils/diffraction_objects.py b/src/diffpy/utils/diffraction_objects.py index 83d7f1cf..6118f46d 100644 --- a/src/diffpy/utils/diffraction_objects.py +++ b/src/diffpy/utils/diffraction_objects.py @@ -284,12 +284,12 @@ def all_arrays(self): ------- ndarray The shape (len(data), 4) 2D array with columns containing the `yarray` (intensity) - and the `xarray` values in q, tth, d, and `yarray`. + and the `xarray` values in q, tth, and d. Examples -------- To access specific arrays individually, use these slices: - + >>> my_do.all_arrays[:, 0] # yarray >>> my_do.all_arrays[:, 1] # xarray in q >>> my_do.all_arrays[:, 2] # xarray in tth