Returns the set of input variables not yet bound by the given test case.
13016
private List<VarDef> getVarsRemaining( FunctionInputDef inputDef, TestCaseDef testCase)
    {
    return getVarsRemaining( new VarDefIterator( inputDef), testCase);
    }
545051
protected Set<String> getPrevExpandedRows() {
		Set<String> prev = getComponentModel().prevExpandedRows;
		if (prev == null) {
			return Collections.emptySet();
		} else {
			return Collections.unmodifiableSet(prev);
		}
	}
351825
private boolean completeSatisfied( TestCaseDef testCase, VarTupleSet tuples, List<VarDef> vars)
    {
    List<VarDef> varsRemaining = getVarsRemaining( vars, testCase);
    VarDef varApplicable;
    boolean complete; 

    // Any variables remaining unbound?
    if( varsRemaining.isEmpty())
      {
      // No, this test case is complete.
      complete = true;
      }
    
    // Any variables remaining that are currently applicable to this test case?
    else if( (varApplicable = varsRemaining.stream().filter( v -> testCase.isApplicable(v)).findFirst().orElse( null)) == null)
      {
      // No, continue with an NA binding for the next variable
      testCase.addCompatible( getNaBindingFor( varsRemaining.get( 0)));
      complete = makeComplete( testCase, tuples, varsRemaining);
      }

    else
      {
      // Find an applicable binding that will lead to a complete test case
      int prevBindings = testCase.getBindingCount();
      Iterator<Tuple> bindingTuples = getBindingsFor( tuples, varApplicable);
      for( complete = false;

           // More tuples to try?
           bindingTuples.hasNext()
             && !(
               // Compatible tuple found?
               testCase.addCompatible( (bindingTuples.next())) != null

               // Did this tuple create an infeasible combination?
               && !testCase.isInfeasible()

               // Can we complete bindings for remaining variables?
               && (complete = makeComplete( testCase, tuples, varsRemaining)));
             
           // No path to completion with this tuple -- try the next one.
           testCase.revertBindings( prevBindings));
      }
    
    return complete;
    }
1091141
public boolean arrayAlreadyExistsForVarName(String varName) {
        SDVariable var = getVariable(varName);
        switch(var.getVariableType()){
            case VARIABLE:
                return variablesArrays.containsKey(varName);
            case ARRAY:
                long tid = Thread.currentThread().getId();
                return sessions.containsKey(tid) && sessions.get(tid).contains(varName, InferenceSession.OUTER_FRAME, 0, null);
            case CONSTANT:
                return constantArrays.containsKey(varName);
            case PLACEHOLDER:
                return placeholdersPerThread.containsKey(Thread.currentThread().getId()) &&
                        placeholdersPerThread.get(Thread.currentThread().getId()).containsKey(varName);
            default:
                throw new RuntimeException("Unknown variable type: " + var.getVariableType());
        }
    }
182704
private List<TestCaseDef> getFailureCases( FunctionInputDef inputDef, VarTupleSet failureTuples, VarTupleSet validTuples)
    {
    logger_.debug( "{}: Creating failure test cases", inputDef);
    
    List<TestCaseDef> failureCases = new ArrayList<TestCaseDef>();

    // For each failure input tuple not yet used in a test case...
    Tuple nextUnused;
    while( (nextUnused = failureTuples.getNextUnused()) != null)
      {
      // Completed bindings for all variables?
      TestCaseDef failureCase = createTestCase( nextUnused, inputDef, validTuples);
      if( failureCase != null)
        {
        // Yes, add new failure test case.
        failureTuples.used( nextUnused);
        failureCases.add( failureCase);
        }
      }

    logger_.info( "{}: Created {} failure test cases", inputDef, failureCases.size());
    return failureCases;
    }
1032388
def get_variables(self) -> Set[str]:
        
        variables = set()
        for cmd in self._cmd:
            for var in self.__formatter.parse(cmd):
                logger.debug("Checking variable: %s", var)
                # creates and requires are special class values
                if var[1] is not None and var[1] not in ["creates", "requires"]:
                    variables.add(var[1])
        return variables
988476
def get_unset_inputs(self):
        
        return set([k for k, v in self._inputs.items() if v.is_empty(False)])
