Skip to content

Commit 5dd0810

Browse files
authored
support python 3.11 (#48)
1 parent 81c6d4f commit 5dd0810

18 files changed

+285
-233
lines changed

.flake8

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
exclude = venv, __init__.py, build, doc/source/examples
3+
# To be added after refactoring code to be compliant: E501
4+
select = W191, W291, W293, W391, E115, E117, E122, E124, E125, E225, E231, E301, E303, F401, F403
5+
count = True
6+
max-complexity = 10
7+
max-line-length = 100
8+
statistics = True

.github/workflows/build-and-deploy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v3
1515

1616
- name: Build wheels
17-
uses: pypa/[email protected].0
17+
uses: pypa/[email protected].1
1818

1919
- uses: actions/upload-artifact@v3
2020
with:
@@ -46,7 +46,7 @@ jobs:
4646
name: artifact
4747
path: dist
4848

49-
- uses: pypa/gh-action-pypi-publish@v1.5.0
49+
- uses: pypa/gh-action-pypi-publish@v1.6.4
5050
with:
5151
user: __token__
5252
password: ${{ secrets.PYPI_TOKEN }}

.pre-commit-config.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
repos:
2+
3+
- repo: https://github.com/pycqa/isort
4+
rev: 5.11.2
5+
hooks:
6+
- id: isort
7+
8+
- repo: https://github.com/psf/black
9+
rev: 22.12.0
10+
hooks:
11+
- id: black
12+
args:
13+
- --line-length=100
14+
15+
- repo: https://github.com/PyCQA/flake8
16+
rev: 6.0.0
17+
hooks:
18+
- id: flake8
19+
20+
- repo: https://github.com/codespell-project/codespell
21+
rev: v2.2.2
22+
hooks:
23+
- id: codespell
24+
args: ["--toml", "pyproject.toml"]
25+
additional_dependencies: ["tomli"]
26+
27+
# - repo: https://github.com/pycqa/pydocstyle
28+
# rev: 6.1.1
29+
# hooks:
30+
# - id: pydocstyle
31+
# additional_dependencies: [toml]
32+
# exclude: "tests/"
33+
34+
- repo: https://github.com/pre-commit/pre-commit-hooks
35+
rev: v4.4.0
36+
hooks:
37+
- id: check-merge-conflict
38+
- id: debug-statements
39+
40+
# this validates our github workflow files
41+
- repo: https://github.com/python-jsonschema/check-jsonschema
42+
rev: 0.19.2
43+
hooks:
44+
- id: check-github-workflows

doc/conf.py

+55-48
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
import os
2-
import sys
31
import datetime
2+
import os
43

4+
import numpy as np
55
import pymeshfix
66

77
# -- pyvista configuration ---------------------------------------------------
88
import pyvista
9-
import numpy as np
9+
1010
# Manage errors
11-
pyvista.set_error_output_file('errors.txt')
11+
pyvista.set_error_output_file("errors.txt")
1212
# Ensure that offscreen rendering is used for docs generation
13-
pyvista.OFF_SCREEN = True # Not necessary - simply an insurance policy
13+
pyvista.OFF_SCREEN = True # Not necessary - simply an insurance policy
1414
# Preferred plotting style for documentation
15-
pyvista.set_plot_theme('document')
16-
pyvista.rcParams['window_size'] = np.array([1024, 768]) * 2
15+
pyvista.set_plot_theme("document")
16+
pyvista.rcParams["window_size"] = np.array([1024, 768]) * 2
1717
# Save figures in specified directory
18-
pyvista.FIGURE_PATH = os.path.abspath('./images/')
18+
pyvista.FIGURE_PATH = os.path.abspath("./images/")
1919
if not os.path.exists(pyvista.FIGURE_PATH):
2020
os.makedirs(pyvista.FIGURE_PATH)
2121

2222
pyvista.BUILDING_GALLERY = True
2323

2424
# -- Project information -----------------------------------------------------
2525

26-
project = 'pymeshfix'
26+
project = "pymeshfix"
2727
year = datetime.date.today().year
2828
copyright = f"2017-{year}, The PyVista Developers"
29-
author = 'Alex Kaszynski'
29+
author = "Alex Kaszynski"
3030

3131
# The short X.Y version
3232
version = release = pymeshfix.__version__
@@ -42,29 +42,30 @@
4242
# Add any Sphinx extension module names here, as strings. They can be
4343
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4444
# ones.
45-
extensions = ['sphinx.ext.autodoc',
46-
'sphinx.ext.napoleon',
47-
'sphinx.ext.doctest',
48-
'sphinx.ext.autosummary',
49-
'notfound.extension',
50-
'sphinx_copybutton',
51-
'sphinx_gallery.gen_gallery',
52-
'sphinx.ext.extlinks',
53-
]
45+
extensions = [
46+
"sphinx.ext.autodoc",
47+
"sphinx.ext.napoleon",
48+
"sphinx.ext.doctest",
49+
"sphinx.ext.autosummary",
50+
"notfound.extension",
51+
"sphinx_copybutton",
52+
"sphinx_gallery.gen_gallery",
53+
"sphinx.ext.extlinks",
54+
]
5455

5556
html_static_path = ["_static"]
5657

5758
# Add any paths that contain templates here, relative to this directory.
58-
templates_path = ['_templates']
59+
templates_path = ["_templates"]
5960

6061
# The suffix(es) of source filenames.
6162
# You can specify multiple suffix as a list of string:
6263
#
6364
# source_suffix = ['.rst', '.md']
64-
source_suffix = '.rst'
65+
source_suffix = ".rst"
6566

6667
# The master toctree document.
67-
master_doc = 'index'
68+
master_doc = "index"
6869

6970
# The language for content autogenerated by Sphinx. Refer to documentation
7071
# for a list of supported languages.
@@ -79,11 +80,11 @@
7980
exclude_patterns = []
8081

8182
# The name of the Pygments (syntax highlighting) style to use.
82-
pygments_style = 'sphinx'
83+
pygments_style = "sphinx"
8384

8485
# Copy button customization ---------------------------------------------------
8586
# exclude traditional Python prompts from the copied code
86-
copybutton_prompt_text = r'>>> ?|\.\.\. '
87+
copybutton_prompt_text = r">>> ?|\.\.\. "
8788
copybutton_prompt_is_regexp = True
8889

8990

@@ -95,17 +96,20 @@
9596
html_theme = "pydata_sphinx_theme"
9697
html_context = {
9798
# Enable the "Edit in GitHub link within the header of each page.
98-
'display_github': True,
99+
"display_github": True,
99100
# Set the following variables to generate the resulting github URL for each page.
100101
# Format Template: https://{{ github_host|default("github.com") }}/{{ github_user }}/{{ github_repo }}/blob/{{ github_version }}{{ conf_py_path }}{{ pagename }}{{ suffix }}
101-
'github_user': 'pyvista',
102-
'github_repo': 'pymeshfix',
103-
'github_version': 'master/doc/',
104-
'menu_links_name': 'Getting Connected',
105-
'menu_links': [
106-
('<i class="fa fa-slack fa-fw"></i> Slack Community', 'http://slack.pyvista.org'),
107-
('<i class="fa fa-comment fa-fw"></i> Support', 'https://github.com/pyvista/pyvista-support'),
108-
('<i class="fa fa-github fa-fw"></i> Source Code', 'https://github.com/pyvista/pymeshfix'),
102+
"github_user": "pyvista",
103+
"github_repo": "pymeshfix",
104+
"github_version": "master/doc/",
105+
"menu_links_name": "Getting Connected",
106+
"menu_links": [
107+
('<i class="fa fa-slack fa-fw"></i> Slack Community', "http://slack.pyvista.org"),
108+
(
109+
'<i class="fa fa-comment fa-fw"></i> Support',
110+
"https://github.com/pyvista/pyvista-support",
111+
),
112+
('<i class="fa fa-github fa-fw"></i> Source Code', "https://github.com/pyvista/pymeshfix"),
109113
],
110114
}
111115

@@ -118,7 +122,7 @@
118122
# -- Options for HTMLHelp output ---------------------------------------------
119123

120124
# Output file base name for HTML help builder.
121-
htmlhelp_basename = 'PyMeshFix'
125+
htmlhelp_basename = "PyMeshFix"
122126

123127

124128
# -- Options for LaTeX output ------------------------------------------------
@@ -129,19 +133,15 @@
129133
# (source start file, target name, title,
130134
# author, documentclass [howto, manual, or own class]).
131135
latex_documents = [
132-
(master_doc, 'pymeshfix.tex', 'PyMeshFix Documentation',
133-
'Alex Kaszynski', 'manual'),
136+
(master_doc, "pymeshfix.tex", "PyMeshFix Documentation", "Alex Kaszynski", "manual"),
134137
]
135138

136139

137140
# -- Options for manual page output ------------------------------------------
138141

139142
# One entry per manual page. List of tuples
140143
# (source start file, name, description, authors, manual section).
141-
man_pages = [
142-
(master_doc, 'PyMeshFix', 'PyMeshFix Documentation',
143-
[author], 1)
144-
]
144+
man_pages = [(master_doc, "PyMeshFix", "PyMeshFix Documentation", [author], 1)]
145145

146146

147147
# -- Options for Texinfo output ----------------------------------------------
@@ -150,9 +150,15 @@
150150
# (source start file, target name, title, author,
151151
# dir menu entry, description, category)
152152
texinfo_documents = [
153-
(master_doc, 'PyMeshFix', 'PyMeshFix Documentation',
154-
author, 'PyMeshFix', 'One line description of project.',
155-
'Miscellaneous'),
153+
(
154+
master_doc,
155+
"PyMeshFix",
156+
"PyMeshFix Documentation",
157+
author,
158+
"PyMeshFix",
159+
"One line description of project.",
160+
"Miscellaneous",
161+
),
156162
]
157163

158164

@@ -161,9 +167,10 @@
161167
# -- Options for intersphinx extension ---------------------------------------
162168

163169
# Example configuration for intersphinx: refer to the Python standard library.
164-
intersphinx_mapping = {'https://docs.python.org/': None,
165-
'https://docs.pyvista.org': None,
166-
}
170+
intersphinx_mapping = {
171+
"https://docs.python.org/": None,
172+
"https://docs.pyvista.org": None,
173+
}
167174

168175
# -- Options for todo extension ----------------------------------------------
169176

@@ -181,7 +188,7 @@
181188
],
182189
# path where to save gallery generated examples
183190
"gallery_dirs": ["examples"],
184-
# Patter to search for example files
191+
# Pattern to search for example files
185192
"filename_pattern": r"\.py",
186193
# Remove the "Download all examples" button from the top level gallery
187194
"download_all_examples": False,
@@ -191,7 +198,7 @@
191198
"backreferences_dir": None,
192199
# Modules for which function level galleries are created. In
193200
"doc_module": "pymeshfix",
194-
"image_scrapers": (pyvista.Scraper(), 'matplotlib'),
201+
"image_scrapers": (pyvista.Scraper(), "matplotlib"),
195202
"thumbnail_size": (350, 350),
196203
}
197204

