Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
deploy-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.x'

Expand All @@ -24,7 +24,6 @@ jobs:
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI}}
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
poetry install
poetry build
poetry publish
6 changes: 3 additions & 3 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
build-sphinx-doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.x'

Expand All @@ -24,7 +24,7 @@ jobs:

- name: Build HTML documentation
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
pip install poetry-dynamic-versioning
poetry install --with docs
poetry run sphinx-build docs ./docs/_build/html/

Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12', '3.13']
python-version: ['3.11', '3.12', '3.13']

runs-on: ${{ matrix.os }}

env:
POETRY_VIRTUALENVS_IN_PROJECT: "true"
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/poetry

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -26,6 +31,5 @@ jobs:

- name: Run ci
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
poetry install --without docs
make ci
32 changes: 11 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default_language_version:
# Built-in hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -24,44 +24,34 @@ repos:

# Pyupgrade
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
rev: v3.21.2
hooks:
- id: pyupgrade

# Conventional commit
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.0.0
rev: v4.4.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []

# Ruff
# We put this hook before Black hook, as autofix results may need to be reformatted by Black linter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.4
rev: v0.15.7
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
exclude: ^(tests|docs)/
# Black
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
# Isort
- repo: https://github.com/pycqa/isort
rev: 6.0.1
hooks:
- id: isort
exclude: ^.*/?setup\.py$
# Run the linter.
- id: ruff-check
args: [ --fix, --exit-non-zero-on-fix ]
# Run the formatter.
- id: ruff-format

# MyPy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0 # Use the sha / tag you want to point at
rev: v1.19.1 # Use the sha / tag you want to point at
hooks:
- id: mypy
args: [--ignore-missing-imports]
files: ^statsplotly/
additional_dependencies:
- "pydantic>=2.4"
- "numpy"
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PYTHON_SHELL_VERSION := $(shell python --version | cut -d " " -f 2)
POETRY_AVAILABLE := $(shell which poetry > /dev/null && echo 1 || echo 0)

# CI variables
CI_EXCLUDED_DIRS = __pycache__ dist tests docs
CI_EXCLUDED_DIRS = __pycache__ dist docs
CI_DIRECTORIES=$(filter-out $(CI_EXCLUDED_DIRS), $(foreach dir, $(dir $(wildcard */)), $(dir:/=)))

# Project targets
Expand Down Expand Up @@ -33,13 +33,21 @@ endif
# CI targets
lint-%:
@echo lint-"$*"
@poetry run black --check "$*"
@poetry run isort --check "$*"
@poetry run ruff check "$*"
@poetry run ruff format --check "$*"
@echo " ✅ All good"

lint: $(addprefix lint-, $(CI_DIRECTORIES))


fix-%:
@echo fix-"$*"
@poetry run ruff check --fix "$*"
@poetry run ruff format "$*"
@echo " ✅ All fixed"

fix: $(addprefix fix-, $(CI_DIRECTORIES)) ci

typecheck-%:
@echo typecheck-"$*"
@poetry run mypy "$*"
Expand Down Expand Up @@ -67,7 +75,7 @@ run-pre-commit:

# Documentation
update-doc:
@poetry run sphinx-apidoc --module-first --no-toc --force -o docs/source $(PROJECT_NAME)
@poetry run sphinx-apidoc --module-first --no-toc --force -o docs/source src/$(PROJECT_NAME)

build-doc:
@poetry run sphinx-build docs ./docs/_build/html/
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

