Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #49 from nschloe/p3.10
Browse files Browse the repository at this point in the history
support python 3.10
  • Loading branch information
nschloe authored Oct 21, 2021
2 parents 383a182 + 5c78b87 commit fa94fcc
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

<img src="https://nschloe.github.io/dufte/data-ink.webp" width="50%"/>
<img src="https://nschloe.github.io/dufte/data-ink.webp" width="50%"/>

* [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)
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = dufte
version = 0.2.27
version = 0.2.28
author = Nico Schlömer
author_email = [email protected]
description = Clean matplotlib plots
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/dufte/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/dufte/optimize.py
Original file line number Diff line number Diff line change
@@ -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
# <https://en.wikipedia.org/wiki/Non-negative_least_squares>
A = numpy.asarray(A)
Expand Down

0 comments on commit fa94fcc

Please sign in to comment.