Changeset 1295
- Timestamp:
- 02/21/24 18:04:48 (10 months ago)
- Location:
- framspy
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
framspy/FramsticksLib.py
r1265 r1295 222 222 elif method in (-2, -3): 223 223 if self.dissim_measure_density_distribution is None: 224 from dissimilarity.density Distribution import DensityDistribution224 from dissimilarity.density_distribution import DensityDistribution 225 225 self.dissim_measure_density_distribution = DensityDistribution(frams) 226 226 self.dissim_measure_density_distribution.frequency = (method == -3) -
framspy/dissimilarity/density_distribution.py
r1294 r1295 3 3 from ctypes import cdll 4 4 from ctypes.util import find_library 5 from alignmodel import align5 from .alignmodel import align 6 6 7 7 class DensityDistribution: 8 8 """Two dissimilarity measures based on the spatial distribution of two Models. The Model bounding box is divided into a grid of equally-sized cuboids, the number of which is the 'resolution' parameter cubed. Then the Model surface is covered with points; the density of the surface sampling is determined by the 'density' parameter. There are two versions of the measure. In the default version ('frequency'=False), a signature of each cuboid is the centroid and the number of samples. In the 'frequency'=True version, FFT is computed from the vector containing the number of samples in each cuboid. The final result of the dissimilarity measure is the distance between the signatures and it can be computed using EMD, L1, or L2 norms (the 'metric' parameter). 9 9 """ 10 11 libm = cdll.LoadLibrary(find_library('m')) # for disabling/enabling floating point exceptions (division by zero occurs in the EMD library) 10 11 OLD_FPEX = False # update floating point exception handling/pyemd problems (if still needed) for new python versions 12 if OLD_FPEX: 13 libm = cdll.LoadLibrary(find_library('m')) # for disabling/enabling floating point exceptions (division by zero occurs in the EMD library) 12 14 EPSILON = 0.0001 13 15 … … 291 293 dist_matrix = self.calculateDistanceMatrix(s1[0],s2[0]) 292 294 293 self.libm.fedisableexcept(0x04) # change default flag value - don't cause exceptions when dividing by 0 (pyemd does it) 295 if self.OLD_FPEX: 296 self.libm.fedisableexcept(0x04) # change default flag value - don't cause exceptions when dividing by 0 (pyemd does it) 294 297 295 298 if self.frequency: … … 298 301 out = emd(self.normalize(s1[1]),self.normalize(s2[1]),dist_matrix) 299 302 300 self.libm.feclearexcept(0x04) # restoring default flag values... 301 self.libm.feenableexcept(0x04) 303 if self.OLD_FPEX: 304 self.libm.feclearexcept(0x04) # restoring default flag values... 305 self.libm.feenableexcept(0x04) 302 306 303 307 else:
Note: See TracChangeset
for help on using the changeset viewer.