Skip to content

Commit

Permalink
Merge pull request #28 from axelfahy/feat/plot-module
Browse files Browse the repository at this point in the history
feat/plot module
  • Loading branch information
axelfahy committed Aug 29, 2019
2 parents faaa7ea + bad16c2 commit 0358833
Show file tree
Hide file tree
Showing 37 changed files with 1,995 additions and 466 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Baseline images for tests
tests/baseline

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -70,7 +73,6 @@ instance/
doc/_build
doc/build
doc/source/generated
doc/source/_static

# PyBuilder
target/
Expand Down
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ install:
- pip install -r requirements_dev.txt
- pip install -e .
script:
- flake8 bff
- pytest --codestyle --docstyle --pylint --pylint-rcfile=.pylintrc --pylint-error-types=CWEF
- flake8
- mypy bff tests
- pytest --codestyle --docstyle
- pytest --pylint --pylint-rcfile=.pylintrc --pylint-error-types=CWEF
- pytest --cov=bff tests
after_success:
- coveralls
Expand Down
34 changes: 31 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,52 @@
# Makefile to simplify test and build.

.PHONY: test clean test-env lint style coverage

.PHONY: all
all: test

.PHONY: all
build-python:
python setup.py sdist bdist_wheel

.PHONY: build-notebook
build-notebook:
# Convert .ipynb to rst file. Needs pandoc installed.
jupyter nbconvert --to rst notebooks/notebook-bff-plot.ipynb

.PHONY: clean
clean:
rm -rf coverage_html_report .coverage
rm -rf bff.egg-info
rm -rf venv-dev
rm -rf dist/
rm -rf notebooks/notebook-bff-plot_files/

.PHONY: clean-notebooks
clean-notebooks:
# Corrections of path to images in notebook export.
sed -i 's/\.\. image:: /\.\. image:: \.\.\/\.\.\/notebooks\//g' notebooks/notebook-bff-plot.rst

.PHONY: test
test: code lint style coverage

.PHONY: baseline-plot
baseline-plot:
pytest --mpl-generate-path=tests/baseline tests

test: lint style coverage
.PHONY: code
code:
pytest --mpl tests

.PHONY: lint
lint:
pytest --pylint --pylint-rcfile=.pylintrc --pylint-error-types=CWEF

.PHONY: style
style:
flake8
mypy bff tests
pytest --codestyle --docstyle

.PHONY: coverage
coverage:
rm -rf coverage_html_report .coverage
pytest --cov=bff tests --cov-report=html:coverage_html_report
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ git clone https://github.com/axelfahy/bff.git
cd bff
python -m venv venv-dev
source venv-dev/bin/activate
pip install requirements_dev.txt
pip install -r requirements_dev.txt
pip install -e .
```

Expand All @@ -44,8 +44,17 @@ pip install -e .
make all
```

To test plots, images with baseline should be placed in `tests/baseline` and can be generated using `make build-baseline`.

As of *v0.2*, plots are not yet tested in the travis build.

## Release History

* 0.2.0
* ADD: Separation of plots in submodule ``plot``. This breaks the previous API.
* ADD: Tests for the plot module using ``pytest-mlp``.
* ADD: Images from plot in the documentation and notebook with examples.
* FIX: Correction of resampling in the ``plot_series`` function.
* 0.1.9
* ADD: Option ``loc`` in ``plot_series`` function.
* ADD: Function ``cast_to_category_pd`` to cast columns to category ``dtype`` automatically.
Expand All @@ -65,16 +74,16 @@ make all
* ADD: Add Makefile for testing code and style.
* ADD: Add python-versioneer to handle version of package.
* 0.1.3
* CHANGE: Restructuration of repo.
* ADD: Travis, flake8, coveralls and PyUp configurations.
* ADD: Function `get_peaks` to get the peaks of a time series.
* ADD: Function `plot_series` to plot a time series.
* CHANGE: Restructuration of repo.
* 0.1.2
* CHANGE: Add axes in plot functions.
* ADD: Function `plot_predictions` function to plot the actual values and the predictions of a model.
* CHANGE: Add axes in plot functions.
* 0.1.1
* CHANGE: Improvement of `plot_history` function.
* ADD: Readme with instructions.
* CHANGE: Improvement of `plot_history` function.
* FIX: Fix the imports in the test.
* 0.1.0
* Initial release.
Expand Down
24 changes: 15 additions & 9 deletions bff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@

from ._version import get_versions

# Import submodules.
from . import plot

from .fancy import (
cast_to_category_pd, concat_with_categories, get_peaks, idict,
mem_usage_pd, parse_date, plot_history, plot_predictions, plot_series,
plot_true_vs_pred, read_sql_by_chunks, sliding_window, value_2_list
cast_to_category_pd,
concat_with_categories,
get_peaks,
idict,
mem_usage_pd,
parse_date,
read_sql_by_chunks,
sliding_window,
value_2_list,
)

from .config import FancyConfig
Expand All @@ -19,19 +28,16 @@
'idict',
'mem_usage_pd',
'parse_date',
'plot_history',
'plot_predictions',
'plot_series',
'plot_true_vs_pred',
'plot',
'read_sql_by_chunks',
'sliding_window',
'value_2_list',
'FancyConfig',
]

# Logging configuration.
FORMAT = '%(asctime)-15s %(message)s'
logging.basicConfig(format=FORMAT)
FORMAT = '%(asctime)s [%(levelname)-7s] %(name)s: %(message)s'
logging.basicConfig(format=FORMAT, level=logging.INFO)

__version__ = get_versions()['version']
del get_versions
Loading

0 comments on commit 0358833

Please sign in to comment.