Skip to content

Commit

Permalink
Ruff new color (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
wckdouglas authored Sep 17, 2023
1 parent 1e97fba commit 914aeaa
Show file tree
Hide file tree
Showing 6 changed files with 682 additions and 86 deletions.
18 changes: 12 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
repos:
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 22.3.0
hooks:
- id: black
args: ["-l", "120"]
language_version: python3
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.290
hooks:
- id: ruff
args: ["--fix"]
718 changes: 648 additions & 70 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ numpy = "^1.21.1"
pytest = "^6.2.5"
pytest-cov = "^2.12.1"
mypy = "^0.910"
black = "22.3.0"
ruff = "^0.0.290"

[tool.poetry-dynamic-versioning]
enable = true
Expand All @@ -33,7 +35,7 @@ requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
build-backend = "poetry_dynamic_versioning.backend"

[tool.poetry.extras]
dev = ["pytest", "pytest-cov", "mypy"]
dev = ["pytest", "pytest-cov", "mypy", "ruff", "black"]

[tool.mypy]
plugins = "numpy.typing.mypy_plugin"
Expand All @@ -45,3 +47,7 @@ module = [
]
ignore_missing_imports = true

[tool.ruff]
line-length = 120
select = ['E', 'F', 'W', 'I']

2 changes: 1 addition & 1 deletion ridgeplot/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from ridgeplot.ridge_plot import RidgePlotError, ridgeplot
from ridgeplot.ridge_plot import RidgePlotError, ridgeplot # noqa: F401
11 changes: 7 additions & 4 deletions ridgeplot/colors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""This module collects functions for manipulating color legends
for matplotlib plots and a collections of color palettes.
for matplotlib plots and a collections of color palettes.
"""

from collections import OrderedDict
Expand Down Expand Up @@ -84,21 +84,23 @@
"#686b69",
"#417d55",
],
purples=["#9c6cf8", "#9c14e7", "#460ecf", "#54186f", "#f75af8"],
)


def ordered_set(xs: List[str]) -> List[str]:
"""
this is a simple function to make a set according to the order of the input list
because python set is unordered, https://stackoverflow.com/questions/9792664/converting-a-list-to-a-set-changes-element-order
because python set is unordered, see:
https://stackoverflow.com/questions/9792664/converting-a-list-to-a-set-changes-element-order
Args:
xs: list of input values
Returns:
a list of unique input values in the order of how they arranged in the input list
"""
""" # noqa: E501
xs = list(xs)
return sorted(set(xs), key=xs.index)

Expand Down Expand Up @@ -215,7 +217,8 @@ def transform(self, categories: List[str]) -> List[str]:

def fit_transform(self, categories: List[str], colors: List[str] = ColorPalette["invitae"]) -> List[str]:
"""
first map the color to the categories, and then return the corresponding color for each category in the input list
first map the color to the categories, and then return the
corresponding color for each category in the input list
Example:
```
Expand Down
11 changes: 7 additions & 4 deletions ridgeplot/ridge_plot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module contains the main function to plot
"""This module contains the main function to plot
[ridgeplots](https://clauswilke.com/blog/2017/09/15/goodbye-joyplots/).
"""
from __future__ import annotations
Expand Down Expand Up @@ -45,10 +45,13 @@ def ridgeplot(
Args:
ax: a matplotlib ax object for writing the plot
data: a dictionary of data, key is the label of the group, values are the data values in the group
data: a dictionary of data, key is the label of
the group, values are the data values in the group
xlim: x-limits for the plot (xmin, xmax)
fill_colors: colors for the fill under the distribution, must be same length as input data (default: all steelblue)
line_colors: colors for the line drawing the distribution, must be same length as input data (default: all white)
fill_colors: colors for the fill under the distribution,
must be same length as input data (default: all steelblue)
line_colors: colors for the line drawing the distribution,
must be same length as input data (default: all white)
label_size: label size of the name of each distribution
fill_alpha: alpha value for the fill under the distribution (default: 0.5)
Expand Down

0 comments on commit 914aeaa

Please sign in to comment.