diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..bc4d80d --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +[flake8] +ignore = E203, E266, E501, W503, C901, E741 +max-line-length = 88 +max-complexity = 18 +select = B,C,E,F,W,T4,B9 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cda10ba..12ea453 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,15 +23,15 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] steps: - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - uses: actions/checkout@v2 - - name: Test with tox - run: | - pip install tox - tox -- --cov dufte --cov-report xml --cov-report term - - uses: codecov/codecov-action@v1 - if: ${{ matrix.python-version == '3.9' }} + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/checkout@v2 + - name: Test with tox + run: | + pip install tox + tox -- --cov dufte --cov-report xml --cov-report term + - uses: codecov/codecov-action@v1 + if: ${{ matrix.python-version == '3.9' }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d159047..8fb20e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,16 +1,16 @@ repos: - repo: https://github.com/PyCQA/isort - rev: 5.9.1 + rev: 5.9.3 hooks: - id: isort - - repo: https://github.com/python/black - rev: 21.6b0 + - repo: https://github.com/psf/black + rev: 21.9b0 hooks: - id: black language_version: python3 - - repo: https://github.com/PyCQA/pylint - rev: v2.9.5 + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 hooks: - - id: pylint + - id: flake8 diff --git a/README.md b/README.md index 44aa4e8..51b691f 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ This package creates clean and beautiful plots that work on light and dark backg Inspired by the work of [Edward Tufte](https://en.wikipedia.org/wiki/Edward_Tufte). To use, simply select the `dufte` style: + ```python import dufte import matplotlib.pyplot as plt @@ -68,40 +69,51 @@ See [here](tests/create_comparison.py) for how to create the below plots. Further reading: - * [Remove to improve: data-ink ratio](https://www.darkhorseanalytics.com/blog/data-looks-better-naked) +- [Remove to improve: data-ink ratio](https://www.darkhorseanalytics.com/blog/data-looks-better-naked) - + - * [Remove to improve: Line Graph Edition](https://youtu.be/bDbJBWvonVI) - * [Show the Data - Maximize the Data Ink Ratio](https://youtu.be/pCp0a5_YIWE) - * [Randal S. Olson's blog entry](http://www.randalolson.com/2014/06/28/how-to-make-beautiful-data-visualizations-in-python-with-matplotlib/) - * [prettyplotlib](https://github.com/olgabot/prettyplotlib) - * [Wikipedia: Chartjunk](https://en.wikipedia.org/wiki/Chartjunk) +- [Remove to improve: Line Graph Edition](https://youtu.be/bDbJBWvonVI) +- [Show the Data - Maximize the Data Ink Ratio](https://youtu.be/pCp0a5_YIWE) +- [Randal S. Olson's blog entry](http://www.randalolson.com/2014/06/28/how-to-make-beautiful-data-visualizations-in-python-with-matplotlib/) +- [prettyplotlib](https://github.com/olgabot/prettyplotlib) +- [Wikipedia: Chartjunk](https://en.wikipedia.org/wiki/Chartjunk) Projects using dufte: - * [perfplot](https://github.com/nschloe/perfplot) - * [stargraph](https://github.com/nschloe/stargraph) - +- [perfplot](https://github.com/nschloe/perfplot) +- [stargraph](https://github.com/nschloe/stargraph) ### Background + [![xdoc](https://img.shields.io/badge/Rendered%20with-xdoc-f2eecb?style=flat-square)](https://chrome.google.com/webstore/detail/xdoc/anidddebgkllnnnnjfkmjcaallemhjee) The position $`x_i`$ of the line annotations is computed as the solution of a non-negative least-squares problem + ```math \begin{align} \frac{1}{2}\sum_i (x_i - t_i)^2 \to \min_x,\\ (x_i - x_j)^2 \ge a^2 \quad \forall i,j. \end{align} ``` + where $`a`$ is the minimum distance between two entries and $`t_i`$ is the target position. - ### Testing To run the dufte unit tests, check out this repository and type + ``` pytest ``` + +### Other style sheets and further reading + +- [John Garrett, _Science Plots_](https://github.com/garrettj403/SciencePlots) +- [Dominik Haitz, _Cyberpunk style_](https://github.com/dhaitz/mplcyberpunk) +- [Dominik Haitz, _Matplotlib stylesheets_](https://github.com/dhaitz/matplotlib-stylesheets) +- [Carlos da Costa, _The Grand Budapest Hotel_](https://github.com/cako/mpl_grandbudapest) +- [Danny Antaki, _vaporwave aesthetics_](https://github.com/dantaki/vapeplot) +- [QuantumBlack Labs, _QuantumBlack_](https://github.com/quantumblacklabs/qbstyles) diff --git a/setup.cfg b/setup.cfg index 3701e20..7a40c7c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = dufte -version = 0.2.27 +version = 0.2.28 author = Nico Schlömer author_email = nico.schloemer@gmail.com description = Clean matplotlib plots @@ -23,6 +23,7 @@ classifiers = Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 Topic :: Utilities [options] diff --git a/src/dufte/main.py b/src/dufte/main.py index 664bfed..41e9c1a 100644 --- a/src/dufte/main.py +++ b/src/dufte/main.py @@ -93,7 +93,7 @@ style_bar["axes.titlesize"] = 18 -def _move_min_distance(targets, min_distance): +def _move_min_distance(targets, min_distance: float): """Move the targets such that they are close to their original positions, but keep min_distance apart. diff --git a/src/dufte/optimize.py b/src/dufte/optimize.py index d05f93e..2b7c414 100644 --- a/src/dufte/optimize.py +++ b/src/dufte/optimize.py @@ -1,7 +1,7 @@ import numpy -def nnls(A, b, eps=1.0e-10, max_steps=100): +def nnls(A, b, eps: float = 1.0e-10, max_steps: int = 100): # non-negative least-squares after # A = numpy.asarray(A)