Changeset 1214 for framspy/dissimilarity


Ignore:
Timestamp:
04/15/23 03:33:20 (21 months ago)
Author:
Maciej Komosinski
Message:

The number of "steps" has now the interpretation of the number of intervals

File:
1 edited

Legend:

Unmodified
Added
Removed
  • framspy/dissimilarity/density-distribution.py

    r1210 r1214  
    1212        Args:
    1313            density (int, optional): density of samplings for frams.ModelGeometry . Defaults to 10.
    14             steps (int, optional): How many steps is used for sampling space of voxels,
    15                 The higher value the more accurate sampling and the longer calculations. Defaults to 3.
     14            steps (int, optional): How many steps are used for sampling the space of voxels,
     15                The higher the value, the more accurate the sampling and the longer the calculations. Defaults to 3.
    1616            reduce (bool, optional): If we should use reduction to remove blank samples. Defaults to True.
    1717            frequency (bool, optional): If we should use frequency distribution. Defaults to False.
     
    7373    def calculateDistanceMatrix(self,array1, array2):
    7474        """
    75 
    7675        Args:
    7776            array1 ([type]): array of size n with points representing firsts model
     
    173172
    174173    def getSignaturesForPair(self,array1,array2):
    175         """generates signatures for given pair of models represented by array of voxels.
     174        """Generates signatures for given pair of models represented by array of voxels.
    176175        We calculate space for given models by taking the extremas for each axis and dividing the space by the number of steps.
    177176        This divided space generate us samples which contains points. Each sample will have new coordinates which are mean of all points from it and weight
     
    182181            array2 (np.array(np.array(,dtype=float))): array with voxels representing model2
    183182            steps (int, optional): How many steps is used for sampling space of voxels. Defaults to self.steps (3).
    184 
     183               
    185184        Returns:
    186185            s1 ([np.array(,dtype=np.float64),np.array(,dtype=np.float64)]): [coordinates of samples, weights]
     
    188187        """
    189188
    190         min_x = np.min([np.min(array1[:,0]),np.min(array2[:,0])])
     189        min_x = np.min([np.min(array1[:,0]),np.min(array2[:,0])])   
    191190        max_x = np.max([np.max(array1[:,0]),np.max(array2[:,0])])
    192191        min_y = np.min([np.min(array1[:,1]),np.min(array2[:,1])])
     
    195194        max_z = np.max([np.max(array1[:,2]),np.max(array2[:,2])])
    196195
    197         x_steps,x_step = np.linspace(min_x,max_x,self.steps,retstep=True)
    198         y_steps,y_step = np.linspace(min_y,max_y,self.steps,retstep=True)
    199         z_steps,z_step = np.linspace(min_z,max_z,self.steps,retstep=True)
     196        # We request self.steps+1 samples since we need self.steps intervals
     197        x_steps,x_step = np.linspace(min_x,max_x,self.steps+1,retstep=True)
     198        y_steps,y_step = np.linspace(min_y,max_y,self.steps+1,retstep=True)
     199        z_steps,z_step = np.linspace(min_z,max_z,self.steps+1,retstep=True)
    200200       
    201201        for intervals in (x_steps, y_steps, z_steps):  # EPSILON subtracted to deal with boundary voxels (one-sided open intervals and comparisons in loops in function getSignatures())
     
    212212
    213213    def getVoxels(self,geno):
    214         """ Generates voxels for genotype using frams.ModelGeometry
     214        """Generates voxels for genotype using frams.ModelGeometry
    215215
    216216        Args:
     
    230230
    231231    def calculateDissimforVoxels(self, voxels1, voxels2):
    232         """ Calculate EMD for pair of voxels representing models.
     232        """Calculates EMD for pair of voxels representing models.
    233233        Args:
    234234            voxels1 np.array([np.array(,dtype=float)]: list of voxels representing model1.
     
    296296
    297297    def calculateDissimforGeno(self, geno1, geno2):
    298         """ Calculate EMD for pair of genos.
     298        """Calculates EMD for pair of genos.
    299299        Args:
    300300            geno1 (string): representation of model1 in one of the formats handled by frams http://www.framsticks.com/a/al_genotype.html
     
    322322    def getDissimilarityMatrix(self,listOfGeno):
    323323        """
    324 
    325324        Args:
    326325            listOfGeno ([string]): list of strings representing genotypes in one of the formats handled by frams http://www.framsticks.com/a/al_genotype.html
Note: See TracChangeset for help on using the changeset viewer.