Skip to content

Commit d5bab1d

Browse files
committed
get rid of all unstructured stuff
1 parent 158f416 commit d5bab1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+210
-111
lines changed

src/compas/colors/color.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class Color(Data):
4040
Transparency setting.
4141
If ``alpha = 0.0``, the color is fully transparent.
4242
If ``alpha = 1.0``, the color is fully opaque.
43+
name : str, optional
44+
The name of the color.
4345
4446
Attributes
4547
----------
@@ -152,8 +154,12 @@ class Color(Data):
152154
"required": ["red", "green", "blue", "alpha"],
153155
}
154156

155-
def __init__(self, red, green, blue, alpha=1.0, **kwargs):
156-
super(Color, self).__init__(**kwargs)
157+
@property
158+
def __data__(self):
159+
return {"red": self.r, "green": self.g, "blue": self.b, "alpha": self.a}
160+
161+
def __init__(self, red, green, blue, alpha=1.0, name=None):
162+
super(Color, self).__init__(name=name)
157163
self._r = 1.0
158164
self._g = 1.0
159165
self._b = 1.0
@@ -184,14 +190,6 @@ def __iter__(self):
184190
def __eq__(self, other):
185191
return all(a == b for a, b in zip(self, other))
186192

187-
# --------------------------------------------------------------------------
188-
# Data
189-
# --------------------------------------------------------------------------
190-
191-
@property
192-
def __data__(self):
193-
return {"red": self.r, "green": self.g, "blue": self.b, "alpha": self.a}
194-
195193
# --------------------------------------------------------------------------
196194
# Properties
197195
# --------------------------------------------------------------------------

src/compas/colors/colordict.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class ColorDict(Data):
1313
----------
1414
default : :class:`compas.colors.Color`
1515
The default color to use if the requested key is not in the dictionary.
16+
name : str, optional
17+
The name of the color dictionary.
1618
1719
Attributes
1820
----------
@@ -21,8 +23,12 @@ class ColorDict(Data):
2123
2224
"""
2325

24-
def __init__(self, default, **kwargs):
25-
super(ColorDict, self).__init__(**kwargs)
26+
@property
27+
def __data__(self):
28+
return {"default": self.default.__data__, "dict": self._dict}
29+
30+
def __init__(self, default, name=None):
31+
super(ColorDict, self).__init__(name=name)
2632
self._default = None
2733
self.default = default
2834
self._dict = {}
@@ -57,10 +63,6 @@ def __len__(self):
5763
def __contains__(self, key):
5864
return key in self._dict
5965

60-
@property
61-
def __data__(self):
62-
return {"default": self.default.data, "dict": self._dict}
63-
6466
def items(self):
6567
return self._dict.items()
6668

src/compas/datastructures/assembly/assembly.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class Assembly(Datastructure):
1414
----------
1515
name : str, optional
1616
The name of the assembly.
17+
**kwargs : dict, optional
18+
Additional keyword arguments, which are stored in the attributes dict.
1719
1820
Attributes
1921
----------
@@ -49,8 +51,8 @@ def __from_data__(cls, data):
4951
assembly._parts = {part.guid: part.key for part in assembly.parts()} # type: ignore
5052
return assembly
5153

52-
def __init__(self, name=None):
53-
super(Assembly, self).__init__(name=name)
54+
def __init__(self, name=None, **kwargs):
55+
super(Assembly, self).__init__(kwargs, name=name)
5456
self.graph = Graph()
5557
self._parts = {}
5658

src/compas/datastructures/cell_network/cell_network.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class CellNetwork(Datastructure):
5454
Default values for cell attributes.
5555
name : str, optional
5656
The name of the cell network.
57+
**kwargs : dict, optional
58+
Additional keyword arguments, which are stored in the attributes dict.
5759
5860
Attributes
5961
----------
@@ -228,8 +230,9 @@ def __init__(
228230
default_face_attributes=None,
229231
default_cell_attributes=None,
230232
name=None,
233+
**kwargs
231234
):
232-
super(CellNetwork, self).__init__(name=name)
235+
super(CellNetwork, self).__init__(kwargs, name=name)
233236
self._max_vertex = -1
234237
self._max_face = -1
235238
self._max_cell = -1

src/compas/datastructures/datastructure.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
class Datastructure(Data):
99
"""Base class for all data structures."""
1010

11+
def __init__(self, attributes=None, name=None):
12+
super(Datastructure, self).__init__(name=name)
13+
self.attributes = attributes or {}
14+
1115
def transform(self, transformation):
1216
"""Transforms the data structure.
1317

