From 3b15e2f508712cbd2a2569ce93cc515ed9094287 Mon Sep 17 00:00:00 2001 From: yemeen Date: Thu, 24 Apr 2025 15:15:34 -0400 Subject: [PATCH 1/3] remove parallel tag on shape_descriptor --- src/ect/ect_graph.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/ect/ect_graph.py b/src/ect/ect_graph.py index 4eec3b6..7edd271 100644 --- a/src/ect/ect_graph.py +++ b/src/ect/ect_graph.py @@ -55,8 +55,7 @@ def _ensure_directions(self, graph_dim, theta=None): """Ensures directions is a valid Directions object of correct dimension""" if self.directions is None: if self.num_dirs is None: - raise ValueError( - "Either 'directions' or 'num_dirs' must be provided.") + raise ValueError("Either 'directions' or 'num_dirs' must be provided.") self.directions = Directions.uniform(self.num_dirs, dim=graph_dim) elif isinstance(self.directions, list): # if list of vectors, convert to Directions object @@ -127,12 +126,10 @@ def calculate( # override with theta if provided directions = ( - self.directions if theta is None else Directions.from_angles([ - theta]) + self.directions if theta is None else Directions.from_angles([theta]) ) - simplex_projections = self._compute_simplex_projections( - graph, directions) + simplex_projections = self._compute_simplex_projections(graph, directions) ect_matrix = self._compute_directional_transform( simplex_projections, self.thresholds, self.shape_descriptor, self.dtype @@ -162,11 +159,9 @@ def _compute_simplex_projections( if isinstance(graph, EmbeddedCW) and len(graph.faces) > 0: node_to_index = {n: i for i, n in enumerate(graph.node_list)} - face_indices = [[node_to_index[v] for v in face] - for face in graph.faces] + face_indices = [[node_to_index[v] for v in face] for face in graph.faces] face_maxes = np.array( - [np.max(node_projections[face, :], axis=0) - for face in face_indices] + [np.max(node_projections[face, :], axis=0) for face in face_indices] ) simplex_projections.append(face_maxes) @@ -212,7 +207,7 @@ def _compute_directional_transform( return result @staticmethod - @njit(parallel=True, fastmath=True) + @njit(fastmath=True) def shape_descriptor(simplex_counts_list): """Calculate shape descriptor from simplex counts (Euler characteristic)""" chi = 0 From 947bd2eb91d6704b6f7e1f1b1318d92da478d050 Mon Sep 17 00:00:00 2001 From: yemeen Date: Thu, 24 Apr 2025 15:21:49 -0400 Subject: [PATCH 2/3] Bump version to 1.0.3 in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 18aa335..7b0b845 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "ect" -version = "1.0.2" +version = "1.0.3" authors = [ { name="Liz Munch", email="muncheli@msu.edu" }, ] From 3cd51a0b96c0cf96e270844d019a2caccb2fd511 Mon Sep 17 00:00:00 2001 From: yemeen Date: Thu, 24 Apr 2025 15:31:20 -0400 Subject: [PATCH 3/3] Update List type for simplex_projections and sorted_projections --- src/ect/ect_graph.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ect/ect_graph.py b/src/ect/ect_graph.py index 7edd271..3a6c5ba 100644 --- a/src/ect/ect_graph.py +++ b/src/ect/ect_graph.py @@ -1,5 +1,6 @@ import numpy as np from numba import prange, njit +from numba.typed import List from typing import Optional, Union from .embed_cw import EmbeddedCW @@ -145,7 +146,7 @@ def _compute_simplex_projections( self, graph: Union[EmbeddedGraph, EmbeddedCW], directions ): """Compute projections of each simplex (vertices, edges, faces)""" - simplex_projections = [] + simplex_projections = List() node_projections = self._compute_node_projections( graph.coord_matrix, directions ) @@ -187,7 +188,7 @@ def _compute_directional_transform( num_thresh = thresholds.shape[0] result = np.empty((num_dir, num_thresh), dtype=dtype) - sorted_projections = [] + sorted_projections = List() for proj in simplex_projections_list: sorted_proj = np.empty_like(proj) for i in prange(num_dir): @@ -197,7 +198,7 @@ def _compute_directional_transform( for j in prange(num_thresh): thresh = thresholds[j] for i in range(num_dir): - simplex_counts_list = [] + simplex_counts_list = List() for k in range(len(sorted_projections)): projs = sorted_projections[k][:, i] simplex_counts_list.append(