examples/bunny.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,36 @@
22
Bunny
33
-----
44
5-
Repair the holes in the bunny mesh
5+
Repair the holes in the bunny mesh.
66
"""
77

8+
import pymeshfix as mf
9+
810
# sphinx_gallery_thumbnail_number = 2
911
import pyvista as pv
10-
import pymeshfix as mf
1112
from pyvista import examples
1213

1314
################################################################################
1415
bunny = examples.download_bunny()
1516

1617
# Define a camera position that shows the holes in the mesh
17-
cpos = [(-0.2, -0.13, 0.12),
18-
(-0.015, 0.10, -0.0),
19-
(0.28, 0.26, 0.9)]
18+
cpos = [(-0.2, -0.13, 0.12), (-0.015, 0.10, -0.0), (0.28, 0.26, 0.9)]
2019

2120
# Show mesh
2221
bunny.plot(cpos=cpos)
2322

2423
################################################################################
25-
# Genereate a meshfix mesh ready for fixing and extract the holes
24+
# Generate a meshfix mesh ready for fixing and extract the holes
2625
meshfix = mf.MeshFix(bunny)
2726
holes = meshfix.extract_holes()
2827

2928
################################################################################
3029
# Render the mesh and outline the holes
3130
p = pv.Plotter()
3231
p.add_mesh(bunny, color=True)
33-
p.add_mesh(holes, color='r', line_width=8)
32+
p.add_mesh(holes, color="r", line_width=8)
3433
p.camera_position = cpos
35-
p.enable_eye_dome_lighting() # helps depth perception
34+
p.enable_eye_dome_lighting() # helps depth perception
3635
p.show()
3736

3837
################################################################################

examples/cow.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,35 @@
55
Repair a holey cow
66
"""
77

