Check whether the initial state is of the correct type.
        The state should be either an int, list, tuple or np.array and all its elements must be integer.
        Returns an int if the state is an integer, otherwise a tuple.
327227
def checkInitialState(self,initialState):
        
        assert initialState is not None, "Initial state has not been specified."
        assert isinstance(initialState,(int,list,tuple,np.ndarray,set)), "initialState %r is not an int, tuple, list, set or numpy array" % initialState

         
        if isinstance(initialState,list): 
            #Check whether all entries of the list are ints. Return an int if the len ==1, otherwise a tuple.
            assert all(isinstance(i, int) for i in initialState), "initialState %r is not integer" % initialState 
            initialState = int(initialState) if len(initialState)==1 else tuple(initialState)          

        elif isinstance(initialState,tuple): 
            #Check whether all entries are ints. Return an int if the len ==1, otherwise a tuple.
            assert all(isinstance(i, int) for i in initialState), "initialState %r is not integer" % initialState
            if len(initialState)==1:
                initialState = int(initialState)     
        
        elif isinstance(initialState,np.ndarray):
            #Check whether the state is a 1d numpy array. Return an int if it has length 1.
            assert issubclass(initialState.dtype.type, np.integer) and initialState.ndim==1, "initialState %r is not a one-dimensional integer numpy array" % initialState 
            initialState = int(initialState) if len(initialState)==1 else tuple(initialState)
            
        elif isinstance(initialState,set):
            #If we have a set, then check whether all elements are ints or tuples.
            for state in initialState:                
                assert isinstance(state,(tuple,int)), "the set initialState %r should contain tuples or ints" % initialState 
                if isinstance(state,tuple):
                    assert all(isinstance(i,int) for i in state), "the state %r should be integer" % initialState 
                
        return initialState
263920
def is_natural(x):
    """"""
    try:
        is_integer = int(x) == x
    except (TypeError, ValueError):
        return False
    return is_integer and x >= 0
1326503
def is_type(type_, *p):
    
    try:
        for i in p:
            if i.type_ != type_:
                return False

        return True
    except:
        pass

    return False
820418
def is_enum_type(type_):
    

    return isinstance(type_, type) and issubclass(type_, tuple(_get_types(Types.ENUM)))
24932
def get_int(self, input_string):
        

        if input_string in ('--ensemble_size', '--ncpu'):

            # was the flag set?
            try:
                index = self.args.index(input_string) + 1
            except ValueError:
                # it wasn't, so if it's required, exit
                if input_string in self.required:
                    print("\n {flag} is required\n".format(flag=input_string))
                    print_short_help()
                    sys.exit(1)
                # otherwise return the appropriate default
                else:
                    return None

            # the flag was set, so check if a value was set, otherwise exit
            try:
                if self.args[index] in self.flags:
                    print("\n {flag} was set but a value was not specified".format(flag=input_string))
                    print_short_help()
                    sys.exit(1)
            except IndexError:
                print("\n {flag} was set but a value was not specified".format(flag=input_string))
                print_short_help()
                sys.exit(1)

            # a value was set, so check if its the correct type
            try:
                value = int(self.args[index])
            except ValueError:
                print("\n {flag} must be an integer".format(flag=input_string))
                print_short_help()
                sys.exit(1)

            # verify the value provided is not negative
            if value < 0:
                print("\n {flag} must be an integer greater than 0".format(flag=input_string))
                print_short_help()
                sys.exit(1)

            # everything checks out, so return the value
            return value
32348
def check_state(self, state):
        

        if state.addr == self.function.addr:
            arch = state.arch
            if self._check_arguments(arch, state):
                return True

        return False
901985
def check_type(value, type_def):
        
        if type_def == 'integer':
            try:
                # We accept string with integer ex: '123'
                int(value)
                return True
            except ValueError:
                return isinstance(value, six.integer_types) and not isinstance(value, bool)
        elif type_def == 'number':
            return isinstance(value, (six.integer_types, float)) and not isinstance(value, bool)
        elif type_def == 'string':
            return isinstance(value, (six.text_type, six.string_types, datetime.datetime))
        elif type_def == 'boolean':
            return (isinstance(value, bool) or
                    (isinstance(value, (six.text_type, six.string_types,)) and
                     value.lower() in ['true', 'false'])
                    )
        else:
            return False
919835
def _int_values(self, shape):
        
        return (self.state.randint(low=0, high=100, size=shape)
                .astype('int64'))
929671
def _is_pair(item):
    
    return (isinstance(item, (list, tuple, set)) and
            len(item) == 2 and
            not isinstance(item[0], (list, tuple, set)) and
            not isinstance(item[1], (list, tuple, set)))
715117
def ok(self):
        
        try:
            v = int(self._value)
            if v < 0:
                return False
            else:
                return True
        except:
            return False
1013689
def get_t(self):
        '''
        
        '''
        if isinstance(self.__t, int) is False:
            raise TypeError("The type of __t must be int.")
        return self.__t
755321
def is_tuple(obj, len_=None):
    
    if not isinstance(obj, tuple):
        return False

    if len_ is None:
        return True
    if not isinstance(len_, Integral):
        raise TypeError(
            "length must be a number (got %s instead)" % type(len_).__name__)
    if len_ < 0:
        raise ValueError("length must be positive (got %s instead)" % len_)

    return len(obj) == len_
659344
def p_array_type(self, p):
        ''''''
        if len(p) == 2:
            p[0] = p[1][0],
        elif len(p) == 5 and p[4] == ']':
            def args(t):
                return t.__args__ if isinstance(t, NDArray) else (t,)
            p[0] = tuple(NDArray[args(t) + p[3]] for t in p[1])
810640
function isType(type, val) {
  if (Struct.typeChecker[type]) {
    return Struct.typeChecker[type](val);
  }
  return false;
}
567314
def check_type_of_param_list_elements(param_list):
    
    try:
        assert isinstance(param_list[0], np.ndarray)
        assert all([(x is None or isinstance(x, np.ndarray))
                    for x in param_list])
    except AssertionError:
        msg = "param_list[0] must be a numpy array."
        msg_2 = "All other elements must be numpy arrays or None."
        total_msg = msg + "\n" + msg_2
        raise TypeError(total_msg)

    return None
523516
private State checkh(State state) throws DatatypeException, IOException {
        if (state.context.length() == 0) {
            state = appendToContext(state);
        }
        state.current = state.reader.read();
        state = appendToContext(state);
        state = skipSpaces(state);
        boolean expectNumber = true;

        for (;;) {
            switch (state.current) {
                default:
                    if (expectNumber)
                        reportNonNumber('h', state.current, state.context);
                    return state;

                case '+':
                case '-':
                case '.':
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                    break;
            }
            state = checkArg('h', "x coordinate", state);

            state = skipCommaSpaces2(state);
            expectNumber = state.skipped;
        }
    }
1366348
def is_seq(arg):
    '''
    
    '''
    return isinstance(arg, (list_type, tuple_type, pyr.PVector, pyr.PList)) or is_nparray(arg)