Skip to content

Commit 5ae2997

Browse files
committed
black...
1 parent f0958b2 commit 5ae2997

File tree

6 files changed

+228
-159
lines changed

6 files changed

+228
-159
lines changed

src/compas/artists/artist.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,34 @@
1515
from .colordict import DescriptorProtocol
1616

1717

18-
@pluggable(category='drawing-utils')
18+
@pluggable(category="drawing-utils")
1919
def clear():
2020
raise NotImplementedError
2121

2222

23-
@pluggable(category='drawing-utils')
23+
@pluggable(category="drawing-utils")
2424
def redraw():
2525
raise NotImplementedError
2626

2727

28-
@pluggable(category='factories', selector='collect_all')
28+
@pluggable(category="factories", selector="collect_all")
2929
def register_artists():
3030
raise NotImplementedError
3131

3232

3333
def identify_context():
3434
if compas.is_grasshopper():
35-
return 'Grasshopper'
35+
return "Grasshopper"
3636
if compas.is_rhino():
37-
return 'Rhino'
37+
return "Rhino"
3838
if compas.is_blender():
39-
return 'Blender'
39+
return "Blender"
4040
return None
4141

4242

4343
def _get_artist_cls(data, **kwargs):
44-
if 'context' in kwargs:
45-
Artist.CONTEXT = kwargs['context']
44+
if "context" in kwargs:
45+
Artist.CONTEXT = kwargs["context"]
4646
else:
4747
Artist.CONTEXT = identify_context()
4848

@@ -52,17 +52,22 @@ def _get_artist_cls(data, **kwargs):
5252
dtype = type(data)
5353
cls = None
5454

55-
if 'artist_type' in kwargs:
56-
cls = kwargs['artist_type']
55+
if "artist_type" in kwargs:
56+
cls = kwargs["artist_type"]
5757
else:
5858
context = Artist.ITEM_ARTIST[Artist.CONTEXT]
59+
5960
for type_ in inspect.getmro(dtype):
6061
cls = context.get(type_, None)
6162
if cls is not None:
6263
break
6364

6465
if cls is None:
65-
raise DataArtistNotRegistered('No artist is registered for this data type: {} in this context: {}'.format(dtype, Artist.CONTEXT))
66+
raise DataArtistNotRegistered(
67+
"No artist is registered for this data type: {} in this context: {}".format(
68+
dtype, Artist.CONTEXT
69+
)
70+
)
6671

6772
return cls
6873

@@ -85,7 +90,7 @@ class Artist(object):
8590

8691
__ARTISTS_REGISTERED = False
8792

88-
AVAILABLE_CONTEXTS = ['Rhino', 'Grasshopper', 'Blender', 'Plotter']
93+
AVAILABLE_CONTEXTS = ["Rhino", "Grasshopper", "Blender", "Plotter"]
8994
CONTEXT = None
9095
ITEM_ARTIST = defaultdict(dict)
9196

@@ -95,7 +100,9 @@ def __new__(cls, item, **kwargs):
95100
Artist.__ARTISTS_REGISTERED = True
96101

97102
if item is None:
98-
raise ValueError('Cannot create an artist for None. Please ensure you pass a instance of a supported class.')
103+
raise ValueError(
104+
"Cannot create an artist for None. Please ensure you pass a instance of a supported class."
105+
)
99106

100107
cls = _get_artist_cls(item, **kwargs)
101108
PluginValidator.ensure_implementations(cls)

src/compas/data/__init__.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@
7979
from .json import json_load, json_loads, json_dump, json_dumps
8080

8181
__all__ = [
82-
'Data',
83-
'DataEncoder',
84-
'DataDecoder',
85-
'DecoderError',
86-
'is_sequence_of_int',
87-
'is_sequence_of_uint',
88-
'is_sequence_of_float',
89-
'is_int3',
90-
'is_float3',
91-
'is_float4x4',
92-
'json_load',
93-
'json_loads',
94-
'json_dump',
95-
'json_dumps',
96-
'validate_data'
82+
"Data",
83+
"DataEncoder",
84+
"DataDecoder",
85+
"DecoderError",
86+
"is_sequence_of_int",
87+
"is_sequence_of_uint",
88+
"is_sequence_of_float",
89+
"is_int3",
90+
"is_float3",
91+
"is_float4x4",
92+
"json_load",
93+
"json_loads",
94+
"json_dump",
95+
"json_dumps",
96+
"validate_data",
9797
]

src/compas/datastructures/mesh/slice.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from compas.geometry import dot_vectors
55

66

7-
__all__ = ['mesh_slice_plane']
7+
__all__ = ["mesh_slice_plane"]
88

99

1010
def mesh_slice_plane(mesh, plane):
@@ -45,7 +45,6 @@ def mesh_slice_plane(mesh, plane):
4545