8+
import numpy as np
9+
import pymeshfix as mf
10+
811
# sphinx_gallery_thumbnail_number = 1
912
import pyvista as pv
10-
import pymeshfix as mf
1113
from pyvista import examples
12-
import numpy as np
1314

1415
################################################################################
1516
cow = examples.download_cow()
1617

1718
# Add holes and cast to triangulated PolyData
18-
cow['random'] = np.random.rand(cow.n_cells)
19+
cow["random"] = np.random.rand(cow.n_cells)
1920
holy_cow = cow.threshold(0.9, invert=True).extract_geometry().triangulate()
2021
print(holy_cow)
2122

2223
################################################################################
2324

2425
# A nice camera location of the cow
25-
cpos= [(6.56, 8.73, 22.03),
26-
(0.77, -0.44, 0.0),
27-
(-0.13, 0.93, -0.35)]
26+
cpos = [(6.56, 8.73, 22.03), (0.77, -0.44, 0.0), (-0.13, 0.93, -0.35)]
2827

2928
meshfix = mf.MeshFix(holy_cow)
3029
holes = meshfix.extract_holes()
3130

3231
# Render the mesh and outline the holes
3332
p = pv.Plotter()
3433
p.add_mesh(holy_cow, color=True)
35-
p.add_mesh(holes, color='r', line_width=8)
34+
p.add_mesh(holes, color="r", line_width=8)
3635
p.camera_position = cpos
37-
p.enable_eye_dome_lighting() # helps depth perception
36+
p.enable_eye_dome_lighting() # helps depth perception
3837
p.show()
3938

4039

0 commit comments

Comments
 (0)