Skip to content

Commit aab31d0

Browse files
Sync with FEM on Colab website: fem-on-colab/fem-on-colab.github.io@f4fce9f1
1 parent cbe9433 commit aab31d0

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v4
2020
- name: Install dependencies
2121
run: |
22-
python3 -m pip -q install yamllint
22+
python3 -m pip install --break-system-packages -q yamllint
2323
- name: Run yamllint
2424
run: |
2525
python3 -m yamllint -d "{extends: default, rules: {document-start: {present: false}, line-length: disable, truthy: {check-keys: false}}}" .

Diff for: .github/workflows/stats.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
wget https://github.com/fem-on-colab/release-download-count-script/raw/main/scripts/requirements.txt
25-
python3 -m pip -q install -r requirements.txt
25+
python3 -m pip install --break-system-packages -q -r requirements.txt
2626
rm requirements.txt
27-
python3 -m pip -q install pandas
27+
python3 -m pip install --break-system-packages -q pandas
2828
SITE_PACKAGES=$(python3 -c 'import site; print(site.getsitepackages()[0])')
2929
sudo wget https://github.com/fem-on-colab/release-download-count-script/raw/main/scripts/release_download_count.py -P $SITE_PACKAGES
3030
- name: Update release download stats

Diff for: .github/workflows/website.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
path: _build/html
3636
- name: Install dependencies
3737
run: |
38-
pip3 -q install pandas plotly sphinx-material
38+
python3 -m pip install --break-system-packages -q pandas plotly sphinx-material
3939
- name: Generate sphinx website
4040
run: |
4141
pushd _stats

Diff for: _ext/ext.py

+25-7
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def _library_image(library):
211211
logo = "_static/images/occ-logo.png"
212212
elif library == "petsc4py":
213213
logo = "_static/images/petsc4py-logo.png"
214-
elif library == "pybind11" or library.startswith("pybind11 ("):
214+
elif library == "pybind11" or library.startswith("pybind11 & nanobind ("):
215215
logo = "_static/images/pybind11-logo.png"
216216
elif library == "RBniCS":
217217
logo = "_static/images/rbnics-logo.png"
@@ -226,6 +226,17 @@ def _library_image(library):
226226
class Stats(Directive):
227227

