romspline/random_seeds.py
def make(self, x, y, Nseeds, parallel=True):
    """Make reduced-order splines for Nseeds number of random sets of seed points.
    
    Input
    -----
      x        -- samples
      y        -- data to be downsampled
      Nseeds   -- number of random sets of seed points
      parallel -- parallelize the computation for each random seed set?
                  (default True)
    
    Attributes
    ----------
      errors -- greedy errors associated with each random set of seed points
      sizes  -- reduced data sizes from each random set of seed points
      seeds  -- the full set of random seed points
      Xs     -- reduced data from each random set of seed points
    
    Comments
    --------
    The `parallel` option also accepts positive integers indicating the
    number of processors that the user wants to use. 
    
    Parallelization uses some features from the concurrent.futures module.
    """
    
    # Allocate some memory
    self.errors = np.zeros(Nseeds, dtype='double')                # Greedy errors
    self.sizes = np.zeros(Nseeds, dtype='double')                 # Sizes of each reduced data
    self.seeds = np.zeros((Nseeds, self._deg+1), dtype='double')  # All seeds
    self.Xs = []                                                  # Reduced data for each seed
    
    if (parallel is False) or (state._PARALLEL is False):
      for nn in range(Nseeds):
        seeds = np.sort( np.random.choice(range(len(x)), self._deg+1, replace=False) )
        self.errors[nn], self.sizes[nn], self.seeds[nn], Xs = _randomSeeds(x, y, seeds, tol=self._tol, rel=self._rel, deg=self._deg)
        self.Xs.append(Xs)
    elif state._PARALLEL is True:
      # Determine the number of processes to run on
      if parallel is True:
        try:
          numprocs = cpu_count()
        except NotImplementedError:
          numprocs = 1
      else:
        numprocs = parallel
      
      # Create a parallel process executor
      executor = ProcessPoolExecutor(max_workers=numprocs)
      
      # Build reduced-order splines for many random sets of seed points
      output = []
      for nn in range(Nseeds):
        seeds = np.sort( np.random.choice(range(len(x)), self._deg+1, replace=False) )
        output.append(executor.submit(_randomSeeds, x, y, seeds, tol=self._tol, rel=self._rel, deg=self._deg))
      
      # Gather the results as they complete
      #for ii, oo in enumerate(as_completed(output)):
      for ii, oo in enumerate(output):
        self.errors[ii], self.sizes[ii], self.seeds[ii], Xs = oo.result()
        self.Xs.append(Xs)
    
    self._made = True
Make reduced-order splines for Nseeds number of random sets of seed points.
    
    Input
    -----
      x        -- samples
      y        -- data to be downsampled
      Nseeds   -- number of random sets of seed points
      parallel -- parallelize the computation for each random seed set?
                  (default True)
    
    Attributes
    ----------
      errors -- greedy errors associated with each random set of seed points
      sizes  -- reduced data sizes from each random set of seed points
      seeds  -- the full set of random seed points
      Xs     -- reduced data from each random set of seed points
    
    Comments
    --------
    The `parallel` option also accepts positive integers indicating the
    number of processors that the user wants to use. 
    
    Parallelization uses some features from the concurrent.futures module.
    
Make reduced-order splines for Nseeds number of random sets of seed points.
Input



Attributes



Comments

The `parallel` option also accepts positive integers indicating the
number of processors that the user wants to use.

