Package: body-mass-index
Body Mass Index (BMI) - UtilitiesPython module that provides utilities related to the Body Mass Index (BMI). Also provides a Command Line Interface (CLI).Table of contentsModule usageInstall & ImportAvailable functionsStandalone usageRun the CLIAvailable CLI commandsSource code usageBuildTestRunContributeModule usageThis library can be used from Python code, imported as a Python module.Install & ImportInstall it with pip:pip install body-mass-indexAlthough you might consider usingpipenv, which creates a Pipfile to keep track of your dependencies.
In that case, the install command would be:pipenv install body-mass-indexThen, import this module in your code:from bmi import BmiNote that theBmiclass contains all the utilities of this moduleNow, use it.E.g.Bmi.calculate_bmi(80, 1.80)Available functionsTwo static methods:calculate_bmi: Calculates BMI, provided weight (kg) and height (m)calculate_weight: Calculates weight (kg), provided height (m) and BMISeveral 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 SpanishStandalone usageThis library can also be used as a CLI utility. And it can be run both with Python or with Docker.Run the CLIInstall it with pip.Then, you can run the CLI utility in two different ways.As a Python modulepython3 -m bmi  [command] [params]As a Docker containerdocker run -it romenrg/bmi:0.0.1 [command] [params]Notes:If no command is provided, help will be displayedExample providing command with parametersdocker run -it romenrg/bmi:0.0.1 calculate 80 1.80Available CLI commandscalculate_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 usageYou 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.BuildPython, as an interpreted language, doesn't have to be built, but the Docker image does.Create a Docker image from sourcesdocker build --tag=romenrg/bmi:0.0.1 .TestExisting unit tests can be run in two different ways.As a Python modulepython3 -m unittestAs a Docker containerdocker run -it --entrypoint python3 romenrg/bmi:0.0.1 -m unittestRunYou can run the CLI from the source code in the same way you can when you installed it. See theRun the CLIsection.ContributeAny contributions (i.e. PRs or issues) are welcome. Please feel free to propose changes followingthe contributing guideline.