861103
def getInputOrder(ast, input_order=None):
    
    variables = {}
    for a in ast.allOf('variable'):
        variables[a.value] = a
    variable_names = set(variables.keys())

    if input_order:
        if variable_names != set(input_order):
            raise ValueError(
                "input names (%s) don't match those found in expression (%s)"
                % (input_order, variable_names))

        ordered_names = input_order
    else:
        ordered_names = list(variable_names)
        ordered_names.sort()
    ordered_variables = [variables[v] for v in ordered_names]
    return ordered_variables
286225
@Nonnull
  public EChange removeVariables (@Nullable final Iterable <String> aNames)
  {
    EChange eChange = EChange.UNCHANGED;
    if (aNames != null)
      for (final String sName : aNames)
        eChange = eChange.or (removeVariable (sName));
    return eChange;
  }

  /**
   * @return A mutable copy of all contained variables. Never <code>null</code>
   *         but maybe empty.
   */
  @Nonnull
  @ReturnsMutableCopy
  public ICommonsMap <String, ?> getAllVariables ()
  {
    return m_aMap.getClone ();
  }

  /**
   * @return The number of contained variables. Always &ge; 0.
   */
  @Nonnegative
  public int getVariableCount ()
  {
    return m_aMap.size ();
  }

  /**
   * Remove all variables at once.
   *
   * @return {@link EChange#CHANGED} if at least one variable was removed.
   */
  @Nonnull
  public EChange clear ()
  {
    return m_aMap.removeAll ();
  }

  /**
   * Set multiple variables at once.
   *
   * @param aVars
   *        The variables to be set. May be <code>null</code>.
   */
  public void setAllVariables (@Nullable final Map <String, ?> aVars)
  {
    m_aMap.setAll (aVars);
  }

  @Nullable
  public Object resolveVariable (@Nonnull final QName aVariableName)
  {
    ValueEnforcer.notNull (aVariableName, "VariableName");

    final String sLocalName = aVariableName.getLocalPart ();
    return m_aMap.get (sLocalName);
  }

  @Nonnull
  @ReturnsMutableCopy
  public MapBasedXPathVariableResolver getClone ()
  {
    return new MapBasedXPathVariableResolver (this);
  }

  @Override
  public boolean equals (final Object o)
  {
    if (o == this)
      return true;
    if (o == null || !getClass ().equals (o.getClass ()))
      return false;
    final MapBasedXPathVariableResolver rhs = (MapBasedXPathVariableResolver) o;
    return EqualsHelper.equals (m_aMap, rhs.m_aMap);
  }

  @Override
  public int hashCode ()
  {
    return new HashCodeGenerator (this).append (m_aMap).getHashCode ();
  }

  @Override
  public String toString ()
  {
    return new ToStringGenerator (this).append ("map", m_aMap).getToString ();
  }
}
1177513
private VarDef getNextVarDef()
    {
    if( nextVarDef_ == null)
      {
      // Still traversing current VarSet?
      if( nextVarSet_ != null && nextVarSet_.hasNext())
        {
        // Yes, return next VarSet member.
        nextVarDef_ = nextVarSet_.next();
        }
      else
        {
        // No, get next variable, skipping any empty VarSet.
        nextVarSet_ = null;
        Iterator<IVarDef> members = null;
        IVarDef varDef;
        for( varDef = null;

             varDefs_.hasNext()
               && (members = (varDef = varDefs_.next()).getMembers()) != null
               && !members.hasNext();

             varDef = null);

        nextVarDef_ =
          // No VarDef left to visit?
          varDef == null? null :

          // Next variable is a VarDef?
          members == null? (VarDef) varDef :

          // No, start traversing next VarSet.
          (nextVarSet_ = new VarDefIterator( members)).next();

        }
      }

    return nextVarDef_;
    }
174169
protected static void checkSameExecutionContext(DataSet<?> set1, DataSet<?> set2) {
		if (set1.getExecutionEnvironment() != set2.getExecutionEnvironment()) {
			throw new IllegalArgumentException("The two inputs have different execution contexts.");
		}
	}
1339887
def _find_uninitialized(self):
    
    return set(name
               for name, prop in self._properties.iteritems()
               if not prop._is_initialized(self))
724145
public List<String> inputs() {
        List<String> out = new ArrayList<>();
        for(String s : variables.keySet()){
            if(isPlaceHolder(s))
                out.add(s);
        }
        return out;
    }
