Skip to content

Commit

Permalink
Remove slow cdist as scipy is now a hard dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
JDBetteridge committed Oct 4, 2024
1 parent 12b5ddd commit 4874b86
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions ngsPETSc/utils/firedrake/meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@

import numpy as np
from petsc4py import PETSc

try:
from scipy.spatial.distance import cdist
HAVE_SCIPY = True
except ImportError:
HAVE_SCIPY = False
from scipy.spatial.distance import cdist

import netgen
import netgen.meshing as ngm
Expand Down Expand Up @@ -77,18 +72,6 @@ def refineMarkedElements(self, mark):
raise NotImplementedError("No implementation for dimension other than 2 and 3.")


def _slow_cdist(XA, XB):
dist = np.zeros([len(XA), len(XB)])
for ii, a in enumerate(XA):
for jj, b in enumerate(XB):
dist[ii, jj] = np.linalg.norm(b - a)
return dist


if not HAVE_SCIPY:
cdist = PETSc.Log.EventDecorator()(_slow_cdist)


@PETSc.Log.EventDecorator()
def find_permutation(points_a, points_b, tol=1e-5):
""" Find all permutations between a list of two sets of points.
Expand Down

0 comments on commit 4874b86

Please sign in to comment.