Skip to content

Commit 98ef2b4

Browse files
authored
Fix CI Build matplotlib error (#288)
* Fix matplotlib error caused by erroneous labelling of x-axes in plots * Cruft update
1 parent c8bff76 commit 98ef2b4

File tree

11 files changed

+103
-25
lines changed

11 files changed

+103
-25
lines changed

.cruft.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/arup-group/cookiecutter-pypackage.git",
3-
"commit": "b7724521f898ab28f541d492aff8e2be2ed76a01",
3+
"commit": "f0270b09dcc9dd85140b6ad9f146382e1dacdedd",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -15,11 +15,13 @@
1515
"project_short_description": "The Population activity Modeller (PAM) is a python API for activity sequence modelling.",
1616
"upload_pypi_package": "y",
1717
"upload_conda_package": "y",
18+
"upload_aws_image": "n",
1819
"conda_channel": "city-modelling-lab",
1920
"command_line_interface": "y",
2021
"create_docker_file": "y",
2122
"create_author_file": "n",
2223
"create_jupyter_notebook_directory": "y",
24+
"check_docs_accessibility_in_CI": "n",
2325
"open_source_license": "MIT license",
2426
"_template": "https://github.com/arup-group/cookiecutter-pypackage.git"
2527
}

.github/workflows/docs.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@ name: Build docs
33
on:
44
push:
55
branches:
6-
- "**"
6+
- main
7+
8+
pull_request:
9+
branches:
10+
- main
711
paths-ignore:
812
- tests/**
13+
- ".github/**/*"
14+
- "!.github/workflows/docs.yml"
15+
916

1017
jobs:
1118
docs-test:

.github/workflows/pr-ci.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,20 @@ on:
1111
- CONTRIBUTING.md
1212
- docs/**
1313
- mkdocs.yml
14+
- ".github/**/*"
15+
- "!.github/workflows/pr-ci.yml"
1416

1517
jobs:
18+
lint:
19+
if: github.event.repository.private
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: pre-commit/[email protected]
24+
1625
test:
26+
needs: lint
27+
if: always() && (needs.lint.result == 'success' || needs.lint.result == 'skipped')
1728
strategy:
1829
matrix:
1930
os: [windows-latest, ubuntu-latest, macos-latest]
@@ -29,14 +40,16 @@ jobs:
2940
upload_to_codecov: false
3041

3142
test-coverage:
43+
needs: lint
44+
if: always() && (needs.lint.result == 'success' || needs.lint.result == 'skipped')
3245
uses: arup-group/actions-city-modelling-lab/.github/workflows/python-install-lint-test.yml@main
3346
with:
3447
os: ubuntu-latest
3548
py3version: "12"
3649
notebook_kernel: pam
3750
lint: false
3851
pytest_args: 'tests/' # ignore example notebooks
39-
upload_to_codecov: true
52+
upload_to_codecov: ${{ github.event.repository.visibility == 'public' }} # only attempt to upload if the project is public
4053

4154
memory-profile:
4255
uses: arup-group/actions-city-modelling-lab/.github/workflows/python-memory-profile.yml@main

.pa11yci

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"defaults": {
3+
"reporters": [
4+
"cli",
5+
[
6+
"pa11y-ci-reporter-html",
7+
{ "destination": "./reports/pa11y", "includeZeroIssues": false }
8+
]
9+
],
10+
"timeout": 100000,
11+
"wait": 2000,
12+
"ignore": ["color-contrast"],
13+
"runners": [
14+
"htmlcs", "axe"
15+
],
16+
"hideElements": "[id^='__codelineno'], .md-search__form, #__toc, clipboard-copy"
17+
},
18+
"standard": "WCAG2AA",
19+
"comments": [
20+
"Ignoring color-contrast due to https://github.com/pa11y/pa11y/issues/697.",
21+
"Hiding `clipboard-copy` until https://github.com/danielfrg/mkdocs-jupyter/pull/206 is merged.",
22+
"Hiding `[id^='__codelineno'], .md-search__form, #__toc` due to known false positives in mkdocs-material: https://github.com/squidfunk/mkdocs-material/discussions/4102"
23+
]
24+
}

