Changeset 1295


Ignore:
Timestamp:
02/21/24 18:04:48 (8 weeks ago)
Author:
Maciej Komosinski
Message:

Updated for Python 3.9+

Location:
framspy
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • framspy/FramsticksLib.py

    r1265 r1295  
    222222                elif method in (-2, -3):
    223223                        if self.dissim_measure_density_distribution is None:
    224                                 from dissimilarity.densityDistribution import DensityDistribution
     224                                from dissimilarity.density_distribution import DensityDistribution
    225225                                self.dissim_measure_density_distribution = DensityDistribution(frams)
    226226                        self.dissim_measure_density_distribution.frequency = (method == -3)
  • framspy/dissimilarity/density_distribution.py

    r1294 r1295  
    33from ctypes import cdll
    44from ctypes.util import find_library
    5 from alignmodel import align
     5from .alignmodel import align
    66
    77class DensityDistribution:
    88    """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).
    99    """
    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)
    1214    EPSILON = 0.0001
    1315   
     
    291293                dist_matrix = self.calculateDistanceMatrix(s1[0],s2[0])
    292294
    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)
    294297
    295298            if self.frequency:
     
    298301                out = emd(self.normalize(s1[1]),self.normalize(s2[1]),dist_matrix)
    299302
    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)
    302306
    303307        else:
Note: See TracChangeset for help on using the changeset viewer.