"on":
push: {}
+permissions:
+ contents: read
+
jobs:
python:
runs-on: ubuntu-18.04
"on":
push: {}
+permissions:
+ contents: read
+
jobs:
lint:
runs-on: ubuntu-latest
"on":
push: {}
+permissions:
+ contents: read
+
jobs:
test:
runs-on: [self-hosted, dev-east]
# macOS/backup files
.~*
._*
+~$*
.DS_Store
*.swp
*.sqlite
.nutra*
+
+# Temporary
+docs*
+
+
####################
## Python Ignores ##
####################
- Example recipe ``csv`` files.
- ``unittest`` compatibility, not sure this will stay.
May revert to ``pytest``.
+- Dedicated test file for calculate service.
Changed
~~~~~~~
* - Category
-
-
- * - Test / Linux
- - .. image:: https://github.com/nutratech/cli/actions/workflows/test-linux.yml/badge.svg
- :target: https://github.com/nutratech/cli/actions/workflows/test-linux.yml
+ * - Install / Linux
+ - .. image:: https://github.com/nutratech/cli/actions/workflows/install-linux.yml/badge.svg
+ :target: https://github.com/nutratech/cli/actions/workflows/install-linux.yml
:alt: Test status unknown (Linux)
-
- * - Test / Windows
- - .. image:: https://github.com/nutratech/cli/actions/workflows/test-win32.yml/badge.svg
- :target: https://github.com/nutratech/cli/actions/workflows/test-win32.yml
+ * - Install / Windows
+ - .. image:: https://github.com/nutratech/cli/actions/workflows/install-win32.yml/badge.svg
+ :target: https://github.com/nutratech/cli/actions/workflows/install-win32.yml
:alt: Test status unknown (Windows)
-
* - Other checks
# -*- coding: utf-8 -*-
+# PYTHON_ARGCOMPLETE_OK
"""
Main module which is called by scripts.
Top-level argument parsing logic; error handling.
# -*- coding: utf-8 -*-
"""
-Calculate service for one rep max, BMR, body fat.
+Calculate service for one rep max, BMR, body fat, lean body limit, etc.
Created on Tue Aug 11 20:53:14 2020
"""
import argparse
import math
-from datetime import datetime
from ntclient import Gender
one_rm = _one_rm()
def weight_max_reps(target_reps: float) -> float:
- _un_rounded_result = one_rm / (1 + (target_reps - 1) / 30)
+ _un_rounded_result = one_rm * (37 - target_reps) / 36
return round(_un_rounded_result, 1)
maxes = {n_reps: weight_max_reps(n_reps) for n_reps in common_n_reps}
"thigh": round(1.3868 * ankle + 0.1805 * height, 2),
"calf": round(0.9298 * ankle + 0.1210 * height, 2),
}
-
-
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# Misc functions
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-def _age(dob: int) -> float:
- """
- Calculate age based on birthday.
-
- @param dob: birth time in UNIX seconds
- @return: age in years
- """
- now = datetime.now().timestamp()
- years = (now - dob) / (365 * 24 * 3600)
- return years
-#!/usr/bin/env python3
-"""Python 3 reimplementation of the linux 'tree' utility"""
+"""Python 3 re-implementation of the Linux 'tree' utility"""
import os
import sys
Prints the whole tree
TODO: integrate with data sources to display more than just filenames
- TODO: filter hidden files, non-CSV files, and hide *.csv extension from files
+ TODO: hide non-CSV files, and don't show *.csv extension (just file name)
"""
n_dirs = 0
n_files = 0
dir_len = len(os.listdir(_dir)) - 1
for i, file in enumerate(sorted(os.listdir(_dir), key=str.lower)):
path = os.path.join(_dir, file)
- if file[0] == "." and not SHOW_HIDDEN:
+ if file.startswith(".") and not SHOW_HIDDEN:
continue
if os.path.isdir(path):
print(pre + strs[2 if i == dir_len else 1] + colorize(path))
)
)
return 0
-
-
-if __name__ == "__main__":
- sys.exit(main_tree())
flake8>=4.0
mypy>=0.960
pylint>=2.13
+types-colorama>=0.4.15
+types-psycopg2>=2.9.18
+types-setuptools>=57.4.0
types-tabulate>=0.8.11
yamllint>=1.27
+++ /dev/null
-#!/usr/bin/python3
-# -*- coding: utf-8 -*-
-# PYTHON_ARGCOMPLETE_OK
-"""Executable script, copied over by pip"""
-import re
-import sys
-
-from ntclient.__main__ import main
-
-if __name__ == "__main__":
- sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
- sys.exit(main())
+++ /dev/null
-#!/usr/bin/python3
-# -*- coding: utf-8 -*-
-# PYTHON_ARGCOMPLETE_OK
-"""Executable script, copied over by pip"""
-import re
-import sys
-
-from ntclient.__main__ import main
-
-if __name__ == "__main__":
- sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
- sys.exit(main())
ignore_missing_imports = True
# 3rd party packages missing types
-[mypy-argcomplete,colorama,coverage,fuzzywuzzy,psycopg2.*,setuptools]
+[mypy-argcomplete,coverage,fuzzywuzzy]
ignore_missing_imports = True
@author: shane
"""
-
-import glob
import os
import platform
optional_reqs = file.read().split()
REQUIREMENTS.extend(optional_reqs)
-# Prepare setup() inputs (OS dependent)
-kwargs = {
- "name": __title__,
- "author": __author__,
- "author_email": __email__,
- "classifiers": CLASSIFIERS,
- "install_requires": REQUIREMENTS,
- "python_requires": ">=%s" % PY_MIN_STR,
- "zip_safe": False,
- "packages": find_packages(exclude=["tests", "ntclient.docs"]),
- "include_package_data": True,
- "platforms": ["linux", "darwin", "win32"],
- "description": "Home and office nutrient tracking software",
- "long_description": README,
- "long_description_content_type": "text/x-rst",
- "url": "https://github.com/nutratech/cli",
- "license": "GPL v3",
- "version": __version__,
-}
-
-if PLATFORM_SYSTEM == "Windows":
- kwargs["entry_points"] = {
- "console_scripts": ["nutra=ntclient.__main__:main", "n=ntclient.__main__:main"]
- }
-else:
- kwargs["scripts"] = glob.glob("scripts/*")
-
# Setup method
-setup(**kwargs)
+setup(
+ name=__title__,
+ author=__author__,
+ author_email=__email__,
+ classifiers=CLASSIFIERS,
+ install_requires=REQUIREMENTS,
+ python_requires=">=%s" % PY_MIN_STR,
+ zip_safe=False,
+ packages=find_packages(exclude=["tests", "ntclient.docs"]),
+ include_package_data=True,
+ entry_points={
+ "console_scripts": ["nutra=ntclient.__main__:main", "n=ntclient.__main__:main"]
+ },
+ platforms=["linux", "darwin", "win32"],
+ description="Home and office nutrient tracking software",
+ long_description=README,
+ long_description_content_type="text/x-rst",
+ url="https://github.com/nutratech/cli",
+ license="GPL v3",
+ version=__version__,
+)
--- /dev/null
+# -*- coding: utf-8 -*-
+"""
+Created on Mon Aug 8 12:13:01 2022
+
+@author: shane
+
+Tests the "calculate service" for any anomalies.
+"""
+import pytest
+
+import ntclient.services.calculate as calc
+
+
+@pytest.mark.parametrize("_eq", ["epley", "brzycki", "dos_remedios"])
+@pytest.mark.parametrize(
+ "weight,reps",
+ [
+ (50.0, 1),
+ (50.0, 2),
+ (50.0, 3),
+ (50.0, 5),
+ (50.0, 6),
+ (50.0, 8),
+ (50.0, 10),
+ (50.0, 12),
+ (50.0, 15),
+ (50.0, 20),
+ ],
+)
+def test_000_orm_same_in_same_out(_eq: str, weight: float, reps: int) -> None:
+ """Test one rep max: Epley"""
+ if _eq == "epley":
+ result = calc.orm_epley(weight, reps)
+
+ elif _eq == "brzycki":
+ result = calc.orm_brzycki(weight, reps)
+
+ else: # _eq == "dos_remedios"
+ result = calc.orm_dos_remedios(weight, reps)
+
+ try:
+ # Check results
+ assert result[reps] == weight
+ except KeyError:
+ # dose Remedios does not work for 20 reps currently
+ assert _eq == "dos_remedios"
+ assert reps == 20