Skip to content

Commit

Permalink
Add CSpell and fix findings
Browse files Browse the repository at this point in the history
  • Loading branch information
entorb committed Jan 28, 2024
1 parent 14fc523 commit f1f484d
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 34 deletions.
34 changes: 15 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
28 changes: 14 additions & 14 deletions 2analyze_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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]:
"""
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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:
Expand All @@ -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()
Expand Down
28 changes: 28 additions & 0 deletions cspell-words.txt
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion token-example.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ABABABABABABABABABABABABABABABBA
A234BABABABABABABABABABABABABABA

0 comments on commit f1f484d

Please sign in to comment.