From f1f484d7cac13f77c28b5085c678f2e7d26558b4 Mon Sep 17 00:00:00 2001 From: Torben <59419684+entorb@users.noreply.github.com> Date: Sun, 28 Jan 2024 21:31:18 +0100 Subject: [PATCH] Add CSpell and fix findings --- .pre-commit-config.yaml | 34 +++++++++++++++------------------- 2analyze_v2.py | 28 ++++++++++++++-------------- cspell-words.txt | 28 ++++++++++++++++++++++++++++ cspell.config.yaml | 18 ++++++++++++++++++ token-example.txt | 2 +- 5 files changed, 76 insertions(+), 34 deletions(-) create mode 100644 cspell-words.txt create mode 100644 cspell.config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 54f69aa..15eae4b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ # update hooks to latest version # pre-commit autoupdate -# ruff replaces flake8 +# ruff replaces flake8, pyupgrade, and autoflake # ruff-format replaces black, isort, add-trailing-comma exclude: | @@ -68,12 +68,6 @@ repos: args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.38.0 - hooks: - - id: markdownlint - args: ["--disable", "MD013"] - - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: @@ -89,23 +83,25 @@ repos: - id: rst-inline-touching-normal - id: text-unicode-replacement-char - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 - hooks: - - id: pyupgrade - args: ["--py310-plus"] - - # only for projects where type hints have been added + # # mypy: only for projects where type hints have been added # - repo: https://github.com/pre-commit/mirrors-mypy - # rev: v0.991 + # rev: v1.8.0 # hooks: # - id: mypy - # - repo: https://github.com/codespell-project/codespell - # rev: "v2.2.2" - # hooks: - # - id: codespell + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.38.0 + hooks: + - id: markdownlint + args: ["--disable", "MD013"] + + # # code spell check via cspell + - repo: https://github.com/streetsidesoftware/cspell-cli + rev: v8.3.0 + hooks: + - id: cspell + # # Perl # - repo: https://github.com/henryykt/pre-commit-perl # rev: v0.0.5 # hooks: diff --git a/2analyze_v2.py b/2analyze_v2.py index c8e8832..04ce8e7 100755 --- a/2analyze_v2.py +++ b/2analyze_v2.py @@ -63,10 +63,10 @@ def prep_data_sleep() -> pd.DataFrame: # converting "bedtime_start": "2021-12-30T23:38:05+01:00" # to datetime without timezone (=localtime) for col in ("bedtime_end", "bedtime_start"): - # # V1: proper aproach using tz_convert(None) + # # V1: proper approach using tz_convert(None) # df[col] = pd.to_datetime(df[col], format="%Y-%m-%dT%H:%M:%S%z") # df[col] = df[col].dt.tz_convert(None) - # throws: AttributeError: Can only use .dt accessor with datetimelike values. + # throws: AttributeError: Can only use .dt accessor with datetime-like values. # Did you mean: 'at'? # V2: simple removing the timezone offset @@ -89,7 +89,7 @@ def prep_data_sleep() -> pd.DataFrame: lineterminator="\n", ) - # Adding/calcing some data fields + # Adding/calculating some data fields df["REM sleep %"] = df["rem_sleep_duration"] / df["total_sleep_duration"] * 100 df["deep sleep %"] = df["deep_sleep_duration"] / df["total_sleep_duration"] * 100 @@ -139,7 +139,7 @@ def prep_data_sleep() -> pd.DataFrame: return df -def corrlation_tester( +def correlation_tester( df: pd.DataFrame, was: str, interesting_properties: str ) -> tuple[dict, list, list]: """ @@ -182,7 +182,7 @@ def corrlation_tester( return d_results, l_corr_pos, l_corr_neg -def plotit( +def plot_it( df: pd.DataFrame, was: str, d_results: dict, l_corr_pos: list, l_corr_neg: list ) -> None: """ @@ -257,7 +257,7 @@ def plotit( # axis="x", bottom=False, top=True, labelbottom=False, labeltop=True # ) axes[i - 1].set_xlabel("") - fig.set_tight_layout(True) + fig.set_tight_layout(True) # type: ignore fig.savefig(fname=f"plot/sleep-{was}-{pos_neg}.png", format="png") plt.close() @@ -320,16 +320,16 @@ def plotit( ) -# 1. analize influece of start of sleep +# 1. analize influence of start of sleep was = "start of sleep" -d_results, l_corr_pos, l_corr_neg = corrlation_tester( +d_results, l_corr_pos, l_corr_neg = correlation_tester( df=df, was=was, - interesting_properties=interesting_properties, + interesting_properties=interesting_properties, # type: ignore ) -plotit(df, was, d_results, l_corr_pos, l_corr_neg) +plot_it(df, was, d_results, l_corr_pos, l_corr_neg) # my results: @@ -341,17 +341,17 @@ def plotit( # print("\n") -# 2. analize influece of sleep duration +# 2. analize influence of sleep duration was = "duration of sleep" -d_results, l_corr_pos, l_corr_neg = corrlation_tester( +d_results, l_corr_pos, l_corr_neg = correlation_tester( df=df, was=was, - interesting_properties=interesting_properties, + interesting_properties=interesting_properties, # type: ignore ) -plotit(df, was, d_results, l_corr_pos, l_corr_neg) +plot_it(df, was, d_results, l_corr_pos, l_corr_neg) fh_report.close() diff --git a/cspell-words.txt b/cspell-words.txt new file mode 100644 index 0000000..1805cdd --- /dev/null +++ b/cspell-words.txt @@ -0,0 +1,28 @@ +# CSpell Custom Dictionary Words +analize +autoflake +autoupdate +dayofweek +figsize +hypnogram +isort +labelbottom +labeltop +linewidth +Menke +mrssd +mtick +ncols +noqa +nrows +numplots +Oura +pyupgrade +sharex +suptitle +Torben +viridis +xlabel +yaxis +ylabel +zorder diff --git a/cspell.config.yaml b/cspell.config.yaml new file mode 100644 index 0000000..2bd4d5e --- /dev/null +++ b/cspell.config.yaml @@ -0,0 +1,18 @@ +--- +$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json +version: "0.2" +useGitignore: true +language: en-US +dictionaryDefinitions: + - name: cspell-words + path: "./cspell-words.txt" + addWords: true +dictionaries: + - cspell-words +ignorePaths: + - ".*" + - "dist" + - "build" + - "node_modules" + - "requirements.txt" + - "api-v1" diff --git a/token-example.txt b/token-example.txt index 6946d33..6d51945 100644 --- a/token-example.txt +++ b/token-example.txt @@ -1 +1 @@ -ABABABABABABABABABABABABABABABBA +A234BABABABABABABABABABABABABABA