cytriangle 1.0.1__cp311-cp311-macosx_14_0_arm64.whl → 1.0.2__cp311-cp311-macosx_14_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cytriangle might be problematic. Click here for more details.

Binary file
cytriangle/cytriangle.pyx CHANGED
@@ -1,4 +1,3 @@
1
- from cytriangle.ctriangle cimport triangulateio
2
1
  from cytriangle.ctriangle cimport triangulate as ctriangulate
3
2
  from cytriangle.cytriangleio cimport TriangleIO
4
3
  import re
@@ -49,7 +48,7 @@ cdef class CyTriangle:
49
48
  self._in = TriangleIO(input_dict)
50
49
  else:
51
50
  self._in = TriangleIO()
52
- self._out = TriangleIO(kind='out')
51
+ self._out = TriangleIO()
53
52
  self._vorout = TriangleIO()
54
53
 
55
54
  @property
@@ -75,23 +74,24 @@ cdef class CyTriangle:
75
74
 
76
75
  def validate_input_flags(self, opts):
77
76
  if "r" in opts:
78
- if not 'triangles' in self._in.to_dict():
77
+ if 'triangles' not in self._in.to_dict():
79
78
  raise ValueError("Triangle list must be provided when using 'r' flag")
80
79
  if "p" in opts:
81
- if not 'segments' in self._in.to_dict():
80
+ if 'segments' not in self._in.to_dict():
82
81
  raise ValueError("Segment list must be provided when using 'p' flag")
83
82
  if "a" in opts:
84
83
  if not ('triangle_max_area' in self._in.to_dict() or 'A'
85
- in opts or bool(re.search('a[\d.*.]+\d.*', opts))):
86
- raise ValueError(f"""When using 'a' flag for area constraints, a global
84
+ in opts or bool(re.search(r'a[\d.*.]+\d.*', opts))):
85
+ raise ValueError("""When using 'a' flag for area constraints, a global
87
86
  area flag (e.g. a0.2), 'A' flag, or local triangle area
88
87
  constraint list (e.g. [3.0, 1.0]) must be provided""")
89
88
  if "q" in opts:
90
- if not bool(re.search('q[\d.*.]+\d.*', opts)):
91
- raise ValueError("When using 'q' flag for minimum angles, an angle must be provided")
89
+ if not bool(re.search(r'q[\d.*.]+\d.*', opts)):
90
+ raise ValueError("""When using 'q' flag for minimum angles, an angle
91
+ must be provided""")
92
92
 
93
93
  # generic triangulation that accepts any switch
94
- cpdef triangulate(self, triflags=''):
94
+ cpdef triangulate(self, triflags='', verbose=False):
95
95
  """
96
96
  Runs the main triangulation method on the in_ object with any additional
97
97
  user flags input as triflags.
@@ -121,27 +121,31 @@ cdef class CyTriangle:
121
121
  - Check the consistency and Delaunay property of the mesh (-C).
122
122
 
123
123
  """
124
- if triflags: self.validate_input_flags(triflags)
125
- opts = f"Qz{triflags}".encode('utf-8')
126
- if ctriangulate(opts, self._in._io, self._out._io, self._vorout._io) is not None:
124
+ if triflags:
125
+ self.validate_input_flags(triflags)
126
+ opts = f"{'Q' if not verbose else 'V'}z{triflags}".encode('utf-8')
127
+ if ctriangulate(opts, self._in._io, self._out._io, self._vorout._io) \
128
+ is not None:
127
129
  raise RuntimeError('Triangulation failed')
128
130
  return self.out
129
131
 
130
- cpdef delaunay(self):
132
+ cpdef delaunay(self, verbose=False):
131
133
  """
132
- Run the main triangulation method on the in_ object with *only* -Qz flags enabled.
134
+ Run the main triangulation method on the in_ object with *only* -Qz
135
+ flags enabled.
133
136
 
134
137
  - Q Quiet: suppresses all output messages from Triangle library
135
138
 
136
139
  - z Numbers all items starting from zero (zero-indexed) rather than one.
137
140
 
138
141
  """
139
- opts = "Qz".encode('utf-8')
140
- if ctriangulate(opts, self._in._io, self._out._io, self._vorout._io) is not None:
142
+ opts = f"{'Q' if not verbose else 'V'}z".encode('utf-8')
143
+ if ctriangulate(opts, self._in._io, self._out._io, self._vorout._io) \
144
+ is not None:
141
145
  raise RuntimeError('Delaunay triangulation failed')
142
146
  return self.out
143
147
 
144
- cpdef convex_hull(self):
148
+ cpdef convex_hull(self, verbose=False):
145
149
  """
146
150
  Run the main triangulation method on the in_ object with -Qzc flags enabled.
147
151
 
@@ -152,12 +156,14 @@ cdef class CyTriangle:
152
156
  - c Encloses the convex hull with segments
153
157
 
154
158
  """
155
- opts = f"Qzc".encode('utf-8')
156
- if ctriangulate(opts, self._in._io, self._out._io, self._vorout._io) is not None:
157
- raise RuntimeError('Delaunay triangulation and convex hull construction failed')
159
+ opts = f"{'Q' if not verbose else 'V'}zc".encode('utf-8')
160
+ if ctriangulate(opts, self._in._io, self._out._io, self._vorout._io) \
161
+ is not None:
162
+ raise RuntimeError("""Delaunay triangulation and convex hull
163
+ construction failed""")
158
164
  return self.out
159
165
 
160
- cpdef voronoi(self):
166
+ cpdef voronoi(self, verbose=False):
161
167
  """
162
168
  Run the main triangulation method on the in_ object with -Qzv flags enabled.
163
169
 
@@ -168,11 +174,14 @@ cdef class CyTriangle:
168
174
  - v Generates a Voronoi diagram.
169
175
 
170
176
  """
171
- opts = f"Qzv".encode('utf-8')
172
- if ctriangulate(opts, self._in._io, self._out._io, self._vorout._io) is not None:
173
- raise RuntimeError('Delaunay triangulation and generation of voronoi diagram failed')
177
+ opts = f"{'Q' if not verbose else 'V'}zv".encode('utf-8')
178
+ if ctriangulate(opts, self._in._io, self._out._io, self._vorout._io) \
179
+ is not None:
180
+ raise RuntimeError("""Delaunay triangulation and generation of
181
+ voronoi diagram failed""")
174
182
  return self.out
175
183
 
184
+
176
185
  def triangulate(input_dict, flags):
177
186
  """
178
187
  Triangulates an input dict with the following properties: