def sample_iter_subs(expr, condition=None, numsamples=S.Infinity, **kwargs):
 if (condition is not None):
  ps = pspace(Tuple(expr, condition))
 else:
  ps = pspace(expr)
 count = 0
 while (count < numsamples):
  d = ps.sample()
  if (condition is not None):
   gd = condition.xreplace(d)
   if ((gd != True) and (gd != False)):
    raise ValueError('Conditions must not contain free symbols')
   if (not gd):
    continue
  (yield expr.xreplace(d))
  count += 1

def sample_iter_subs ( expr , condition = None , numsamples = S . Infinity , ** kwargs ) : if ( condition is not None ) : ps = pspace ( Tuple ( expr , condition ) ) else : ps = pspace ( expr ) count = 0 while ( count < numsamples ) : d = ps . sample ( ) if ( condition is not None ) : gd = condition . xreplace ( d ) if ( ( gd != True ) and ( gd != False ) ) : raise ValueError ( 'Conditions must not contain free symbols' ) if ( not gd ) : continue ( yield expr . xreplace ( d ) ) count += 1
see sample_iter uses subs for computation .