[![Documentation](https://img.shields.io/website?label=docs&url=https://parici75.github.io/statsplotly)](https://parici75.github.io/statsplotly)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/statsplotly)
[![Black](https://img.shields.io/badge/Code%20style-Black-black)](https://black.readthedocs.io/en/stable/)
[![linting - Ruff](https://img.shields.io/badge/Linting-Ruff-yellow)](https://docs.astral.sh/ruff/)
[![linting - Ruff](https://img.shields.io/badge/Linting_&_Formatting-Ruff-151B54)](https://docs.astral.sh/ruff/)
[![mypy](https://img.shields.io/badge/mypy-checked-blue)](https://mypy.readthedocs.io/en/stable/index.html#)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://pre-commit.com/)
[![CI](https://github.com/Parici75/statsplotly/actions/workflows/test.yml/badge.svg)](https://github.com/Parici75/statsplotly/actions/workflows/test.yml)
Expand Down Expand Up @@ -95,7 +94,7 @@ On the Jupyter server, select the created kernel in “Kernel” -> “Change ke
The Makefile provides several targets to assist in development and code quality :

- `init` creates a project-specific virtual environment and installs the dependencies of the `poetry.lock` file.
- `ci` launches Black, Ruff, mypy and pytest on your source code.
- `ci` launches Ruff, mypy and pytest on your source code.
- `pre-commit` set up and run pre-commit hooks (see pre-commit [documentation](https://pre-commit.com/)).
- `update-doc` and `build-doc` generates documentation from source code and builds it with [Sphinx](https://www.sphinx-doc.org/en/master/index.html).
- `coverage` generates code [coverage](https://coverage.readthedocs.io/en/7.6.4/) report.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import os
import sys

sys.path.insert(0, os.path.abspath("../"))
sys.path.insert(0, os.path.abspath("../src"))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
Expand Down
30 changes: 16 additions & 14 deletions docs/notebooks/barplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
},
"source": [
"# Bar plots\n",
"\n",
"A bar plot uses bars of different heights or colors to compare categorical data across different groups or categories.\n",
"\n",
"Bar plots are often used to represent a measure of central tendency, with an estimation of the associated error."
"Bar plots are often used to represent a measure of central tendency, with an estimation of the associated error.\n"
]
},
{
Expand Down Expand Up @@ -51,6 +52,7 @@
"outputs": [],
"source": [
"import plotly.express as px\n",
"\n",
"import statsplotly"
]
},
Expand Down Expand Up @@ -82,9 +84,9 @@
"source": [
"## Controlling bar colors\n",
"\n",
"Color can be specified independently of the slicer by providing the `color` parameter. \n",
"Color can be specified independently of the slicer by providing the `color` parameter.\n",
"\n",
"To keep track of data slices, the `slicer` identifier is indicated on the corresponding bars."
"To keep track of data slices, the `slicer` identifier is indicated on the corresponding bars.\n"
]
},
{
Expand Down Expand Up @@ -114,11 +116,11 @@
"source": [
"## Aggregating data and displaying error bars\n",
"\n",
"Barplot are often used to summarize the central tendency of data. This is accomplished with the `aggregation_func` argument. Error bars can also be specified. \n",
"Barplot are often used to summarize the central tendency of data. This is accomplished with the `aggregation_func` argument. Error bars can also be specified.\n",
"\n",
"Supplying only one dimension is equivalent to a count plot, with optional normalization.\n",
"\n",
"Below we aggregate the fraction of tips distributed each day:"
"Below we aggregate the fraction of tips distributed each day:\n"
]
},
{
Expand Down Expand Up @@ -146,9 +148,9 @@
"id": "4a8ad8c9-146b-4a4f-a10b-5e865440e5af",
"metadata": {},
"source": [
"Supplying `x`and `y` dimensions with an `aggregation_func` argument aggregate the numeric dimension across values of the other dimensions. \n",
"Supplying `x`and `y` dimensions with an `aggregation_func` argument aggregate the numeric dimension across values of the other dimensions.\n",
"\n",
"Here we perform bootstrap resampling to draw a 95% confidence interval error bar:"
"Here we perform bootstrap resampling to draw a 95% confidence interval error bar:\n"
]
},
{
Expand Down Expand Up @@ -178,7 +180,7 @@
"id": "5c8d3e97-d612-4bb7-b03d-6ede22843386",
"metadata": {},
"source": [
"The `aggregation_func` and `error_bar` arguments also accepts `Callable` arguments :"
"The `aggregation_func` and `error_bar` arguments also accepts `Callable` arguments :\n"
]
},
{
Expand Down Expand Up @@ -222,9 +224,9 @@
"source": [
"## Horizontal bar plots\n",
"\n",
"The numeric dimension is the default aggregated dimension. Swapping the `x` and `y` dimensions thus produces an horizontal plot. \n",
"The numeric dimension is the default aggregated dimension. Swapping the `x` and `y` dimensions thus produces an horizontal plot.\n",
"\n",
"Below we plot the median with the interquartile range:"
"Below we plot the median with the interquartile range:\n"
]
},
{
Expand Down Expand Up @@ -252,15 +254,15 @@
"id": "4673ec5a-bf2b-475d-88d0-a0ad04b9f016",
"metadata": {},
"source": [
"Full details of the API : {func}`~statsplotly.barplot`."
"Full details of the API : {func}`~statsplotly.barplot`.\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "statsplotly",
"display_name": ".venv",
"language": "python",
"name": "statsplotly"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -272,7 +274,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.7"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
1 change: 1 addition & 0 deletions docs/notebooks/catplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"outputs": [],
"source": [
"import plotly.express as px\n",
"\n",
"import statsplotly"
]
},
Expand Down
1 change: 1 addition & 0 deletions docs/notebooks/distplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"outputs": [],
"source": [
"import plotly.express as px\n",
"\n",
"import statsplotly"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/heatmap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import plotly.express as px\n",
"from plotly.subplots import make_subplots\n",
"import pandas as pd\n",
"\n",
"import statsplotly"
]
Expand Down
3 changes: 1 addition & 2 deletions docs/notebooks/jointplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"outputs": [],
"source": [
"import plotly.express as px\n",
"\n",
"import statsplotly"
]
},
Expand Down Expand Up @@ -206,8 +207,6 @@
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"df = px.data.stocks().set_index(\"date\")\n",
"\n",
"fig = statsplotly.jointplot(\n",
Expand Down
1 change: 1 addition & 0 deletions docs/notebooks/lineplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"outputs": [],
"source": [
"import plotly.express as px\n",
"\n",
"import statsplotly"
]
},
Expand Down
4 changes: 1 addition & 3 deletions docs/notebooks/managing_subplots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,7 @@
" shared_grid_axis=\"rows\", plot_axis=\"yaxis\", link_axes=True\n",
").set_common_axis_limit(\n",
" shared_grid_axis=\"all\", plot_axis=\"xaxis\", link_axes=True\n",
").set_common_coloraxis(\n",
" shared_grid_axis=\"rows\"\n",
").tidy_subplots(\n",
").set_common_coloraxis(shared_grid_axis=\"rows\").tidy_subplots(\n",
" title=\"Sex difference in response to treatment\",\n",
" col_titles=[\"control\", \"treatment\"],\n",
" row_titles=[\"raw data\", \"distribution\"],\n",
Expand Down
1 change: 1 addition & 0 deletions docs/notebooks/scatterplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"outputs": [],
"source": [
"import plotly.express as px\n",
"\n",
"import statsplotly"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This independence allows to leverage the powerful interactivity offered by [plot

All plotting functions return a {obj}`plotly.graph_objects.Figure` object, and must be supplied with :

- a {obj}`pandas.DataFrame`-comptatible data structure. Dictionaries or tidy (i.e., [long-form](https://en.wikipedia.org/wiki/Wide_and_narrow_data)) DataFrames are the recommended entry point. Note that hierarchical indexes are supported only on DataFrame's {obj}`~pandas.DataFrame.index`.
- a {obj}`pandas.DataFrame`-compatible data structure. Dictionaries or tidy (i.e., [long-form](https://en.wikipedia.org/wiki/Wide_and_narrow_data)) DataFrames are the recommended entry point. Note that hierarchical indexes are supported only on a DataFrame's {obj}`~pandas.DataFrame.index`.
- column or index identifiers to specify `x`, `y` and `z` -when applicable- plotting dimensions.

> 💡 Read more on [tidy data](https://aeturrell.github.io/python4DS/data-tidy.html).
Expand Down
Loading
Loading