Skip to content

Commit 0b125f9

Browse files
Merge pull request #25 from JosephBARBIERDARNAL/updates
add linter in ci
2 parents 3139e82 + a8dd369 commit 0b125f9

27 files changed

+276
-29
lines changed

.github/workflows/lint.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Code Formatting
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check-formatting:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: "3.13"
20+
21+
- name: Install Ruff
22+
run: pip install ruff==0.9.10
23+
24+
- name: Run Ruff format check
25+
run: ruff format --check .
26+
27+
- name: Run Ruff linting and auto-fix
28+
run: ruff check --fix .

.github/workflows/site.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
name: ci
1+
name: ci
2+
23
on:
34
push:
4-
branches:
5-
- master
6-
- main
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
79
permissions:
810
contents: write
11+
912
jobs:
1013
deploy:
1114
runs-on: ubuntu-latest
@@ -18,12 +21,12 @@ jobs:
1821
- uses: actions/setup-python@v5
1922
with:
2023
python-version: 3.x
21-
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
24+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
2225
- uses: actions/cache@v4
2326
with:
2427
key: mkdocs-material-${{ env.cache_id }}
2528
path: .cache
2629
restore-keys: |
2730
mkdocs-material-
28-
- run: pip install mkdocs-material
29-
- run: mkdocs gh-deploy --force
31+
- run: pip install mkdocs-material
32+
- run: mkdocs gh-deploy --force

dayplot/main.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def calendar(
2222
edgecolor: str = "black",
2323
edgewidth: float = 0.0,
2424
cmap: Union[str, LinearSegmentedColormap] = "Greens",
25+
week_starts_on: str = "Sunday",
2526
month_kws: Optional[Dict] = None,
2627
day_kws: Optional[Dict] = None,
2728
day_x_margin: float = 0.02,
@@ -31,7 +32,6 @@ def calendar(
3132
vcenter: Optional[float] = None,
3233
boxstyle: Union[str, matplotlib.patches.BoxStyle] = "square",
3334
ax: Optional[matplotlib.axes.Axes] = None,
34-
week_starts_on: str = "Sunday",
3535
**kwargs,
3636
) -> List[matplotlib.patches.Rectangle]:
3737
"""
@@ -50,6 +50,7 @@ def calendar(
5050
5151
Parameters
5252
----------
53+
5354
dates
5455
A list of date-like objects (e.g., datetime.date, datetime.datetime, or
5556
strings in "YYYY-MM-DD" format). Must have the same length as values.
@@ -77,6 +78,9 @@ def calendar(
7778
A valid Matplotlib colormap name or a LinearSegmentedColormap instance.
7879
Defaults to "Greens". The colormap is used to determine the fill color
7980
intensity of each day's cell based on its value.
81+
week_starts_on
82+
The starting day of the week, which can be specified as a string ("Sunday", "Monday",
83+
..., "Saturday"). Defaults to "Sunday".
8084
month_kws
8185
Additional keyword arguments passed to the matplotlib.axes.Axes.text function when
8286
labeling month names (outside of x, y and s).
@@ -111,25 +115,25 @@ def calendar(
111115
A matplotlib axes. If None, plt.gca() will be used. It is advisable to make
112116
this explicit to avoid unexpected behaviour, particularly when manipulating a
113117
figure with several axes.
114-
week_starts_on
115-
The starting day of the week, which can be specified as a string ("Sunday", "Monday",
116-
..., "Saturday"). Defaults to "Sunday".
117118
kwargs
118119
Any additional arguments that will be passed to matplotlib.patches.FancyBboxPatch. For example,
119120
you can set `alpha`, `hatch`, `linestyle`, etc.
120121
You can find them all here: https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.FancyBboxPatch.html
121122
122123
Returns
123124
-------
125+
124126
A list of matplotlib.patches.FancyBboxPatch (one for each cell).
125127
126128
Notes
127129
-----
130+
128131
- The function aggregates multiple entries for the same date by summing their
129132
values.
130133
131134
Examples
132135
--------
136+
133137
>>> import dayplot as dp
134138
>>> import pandas as pd
135139
>>> df = pd.DataFrame({
@@ -343,21 +347,3 @@ def calendar(
343347
ax.text(-day_x_margin, y_tick, day_label, **day_text_style)
344348

345349
return rect_patches
346-
347-
348-
if __name__ == "__main__":
349-
import numpy as np
350-
import dayplot as dp
351-
352-
df = dp.load_dataset()
353-
354-
fig, ax = plt.subplots(figsize=(15, 6))
355-
calendar(
356-
df["dates"],
357-
df["values"],
358-
start_date="2024-01-01",
359-
end_date="2024-12-31",
360-
week_starts_on="Sunday",
361-
)
362-
fig.savefig("test.png", dpi=300, bbox_inches="tight")
363-
plt.close()

docs/gallery.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,9 @@
8585
[![advanced-2](img/advanced/advanced-2.png)](tuto/advanced.md)
8686

8787

88+
<br>
89+
[![advanced-3](img/advanced/advanced-3.png)](tuto/advanced.md)
90+
91+
8892
<br>
8993

docs/img/advanced/advanced-1.png

-14 Bytes
Loading

docs/img/advanced/advanced-2.png

60 Bytes
Loading

docs/img/advanced/advanced-3.png

304 KB
Loading

docs/img/basic-styling/cmap.png

10 Bytes
Loading

docs/img/basic-styling/colors.png

0 Bytes
Loading

docs/img/basic-styling/text.png

-9 Bytes
Loading

0 commit comments

Comments
 (0)