228228
def run(self):
229+
def get_week_representation(day: datetime.date) -> str:
230+
"""
231+
Get the week representation year-week number.
232+
233+
Uses day.isocalendar() rather than day.strftime("%Y-%W") to prevent
234+
wrong identification of the (week number, year) pair on the first week
235+
of the year, see the documentation of datetime.date.isocalendar().
236+
"""
237+
isocalendar_tuple = day.isocalendar()
238+
return f"{isocalendar_tuple.year}-{isocalendar_tuple.week}"
239+
229240
# Get release download stats from file, and convert it to a plot
230241
stats = pd.read_csv("_stats/stats.csv")
231242
first_day = None
@@ -237,13 +248,13 @@ def run(self):
237248
first_day = day
238249
else:
239250
first_day = min(first_day, day)
240-
week = day.strftime("%Y-%W")
251+
week = get_week_representation(day)
241252
if week not in week_to_headers:
242253
week_to_headers[week] = list()
243254
week_to_headers[week].append(header)
244255
weeks = pd.date_range(
245256
start=first_day - timedelta(days=first_day.weekday()), end=datetime.now(), freq="W-MON").tolist()[:-1]
246-
weeks_str = [week.strftime("%Y-%W") for week in weeks]
257+
weeks_str = [get_week_representation(week) for week in weeks]
247258
weekly_stats = pd.DataFrame(0, columns=list(packages.keys()), index=weeks_str)
248259
for package in weekly_stats.columns:
249260
condition = stats.package.str.fullmatch(package)
@@ -253,18 +264,25 @@ def run(self):
253264
weekly_stats.loc[week, package] = max(stats_package[header] for header in headers)
254265
if len(weeks) > 1:
255266
fig = go.Figure()
267+
max_downloads = 0
256268
for package in weekly_stats.columns:
257269
weekly_stats_package = weekly_stats[package]
270+
weekly_stats_package_diff = weekly_stats_package.diff().to_numpy()
258271
fig.add_scatter(
259-
x=weeks[1:], y=np.diff(weekly_stats_package), mode="lines+markers",
272+
x=weeks[1:], y=weekly_stats_package_diff, mode="lines+markers",
260273
name=packages[package]["title"])
274+
if len(weeks) > 13:
275+
max_downloads = max(max_downloads, np.max(weekly_stats_package_diff[-14:]))
276+
else:
277+
max_downloads = max(max_downloads, np.max(weekly_stats_package_diff))
261278
milliseconds_in_one_week = 604800000
262279
fig.update_xaxes(tickformat="%Y-%W", dtick=milliseconds_in_one_week)
263280
if len(weeks) > 13:
264281
fig.update_xaxes(
265282
tick0=weeks[-14], range=[weeks[-14] - timedelta(days=3), weeks[-1] + timedelta(days=3)])
266283
else:
267284
fig.update_xaxes(tick0=weeks[0])
285+
fig.update_yaxes(tick0=- 0.1 * max_downloads, range=[- 0.1 * max_downloads, 1.1 * max_downloads])
268286
html_buffer = io.StringIO()
269287
fig.write_html(html_buffer, full_html=False)
270288
return [nodes.raw(text=html_buffer.getvalue(), format="html")]
@@ -275,22 +293,22 @@ def on_build_finished(app, exc):
275293
if exc is None and app.builder.format == "html":
276294
# Unescape at symbol
277295
subprocess.run(
278-
"find " + str(app.outdir) + " -type f -not -path '*/\.git/*' -exec sed -i 's/%40/@/g' {} +",
296+
"find " + str(app.outdir) + r" -type f -not -path '*/\.git/*' -exec sed -i 's/%40/@/g' {} +",
279297
shell=True)
280298
subprocess.run( # undo incorrect escape in plotly js
281299
"sed -i 's/t@0=/t%400=/g' " + str(app.outdir) + "/packages.html",
282300
shell=True)
283301
# Mark current page as active
284302
subprocess.run(
285-
"find " + str(app.outdir) + " -type f -not -path '*/\.git/*' -exec sed -i 's/"
303+
"find " + str(app.outdir) + r" -type f -not -path '*/\.git/*' -exec sed -i 's/"
286304
+ '<li class="md-tabs__item"><a href="#" class="md-tabs__link">'
287305
+ "/"
288306
+ '<li class="md-tabs__item md-tabs__item_current"><a href="#" class="md-tabs__link">'
289307
+ "/g' {} +",
290308
shell=True)
291309
# Disable going to submenus on mobile
292310
subprocess.run(
293-
"find " + str(app.outdir) + " -type f -not -path '*/\.git/*' -exec sed -i 's/"
311+
"find " + str(app.outdir) + r" -type f -not -path '*/\.git/*' -exec sed -i 's/"
294312
+ 'id="__toc"'
295313
+ "/"
296314
+ 'id="__toc_disabled"'

Diff for: _ext/packages.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,16 @@
165165
},
166166
},
167167
"pybind11": {
168-
"title": "pybind11",
168+
"title": "pybind11 & nanobind",
169169
"installation": """
170170
!wget "https://fem-on-kaggle.github.io/releases/pybind11-install.sh" -O "/tmp/pybind11-install.sh" && bash "/tmp/pybind11-install.sh"
171171
import pybind11
172172
""",
173173
"installation_suffixes": [""],
174174
"tests": {
175-
"pybind11 (with default compiler)": "pybind11/test-none.ipynb",
176-
"pybind11 (exporting g++ compiler)": "pybind11/test-gpp.ipynb",
177-
"pybind11 (exporting mpicxx compiler)": "pybind11/test-mpicxx.ipynb",
175+
"pybind11 & nanobind (with default compiler)": "pybind11/test-none.ipynb",
176+
"pybind11 & nanobind (exporting g++ compiler)": "pybind11/test-gpp.ipynb",
177+
"pybind11 & nanobind (exporting mpicxx compiler)": "pybind11/test-mpicxx.ipynb",
178178
},
179179
},
180180
"slepc4py": {

0 commit comments

Comments
 (0)