END_OF_TUPLE_DEPENDENT_CODE
431549
private static final <T extends Tuple, K> TypeComparator<T> createLeadingFieldComparator(boolean ascending, TypeInformation<?> info) {
		if (!(info.isKeyType() && info instanceof AtomicType)) {
			throw new IllegalArgumentException("The field at position 0 (" + info + ") is no atomic key type.");
		}
		
		@SuppressWarnings("unchecked")
		AtomicType<K> typedInfo = (AtomicType<K>) info;
		return new TupleLeadingFieldComparator<T, K>(typedInfo.createComparator(ascending));
	}
81900
def attribute_dependend_key(key_function, *dependencies):
    """"""

    def dependend_key_function(self, *args, **kwargs):
        key = hash_key(*args, **kwargs)
        
        if len(dependencies) > 0:
            dependecies_dict = {}
            for dependency in dependencies:
                value = eval(dependency)
                dependecies_dict[dependency] = value
            
            key = key + cachetools.keys._HashedTuple(_dependency_mark + tuple(itertools.chain(sorted(dependecies_dict.items()))))

        return key
    
    return dependend_key_function
841930
function Tuple(n, args) {
    const parts = [].slice.call(args)
    if (n !== parts.length) {
      throw new TypeError(
        `${n}-Tuple: Expected ${n} values, but got ${parts.length}`
      )
    }

    const inspect = () =>
      `${n}-Tuple(${parts.map(_inspect).join(',')} )`

    function map(method) {
      return function(fn) {
        if (!isFunction(fn)) {
          throw new TypeError(`${n}-Tuple.${method}: Function required`)
        }

        return Tuple(n, parts
          .slice(0, parts.length - 1)
          .concat(fn(parts[parts.length - 1]))
        )
      }
    }

    const equals = m =>
      isSameType({ type }, m)
        && _equals(parts, m.toArray())

    function concat(method) {
      return function(t) {
        if (!isSameType({ type }, t)) {
          throw new TypeError(`${n}-Tuple.${method}: Tuple of the same length required`)
        }

        const a = t.toArray()

        return Tuple(n, parts.map((v, i, o) => {
          if (!(isSemigroup(a[i]) && isSemigroup(o[i]))) {
            throw new TypeError(
              `${n}-Tuple.${method}: Both Tuples must contain Semigroups of the same type`
            )
          }

          if (!isSameType(a[i], o[i])) {
            throw new TypeError(
              `${n}-Tuple.${method}: Both Tuples must contain Semigroups of the same type`
            )
          }

          return o[i].concat(a[i])
        }))
      }
    }

    function merge(fn) {
      if (!isFunction(fn)) {
        throw new TypeError(`${n}-Tuple.merge: Function required`)
      }

      return fn(...parts)
    }

    function mapAll(...args) {
      if (args.length !== parts.length) {
        throw new TypeError(
          `${n}-Tuple.mapAll: Requires ${parts.length} functions`
        )
      }

      return Tuple(
        n,
        parts.map((v, i) => {
          if (!isFunction(args[i])) {
            throw new TypeError(
              `${n}-Tuple.mapAll: Functions required for all arguments`
            )
          }
          return args[i](v)
        })
      )
    }

    function project(index) {
      if (!isInteger(index) || index < 1 || index > n) {
        throw new TypeError(
          `${n}-Tuple.project: Index should be an integer between 1 and ${n}`
        )
      }

      return parts[index - 1]
    }

    function toArray() {
      return parts.slice()
    }

    return {
      inspect, toString: inspect, merge,
      project, mapAll, toArray,
      tupleLength, type, equals,
      map: map('map'),
      concat: concat('concat'),
      [fl.map]: map(fl.map),
      [fl.concat]: concat(fl.concat),
      [fl.equals]: equals,
      ['@@type']: typeString,
      constructor: Tuple
    }
  }
1045556
private static Collection<Tuple> getTuples( List<VarDef> varDefs, int varStart, int varEnd, int tupleSize)
    {
    Collection<Tuple> tuples = new ArrayList<Tuple>();

    // For each variable up to the last included...
    for( int i = varStart; i < varEnd; i++)
      {
      // Combine each valid value...
      VarDef                nextVar   = varDefs.get(i);
      Iterator<VarValueDef> values    = nextVar.getValidValues();
      if( !values.hasNext())
        {
        throw new IllegalStateException( "Can't complete tuples -- no valid values defined for var=" + nextVar);
        }

      // With all subtuples from the remaining variables.
      Collection<Tuple> subTuples =
        tupleSize==1
        ? null
        : getTuples( varDefs, i + 1, varEnd + 1, tupleSize - 1);

      // Only one variable to combine?
      if( subTuples == null)
        {
        // Yes, return list of 1-tuples for this variable.
        while( values.hasNext())
          {
          tuples.add( new Tuple( new VarBindingDef( nextVar, values.next())));
          }
        }

      // Any compatible subtuples for remaining variables?
      else if( !subTuples.isEmpty())
        {
        // Yes, add all compatible combinations with values for this variable.
        while( values.hasNext())
          {
          VarBindingDef nextBinding = new VarBindingDef( nextVar, values.next());
          for( Tuple subTuple : subTuples)
            {
            Tuple nextTuple = new Tuple( nextBinding).addAll( subTuple);
            if( nextTuple.isCompatible())
              {
              tuples.add( nextTuple);
              }
            }
          }
        }
      }
    
    return tuples;
    }
