How to use the parmap.starmap function in parmap

To help you get started, we’ve selected a few parmap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeehio / parmap / test_parmap.py View on Github external
def test_starmap(self):
        items = [(1, 2), (3, 4), (5, 6)]
        pfalse = parmap.starmap(_identity, items, 5, 6, pm_parallel=False)
        ptrue = parmap.starmap(_identity, items, 5, 6, pm_parallel=True)
        self.assertEqual(pfalse, ptrue)
github zeehio / parmap / test_parmap.py View on Github external
def test_starmap(self):
        items = [(1, 2), (3, 4), (5, 6)]
        pfalse = parmap.starmap(_identity, items, 5, 6, pm_parallel=False)
        ptrue = parmap.starmap(_identity, items, 5, 6, pm_parallel=True)
        self.assertEqual(pfalse, ptrue)
github patrick-dd / landsat-landstats / data_cleaning.py View on Github external
"""
        self.ncols = self.satellite_gdal.RasterXSize / 2
        self.nrows = self.satellite_gdal.RasterYSize / 2
        self.length_df = self.nrows * self.ncols
        print 'Columns, rows', self.ncols, self.nrows
        cols_grid, rows_grid = np.meshgrid(
                    range(0, self.ncols), 
                    range(0, self.nrows))
        self.cols_grid = cols_grid.flatten()
        self.rows_grid = rows_grid.flatten()
        print 'Checking the meshgrid procedure works'
        # getting a series of lat lon points for each pixel
        self.geotransform = self.satellite_gdal.GetGeoTransform()
        print 'Getting locations'
        self.location_series = np.array(parmap.starmap(
                        pixel_to_coordinates, 
                        zip(self.cols_grid, self.rows_grid), 
                        self.geotransform,
                        processes = self.processes))
        print 'Converting to Points'
        pool = Pool(self.processes)
        self.location_series = pool.map(
                        point_wrapper, 
                        self.location_series)
github patrick-dd / landsat-landstats / data_cleaning.py View on Github external
Have to shuffle here to ensure that the last ten percent isn't just
            the southern most rows of information
        """
        # Getting the sum of urban pixels for each patch
        self.pop_array = self.df_image['pop_density'].fillna(0)
        self.pop_array = np.array(
                self.pop_array).reshape((self.nrows, self.ncols))
        print 'extract patches'
        self.image_slicer(self.pop_array)
        print 'get locations for individual frames'
        pool = Pool(self.processes)
        cols_grid = pool.map(adder, self.indices[:,0])
        rows_grid = pool.map(adder, self.indices[:,1])
        print 'Max of cols grid after slicing:',  max(cols_grid)
        print 'Max of rows grid after slicing:',  max(rows_grid)
        self.frame_location_series = parmap.starmap(
                pixel_to_coordinates,
                zip(cols_grid, rows_grid), self.geotransform, 
                processes=self.processes)
        print 'converting locations to Points'
        self.frame_location_series = \
                pool.map(Point, self.frame_location_series)
        pop_count = np.array([np.mean(patch) for patch in self.patches])
        self.df_sample = pd.DataFrame(pop_count, columns=['pop_ave'])
        # Getting the locations
        self.df_sample['location'] = self.frame_location_series
        # Creating sample weights 
        seed  =1975
        self.pop_mean_sample = self.df_sample.sample(
                frac=self.sample_rate,
                replace=True,
                weights='pop_ave',

parmap

map and starmap implementations passing additional arguments and parallelizing if possible

Apache-2.0
Latest version published 1 year ago

Package Health Score

50 / 100
Full package analysis

Similar packages