Utilities related to the Body Mass Index (BMI): Calculating it, calculating healthy weight, ranges, boundaries,...
Project description
Body Mass Index (BMI) - Utilities
Python module that provides utilities related to the Body Mass Index (BMI). Also provides a Command Line Interface (CLI).
Table of contents
Module usage
This library can be used from Python code, imported as a Python module.
Install & Import
- Install it with pip:
pip install body-mass-index
- Although you might consider using
pipenv
, which creates a Pipfile to keep track of your dependencies. In that case, the install command would be:pipenv install body-mass-index
- Then, import this module in your code:
from bmi import Bmi
- Note that the
Bmi
class contains all the utilities of this module
- Now, use it.
- E.g.
Bmi.calculate_bmi(80, 1.80)
- E.g.
Available functions
- Two static methods:
calculate_bmi
: Calculates BMI, provided weight (kg) and height (m)calculate_weight
: Calculates weight (kg), provided height (m) and BMI
- Several class methods:
calculate_bmi_with_info
: Calculate BMI with range info, provided weight (kg), height (m) and languageget_bmi_range_info
: Return range info, provided BMI and languageget_bmi_ranges_info
: Return info of all rangescalculate_weight_boundaries
: Calculate weight boundaries (kg), based on BMI; provided height (m)calculate_weight_ranges_with_info
: Calculate weight ranges (kg), based on BMI ranges; provided height (m) and languagecalculate_healthy_weight
: Calculate healthy weight range (kg), provided height (m)
- Module provides class attributes:
boundaries
: List with the boundaries for BMI ranges, as defined by the WHOranges_i18n
: Text defining each BMI range, as per the WHO, in English and Spanish
Standalone usage
This library can also be used as a CLI utility. And it can be run both with Python or with Docker.
Run the CLI
Install it with pip.
Then, you can run the CLI utility in two different ways.
As a Python module
python3 -m bmi [command] [params]
As a Docker container
docker run -it romenrg/bmi:0.0.1 [command] [params]
Notes:
- If no command is provided, help will be displayed
- Example providing command with parameters
docker run -it romenrg/bmi:0.0.1 calculate 80 1.80
Available CLI commands
calculate_bmi
: Calculate BMI, provided weight (kg) and height (m) [info]get_bmi_range_info
: Return range info, provided BMI and languageget_bmi_ranges_info
: Return info of all BMI rangescalculate_weight
: Calculate weight (kg), provided height (m) and BMIcalculate_weight_ranges_info
: Calculate weight ranges (kg), based on BMI ranges; provided height (m)calculate_healthy_weight
: Calculate healthy weight range (kg), provided height (m)
Source code usage
You can also clone the repository in order to build a Docker image, run tests, execute the module locally and/or contribute to keep improving this module.
Build
Python, as an interpreted language, doesn't have to be built, but the Docker image does.
Create a Docker image from sources
docker build --tag=romenrg/bmi:0.0.1 .
Test
Existing unit tests can be run in two different ways.
As a Python module
python3 -m unittest
As a Docker container
docker run -it --entrypoint python3 romenrg/bmi:0.0.1 -m unittest
Run
You can run the CLI from the source code in the same way you can when you installed it. See the Run the CLI section.
Contribute
Any contributions (i.e. PRs or issues) are welcome. Please feel free to propose changes following the contributing guideline.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file body-mass-index-1.0.1.tar.gz
.
File metadata
- Download URL: body-mass-index-1.0.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba05376d15fe9feaec5da34e3ea21cd8a28e88ce9d5e51bd824535ace820e98a |
|
MD5 | 4ee76ac38df4e8b29e505b315c00d1b6 |
|
BLAKE2b-256 | 9de1cc7d673174e8427a00ac42177381c637e82f8ed03c841cd142d20a0cd065 |
File details
Details for the file body_mass_index-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: body_mass_index-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15ef4b494e0b0536eace40f36b6b0307204e0eea071656d52bd0f75be0d7bf28 |
|
MD5 | f08bcac2e447e53ae3f7ba180d39ed23 |
|
BLAKE2b-256 | 6a55c1b6f7a7b9421a972f1ae14b34522456c091d3e2b92c6cae08321d8d3668 |