This package is a simple implementation of linear regression between two variables: housing price against house area. The package contains the implementation of the algorithm and the unit tests for the algorithm. It is intended to be used as a guide for those who are developing a project in python.
First, clone the repository:
git clone ...
Second, create the environment:
cd Python_Package_Project
make env
Third, activate the environment:
source vLocalEnv/bin/activate
Fourth, install the package:
cd ..
pip install -e Python_Package_Project
where Python_Package_Project
is the name of the directory where the package is located and it is installed in development mode (flag -e
). For more information about the installation, please visit: https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/
The package was developed using Python 3.9.16
and make
. The following packages are required to run the code:
- jupyter
- matplotlib
- numpy
- scipy
For more information about the requirements, please visit the requirements.txt
file.
For the development, the following packages were used:
- pytest
- pytest-mpl
- pytest-mock
- autopep8
For more information about the development requirements, please visit the requirements-dev.txt
file.
This package use autoPEP8 to format the code. For more information about autoPEP8, please visit: https://peps.python.org/pep-0008/
The following commands are available for the development:
make env
: Create a virtual environment, if not exist, and install the requirements. The environment is created in thevLocalEnv
directory in the root of the project.make dev-env
: Create venv directory if not exist with dev requirements. The environment is created in thevLocalEnv
directory in the root of the project.make test
: Run tests quickly with the Python in the virtual environmentvLocalEnv
.make clean
: Remove all build, test, coverage and Python artifactsmake test-image
: Run tests quickly with the Python in the virtual environmentvLocalEnv
and generate the images for the unit tests.make dist
: Builds source package with sdist. For more information about sdist, please visit: https://packaging.python.org/guides/distributing-packages-using-setuptools/#source-distributions
To generate the images base-line for the unit tests, run the following command:
pytest -k "TestGetPlotForBestFitLine" --mpl-generate-path tests/visualization/baseline
This image will be saved in the tests/visualization/baseline
directory. To run the unit tests and compare the generated images with the base-line images, run the following command:
pytest -k "TestGetPlotForBestFitLine" --mpl
To run the unit tests without make, run the following command:
pytest --mpl
To generate the badges travis and codecov, please visit: https://docs.travis-ci.com/user/status-images/ and https://docs.codecov.io/docs/quick-start
- If some tests are added and they have the same name but in different files, is necessary to make subpackages of the tests. For more information, please visit: https://docs.pytest.org/en/6.2.x/goodpractices.html#tests-outside-application-code