Skip to content

Commit

Permalink
Fix docs build (#270)
Browse files Browse the repository at this point in the history
* _

* skip tests

* _

* symfem.

* ruff format

* symfem.

* symfem.

* remove isort

* add __all__

* __all__

* typos

* __all__

* __all__

* typing

* undo changes to workflow
  • Loading branch information
mscroggs committed Jun 10, 2024
1 parent 20e55ec commit 93aa8b9
Show file tree
Hide file tree
Showing 107 changed files with 5,252 additions and 2,813 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/trigger_rtd_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import requests

URL = 'https://readthedocs.org/api/v3/projects/symfem/versions/latest/builds/'
URL = "https://readthedocs.org/api/v3/projects/symfem/versions/latest/builds/"
TOKEN = sys.argv[-1]
HEADERS = {'Authorization': f'token {TOKEN}'}
HEADERS = {"Authorization": f"token {TOKEN}"}
response = requests.post(URL, headers=HEADERS)
print(response.json())
29 changes: 21 additions & 8 deletions .github/scripts/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,35 @@
raise RuntimeError("CHANGELOG_SINCE_LAST_VERSION.md should not be empty")

symfem.create_git_tag_and_release(
f"v{version}", f"Version {version}", f"Version {version}", changes,
branch.commit.sha, "commit")
f"v{version}",
f"Version {version}",
f"Version {version}",
changes,
branch.commit.sha,
"commit",
)

old_changelog_file = symfem.get_contents("CHANGELOG.md", new_branch.commit.sha)
old_changes = old_changelog_file.decoded_content.decode("utf8").strip()

new_changelog = (f"# Version {version} ({datetime.now().strftime('%d %B %Y')})\n\n"
f"{changes}\n\n{old_changes}\n")
new_changelog = (
f"# Version {version} ({datetime.now().strftime('%d %B %Y')})\n\n"
f"{changes}\n\n{old_changes}\n"
)

symfem.update_file(
"CHANGELOG.md", "Update CHANGELOG.md", new_changelog, sha=old_changelog_file.sha,
branch=f"v{version}-changelog"
"CHANGELOG.md",
"Update CHANGELOG.md",
new_changelog,
sha=old_changelog_file.sha,
branch=f"v{version}-changelog",
)
symfem.update_file(
"CHANGELOG_SINCE_LAST_VERSION.md", "Reset CHANGELOG_SINCE_LAST_VERSION.md", "",
sha=changelog_file.sha, branch=f"v{version}-changelog"
"CHANGELOG_SINCE_LAST_VERSION.md",
"Reset CHANGELOG_SINCE_LAST_VERSION.md",
"",
sha=changelog_file.sha,
branch=f"v{version}-changelog",
)

symfem.create_pull(
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/style-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ jobs:
- uses: actions/checkout@v4
- run: sudo apt-get install -y python3-setuptools
- run: pip3 install -e .[style,docs]
- run: python3 -m ruff check .
- run: |
python3 -m ruff check .
python3 -m ruff format --check .
name: Run ruff checks
- run: python3 -m flake8 .
name: Run flake8 checks
- run: python3 -m mypy .
name: Run mypy checks
- run: python3 -m isort --check .
name: Run isort checks
- run: |
cd docs
make html SPHINXOPTS="-W"
Expand Down
6 changes: 3 additions & 3 deletions demo/lagrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
# Check that the basis functions on this edge are equal
for d, edge_f in zip(dofs, edge_basis):
# allequal will simplify the expressions then check that they are equal
assert allequal(basis[d].subs(x[:2], (1 - a, a)), edge_f)
assert allequal(basis[d].subs(x[:2], (1 - a, a)), edge_f)

# Get the DOFs on edge 1 (from vertex 0 (0,0) to vertex 2 (0,1), parametrised (0, a))
dofs = element.entity_dofs(0, 0) + element.entity_dofs(0, 2) + element.entity_dofs(1, 1)
for d, edge_f in zip(dofs, edge_basis):
assert allequal(basis[d].subs(x[:2], (0, a)), edge_f)
assert allequal(basis[d].subs(x[:2], (0, a)), edge_f)

# Get the DOFs on edge 2 (from vertex 0 (0,0) to vertex 1 (1,0), parametrised (a, 0))
dofs = element.entity_dofs(0, 0) + element.entity_dofs(0, 1) + element.entity_dofs(1, 2)
for d, edge_f in zip(dofs, edge_basis):
assert allequal(basis[d].subs(x[:2], (a, 0)), edge_f)
assert allequal(basis[d].subs(x[:2], (a, 0)), edge_f)
18 changes: 9 additions & 9 deletions demo/test_demos.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import pytest


@pytest.mark.parametrize("file", [
file
for file in os.listdir(os.path.dirname(os.path.realpath(__file__)))
if file.endswith(".py") and not file.startswith(".") and not file.startswith("test_")
])
def test_demo(file):
file_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@pytest.mark.parametrize(
"file",
[
file
)
for file in os.listdir(os.path.dirname(os.path.realpath(__file__)))
if file.endswith(".py") and not file.startswith(".") and not file.startswith("test_")
],
)
def test_demo(file):
file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), file)

assert os.system(f"python3 {file_path}") == 0
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"autoapi.extension",
"sphinx.ext.napoleon"
"sphinx.ext.napoleon",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -118,7 +118,7 @@
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
'papersize': 'a4paper',
"papersize": "a4paper",
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
Expand Down
3 changes: 1 addition & 2 deletions prepare_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import argparse

parser = argparse.ArgumentParser(description="Build defelement.com")
parser.add_argument('--version', metavar='version',
default="main", help="Symfem version.")
parser.add_argument("--version", metavar="version", default="main", help="Symfem version.")
version = parser.parse_args().version
if version != "main":
version = "v" + version
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ repository = "https://github.com/mscroggs/symfem"
documentation = "https://symfem.readthedocs.io/en/latest/"

[project.optional-dependencies]
style = ["ruff", "flake8", "mypy", "isort"]
style = ["ruff", "mypy"]
docs = ["sphinx", "sphinx-autoapi"]
optional = ["CairoSVG>=2.6.0"]
test = ["pytest", "symfem[optional]", "numpy"]

[tool.ruff]
line-length = 100
indent-width = 4

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
Expand All @@ -37,6 +38,3 @@ convention = "google"

[tool.mypy]
ignore_missing_imports = true

[tool.isort]
line_length = 100
Loading

0 comments on commit 93aa8b9

Please sign in to comment.