Skip to content

Commit 4c2a9e0

Browse files
committed
remove unused and update docstrings
1 parent b3220b0 commit 4c2a9e0

8 files changed

Lines changed: 48 additions & 78 deletions

File tree

src/compas_gmsh/__init__.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
from __future__ import print_function
2-
31
import os
4-
import compas
5-
62

73
__author__ = ["tom van mele"]
84
__copyright__ = "Block Research Group - ETH Zurich"
@@ -18,26 +14,4 @@
1814
DOCS = os.path.abspath(os.path.join(HOME, "docs"))
1915
TEMP = os.path.abspath(os.path.join(HOME, "temp"))
2016

21-
# Check if package is installed from git
22-
# If that's the case, try to append the current head's hash to __version__
23-
try:
24-
git_head_file = compas._os.absjoin(HOME, ".git", "HEAD")
25-
26-
if os.path.exists(git_head_file):
27-
# git head file contains one line that looks like this:
28-
# ref: refs/heads/master
29-
with open(git_head_file, "r") as git_head:
30-
_, ref_path = git_head.read().strip().split(" ")
31-
ref_path = ref_path.split("/")
32-
33-
git_head_refs_file = compas._os.absjoin(HOME, ".git", *ref_path)
34-
35-
if os.path.exists(git_head_refs_file):
36-
with open(git_head_refs_file, "r") as git_head_ref:
37-
git_commit = git_head_ref.read().strip()
38-
__version__ += "-" + git_commit[:8]
39-
40-
except Exception:
41-
pass
42-
4317
__all__ = ["HOME", "DATA", "DOCS", "TEMP"]

src/compas_gmsh/conversions/__init__.py

Whitespace-only changes.

src/compas_gmsh/models/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from .model import Model # noqa: F401
2-
from .shape import ShapeModel # noqa: F401
3-
from .mesh import MeshModel # noqa: F401
4-
from .csg import CSGModel # noqa: F401
1+
# ruff: noqa: F401
2+
3+
from .model import Model
4+
from .shape import ShapeModel
5+
from .mesh import MeshModel
6+
from .csg import CSGModel

src/compas_gmsh/models/csg.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from typing import List
2-
from typing import Tuple
3-
41
import compas.geometry
52
from compas.geometry import Box
63
from compas.geometry import Cylinder
@@ -9,7 +6,7 @@
96
from .model import Model
107

118

12-
def add_cylinder(self, cylinder: Cylinder) -> Tuple[int, int]:
9+
def add_cylinder(self, cylinder: Cylinder) -> tuple[int, int]:
1310
"""Add a cylinder to the model."""
1411
H = cylinder.height
1512
R = cylinder.radius
@@ -23,15 +20,15 @@ def add_cylinder(self, cylinder: Cylinder) -> Tuple[int, int]:
2320
return 3, tag
2421

2522

26-
def add_sphere(self, sphere: Sphere) -> Tuple[int, int]:
23+
def add_sphere(self, sphere: Sphere) -> tuple[int, int]:
2724
"""Add a sphere to the model."""
28-
x, y, z = sphere.point
25+
x, y, z = sphere.base
2926
R = sphere.radius
3027
tag = self.occ.addSphere(x, y, z, R)
3128
return 3, tag
3229

3330

34-
def add_box(self, box: Box) -> Tuple[int, int]:
31+
def add_box(self, box: Box) -> tuple[int, int]:
3532
"""Add a box to the model."""
3633
x0, y0, z0 = box.frame.point
3734
x = x0 - 0.5 * box.xsize
@@ -49,17 +46,17 @@ class CSGModel(Model):
4946
5047
Parameters
5148
----------
52-
tree : dict
49+
tree
5350
The CSG tree as a dictionary mapping operations to operands.
5451
The operations have to be one of ``{"union", "intersection", "difference"}``.
5552
The operands have to be lists of shapes or lists of dicts that are CSG trees themselves.
5653
At every level of the tree, there can be only one operation.
57-
name : str
54+
name
5855
The name of the model.
5956
6057
Attributes
6158
----------
62-
tree : dict
59+
tree
6360
The CSG tree as a dictionary mapping operations to operands.
6461
The operations have to be one of ``{"union", "intersection", "difference"}``.
6562
The operands have to be lists of shapes or lists of dicts that are CSG trees themselves.
@@ -69,7 +66,7 @@ class CSGModel(Model):
6966

