Skip to content

Commit 70be78c

Browse files
committed
black
1 parent c0490c3 commit 70be78c

21 files changed

+153
-173
lines changed

docs/conf.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import sphinx_compas_theme
1414
from sphinx.ext.napoleon.docstring import NumpyDocstring
1515

16-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../src'))
16+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../src"))
1717

1818

1919
# -- General configuration ------------------------------------------------
@@ -25,7 +25,9 @@
2525
version = ".".join(release.split(".")[0:2])
2626

2727
master_doc = "index"
28-
source_suffix = [".rst", ]
28+
source_suffix = [
29+
".rst",
30+
]
2931
templates_path = sphinx_compas_theme.get_autosummary_templates_path()
3032
exclude_patterns = []
3133

@@ -49,7 +51,7 @@
4951
"sphinx.ext.napoleon",
5052
"sphinx.ext.githubpages",
5153
"sphinx.ext.autodoc.typehints",
52-
"tabs"
54+
"tabs",
5355
]
5456

5557
# autodoc options
@@ -72,7 +74,7 @@
7274

7375

7476
def skip(app, what, name, obj, would_skip, options):
75-
if name.startswith('_'):
77+
if name.startswith("_"):
7678
return True
7779
return would_skip
7880

@@ -132,31 +134,32 @@ def patched_parse(self):
132134

133135
# linkcode
134136

137+
135138
def linkcode_resolve(domain, info):
136-
if domain != 'py':
139+
if domain != "py":
137140
return None
138-
if not info['module']:
141+
if not info["module"]:
139142
return None
140-
if not info['fullname']:
143+
if not info["fullname"]:
141144
return None
142145

143-
package = info['module'].split('.')[0]
144-
if not package.startswith('compas_cgal'):
146+
package = info["module"].split(".")[0]
147+
if not package.startswith("compas_cgal"):
145148
return None
146149

147-
module = importlib.import_module(info['module'])
148-
parts = info['fullname'].split('.')
150+
module = importlib.import_module(info["module"])
151+
parts = info["fullname"].split(".")
149152

150153
if len(parts) == 1:
151-
obj = getattr(module, info['fullname'])
152-
filename = inspect.getmodule(obj).__name__.replace('.', '/')
154+
obj = getattr(module, info["fullname"])
155+
filename = inspect.getmodule(obj).__name__.replace(".", "/")
153156
lineno = inspect.getsourcelines(obj)[1]
154157
elif len(parts) == 2:
155158
obj_name, attr_name = parts
156159
obj = getattr(module, obj_name)
157160
attr = getattr(obj, attr_name)
158161
if inspect.isfunction(attr):
159-
filename = inspect.getmodule(obj).__name__.replace('.', '/')
162+
filename = inspect.getmodule(obj).__name__.replace(".", "/")
160163
lineno = inspect.getsourcelines(attr)[1]
161164
else:
162165
return None
@@ -165,6 +168,7 @@ def linkcode_resolve(domain, info):
165168

166169
return f"https://github.com/compas-dev/compas_cgal/blob/master/src/{filename}.py#L{lineno}"
167170

171+
168172
# extlinks
169173

170174
extlinks = {}
@@ -175,13 +179,13 @@ def linkcode_resolve(domain, info):
175179
html_theme_path = sphinx_compas_theme.get_html_theme_path()
176180

177181
html_theme_options = {
178-
"package_name" : "compas_cgal",
179-
"package_title" : project,
180-
"package_version" : release,
181-
"package_author" : "compas-dev",
182-
"package_docs" : "https://compas.dev/compas_cgal/",
183-
"package_repo" : "https://github.com/compas-dev/compas_cgal",
184-
"package_old_versions_txt": "https://compas.dev/compas_cgal/doc_versions.txt"
182+
"package_name": "compas_cgal",
183+
"package_title": project,
184+
"package_version": release,
185+
"package_author": "compas-dev",
186+
"package_docs": "https://compas.dev/compas_cgal/",
187+
"package_repo": "https://github.com/compas-dev/compas_cgal",
188+
"package_old_versions_txt": "https://compas.dev/compas_cgal/doc_versions.txt",
185189
}
186190

187191
html_context = {}

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
autopep8
22
attrs >=17.4
3+
black
34
bump2version >=1.0.1
45
check-manifest >=0.36
56
doc8

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
compas
12
nptyping
23
typing_extensions

setup.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,62 +17,59 @@
1717

1818
def read(*names, **kwargs):
1919
return io.open(
20-
os.path.join(here, *names),
21-
encoding=kwargs.get("encoding", "utf8")
20+
os.path.join(here, *names), encoding=kwargs.get("encoding", "utf8")
2221
).read()
2322

2423

2524
long_description = read("README.md")
2625
requirements = read("requirements.txt").split("\n")
2726
optional_requirements = {}
2827

