b1316a19bc2c0ad8647b523cafcb0516754869f8,trackpy/tracking.py,Hash_table,get_region,#Hash_table#Any#Any#,37

Before Change


            self.cached_shifts = shifts
        region = []
        for s in shifts:
            try:
                region.extend(self.hash_table[self.cord_to_indx(center + s)])
            except Hash_table.Out_of_hash_excpt:
                pass
        return region
    
    def add_point(self,point):
        self.hash_table[self.hash_fun(point.pos)].append(point)

After Change


        """
        hash_size = self.hash_dims        
        center = np.floor(point.pos/self.box_size)
        if any(center  >= hash_size) or any(center < 0):
            raise Hash_table.Out_of_hash_excpt("cord out of range")

        rrange = int(np.ceil(rrange/ self.box_size))

        // check if we have already computed the shifts
        if rrange == self.cached_rrange and self.cached_shifts is not None:
            shifts = self.cached_shifts   // if we have, use them
        // Other wise, generate them
        else:
            if self.spat_dims == 2:
                shifts = [np.array([j,k]) 
                            for j in range(-rrange,rrange + 1) 
                            for k in range(-rrange,rrange + 1)]
            elif self.spat_dims ==3:
                shifts = [np.array([j,k,m])
                            for j in range(-rrange,rrange + 1)
                            for k in range(-rrange,rrange + 1)
                            for m in range(-rrange,rrange + 1)]
            else:
                raise NotImplementedError("only 2 and 3 dimensions implemented")
            self.cached_rrange = rrange   // and save them
            self.cached_shifts = shifts
        region = []

        for s in shifts:
            cord = center + s
            if any(cord  >= hash_size) or any(cord < 0):
                continue
            indx = int(sum(cord * self.strides))
            region.extend(self.hash_table[indx])
        return region
    
    def add_point(self,point):
        Adds the `point` to the hash table.  Assumes that :py:attr:`point.pos` exists and
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: soft-matter/trackpy
Commit Name: b1316a19bc2c0ad8647b523cafcb0516754869f8
Time: 2012-09-17
Author: tcaswell@gmail.com
File Name: trackpy/tracking.py
Class Name: Hash_table
Method Name: get_region


Project Name: brian-team/brian2
Commit Name: fdb8ed82b7323e0e6b8492f84c2aff78bc72c2e5
Time: 2019-11-04
Author: marcel.stimberg@inserm.fr
File Name: brian2/tests/__init__.py
Class Name:
Method Name: run


Project Name: pyinstaller/pyinstaller
Commit Name: 98100abde55f1fb0ab455f95b9259c3adcdbab2c
Time: 2015-10-19
Author: h.goebel@crazy-compilers.com
File Name: PyInstaller/building/imphook.py
Class Name: ImportHook
Method Name: _process_excludedimports