diff --git a/adze/util.py b/adze/util.py index 15862c4..693c228 100644 --- a/adze/util.py +++ b/adze/util.py @@ -7,12 +7,12 @@ poly_t = dict[str, NDArray] def build_empty() -> poly_t: - ''' + """ Build an empty Schlegel representation (containing no vertices). Returns: Empty Schelegel representation. - ''' + """ return { 'vertices': numpy.empty((0, 3), dtype=float), 'neighbors': numpy.empty((0, 3), dtype=int), @@ -103,13 +103,13 @@ def find_faces(neighbors: NDArray[numpy.integer]) -> list[NDArray[numpy.integer] faces_set.append(faces[i]) return faces_set - ''' + """ Starting at all vertices, take a step along all edges. If the vertex index decreases, stop traversal and mark the path for removal. Otherwise, continue stepping along the _next_ edge each time, until a) the vertex index decreases (stop and mark for removal) b) we reach the original vertex (stop, done with this path) - ''' + """ k = 1 mask = v_next > v_current v = numpy.vstack((edge_id, v_start, v_current, v_next))[:, mask] @@ -133,10 +133,10 @@ def find_faces(neighbors: NDArray[numpy.integer]) -> list[NDArray[numpy.integer] def _get_map(a, b): - ''' + """ Returns m such that a[m] == b Assumes that all elements appear exactly once in each array - ''' + """ if a.size == 0: return numpy.array(()), numpy.array(()) sa = a.argsort() @@ -147,9 +147,9 @@ def _get_map(a, b): def _get_map_rows(a, b): - ''' + """ Row-wise _get_map - ''' + """ dims = numpy.maximum(a.max(0), b.max(0)) + 1 a1d = numpy.ravel_multi_index(a.T, dims) b1d = numpy.ravel_multi_index(b.T, dims) @@ -157,10 +157,10 @@ def _get_map_rows(a, b): def _get_maps(a, b): - ''' + """ Returns m, n such that a[m] == b, b[n] == a Assumes that all elements appear exactly once in each array - ''' + """ if a.size == 0: return numpy.array(()), numpy.array(()) sa = a.argsort() @@ -174,9 +174,9 @@ def _get_maps(a, b): def _get_maps_rows(a, b): - ''' + """ Row-wise _get_maps - ''' + """ dims = numpy.maximum(a.max(0), b.max(0)) + 1 a1d = numpy.ravel_multi_index(a.T, dims) b1d = numpy.ravel_multi_index(b.T, dims) @@ -184,18 +184,18 @@ def _get_maps_rows(a, b): def _argsort_rows(a): - ''' + """ Row-wise argsort - ''' + """ dims = a.max(0) + 1 a1d = numpy.ravel_multi_index(a.T, dims) return numpy.argsort(a1d) def _searchsorted_rows(a, b): - ''' + """ Row-wise searchsorted - ''' + """ dims = numpy.maximum(a.max(0), b.max(0)) + 1 a1d = numpy.ravel_multi_index(a.T, dims) b1d = numpy.ravel_multi_index(b.T, dims) @@ -203,7 +203,7 @@ def _searchsorted_rows(a, b): def check_poly(poly: poly_t, check_connectivity: bool = True) -> None: - ''' + """ Verify that the polyhedron - has no out-of-bounds neighbors - has no duplicate neighbors @@ -217,7 +217,7 @@ def check_poly(poly: poly_t, check_connectivity: bool = True) -> None: Raises: Exception if the polyhedron fails a check - ''' + """ neighbors = poly['neighbors'] vertices = poly['vertices'] num_vertices = vertices.shape[0]