romspline/greedy.py
def _seed(x, deg=5, seeds=None):
  """Seed the greedy algorithm with (deg+1) evenly spaced indices
  
  Input
  -----
    x     -- samples
    deg   -- degree of spline polynomial
             (default 5)
    seeds -- list or array of indices of initial seed samples
             (default None)
  
  Comment
  -------
  If `seeds` is None then the code chooses the seed points to be the
  first and last indices and (deg-1) points in between that are
  as nearly equally spaced as possible.
  
  If a list or array of `seeds` are entered then these are used
  instead.
  """
  if seeds is None:
    # TODO: Check that these are actually equally spaced...
    f = lambda m, n: [ii*n//m + n//(2*m) for ii in range(m)]
    indices = np.sort(np.hstack([[0, len(x)-1], f(deg-1, len(x))]))
  else:
    assert type(seeds) in [list, np.ndarray], "Expecting a list or numpy array."
    assert len(seeds) == len(np.unique(seeds)), "Expecting `seeds` to have distinct entries."
    assert len(seeds) >= deg+1, "Expecting `seeds` list to have at least {} entries.".format(deg+1)
    indices = seeds
  errors = []
  
  return np.array(indices, dtype='int'), errors
Seed the greedy algorithm with (deg+1) evenly spaced indices
  
  Input
  -----
    x     -- samples
    deg   -- degree of spline polynomial
             (default 5)
    seeds -- list or array of indices of initial seed samples
             (default None)
  
  Comment
  -------
  If `seeds` is None then the code chooses the seed points to be the
  first and last indices and (deg-1) points in between that are
  as nearly equally spaced as possible.
  
  If a list or array of `seeds` are entered then these are used
  instead.
  
Seed the greedy algorithm with (deg+1) evenly spaced indices
Input



Comment

If `seeds` is None then the code chooses the seed points to be the
first and last indices and (deg-1) points in between that are
as nearly equally spaced as possible.

If a list or array of `seeds` are entered then these are used
instead.
Seed the greedy algorithm with ( deg + 1 ) evenly spaced indices Input Comment If ` seeds ` is None then the code chooses the seed points to be the first and last indices and ( deg - 1 ) points in between that are as nearly equally spaced as possible . If a list or array of ` seeds ` are entered then these are used instead .
def _seed(x, deg=5, seeds=None):
  if seeds is None:
    f = lambda m, n: [ii*n//m + n//(2*m) for ii in range(m)]
    indices = np.sort(np.hstack([[0, len(x)-1], f(deg-1, len(x))]))
  else:
    assert type(seeds) in [list, np.ndarray], "Expecting a list or numpy array."
    assert len(seeds) == len(np.unique(seeds)), "Expecting `seeds` to have distinct entries."
    assert len(seeds) >= deg+1, "Expecting `seeds` list to have at least {} entries.".format(deg+1)
    indices = seeds
  errors = []
  return np.array(indices, dtype='int'), errors
def _seed ( x , deg = 5 , seeds = None ) : if seeds is None : f = lambda m , n : [ ii * n // m + n // ( 2 * m ) for ii in range ( m ) ] indices = np . sort ( np . hstack ( [ [ 0 , len ( x ) - 1 ] , f ( deg - 1 , len ( x ) ) ] ) ) else : assert type ( seeds ) in [ list , np . ndarray ] , "Expecting a list or numpy array." assert len ( seeds ) == len ( np . unique ( seeds ) ) , "Expecting `seeds` to have distinct entries." assert len ( seeds ) >= deg + 1 , "Expecting `seeds` list to have at least {} entries." . format ( deg + 1 ) indices = seeds errors = [ ] return np . array ( indices , dtype = 'int' ) , errors
Seed the greedy algorithm with (deg+1) evenly spaced indices
Input
Seed the greedy algorithm with ( deg + 1 ) evenly spaced indices Input
"""Seed the greedy algorithm with (deg+1) evenly spaced indices
  
  Input
  -----
    x     -- samples
    deg   -- degree of spline polynomial
             (default 5)
    seeds -- list or array of indices of initial seed samples
             (default None)
  
  Comment
  -------
  If `seeds` is None then the code chooses the seed points to be the
  first and last indices and (deg-1) points in between that are
  as nearly equally spaced as possible.
  
  If a list or array of `seeds` are entered then these are used
  instead.
  """ # TODO: Check that these are actually equally spaced...
x
deg
seeds