29-
conda_prefix = os.getenv('CONDA_PREFIX')
28+
conda_prefix = os.getenv("CONDA_PREFIX")
3029

31-
windows = os.name == 'nt'
30+
windows = os.name == "nt"
3231

3332

3433
def get_pybind_include():
3534
if windows:
36-
return os.path.join(conda_prefix, 'Library', 'include')
37-
return os.path.join(conda_prefix, 'include')
35+
return os.path.join(conda_prefix, "Library", "include")
36+
return os.path.join(conda_prefix, "include")
3837

3938

4039
def get_eigen_include():
4140
if windows:
42-
return os.path.join(conda_prefix, 'Library', 'include', 'eigen3')
43-
return os.path.join(conda_prefix, 'include', 'eigen3')
41+
return os.path.join(conda_prefix, "Library", "include", "eigen3")
42+
return os.path.join(conda_prefix, "include", "eigen3")
4443

4544

4645
def get_library_dirs():
4746
if windows:
48-
return os.path.join(conda_prefix, 'Library', 'lib')
49-
return os.path.join(conda_prefix, 'lib')
47+
return os.path.join(conda_prefix, "Library", "lib")
48+
return os.path.join(conda_prefix, "lib")
5049

5150

5251
ext_modules = [
5352
Extension(
54-
'compas_cgal._cgal',
55-
sorted([
56-
'src/compas_cgal.cpp',
57-
'src/compas.cpp',
58-
'src/meshing.cpp',
59-
'src/booleans.cpp',
60-
'src/slicer.cpp',
61-
'src/intersections.cpp',
62-
'src/measure.cpp',
63-
'src/subdivision.cpp',
64-
'src/triangulations.cpp',
65-
]),
66-
include_dirs=[
67-
'./include',
68-
get_eigen_include(),
69-
get_pybind_include()
70-
],
53+
"compas_cgal._cgal",
54+
sorted(
55+
[
56+
"src/compas_cgal.cpp",
57+
"src/compas.cpp",
58+
"src/meshing.cpp",
59+
"src/booleans.cpp",
60+
"src/slicer.cpp",
61+
"src/intersections.cpp",
62+
"src/measure.cpp",
63+
"src/subdivision.cpp",
64+
"src/triangulations.cpp",
65+
]
66+
),
67+
include_dirs=["./include", get_eigen_include(), get_pybind_include()],
7168
library_dirs=[
7269
get_library_dirs(),
7370
],
74-
libraries=['mpfr', 'gmp'],
75-
language='c++'
71+
libraries=["mpfr", "gmp"],
72+
language="c++",
7673
),
7774
]
7875

@@ -83,8 +80,9 @@ def has_flag(compiler, flagname):
8380
"""
8481
import tempfile
8582
import os
86-
with tempfile.NamedTemporaryFile('w', suffix='.cpp', delete=False) as f:
87-
f.write('int main (int argc, char **argv) { return 0; }')
83+
84+
with tempfile.NamedTemporaryFile("w", suffix=".cpp", delete=False) as f:
85+
f.write("int main (int argc, char **argv) { return 0; }")
8886
fname = f.name
8987
try:
9088
compiler.compile([fname], extra_postargs=[flagname])
@@ -104,25 +102,25 @@ def cpp_flag(compiler):
104102
The newer version is prefered over c++11 (when it is available).
105103
"""
106104
# flags = ['-std=c++17', '-std=c++14', '-std=c++11']
107-
flags = ['-std=c++14', '-std=c++11']
105+
flags = ["-std=c++14", "-std=c++11"]
108106

109107
for flag in flags:
110108
if has_flag(compiler, flag):
111109
return flag
112110

113-
raise RuntimeError('Unsupported compiler -- at least C++11 support '
114-
'is needed!')
111+
raise RuntimeError("Unsupported compiler -- at least C++11 support " "is needed!")
115112

116113

117114
class BuildExt(build_ext):
118115
"""A custom build extension for adding compiler-specific options."""
116+
119117
c_opts = {
120-
'msvc': ['/EHsc', '/std:c++14'],
121-
'unix': [],
118+
"msvc": ["/EHsc", "/std:c++14"],
119+
"unix": [],
122120
}
123121
l_opts = {
124-
'msvc': [],
125-
'unix': [],
122+
"msvc": [],
123+
"unix": [],
126124
}
127125