Parallelization uses some features from the concurrent.futures module.
Make reduced - order splines for Nseeds number of random sets of seed points . Input Attributes Comments The ` parallel ` option also accepts positive integers indicating the number of processors that the user wants to use . Parallelization uses some features from the concurrent . futures module .
def make(self, x, y, Nseeds, parallel=True):
    self.errors = np.zeros(Nseeds, dtype='double')                
    self.sizes = np.zeros(Nseeds, dtype='double')                 
    self.seeds = np.zeros((Nseeds, self._deg+1), dtype='double')  
    self.Xs = []                                                  
    if (parallel is False) or (state._PARALLEL is False):
      for nn in range(Nseeds):
        seeds = np.sort( np.random.choice(range(len(x)), self._deg+1, replace=False) )
        self.errors[nn], self.sizes[nn], self.seeds[nn], Xs = _randomSeeds(x, y, seeds, tol=self._tol, rel=self._rel, deg=self._deg)
        self.Xs.append(Xs)
    elif state._PARALLEL is True:
      if parallel is True:
        try:
          numprocs = cpu_count()
        except NotImplementedError:
          numprocs = 1
      else:
        numprocs = parallel
      executor = ProcessPoolExecutor(max_workers=numprocs)
      output = []
      for nn in range(Nseeds):
        seeds = np.sort( np.random.choice(range(len(x)), self._deg+1, replace=False) )
        output.append(executor.submit(_randomSeeds, x, y, seeds, tol=self._tol, rel=self._rel, deg=self._deg))
      for ii, oo in enumerate(output):
        self.errors[ii], self.sizes[ii], self.seeds[ii], Xs = oo.result()
        self.Xs.append(Xs)
    self._made = True
def make ( self , x , y , Nseeds , parallel = True ) : self . errors = np . zeros ( Nseeds , dtype = 'double' ) self . sizes = np . zeros ( Nseeds , dtype = 'double' ) self . seeds = np . zeros ( ( Nseeds , self . _deg + 1 ) , dtype = 'double' ) self . Xs = [ ] if ( parallel is False ) or ( state . _PARALLEL is False ) : for nn in range ( Nseeds ) : seeds = np . sort ( np . random . choice ( range ( len ( x ) ) , self . _deg + 1 , replace = False ) ) self . errors [ nn ] , self . sizes [ nn ] , self . seeds [ nn ] , Xs = _randomSeeds ( x , y , seeds , tol = self . _tol , rel = self . _rel , deg = self . _deg ) self . Xs . append ( Xs ) elif state . _PARALLEL is True : if parallel is True : try : numprocs = cpu_count ( ) except NotImplementedError : numprocs = 1 else : numprocs = parallel executor = ProcessPoolExecutor ( max_workers = numprocs ) output = [ ] for nn in range ( Nseeds ) : seeds = np . sort ( np . random . choice ( range ( len ( x ) ) , self . _deg + 1 , replace = False ) ) output . append ( executor . submit ( _randomSeeds , x , y , seeds , tol = self . _tol , rel = self . _rel , deg = self . _deg ) ) for ii , oo in enumerate ( output ) : self . errors [ ii ] , self . sizes [ ii ] , self . seeds [ ii ] , Xs = oo . result ( ) self . Xs . append ( Xs ) self . _made = True
Make reduced-order splines for Nseeds number of random sets of seed points.
Make reduced - order splines for Nseeds number of random sets of seed points .
"""Make reduced-order splines for Nseeds number of random sets of seed points.
    
    Input
    -----
      x        -- samples
      y        -- data to be downsampled
      Nseeds   -- number of random sets of seed points
      parallel -- parallelize the computation for each random seed set?
                  (default True)
    
    Attributes
    ----------
      errors -- greedy errors associated with each random set of seed points
      sizes  -- reduced data sizes from each random set of seed points
      seeds  -- the full set of random seed points
      Xs     -- reduced data from each random set of seed points
    
    Comments
    --------
    The `parallel` option also accepts positive integers indicating the
    number of processors that the user wants to use. 
    
    Parallelization uses some features from the concurrent.futures module.
    """ # Allocate some memory # Greedy errors # Sizes of each reduced data # All seeds # Reduced data for each seed # Determine the number of processes to run on # Create a parallel process executor # Build reduced-order splines for many random sets of seed points # Gather the results as they complete #for ii, oo in enumerate(as_completed(output)):
self
x
y
Nseeds
parallel