1194171
def ensure_tuple(obj):
    """"""
    if obj is None:
        return tuple()
    if isinstance(obj, Iterable) and not isinstance(obj, six.string_types):
        return tuple(obj)
    return obj,
684366
def get_tuple(self):
        """"""
        objType, objInstance = self.value

        if isinstance(objType, int):
            pass
        elif isinstance(objType, long):
            objType = int(objType)
        elif isinstance(objType, basestring):
            # turn it back into an integer
            objType = self.objectTypeClass()[objType]
        else:
            raise TypeError("invalid datatype for objType")

        # pack the components together
        return (objType, objInstance)
1317568
private static void reflect(Tuple2d p, Tuple2d base, double a, double b) {
        double x = a * (p.x - base.x) + b * (p.y - base.y) + base.x;
        double y = b * (p.x - base.x) - a * (p.y - base.y) + base.y;
        p.x = x;
        p.y = y;
    }
809702
def cell_ends_with_code(lines):
    """"""
    if not lines:
        return False
    if not lines[-1].strip():
        return False
    if lines[-1].startswith('#'):
        return False
    return True
1301458
def _cast(self, _input, _output):
        

        if isenvelope(_output):
            _output, _flags, _options = _output.unfold()
        else:
            _flags, _options = [], {}

        if len(_flags):
            # TODO: parse flags to check constraints are respected (like not modified alone, etc.)

            if F_NOT_MODIFIED in _flags:
                return _input

            if F_INHERIT in _flags:
                if self._output_type is None:
                    self._output_type = concat_types(
                        self._input_type, self._input_length, self._output_type, len(_output)
                    )
                _output = _input + ensure_tuple(_output)

        if not self._output_type:
            if issubclass(type(_output), tuple):
                self._output_type = type(_output)

        return ensure_tuple(_output, cls=self._output_type)
826074
def get_tuple(self):
        """"""
        objType, objInstance = self.value

        if isinstance(objType, int):
            pass
        elif isinstance(objType, str):
            # turn it back into an integer
            objType = self.objectTypeClass()[objType]
        else:
            raise TypeError("invalid datatype for objType")

        # pack the components together
        return (objType, objInstance)
622291
protected void end() {
        if ( subSolver != null && subSolver.subSolver == null ) {
            if ( type == OperatorDescrType.AND ) {
                if ( possibilityLists.isEmpty() ) {
                    possibilityLists.add( new HashSet<VerifierComponent>() );
                }

                List<Set<VerifierComponent>> newPossibilities = new ArrayList<Set<VerifierComponent>>();

                List<Set<VerifierComponent>> sets = subSolver.getPossibilityLists();
                for ( Set<VerifierComponent> possibilityList : possibilityLists ) {

                    for ( Set<VerifierComponent> set : sets ) {
                        Set<VerifierComponent> newSet = new HashSet<VerifierComponent>();
                        newSet.addAll( possibilityList );
                        newSet.addAll( set );
                        newPossibilities.add( newSet );
                    }
                }
                possibilityLists = newPossibilities;

            } else if ( type == OperatorDescrType.OR ) {

                possibilityLists.addAll( subSolver.getPossibilityLists() );

            }

            subSolver = null;

        } else if ( subSolver != null && subSolver.subSolver != null ) {

            subSolver.end();
        }

    }
558382
def _find_end_token(self, end_token, operation):
        
        ibuffer, icache = operation.state
        length = operation.buffered[ibuffer][2]
        result = None

        for i in range(len(operation.buffered) - ibuffer - 1):
            linenum, statement, charlength = operation.buffered[i + ibuffer + 1]
            length += charlength
            
            if end_token in statement.lower():
                #We already have the absolute char index for the start of the
                #instance; we just need to update the end.
                result = (i + ibuffer + 1, length)
                break        

        #If we didn't find a terminating statement, the full length of the operation
        #is a good estimate for the extent of the instance.
        if result is None:
            result = (None, length)

        return result
11438
def str2tuple(str_in):
    '''
    
    '''
    tuple_out = safe_eval(str_in)
    if not isinstance(tuple_out, tuple):
        tuple_out = None
    return tuple_out
640507
def module_start_end(has_module, module_name)
      module_start = ''
      module_end = ''
      if has_module
        module_start = "module #{module_name}"
        module_end = 'end'
      end
      [module_start, module_end]
    end
903892
def widget_from_tuple(o):
        """"""
        if _matches(o, (Real, Real)):
            min, max, value = _get_min_max_value(o[0], o[1])
            if all(isinstance(_, Integral) for _ in o):
                cls = IntSlider
            else:
                cls = FloatSlider
            return cls(value=value, min=min, max=max)
        elif _matches(o, (Real, Real, Real)):
            step = o[2]
            if step <= 0:
                raise ValueError("step must be >= 0, not %r" % step)
            min, max, value = _get_min_max_value(o[0], o[1], step=step)
            if all(isinstance(_, Integral) for _ in o):
                cls = IntSlider
            else:
                cls = FloatSlider
            return cls(value=value, min=min, max=max, step=step)
129707
def _maybe_end_of_stmt_list(attr_value):
    """"""
    if (attr_value is not None) and isinstance(attr_value, Iterable):
      result = list(attr_value)
      if len(result) > 0:
        return result[-1]
    return None
281393
public void write_tuple_head(final int arity) {
        if (arity < 0xff) {
            write1(OtpExternal.smallTupleTag);
            write1(arity);
        } else {
            write1(OtpExternal.largeTupleTag);
            write4BE(arity);
        }
    }