def _check_weights(weights, n_components):
 weights = check_array(weights, dtype=[np.float64, np.float32], ensure_2d=False)
 _check_shape(weights, (n_components,), 'weights')
 if (any(np.less(weights, 0.0)) or any(np.greater(weights, 1.0))):
  raise ValueError(("The parameter 'weights' should be in the range [0, 1], but got max value %.5f, min value %.5f" % (np.min(weights), np.max(weights))))
 if (not np.allclose(np.abs((1.0 - np.sum(weights))), 0.0)):
  raise ValueError(("The parameter 'weights' should be normalized, but got sum(weights) = %.5f" % np.sum(weights)))
 return weights

def _check_weights ( weights , n_components ) : weights = check_array ( weights , dtype = [ np . float64 , np . float32 ] , ensure_2d = False ) _check_shape ( weights , ( n_components , ) , 'weights' ) if ( any ( np . less ( weights , 0.0 ) ) or any ( np . greater ( weights , 1.0 ) ) ) : raise ValueError ( ( "The parameter 'weights' should be in the range [0, 1], but got max value %.5f, min value %.5f" % ( np . min ( weights ) , np . max ( weights ) ) ) ) if ( not np . allclose ( np . abs ( ( 1.0 - np . sum ( weights ) ) ) , 0.0 ) ) : raise ValueError ( ( "The parameter 'weights' should be normalized, but got sum(weights) = %.5f" % np . sum ( weights ) ) ) return weights
check to make sure weights are valid .