https://github.com/romenrg/body-mass-index
Python module providing utilities related to calculating the Body Mass Index (BMI). Also provides a CLI.
https://github.com/romenrg/body-mass-index
Last synced: 5 months ago
JSON representation
Python module providing utilities related to calculating the Body Mass Index (BMI). Also provides a CLI.
- Host: GitHub
- URL: https://github.com/romenrg/body-mass-index
- Owner: romenrg
- License: mit
- Created: 2020-10-22T14:58:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-07T10:06:34.000Z (about 4 years ago)
- Last Synced: 2024-11-08T09:14:28.294Z (5 months ago)
- Language: Python
- Homepage:
- Size: 87.9 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Body Mass Index (BMI) - Utilities
[](https://github.com/romenrg/body-mass-index/actions?query=workflow%3A%22CI+-+Linter+%26+tests%22)
[](https://coveralls.io/github/romenrg/body-mass-index?branch=master)
[](https://badge.fury.io/py/body-mass-index)
[](https://github.com/romenrg/body-mass-index/blob/master/LICENSE)
> Python module that provides utilities related to the Body Mass Index (BMI). Also provides a Command Line Interface (CLI).## Table of contents
- [Module usage](#module-usage)
- [Install & Import](#install--import)
- [Available functions](#available-functions)
- [Standalone usage](#standalone-usage)
- [Run the CLI](#run-the-cli)
- [Available CLI commands](#available-cli-commands)
- [Source code usage](#source-code-usage)
- [Build](#build)
- [Test](#test)
- [Run](#run)
- [Contribute](#contribute)This library can be used from Python code, imported as a Python module.
* 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)`
### 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 language
* `get_bmi_range_info`: Return range info, provided BMI and language
* `get_bmi_ranges_info`: Return info of all ranges
* `calculate_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 language
* `calculate_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 WHO
* `ranges_i18n`: Text defining each BMI range, as per the WHO, in English and Spanish
This library can also be used as a CLI utility. And it can be run both with Python or with Docker.
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`* `calculate_bmi`: Calculate BMI, provided weight (kg) and height (m) [info]
* `get_bmi_range_info`: Return range info, provided BMI and language
* `get_bmi_ranges_info`: Return info of all BMI ranges
* `calculate_weight`: Calculate weight (kg), provided height (m) and BMI
* `calculate_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)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.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 .`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`You can run the CLI from the source code in the same way you can when you installed it. See the [Run the CLI](#run-the-cli) section.
Any contributions (i.e. PRs or issues) are welcome. Please feel free to propose changes following [the contributing guideline](https://github.com/romenrg/body-mass-index/blob/master/CONTRIBUTING.md).