4646

4747
class IntersectionMeshPlane(object):
48-
4948
def __init__(self, mesh, plane):
5049
self.mesh = mesh
5150
self.plane = plane
@@ -92,7 +91,10 @@ def positive(self):
9291
for key in vertices:
9392
faces += self.mesh.vertex_faces(key)
9493
faces = list(set(faces))
95-
vdict = {key: self.mesh.vertex_coordinates(key) for key in vertices + self.intersections}
94+
vdict = {
95+
key: self.mesh.vertex_coordinates(key)
96+
for key in vertices + self.intersections
97+
}
9698
fdict = [self.mesh.face_vertices(fkey) for fkey in faces]
9799
mesh = self.meshtype.from_vertices_and_faces(vdict, fdict)
98100
if self.is_mesh_closed:
@@ -103,7 +105,7 @@ def is_positive(self, key):
103105
o = self.plane.point
104106
n = self.plane.normal
105107
if key not in self.intersections:
106-
a = self.mesh.vertex_attributes(key, 'xyz')
108+
a = self.mesh.vertex_attributes(key, "xyz")
107109
oa = subtract_vectors(a, o)
108110
similarity = dot_vectors(n, oa)
109111
if similarity > 0.0:
@@ -122,7 +124,10 @@ def negative(self):
122124
for key in vertices:
123125
faces += self.mesh.vertex_faces(key)
124126
faces = list(set(faces))
125-
vdict = {key: self.mesh.vertex_coordinates(key) for key in vertices + self.intersections}
127+
vdict = {
128+
key: self.mesh.vertex_coordinates(key)
129+
for key in vertices + self.intersections
130+
}
126131
fdict = [self.mesh.face_vertices(fkey) for fkey in faces]
127132
mesh = self.meshtype.from_vertices_and_faces(vdict, fdict)
128133
if self.is_mesh_closed:
@@ -134,7 +139,7 @@ def is_negative(self, key):
134139
n = self.plane.normal
135140
if key in self.intersections:
136141
return False
137-
a = self.mesh.vertex_attributes(key, 'xyz')
142+
a = self.mesh.vertex_attributes(key, "xyz")
138143
oa = subtract_vectors(a, o)
139144
similarity = dot_vectors(n, oa)
140145
return similarity < 0.0
@@ -143,12 +148,14 @@ def intersect(self):
143148
intersections = []
144149
vertex_intersections = []
145150
for u, v in list(self.mesh.edges()):
146-
a = self.mesh.vertex_attributes(u, 'xyz')
147-
b = self.mesh.vertex_attributes(v, 'xyz')
151+
a = self.mesh.vertex_attributes(u, "xyz")
152+
b = self.mesh.vertex_attributes(v, "xyz")
148153
x = intersection_segment_plane((a, b), self.plane)
149154
if not x:
150155
continue
151-
if any([i != j for i, j in zip(x, a)]) and any([i != j for i, j in zip(x, b)]):
156+
if any([i != j for i, j in zip(x, a)]) and any(
157+
[i != j for i, j in zip(x, b)]
158+
):
152159
L_ax = length_vector(subtract_vectors(x, a))
153160
L_ab = length_vector(subtract_vectors(b, a))
154161
t = L_ax / L_ab
@@ -164,7 +171,11 @@ def intersect(self):
164171

165172
def split(self):
166173
for fkey in list(self.mesh.faces()):
167-
split = [key for key in self.mesh.face_vertices(fkey) if key in self.intersections]
174+
split = [
175+
key
176+
for key in self.mesh.face_vertices(fkey)
177+
if key in self.intersections
178+
]
168179
if len(split) == 2:
169180
u, v = split
170181
try:

src/compas/geometry/predicates/predicates_2.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88

99

1010
__all__ = [
11-
'is_ccw_xy',
12-
'is_colinear_xy',
13-
'is_polygon_convex_xy',
14-
'is_point_on_line_xy',
15-
'is_point_on_segment_xy',
16-
'is_point_on_polyline_xy',
17-
'is_point_in_triangle_xy',
18-
'is_point_in_polygon_xy',
19-
'is_point_in_convex_polygon_xy',
20-
'is_point_in_circle_xy',
21-
'is_polygon_in_polygon_xy',
22-
'is_intersection_line_line_xy',
23-
'is_intersection_segment_segment_xy',
11+
"is_ccw_xy",
12+
"is_colinear_xy",
13+
"is_polygon_convex_xy",
14+
"is_point_on_line_xy",
15+
"is_point_on_segment_xy",
16+
"is_point_on_polyline_xy",
17+
"is_point_in_triangle_xy",
18+
"is_point_in_polygon_xy",
19+
"is_point_in_convex_polygon_xy",
20+
"is_point_in_circle_xy",
21+
"is_polygon_in_polygon_xy",
22+
"is_intersection_line_line_xy",
23+
"is_intersection_segment_segment_xy",
2424
]
2525