CONTRIBUTING.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ Look at the [development guide in our documentation](https://arup-group.github.i
3636
To contribute changes:
3737

3838
1. Fork the project on GitHub.
39-
2. Create a feature branch to work on in your fork (`git checkout -b new-fix-or-feature`).
40-
3. Test your changes using `pytest`.
41-
4. Commit your changes to the feature branch (you should have `pre-commit` installed to ensure your code is correctly formatted when you commit changes).
42-
5. Push the branch to GitHub (`git push origin new-fix-or-feature`).
43-
6. On GitHub, create a new [pull request](https://github.com/arup-group/pam/pull/new/main) from the feature branch.
39+
1. Create a feature branch to work on in your fork (`git checkout -b new-fix-or-feature`).
40+
1. Test your changes using `pytest`.
41+
1. Commit your changes to the feature branch (you should have `pre-commit` installed to ensure your code is correctly formatted when you commit changes).
42+
1. Push the branch to GitHub (`git push origin new-fix-or-feature`).
43+
1. On GitHub, create a new [pull request](https://github.com/arup-group/pam/pull/new/main) from the feature branch.
4444

4545
### Pull requests
4646

4747
Before submitting a pull request, check whether you have:
4848

49-
* Added your changes to `CHANGELOG.md`.
50-
* Added or updated documentation for your changes.
51-
* Added tests if you implemented new functionality.
49+
- Added your changes to `CHANGELOG.md`.
50+
- Added or updated documentation for your changes.
51+
- Added tests if you implemented new functionality.
5252

5353
When opening a pull request, please provide a clear summary of your changes!
5454

docs/static/extras.css

+22-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,25 @@ div.doc-contents:not(.first) {
77
/* Allow tables to be horizontally scrollable. */
88
.md-typeset__scrollwrap {
99
overflow-x: auto;
10-
}
10+
}
11+
/* Improve contrast of text in rendered Jupyter notebook codeblocks. */
12+
.jp-Notebook {
13+
--jp-cell-prompt-not-active-opacity: 1;
14+
}
15+
.jp-InputArea-editor {
16+
--jp-cell-editor-background: var(--md-code-bg-color);
17+
}
18+
.highlight-ipynb {
19+
--jp-mirror-editor-number-color: var(--md-code-hl-number-color);
20+
--jp-mirror-editor-string-color: var(--md-code-hl-string-color);
21+
--jp-mirror-editor-operator-color: var(--md-code-hl-operator-color);
22+
--jp-mirror-editor-meta-color: var(--md-code-hl-operator-color);
23+
--jp-mirror-editor-comment-color: var(--md-code-hl-comment-color);
24+
--jp-mirror-editor-keyword-color: var(--md-code-hl-keyword-color);
25+
--jp-mirror-editor-builtin-color: var(--md-code-hl-keyword-color);
26+
--jp-mirror-editor-variable-2-color: var(--md-code-hl-punctuation-color);
27+
--jp-mirror-editor-punctuation-color: var(--md-code-hl-punctuation-color);
28+
--jp-mirror-editor-property-color: var(--md-code-hl-punctuation-color);
29+
--jp-mirror-editor-variable-color: var(--md-code-hl-variable-color);
30+
--jp-mirror-editor-def-color: var(--md-code-hl-constant-color);
31+
}

docs/static/hooks.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Hooks to run when building documentation."""
2+
13
import tempfile
24
from pathlib import Path
35

@@ -10,8 +12,17 @@
1012

1113
# Bump priority to ensure files are moved before jupyter notebook conversion takes place
1214
@mkdocs.plugins.event_priority(50)
13-
def on_files(files: list, config: dict, **kwargs):
14-
"""Link (1) top-level files to mkdocs files and (2) generate the python API documentation."""
15+
def on_files(files: list, config: dict, **kwargs) -> list:
16+
"""Link (1) top-level files to mkdocs files and (2) generate the python API documentation.
17+
18+
Args:
19+
files (list): mkdocs file list.
20+
config (dict): mkdocs config dictionary.
21+
**kwargs: Automatic MKDocs hook inputs.
22+
23+
Returns:
24+
list: Updated mkdocs file list.
25+
"""
1526
for file in sorted(Path("./examples").glob("*.ipynb")):
1627
files.append(_new_file(file, config))
1728
_get_nav_list(config["nav"], "Examples").append(file.as_posix())
@@ -48,7 +59,7 @@ def _new_file(path: Path, config: dict, src_dir: str = ".") -> File:
4859

4960

5061
def _api_gen(files: list, config: dict) -> dict:
51-
"""Project Python API generator
62+
"""Project Python API generator.
5263
5364
Args:
5465
files (list): mkdocs file list.
@@ -78,6 +89,7 @@ def _py_to_md(filepath: Path, api_nav: dict, config: dict) -> File:
7889
filepath (Path): Path to python file relative to the package source code directory.
7990
api_nav (dict): Nested dictionary to fill with mkdocs navigation entries.
8091
config (Config): mkdocs config dictionary.
92+
8193
Returns:
8294
File: mkdocs object that links the temp file to the docs directory, ready to be added to the mkdocs file list.
8395
"""
@@ -112,7 +124,6 @@ def _update_nav(api_nav: dict, config: dict) -> None:
112124
api_nav (dict): Python API navigation tree.
113125
config (dict): mkdocs config dictionary (in which `nav` can be found).
114126
"""
115-
116127
api_reference_nav = {
117128
"Python API": [*api_nav.pop("top_level"), *[{k: v} for k, v in api_nav.items()]]
118129
}
@@ -121,6 +132,7 @@ def _update_nav(api_nav: dict, config: dict) -> None:
121132

122133
def _get_nav_list(nav: list[dict | str], ref: str) -> list:
123134
"""Get navigation entry sub-page list.
135+
124136
Navigation list entries can be dictionaries or strings.
125137
Sub-list entries can then also be dictionaries or strings. E.g.,
126138
@@ -144,6 +156,6 @@ def on_post_build(**kwargs):
144156
"""After mkdocs has finished building the docs, remove the temporary directory of markdown files.
145157
146158
Args:
147-
config (Config): mkdocs config dictionary (unused).
159+
**kwargs: Automatic MKDocs hook inputs.
148160
"""
149161
TEMPDIR.cleanup()

mkdocs.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ markdown_extensions:
3636
anchor_linenums: true
3737
line_spans: __span
3838
pygments_lang_class: true
39-
- pymdownx.inlinehilite
39+
- pymdownx.inlinehilite:
40+
style_plain_text: shell
4041
- pymdownx.superfences
4142
- pymdownx.snippets
4243
- pymdownx.tabbed:
4344
alternate_style: true
44-
- pymdownx.tasklist:
45-
clickable_checkbox: true
4645
- toc:
4746
permalink: "#"
4847
toc_depth: 3

requirements/base.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ Rtree >= 1, < 2
1515
s2sphere < 0.3
1616
scikit-learn >= 1.2, < 2
1717
shapely >= 1, < 3
18-
xlrd >= 2, < 3
18+
xlrd >= 2, < 3

requirements/dev.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
cruft >= 2, < 3
22
jupyter < 2
33
mike >= 2, < 3
4-
mkdocs < 1.6
4+
mkdocs >= 1.6, < 2
55
mkdocs-material >= 9.4, < 10
66
mkdocs-click < 0.7
7-
mkdocs-jupyter < 0.24.7
7+
mkdocs-jupyter >= 0.24.8, < 0.25
88
mkdocstrings-python < 2
99
nbmake >= 1.5.1, < 2
1010
pre-commit < 4

src/pam/plot/stats.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def plot_activity_duration(list_of_populations, exclude=None, axis=None):
166166
axis.bar(x, y)
167167
axis.plot()
168168
axis.set_title(title)
169-
axis.xaxis.set_label("")
169+
axis.xaxis.set_label_text("")
170170
axis.xaxis.set_ticks(x)
171171
axis.xaxis.set_ticklabels(x, rotation=x_label_rotation)
172172
return outputs_df
@@ -191,7 +191,7 @@ def plot_leg_duration(list_of_populations, axis=None):
191191
axis.bar(x, y)
192192
axis.plot()
193193
axis.set_title(title)
194-
axis.xaxis.set_label("")
194+
axis.xaxis.set_label_text("")
195195
axis.xaxis.set_ticks(x)
196196
axis.xaxis.set_ticklabels(x, rotation=x_label_rotation)
197197
return outputs_df

0 commit comments

Comments
 (0)