128126
# if sys.platform == 'darwin':
@@ -134,14 +132,16 @@ def build_extensions(self):
134132
ct = self.compiler.compiler_type
135133
opts = self.c_opts.get(ct, [])
136134
link_opts = self.l_opts.get(ct, [])
137-
if ct == 'unix':
135+
if ct == "unix":
138136
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
139137
opts.append(cpp_flag(self.compiler))
140-
if has_flag(self.compiler, '-fvisibility=hidden'):
141-
opts.append('-fvisibility=hidden')
142-
opts.append('-DCGAL_DEBUG=1')
138+
if has_flag(self.compiler, "-fvisibility=hidden"):
139+
opts.append("-fvisibility=hidden")
140+
opts.append("-DCGAL_DEBUG=1")
143141
for ext in self.extensions:
144-
ext.define_macros = [('VERSION_INFO', '"{}"'.format(self.distribution.get_version()))]
142+
ext.define_macros = [
143+
("VERSION_INFO", '"{}"'.format(self.distribution.get_version()))
144+
]
145145
ext.extra_compile_args = opts
146146
ext.extra_link_args = link_opts
147147
build_ext.build_extensions(self)
@@ -182,8 +182,8 @@ def build_extensions(self):
182182
# data_files=[],
183183
# include_package_data=True,
184184
ext_modules=ext_modules,
185-
cmdclass={'build_ext': BuildExt},
186-
setup_requires=['pybind11>=2.5.0'],
185+
cmdclass={"build_ext": BuildExt},
186+
setup_requires=["pybind11>=2.5.0"],
187187
install_requires=requirements,
188188
python_requires=">=3.6",
189189
extras_require=optional_requirements,

src/compas_cgal/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@
9595

9696

9797
__all_plugins__ = [
98-
'compas_cgal.booleans',
99-
'compas_cgal.intersections',
100-
'compas_cgal.meshing',
101-
'compas_cgal.measure',
102-
'compas_cgal.slicer',
103-
'compas_cgal.triangulation',
98+
"compas_cgal.booleans",
99+
"compas_cgal.intersections",
100+
"compas_cgal.meshing",
101+
"compas_cgal.measure",
102+
"compas_cgal.slicer",
103+
"compas_cgal.triangulation",
104104
]
105105

106106
__all__ = ["HOME", "DATA", "DOCS", "TEMP"]

src/compas_cgal/booleans.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ def _boolean(A, B, operation):
3535
VB = np.asarray(VB, dtype=np.float64)
3636
FB = np.asarray(FB, dtype=np.int32)
3737

38-
if operation == 'union':
38+
if operation == "union":
3939
result = booleans.boolean_union(VA, FA, VB, FB)
40-
elif operation == 'difference':
40+
elif operation == "difference":
4141
result = booleans.boolean_difference(VA, FA, VB, FB)
42-
elif operation == 'intersection':
42+
elif operation == "intersection":
4343
result = booleans.boolean_intersection(VA, FA, VB, FB)
44-
elif operation == 'split':
44+
elif operation == "split":
4545
result = booleans.split(VA, FA, VB, FB)
4646
else:
4747
raise NotImplementedError
4848

4949
return result
5050

5151

52-
@plugin(category='booleans', pluggable_name='boolean_union_mesh_mesh')
52+
@plugin(category="booleans", pluggable_name="boolean_union_mesh_mesh")
5353
def boolean_union(A, B):
5454
"""Boolean union of two meshes.
5555
@@ -84,10 +84,10 @@ def boolean_union(A, B):
8484
>>> shape = Polyhedron(*C)
8585
8686
"""
87-
return _boolean(A, B, 'union')
87+
return _boolean(A, B, "union")
8888

8989

90-
@plugin(category='booleans', pluggable_name='boolean_difference_mesh_mesh')
90+
@plugin(category="booleans", pluggable_name="boolean_difference_mesh_mesh")
9191
def boolean_difference(A, B):
9292
"""Boolean difference of two meshes.
9393
@@ -122,10 +122,10 @@ def boolean_difference(A, B):
122122
>>> shape = Polyhedron(*C)
123123
124124
"""
125-
return _boolean(A, B, 'difference')
125+
return _boolean(A, B, "difference")
126126

127127

128-
@plugin(category='booleans', pluggable_name='boolean_intersection_mesh_mesh')
128+
@plugin(category="booleans", pluggable_name="boolean_intersection_mesh_mesh")
129129
def boolean_intersection(A, B):
130130
"""Boolean intersection of two meshes.
131131
@@ -160,10 +160,10 @@ def boolean_intersection(A, B):
160160
>>> shape = Polyhedron(*C)
161161
162162
"""
163-
return _boolean(A, B, 'intersection')
163+
return _boolean(A, B, "intersection")
164164

165165

166-
@plugin(category='booleans', pluggable_name='split_mesh_mesh')
166+
@plugin(category="booleans", pluggable_name="split_mesh_mesh")
167167
def split(A, B):
168168
"""Split one mesh with another.
169169
@@ -198,4 +198,4 @@ def split(A, B):
198198
>>> mesh = Mesh.from_vertices_and_faces(V, F)
199199
200200
"""
201-
return _boolean(A, B, 'split')
201+
return _boolean(A, B, "split")

0 commit comments

Comments
 (0)