Check to ensure arrays are symmetrical, for example:
        [[1, 2, 3], [1, 2]] is invalid
435922
def check_array_struct(array):
    

    #If a list is transformed into a numpy array and the sub elements
    #of this array are still lists, then numpy failed to fully convert
    #the list, meaning it is not symmetrical.
    try:
        arr = np.array(array)
    except:
        raise HydraError("Array %s is not valid."%(array,))
    if type(arr[0]) is list:
        raise HydraError("Array %s is not valid."%(array,))
1078630
function checkArray(points) {
    // if it is already a 2D array of points, we just return them
    if (Array.isArray(points) && Array.isArray(points[0]) && points.length === 2) return points;
    var x = new Array(points.length);
    var y = new Array(points.length);
    for (var i = 0; i < points.length; i++) {
      x[i] = points[i][0];
      y[i] = points[i][1];
    }
    return [x, y];
  }
7541
def force_F_ordered_symmetric(A):
    
    if A.flags['F_CONTIGUOUS']:
        return A
    if A.flags['C_CONTIGUOUS']:
        return A.T
    else:
        return np.asfortranarray(A)
1332685
def tril(array, k=0):
    ''''''
    try:
        tril_array = np.tril(array, k=k)
    except:
        # have to loop
        tril_array = np.zeros_like(array)
        shape = array.shape
        otherdims = shape[:-2]
        for index in np.ndindex(otherdims):
            tril_array[index] = np.tril(array[index], k=k)
    return tril_array
889954
def valid_index(index, shape) -> tuple:
    
    # append slices to index
    index = list(index)
    while len(index) < len(shape):
        index.append(slice(None))
    # fill out, in reverse
    out = []
    for i, s in zip(index[::-1], shape[::-1]):
        if s == 1:
            if isinstance(i, slice):
                out.append(slice(None))
            else:
                out.append(0)
        else:
            out.append(i)
    return tuple(out[::-1])
555630
def as_square_array(arr):
    
    arr = np.atleast_2d(arr)
    if len(arr.shape) != 2 or arr.shape[0] != arr.shape[1]:
        raise ValueError("Expected square array")
    return arr
507495
function _same_array(one, two){
	var retval = true;
	if( one.length != two.length ){
	    retval = false;
	}else{
	    for( var i = 0; i < one.length; i++ ){
		if( one[i] != two[i] ){
		    retval = false;
		    break;
		}
	    }
	}
	return retval;
    }
217635
function isArrayOfArray(o) {
    if(isArray(o)) {
      if(o.length > 0) {
        if(isArray(o[0])) {
          return true;
        }
      }
    }
    return false;
  }
833708
def check_if_numbers_are_consecutive(list_):
    
    return all((True if second - first == 1 else False
                for first, second in zip(list_[:-1], list_[1:])))
1180819
def TeArraySizeCheck(self):
    
    # Only if they are both defined and are arrays
    # Both being arrays is a possible bug in this check routine that I have 
    # intentionally introduced
    if type(self.Te) == np.ndarray and type(self.qs) == np.ndarray:
      # Doesn't touch non-arrays or 1D arrays
      if type(self.Te) is np.ndarray:
        if (np.array(self.Te.shape) != np.array(self.qs.shape)).any():
          sys.exit("q0 and Te arrays have incompatible shapes. Exiting.")
      else:
        if self.Debug: print("Te and qs array sizes pass consistency check")
178215
function checkCombinator3(i) {
  const type = tokens[i].type;
  if (type === TokenType.PlusSign ||
      type === TokenType.GreaterThanSign ||
      type === TokenType.Tilde) return 1;
  else return 0;
}
382033
function deduplicate(array, areEqual) {
        var result;
        if (array) {
            result = [];
            loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) {
                var item = array_6[_i];
                for (var _a = 0, result_1 = result; _a < result_1.length; _a++) {
                    var res = result_1[_a];
                    if (areEqual ? areEqual(res, item) : res === item) {
                        continue loop;
                    }
                }
                result.push(item);
            }
        }
        return result;
    }
596517
def array_equiv(arr1, arr2):
    
    arr1, arr2 = as_like_arrays(arr1, arr2)
    if arr1.shape != arr2.shape:
        return False

    with warnings.catch_warnings():
        warnings.filterwarnings('ignore', "In the future, 'NAT == x'")

        flag_array = (arr1 == arr2)
        flag_array |= (isnull(arr1) & isnull(arr2))

        return bool(flag_array.all())
254033
def check_array_or_list(input):
    """"""
    if type(input) != np.ndarray:
        if type(input) == list:
            output = np.array(input)
        else:
            raise TypeError('Expecting input type as ndarray or list.')
    else:
        output = input

    if output.ndim != 1:
        raise ValueError('Input array must have 1 dimension.')

    if np.sum(output < 0.) > 0:
            raise ValueError("Input array values cannot be negative.")

    return output
1198848
def _ensure_arraylike(values):
    
    if not is_array_like(values):
        inferred = lib.infer_dtype(values, skipna=False)
        if inferred in ['mixed', 'string', 'unicode']:
            if isinstance(values, tuple):
                values = list(values)
            values = construct_1d_object_array_from_listlike(values)
        else:
            values = np.asarray(values)
    return values
337844
def _check_periodic(periodic):
    ''''''
    periodic = np.array(periodic)

    # If it is a matrix
    if len(periodic.shape) == 2:
        assert periodic.shape[0] == periodic.shape[1], 'periodic shoud be a square matrix or a flat array'
        return np.diag(periodic)
    elif len(periodic.shape) == 1:
        return periodic
    else:
        raise ValueError("periodic argument can be either a 3x3 matrix or a shape 3 array.")
122343
function arrayEquals(array1, array2) {
  if (array1.length != array2.length) {
    return false;
  }
  var i;
  for (i = 0; i < array1.length; i++) {
    if (array1[i] != array2[i]) {
      return false;
    }
  }
  return true;
}