7067
def __init__(self, tree: dict, name: str, **kwargs) -> None:
7168
super().__init__(name, **kwargs)
72-
self._tree = None
69+
self._tree = {}
7370
self.tree = tree
7471

7572
@property
@@ -94,13 +91,13 @@ def check(tree: dict) -> None:
9491
else:
9592
self._tree = tree
9693

97-
def add(self, shape: compas.geometry.Shape) -> Tuple[int, int]:
94+
def add(self, shape: compas.geometry.Shape) -> tuple[int, int]:
9895
"""
9996
Add a shape to the underlying OCC model.
10097
10198
Parameters
10299
----------
103-
shape : :class:`compas.geometry.Shape`
100+
shape
104101
A geometric shape.
105102
106103
Returns
@@ -125,7 +122,7 @@ def compute_tree(self) -> None:
125122
126123
"""
127124

128-
def walk(tree: dict) -> List[Tuple[int, int]]:
125+
def walk(tree: dict) -> list[tuple[int, int]]:
129126
operation = next(iter(tree))
130127
operands = tree[operation]
131128

src/compas_gmsh/models/mesh.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ def from_mesh(
2626
2727
Parameters
2828
----------
29-
mesh : :class:`Mesh`
29+
mesh
3030
A COMPAS mesh.
31-
name : str, optional
31+
name
3232
The name of the model.
33-
target_length : float, optional
33+
target_length
3434
Target value for the length of the mesh edges.
3535
3636
Returns
3737
-------
38-
:class:`MeshModel`
38+
MeshModel
3939
4040
"""
4141
model: MeshModel = cls(name)
@@ -69,7 +69,7 @@ def generate_mesh(self, dim: int = 2) -> None:
6969
7070
Parameters
7171
----------
72-
dim : int, optional
72+
dim
7373
The dimension of the mesh.
7474
7575
Returns
@@ -93,7 +93,7 @@ def find_point_at_vertex(self, vertex: int) -> int:
9393
9494
Parameters
9595
----------
96-
vertex : int
96+
vertex
9797
A vertex of the input mesh.
9898
9999
Returns
@@ -110,9 +110,9 @@ def mesh_targetlength_at_vertex(self, vertex: int, target: float) -> None:
110110
111111
Parameters
112112
----------
113-
vertex : int
113+
vertex
114114
The vertex identifier.
115-
target : float
115+
target
116116
The target length value.
117117
118118
Returns

src/compas_gmsh/models/shape.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from typing import List
2-
from typing import Tuple
3-
41
from compas.geometry import Box
52
from compas.geometry import Cylinder
63
from compas.geometry import Sphere
@@ -13,7 +10,7 @@ class ShapeModel(Model):
1310
Model for shape combinations.
1411
"""
1512

16-
def add_cylinder(self, cylinder: Cylinder) -> Tuple[int, int]:
13+
def add_cylinder(self, cylinder: Cylinder) -> tuple[int, int]:
1714
"""Add a cylinder to the model."""
1815
H = cylinder.height
1916
R = cylinder.radius
@@ -26,14 +23,14 @@ def add_cylinder(self, cylinder: Cylinder) -> Tuple[int, int]:
2623
tag = self.occ.add_cylinder(x0, y0, z0, dx, dy, dz, R)
2724
return 3, tag
2825

29-
def add_sphere(self, sphere: Sphere) -> Tuple[int, int]:
26+
def add_sphere(self, sphere: Sphere) -> tuple[int, int]:
3027
"""Add a sphere to the model."""
3128
x, y, z = sphere.frame.point
3229
R = sphere.radius
3330
tag = self.occ.add_sphere(x, y, z, R)
3431
return 3, tag
3532

36-
def add_box(self, box: Box) -> Tuple[int, int]:
33+
def add_box(self, box: Box) -> tuple[int, int]:
3734
"""Add a box to the model."""
3835
x0, y0, z0 = box.frame.point
3936
x = x0 - 0.5 * box.xsize
@@ -44,24 +41,24 @@ def add_box(self, box: Box) -> Tuple[int, int]:
4441

4542
def boolean_intersection(
4643
self,
47-
A: List[Tuple[int, int]],
48-
B: List[Tuple[int, int]],
44+
A: list[tuple[int, int]],
45+
B: list[tuple[int, int]],
4946
remove_objects: bool = True,
5047
remove_tools: bool = True,
51-
) -> List[Tuple[int, int]]:
48+
) -> list[tuple[int, int]]:
5249
"""
5350
Boolean intersection of two sets of shapes.
5451
5552
Parameters
5653
----------
57-
A : list of tuple
54+
A
5855
The *dimtags* of the *object* shapes.
59-
B : tuple
56+
B
6057
The *dimtags* of the *tool* shapes.
6158
6259
Returns
6360
-------
64-
list of tuple
61+
list[tuple[int, int]]
6562
The dimtags of the resulting shapes.
6663
6764
Notes
@@ -76,11 +73,11 @@ def boolean_intersection(
7673

7774
def boolean_union(
7875
self,
79-
A: List[Tuple[int, int]],
80-
B: List[Tuple[int, int]],
76+
A: list[tuple[int, int]],
77+
B: list[tuple[int, int]],
8178
remove_objects: bool = True,
8279
remove_tools: bool = True,
83-
) -> List[Tuple[int, int]]:
80+
) -> list[tuple[int, int]]:
8481
"""
8582
Boolean union of two sets of shapes.
8683
@@ -93,7 +90,7 @@ def boolean_union(
9390
9491
Returns
9592
-------
96-
list of tuple
93+
list[tuple[int, int]]
9794
The dimtags of the resulting shapes.
9895
9996
Notes
@@ -108,11 +105,11 @@ def boolean_union(
108105

109106
def boolean_difference(
110107
self,
111-
A: List[Tuple[int, int]],
112-
B: List[Tuple[int, int]],
108+
A: list[tuple[int, int]],
109+
B: list[tuple[int, int]],
113110
remove_objects: bool = True,
114111
remove_tools: bool = True,
115-
) -> List[Tuple[int, int]]:
112+
) -> list[tuple[int, int]]:
116113
"""
117114
Boolean difference of two sets of shapes.
118115
@@ -125,7 +122,7 @@ def boolean_difference(
125122
126123
Returns
127124
-------
128-
list of tuple
125+
list[tuple[int, int]]
129126
The dimtags of the resulting shapes.
130127
131128
Notes
@@ -140,11 +137,11 @@ def boolean_difference(
140137

141138
def boolean_fragment(
142139
self,
143-
A: List[Tuple[int, int]],
144-
B: List[Tuple[int, int]],
140+
A: list[tuple[int, int]],
141+
B: list[tuple[int, int]],
145142
remove_objects: bool = True,
146143
remove_tools: bool = True,
147-
) -> List[Tuple[int, int]]:
144+
) -> list[tuple[int, int]]:
148145
"""
149146
Boolean fragment of two sets of shapes.
150147
@@ -157,7 +154,7 @@ def boolean_fragment(
157154
158155
Returns
159156
-------
160-
list of tuple
157+
list[tuple[int, int]]
161158
The dimtags of the resulting shapes.
162159
163160
Notes

src/compas_gmsh/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ def algorithm(self, algo: MeshAlgorithm) -> None:
129129

130130
@property
131131
def lmin(self) -> float:
132-
gmsh.option.get_number("Mesh.CharacteristicLengthMin")
132+
return gmsh.option.get_number("Mesh.CharacteristicLengthMin")
133133

134134
@lmin.setter
135135
def lmin(self, value: float):
136136
gmsh.option.set_number("Mesh.CharacteristicLengthMin", value)
137137

138138
@property
139139
def lmax(self) -> float:
140-
gmsh.option.get_number("Mesh.CharacteristicLengthMax")
140+
return gmsh.option.get_number("Mesh.CharacteristicLengthMax")
141141

142142
@lmax.setter
143143
def lmax(self, value: float):

src/compas_gmsh/triangulation/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)