src/compas/datastructures/graph/graph.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class Graph(Datastructure):
5959
Default values for edge attributes.
6060
name : str, optional
6161
The name of the graph.
62+
**kwargs : dict, optional
63+
Additional keyword arguments, which are stored in the attributes dict.
6264
6365
Attributes
6466
----------
@@ -152,8 +154,8 @@ def __from_data__(cls, data):
152154
graph._max_node = data.get("max_node", graph._max_node)
153155
return graph
154156

155-
def __init__(self, default_node_attributes=None, default_edge_attributes=None, name=None):
156-
super(Graph, self).__init__(name=None)
157+
def __init__(self, default_node_attributes=None, default_edge_attributes=None, name=None, **kwargs):
158+
super(Graph, self).__init__(kwargs, name=name)
157159
self._max_node = -1
158160
self.node = {}
159161
self.edge = {}

src/compas/datastructures/mesh/mesh.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class Mesh(Datastructure):
9292
Default values for face attributes.
9393
name : str, optional
9494
Then name of the mesh.
95+
**kwargs : dict, optional
96+
Additional keyword arguments, which are stored in the attributes dict.
9597
9698
Attributes
9799
----------
@@ -229,9 +231,14 @@ def __from_data__(cls, data):
229231
return mesh
230232

231233
def __init__(
232-
self, default_vertex_attributes=None, default_edge_attributes=None, default_face_attributes=None, name=None
234+
self,
235+
default_vertex_attributes=None,
236+
default_edge_attributes=None,
237+
default_face_attributes=None,
238+
name=None,
239+
**kwargs
233240
):
234-
super(Mesh, self).__init__(name=name)
241+
super(Mesh, self).__init__(kwargs, name=name)
235242
self._max_vertex = -1
236243
self._max_face = -1
237244
self.vertex = {}

src/compas/datastructures/tree/tree.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,15 @@ def traverse(self, strategy="depthfirst", order="preorder"):
201201

202202

203203
class Tree(Datastructure):
204-
"""A hierarchical data structure that organizes elements into parent-child relationships. The tree starts from a unique root node, and every node (excluding the root) has exactly one parent.
204+
"""A hierarchical data structure that organizes elements into parent-child relationships.
205+
The tree starts from a unique root node, and every node (excluding the root) has exactly one parent.
205206
206207
Parameters
207208
----------
208209
name : str, optional
209210
The name of the tree.
211+
**kwargs : dict, optional
212+
Additional keyword arguments, which are stored in the attributes dict.
210213
211214
Attributes
212215
----------
@@ -260,8 +263,8 @@ def __from_data__(cls, data):
260263
tree.add(root)
261264
return tree
262265

263-
def __init__(self, name=None):
264-
super(Tree, self).__init__(name=name)
266+
def __init__(self, name=None, **kwargs):
267+
super(Tree, self).__init__(kwargs, name=name)
265268
self._root = None
266269

267270
@property

src/compas/datastructures/volmesh/volmesh.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class VolMesh(Datastructure):
6161
Default values for cell attributes.
6262
name : str, optional
6363
The name of the volmesh.
64+
**kwargs : dict, optional
65+
Additional keyword arguments, which are stored in the attributes dict.
6466
6567
Attributes
6668
----------
@@ -201,8 +203,9 @@ def __init__(
201203
default_face_attributes=None,
202204
default_cell_attributes=None,
203205
name=None,
206+
**kwargs
204207
):
205-
super(VolMesh, self).__init__(name=name)
208+
super(VolMesh, self).__init__(kwargs, name=name)
206209
self._max_vertex = -1
207210
self._max_face = -1
208211
self._max_cell = -1

src/compas/geometry/brep/brep.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ class Brep(Geometry):
7676
This class serves as an interface for a Brep and allows instantiating a Brep object depending on the available Backend.
7777
Note: this is not a full implementation of Brep and rather relies on COMPAS's plugin system for actual implementation.
7878
79+
Parameters
80+
----------
81+
name : str, optional
82+
The name of the Brep.
83+
7984
Attributes
8085
----------
8186
area : float, read-only
@@ -149,8 +154,8 @@ def __from_data__(cls, data):
149154
def __new__(cls, *args, **kwargs):
150155
return new_brep(cls, *args, **kwargs)
151156

152-
def __init__(self, *args, **kwargs):
153-
super(Brep, self).__init__(*args, **kwargs)
157+
def __init__(self, *args, name=None):
158+
super(Brep, self).__init__(*args, name=name)
154159

155160
def __str__(self):
156161
lines = [

0 commit comments

Comments
 (0)