2626

@@ -442,4 +442,6 @@ def is_intersection_segment_segment_xy(ab, cd):
442442
"""
443443
a, b = ab
444444
c, d = cd
445-
return is_ccw_xy(a, c, d) != is_ccw_xy(b, c, d) and is_ccw_xy(a, b, c) != is_ccw_xy(a, b, d)
445+
return is_ccw_xy(a, c, d) != is_ccw_xy(b, c, d) and is_ccw_xy(a, b, c) != is_ccw_xy(
446+
a, b, d
447+
)

src/compas_ghpython/__init__.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
import compas
2121
import compas_rhino
2222

23-
__version__ = '1.16.0'
23+
__version__ = "1.16.0"
2424

2525
if compas.is_rhino():
2626
from .utilities import * # noqa: F401 F403
2727

2828
__all__ = [
29-
'get_grasshopper_managedplugin_path',
30-
'get_grasshopper_library_path',
31-
'get_grasshopper_userobjects_path',
32-
'fetch_ghio_lib'
29+
"get_grasshopper_managedplugin_path",
30+
"get_grasshopper_library_path",
31+
"get_grasshopper_userobjects_path",
32+
"fetch_ghio_lib",
3333
]
3434
__all_plugins__ = [
35-
'compas_ghpython.install',
36-
'compas_ghpython.uninstall',
37-
'compas_ghpython.artists',
35+
"compas_ghpython.install",
36+
"compas_ghpython.uninstall",
37+
"compas_ghpython.artists",
3838
]
3939

4040

@@ -58,13 +58,17 @@ def get_grasshopper_managedplugin_path(version):
5858
managedplugins = compas_rhino._get_rhino_managedplugins_path(version)
5959

6060
if compas.WINDOWS:
61-
gh_managedplugin_path = os.path.join(managedplugins, 'Grasshopper')
61+
gh_managedplugin_path = os.path.join(managedplugins, "Grasshopper")
6262

6363
elif compas.OSX:
64-
gh_managedplugin_path = os.path.join(managedplugins, 'GrasshopperPlugin.rhp')
64+
gh_managedplugin_path = os.path.join(managedplugins, "GrasshopperPlugin.rhp")
6565

6666
if not os.path.exists(gh_managedplugin_path):
67-
raise Exception("The Grasshopper (managed) Plug-in folder does not exist in this location: {}".format(gh_managedplugin_path))
67+
raise Exception(
68+
"The Grasshopper (managed) Plug-in folder does not exist in this location: {}".format(
69+
gh_managedplugin_path
70+
)
71+
)
6872

6973
return gh_managedplugin_path
7074

@@ -76,7 +80,7 @@ def get_grasshopper_managedplugin_path(version):
7680

7781
def get_grasshopper_library_path(version):
7882
"""Retrieve Grasshopper's library (components) path"""
79-
return _get_grasshopper_special_folder(version, 'Libraries')
83+
return _get_grasshopper_special_folder(version, "Libraries")
8084

8185

8286
# =============================================================================
@@ -86,25 +90,27 @@ def get_grasshopper_library_path(version):
8690

8791
def get_grasshopper_userobjects_path(version):
8892
"""Retrieve Grasshopper's user objects path"""
89-
return _get_grasshopper_special_folder(version, 'UserObjects')
93+
return _get_grasshopper_special_folder(version, "UserObjects")
9094

9195

9296
# =============================================================================
9397
# GH_IO Dll
9498
# =============================================================================
9599

96100

97-
def fetch_ghio_lib(target_folder='temp'):
101+
def fetch_ghio_lib(target_folder="temp"):
98102
"""Fetch the GH_IO.dll library from the NuGet packaging system."""
99-
ghio_dll = 'GH_IO.dll'
100-
filename = 'lib/net48/' + ghio_dll
103+
ghio_dll = "GH_IO.dll"
104+
filename = "lib/net48/" + ghio_dll
101105

102-
response = urllib.request.urlopen('https://www.nuget.org/api/v2/package/Grasshopper/')
106+
response = urllib.request.urlopen(
107+
"https://www.nuget.org/api/v2/package/Grasshopper/"
108+
)
103109
dst_file = os.path.join(target_folder, ghio_dll)
104110
zip_file = zipfile.ZipFile(io.BytesIO(response.read()))
105111

106-
with zip_file.open(filename, 'r') as zipped_dll:
107-
with open(dst_file, 'wb') as fp:
112+
with zip_file.open(filename, "r") as zipped_dll:
113+
with open(dst_file, "wb") as fp:
108114
fp.write(zipped_dll.read())
109115

110116
return dst_file

0 commit comments

Comments
 (0)