romspline/helpers.py
def random_partitions(n, K):
  """Split array with n samples into K (nearly) equal 
  partitions of non-overlapping random subsets.
  
  Input
  -----
    n -- number of elements to partition into K subsets
    K -- number of partitions
  
  Output
  ------
  K arrays whose elements are randomly drawn from an array of 
  sequential integers with length n.
  """
  
  assert n >= K, "Number of partitions must not exceed number of samples."
  
  # Make array with unique random integers
  rand = np.random.choice(range(n), n, replace=False)
  
  # Split into K (nearly) equal partitions
  return [np.sort(rand[pp]) for pp in partitions(n, K)]
Split array with n samples into K (nearly) equal 
  partitions of non-overlapping random subsets.
  
  Input
  -----
    n -- number of elements to partition into K subsets
    K -- number of partitions
  
  Output
  ------
  K arrays whose elements are randomly drawn from an array of 
  sequential integers with length n.
  
Split array with n samples into K (nearly) equal
partitions of non-overlapping random subsets.

Input

- number of elements to partition into K subsets
K -- number of partitions

Output

K arrays whose elements are randomly drawn from an array of
sequential integers with length n.
Split array with n samples into K ( nearly ) equal partitions of non - overlapping random subsets . Input - number of elements to partition into K subsets K -- number of partitions Output K arrays whose elements are randomly drawn from an array of sequential integers with length n .
def random_partitions(n, K):
  assert n >= K, "Number of partitions must not exceed number of samples."
  rand = np.random.choice(range(n), n, replace=False)
  return [np.sort(rand[pp]) for pp in partitions(n, K)]
def random_partitions ( n , K ) : assert n >= K , "Number of partitions must not exceed number of samples." rand = np . random . choice ( range ( n ) , n , replace = False ) return [ np . sort ( rand [ pp ] ) for pp in partitions ( n , K ) ]
Split array with n samples into K (nearly) equal
partitions of non-overlapping random subsets.
Split array with n samples into K ( nearly ) equal partitions of non - overlapping random subsets .
"""Split array with n samples into K (nearly) equal 
  partitions of non-overlapping random subsets.
  
  Input
  -----
    n -- number of elements to partition into K subsets
    K -- number of partitions
  
  Output
  ------
  K arrays whose elements are randomly drawn from an array of 
  sequential integers with length n.
  """ # Make array with unique random integers # Split into K (nearly) equal partitions
n
K