821169
public final void removeVariables(Variable[] v) throws VariableNotFound, IllegalVariableRemoval {
		
		HashSet<Constraint> incidentRevised = new HashSet<Constraint>();

		//Keep track of solvers of dependent variables
		HashMap<ConstraintSolver,ArrayList<Variable>> solversToDepVars = new HashMap<ConstraintSolver, ArrayList<Variable>>();

		for (Variable var : v) {
			if (!this.theNetwork.containsVariable(var) ) throw new VariableNotFound(var);
			Constraint[] incident = this.theNetwork.getIncidentEdges(var);
			for (Constraint con : incident) {
				if ((!con.isAutoRemovable() && !(con instanceof DummyConstraint))) {
					throw new IllegalVariableRemoval(var, this.theNetwork.getIncidentEdges(var));
				}
				else if (con instanceof DummyConstraint) {
					Constraint toRemove = this.removeDummyConstraint((DummyConstraint)con);
					if (toRemove != null) incidentRevised.add(toRemove);
				}
				else incidentRevised.add(con);
			}
			
			//Gather solvers of dependent variables
			for (Variable depVar : var.getDependentVariables()) {
				if (!solversToDepVars.containsKey(depVar.getConstraintSolver())) {
					solversToDepVars.put(depVar.getConstraintSolver(), new ArrayList<Variable>());
				}
				solversToDepVars.get(depVar.getConstraintSolver()).add(depVar);
			}
		}
		
		//Remove dependent variables
		for (ConstraintSolver cs : solversToDepVars.keySet()) {
			cs.removeVariables(solversToDepVars.get(cs).toArray(new Variable[solversToDepVars.get(cs).size()]));
			logger.finest("Removed " + solversToDepVars.get(cs).size() + " dependent variables");
		}
		
		this.removeConstraints(incidentRevised.toArray(new Constraint[incidentRevised.size()]));

		removeVariablesSub(v);
		for (Variable var : v) {
			this.theNetwork.removeVariable(var);
		}
		for (ArrayList<Variable> vec : components.values()) {
			vec.removeAll(Arrays.asList(v));
		}
		if (!skipPropagation && autoprop && checkDomainsInstantiated()) this.propagate();
		logger.finest("Removed variables " + Arrays.toString(v));
		
	}
1025871
def get_inputs(self, _visited=None):
        
        if _visited is None:
            _visited = set()

        _visited.add(self)

        for i in self.inputs:
            if i not in _visited:
                i.get_inputs(_visited)

        return _visited
505225
public List<Variable> getUsedVariables() {
        ArrayList<Variable> vars = new ArrayList<Variable>();

        for (Operand o : getOperands()) {
            o.addUsedVariables(vars);
        }

        return vars;
    }
