From 7112fac0c7804badf4ad41733cabec0960f063ff Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Tue, 5 Nov 2024 16:31:25 -0500 Subject: [PATCH 1/6] Add warning to missing global config file --- news/get-user-fix.rst | 23 +++++++++++++++++++++++ src/diffpy/utils/tools.py | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 news/get-user-fix.rst diff --git a/news/get-user-fix.rst b/news/get-user-fix.rst new file mode 100644 index 00000000..5b2fd3df --- /dev/null +++ b/news/get-user-fix.rst @@ -0,0 +1,23 @@ +**Added:** + +* Warning message for missing global config file + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index 1dfb8284..dc908a27 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -3,6 +3,7 @@ import os from copy import copy from pathlib import Path +import warnings def clean_dict(obj): @@ -114,6 +115,7 @@ def get_user_info(args=None): 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: + warnings.warn("No global config file, please follow prompts below. For more information, refer to www.diffpy.org/diffpy.utils/") config_bool = _create_global_config(args) global_config = load_config(Path().home() / "diffpyconfig.json") config = _sorted_merge(clean_dict(global_config), clean_dict(local_config), clean_dict(args)) From d24acb6305e6c9247618fc20b9633162b1096e79 Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Tue, 5 Nov 2024 16:39:23 -0500 Subject: [PATCH 2/6] fix line too long --- src/diffpy/utils/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index dc908a27..7574d093 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -115,7 +115,7 @@ def get_user_info(args=None): 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: - warnings.warn("No global config file, please follow prompts below. For more information, refer to www.diffpy.org/diffpy.utils/") + warnings.warn("No global config file, please follow prompts below.") config_bool = _create_global_config(args) global_config = load_config(Path().home() / "diffpyconfig.json") config = _sorted_merge(clean_dict(global_config), clean_dict(local_config), clean_dict(args)) From 0a59a0be30f1b5acb811dca376d88c18de97ae82 Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Tue, 5 Nov 2024 17:03:12 -0500 Subject: [PATCH 3/6] better wording for capture user info --- news/capture-user.rst | 23 +++++++++++++++++++++++ src/diffpy/utils/tools.py | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 news/capture-user.rst diff --git a/news/capture-user.rst b/news/capture-user.rst new file mode 100644 index 00000000..b789d46e --- /dev/null +++ b/news/capture-user.rst @@ -0,0 +1,23 @@ +**Added:** + +* Better wording on the capture user info functionality + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index 7574d093..aab4a64f 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -115,7 +115,9 @@ def get_user_info(args=None): 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: - warnings.warn("No global config file, please follow prompts below.") + warnings.warn("No global config file, please follow prompts below. " + "The global config file is very important in crediting your work in the future. " + "For more information, please refer to www.diffpy.org/diffpy.utils/examples/toolsexample.html") config_bool = _create_global_config(args) global_config = load_config(Path().home() / "diffpyconfig.json") config = _sorted_merge(clean_dict(global_config), clean_dict(local_config), clean_dict(args)) From 2379a62ca863778361395c8779ff16a190b055fd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 22:05:56 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit hooks --- src/diffpy/utils/tools.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index aab4a64f..2f165f87 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -1,9 +1,9 @@ import importlib.metadata import json import os +import warnings from copy import copy from pathlib import Path -import warnings def clean_dict(obj): @@ -115,9 +115,11 @@ def get_user_info(args=None): 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: - warnings.warn("No global config file, please follow prompts below. " - "The global config file is very important in crediting your work in the future. " - "For more information, please refer to www.diffpy.org/diffpy.utils/examples/toolsexample.html") + warnings.warn( + "No global config file, please follow prompts below. " + "The global config file is very important in crediting your work in the future. " + "For more information, please refer to www.diffpy.org/diffpy.utils/examples/toolsexample.html" + ) config_bool = _create_global_config(args) global_config = load_config(Path().home() / "diffpyconfig.json") config = _sorted_merge(clean_dict(global_config), clean_dict(local_config), clean_dict(args)) From af5a1e81c89981d85887212b851ddbb599679731 Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Tue, 5 Nov 2024 17:22:03 -0500 Subject: [PATCH 5/6] configure codespell at pyproject.toml and pre-commit --- .codespell/ignore_lines.txt | 2 ++ .codespell/ignore_words.txt | 11 +++++++++++ .pre-commit-config.yaml | 6 ++++++ news/codespell.rst | 23 +++++++++++++++++++++++ pyproject.toml | 5 +++++ 5 files changed, 47 insertions(+) create mode 100644 .codespell/ignore_lines.txt create mode 100644 .codespell/ignore_words.txt create mode 100644 news/codespell.rst diff --git a/.codespell/ignore_lines.txt b/.codespell/ignore_lines.txt new file mode 100644 index 00000000..07fa7c8c --- /dev/null +++ b/.codespell/ignore_lines.txt @@ -0,0 +1,2 @@ +;; Please include filenames and explanations for each ignored line. +;; See https://docs.openverse.org/meta/codespell.html for docs. diff --git a/.codespell/ignore_words.txt b/.codespell/ignore_words.txt new file mode 100644 index 00000000..9757d7c0 --- /dev/null +++ b/.codespell/ignore_words.txt @@ -0,0 +1,11 @@ +;; Please include explanations for each ignored word (lowercase). +;; See https://docs.openverse.org/meta/codespell.html for docs. + +;; abbreviation for "materials" often used in a journal title +mater + +;; alternative use of socioeconomic +socio-economic + +;; Frobenius norm used in np.linalg.norm +fro diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3070e199..9cf0556f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,3 +44,9 @@ repos: name: Prevent Commit to Main Branch args: ["--branch", "main"] stages: [pre-commit] + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + additional_dependencies: + - tomli diff --git a/news/codespell.rst b/news/codespell.rst new file mode 100644 index 00000000..8c5ba6d2 --- /dev/null +++ b/news/codespell.rst @@ -0,0 +1,23 @@ +**Added:** + +* Spelling check via Codespell in pre-commit + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index 41fe385a..dedb713b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,11 @@ namespaces = false # to disable scanning PEP 420 namespaces (true by default) [tool.setuptools.dynamic] dependencies = {file = ["requirements/pip.txt"]} +[tool.codespell] +exclude-file = ".codespell/ignore_lines.txt" +ignore-words = ".codespell/ignore_words.txt" +skip = "*.cif,*.dat" + [tool.black] line-length = 115 include = '\.pyi?$' From f75e09d3558072fa0b31774a6cb7c8289fd206c3 Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Tue, 5 Nov 2024 17:29:55 -0500 Subject: [PATCH 6/6] fixed typos given by codespell --- CHANGELOG.rst | 2 +- README.rst | 2 +- src/diffpy/utils/parsers/loaddata.py | 2 +- src/diffpy/utils/parsers/resample.py | 2 +- src/diffpy/utils/parsers/serialization.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b57c7e79..ceed2511 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -90,7 +90,7 @@ v3.2.3 **Added:** -* Compatability with Python 3.12.0rc3, 3.11. +* Compatibility with Python 3.12.0rc3, 3.11. * CI Coverage. * New tests for loadData function. * loadData function now toggleable. Can return either (a) data read from data blocks or (b) header information stored diff --git a/README.rst b/README.rst index 98e34649..48967571 100644 --- a/README.rst +++ b/README.rst @@ -134,7 +134,7 @@ trying to commit again. Improvements and fixes are always appreciated. -Before contribuing, please read our `Code of Conduct `_. +Before contributing, please read our `Code of Conduct `_. Contact ------- diff --git a/src/diffpy/utils/parsers/loaddata.py b/src/diffpy/utils/parsers/loaddata.py index 4bb0d792..18375d90 100644 --- a/src/diffpy/utils/parsers/loaddata.py +++ b/src/diffpy/utils/parsers/loaddata.py @@ -30,7 +30,7 @@ def loadData(filename, minrows=10, headers=False, hdel="=", hignore=None, **kwar Minimum number of rows in the first data block. All rows must have the same number of floating point values. headers: bool - when False (defualt), the function returns a numpy array of the data in the data block. + when False (default), the function returns a numpy array of the data in the data block. When True, the function instead returns a dictionary of parameters and their corresponding values parsed from header (information prior the data block). See hdel and hignore for options to help with parsing header information. diff --git a/src/diffpy/utils/parsers/resample.py b/src/diffpy/utils/parsers/resample.py index f81fc2a2..e88c4f0b 100644 --- a/src/diffpy/utils/parsers/resample.py +++ b/src/diffpy/utils/parsers/resample.py @@ -113,7 +113,7 @@ def resample(r, s, dr): # spad = numpy.concatenate([s,spad]) # rnew = numpy.arange(0, rpad[-1], dr) # snew = numpy.zeros_like(rnew) - # Accomodate for the fact that r[0] might not be 0 + # Accommodate for the fact that r[0] might not be 0 # u = (rnew-r[0]) / dr0 # for n in range(len(spad)): # snew += spad[n] * numpy.sinc(u - n) diff --git a/src/diffpy/utils/parsers/serialization.py b/src/diffpy/utils/parsers/serialization.py index a0bec92c..46d4b8ff 100644 --- a/src/diffpy/utils/parsers/serialization.py +++ b/src/diffpy/utils/parsers/serialization.py @@ -56,7 +56,7 @@ def serialize_data( include a path element in the database entry (default True). If 'path' is not included in hddata, extract path from filename. serial_file - Serial language file to dump dictionary into. If None (defualt), no dumping will occur. + Serial language file to dump dictionary into. If None (default), no dumping will occur. Returns -------