1105871
@Override
	protected List<String> getVariablesToIgnore() {

		List<String> variablesToIgnore = new ArrayList<> ();
		variablesToIgnore.add( "^" + Pattern.quote( MILLI_TIME ) + "$" );
		variablesToIgnore.add( "^" + Pattern.quote( NANO_TIME ) + "$" );
		variablesToIgnore.add( "^" + Pattern.quote( SMART_INDEX ) + "$" );
		variablesToIgnore.add( "^" + Pattern.quote( RANDOM_UUID ) + "$" );

		for( String var : this.context.variables.keySet())
			variablesToIgnore.add( "^\\$\\(" + Pattern.quote( var ) + "\\)$" );

		variablesToIgnore.add( "^" + Pattern.quote( FORMATTED_TIME_PREFIX ) + "[^)]*\\)$" );
		variablesToIgnore.add( "^" + Pattern.quote( EXISTING_INDEX_PREFIX ) + "[^)]*\\)$" );
		return variablesToIgnore;
	}


	/**
	 * Extracts the date pattern for a "formatted time" variable.
	 * @param group a formatted time
	 * @return a non-null string
	 */
	static String extractDatePattern( String group ) {
		return group.substring( FORMATTED_TIME_PREFIX.length(), group.length() - 2 ).trim();
	}


	/**
	 * Replaces variables in instance names.
	 * @param value an expression that can reference other variables (not null)
	 * @param context a context (not null)
	 * @param parentInstancePath the parent instance path (may be null)
	 * @param context a non-null map with context information
	 * @return the updated value, or null if an <code>$(existing_index ...)</code> variable failed to be resolved
	 */
	static String replaceVariables( String value, Context context, String parentInstancePath ) {

		long nanoTime = System.nanoTime();
		long milliTime = TimeUnit.MILLISECONDS.convert( nanoTime, TimeUnit.NANOSECONDS );

		// Simple replacements
		value = value.replace( NANO_TIME, String.valueOf( nanoTime ));
		value = value.replace( MILLI_TIME, String.valueOf( milliTime ));
		value = value.replace( RANDOM_UUID, UUID.randomUUID().toString());

		// A little more complex
		if( value.startsWith( FORMATTED_TIME_PREFIX )
				&& value.endsWith( ")" )) {

			String datePattern = extractDatePattern( value );
			SimpleDateFormat sdf = new SimpleDateFormat( datePattern );

			// We replace the whole value as such variables were validated and span over a entire line
			value = sdf.format( new Date( milliTime ));
		}

		// Even more complex
		int smartCpt = 0;
		if( value.contains( SMART_INDEX )) {
			for( int cpt = 1; smartCpt == 0; cpt++ ) {
				String testName = value.replace( SMART_INDEX, String.valueOf( cpt ));
				String testPath = "/" + testName;
				if( parentInstancePath != null )
					testPath = parentInstancePath + testPath;

				if( ! context.instanceExists( testPath )) {
					smartCpt = cpt;
				}
			}
		}

		value = value.replace( SMART_INDEX, String.valueOf( smartCpt ));

		// To perform in last: deal with existing indexes
		boolean disabled = false;
		Pattern fullPattern = Pattern.compile( EXISTING_INDEX_PATTERN );
		Matcher m = fullPattern.matcher( value );
		if( value.contains( EXISTING_INDEX_PREFIX )
				&& m.matches()) {

			String minOrMax = m.group( 2 );
			String prefix = m.group( 1 );
			String suffix = m.group( 6 );
			String bound = m.group( 5 );
			String instanceNamePattern = "/" + prefix + "(\\d+)" + suffix;
			if( parentInstancePath != null )
				instanceNamePattern = parentInstancePath + instanceNamePattern;

			// Find the index
			int cpt = findIndex( instanceNamePattern, context, bound, "MIN".equals( minOrMax ));

			// If cpt is negative, do not replace anything, nothing matches the requirements.
			// We just return null for the variable's value.
			if( cpt < 0 )
				disabled = true;
			else
				value = m.replaceAll( "$1" + String.valueOf( cpt ) + "$6" );
		}

		// Disabled variable => return null
		if( disabled )
			value = null;

		// Inject other variables, if necessary.
		// Disabled variables are contagious, this is managed during the parsing.
		else
			value = CommandsParser.injectContextVariables( value, context.variables );

		return value;
	}


	/**
	 * @param instanceNamePattern
	 * @param context
	 * @param bound
	 * @param findMinimum true to get the minimum value, false for the maximum
	 * @return -1 if no matching instance was found, a positive integer otherwise
	 */
	private static int findIndex( String instanceNamePattern, Context context, String bound, boolean findMinimum ) {

		// Find all the matching indexes?
		Pattern pattern = Pattern.compile( instanceNamePattern );
		SortedSet<Integer> foundIndexes = new TreeSet<> ();
		for( String instancePath : context.instancePathToComponentName.keySet()) {
			Matcher m = pattern.matcher( instancePath );
			if( ! m .find())
				continue;

			int index = Integer.parseInt( m.group( 1 ));
			foundIndexes.add( index );
		}

		// Exclude indexes that are out of bound
		if( bound != null ) {
			bound = bound.trim();
			int min = 0, max = Integer.MAX_VALUE;
			int value = Integer.parseInt( bound.substring( 1 ).trim());
			if( '<' == bound.charAt( 0 ))
				max = value;
			else
				min = value;

			Set<Integer> toRemove = new HashSet<> ();
			for( Integer index : foundIndexes ) {
				if( index <= min || index >= max )
					toRemove.add( index );
			}

			foundIndexes.removeAll( toRemove );
		}

		// Eventually, decide whether we want the tail or the head
		int result;
		if( foundIndexes.isEmpty())
			result = -1;
		else if( findMinimum )
			result = foundIndexes.first();
		else
			result = foundIndexes.last();

		return result;
	}