Check whether one forward mode input array is of valid shape
        Returns inferred value of T
557439
def _check_forward_mode_input_array(self, X: np.ndarray) -> int:
        
        # Find the length of each variable to infer T
        if not isinstance(X, np.ndarray):
            raise ValueError('X must be a numpy array, dict, or scalar')
        # Get the shape and tensor rank
        shape = X.shape
        tensor_rank = len(shape)
        T = 0
        # Only 1D and 2D arrays are supported
        if tensor_rank not in (0, 1, 2):
            raise ValueError(f'Shape of X = {X.shape}. Numpy array must be a 1D vector or 2D matrix')        
        if tensor_rank == 0:
            T = 1
        # If the input was a 1D vector, its length must EITHER (1) be T, or (2) m, with T == 1
        if tensor_rank == 1 and (shape[0] != self.m) and self.m != 1:
            raise ValueError(f'Error: X has shape {X.shape}, incompatible with m = {self.m} on fluxion.')
        # Return the value of T in this situation
        if tensor_rank == 1 and shape[0] == self.m:
            T = 1
        if tensor_rank == 1 and self.m == 1:
            T = shape[0]
        # If the input was a 2D vector, it must be of shape Txn
        if tensor_rank == 2 and (shape[1] != self.m):
            raise ValueError(f'Error: X has shape {X.shape}, incompatible with m = {self.m} on fluxion.')
        if tensor_rank == 2:
            T = shape[0]
        return T
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])
378638
def is_array(type_):
    """"""
    nake_type = remove_alias(type_)
    nake_type = remove_reference(nake_type)
    nake_type = remove_cv(nake_type)
    return isinstance(nake_type, cpptypes.array_t)
979954
def _get_c_valid_arr(self, x):
        
        orig_shape = x.shape
        x = np.ascontiguousarray(x.reshape(orig_shape[0], -1).T)
        return orig_shape, x
381158
def checkIsConsistent(self):
        
        if is_an_array(self.mask) and self.mask.shape != self.data.shape:
            raise ConsistencyError("Shape mismatch mask={}, data={}"
                                   .format(self.mask.shape != self.data.shape))
591859
def _infer_shape(self, dimensions):
    
    # Size of input
    n = np.prod(dimensions)
    # Size of output where defined
    m = np.prod(abs(np.array(self._shape)))
    # Replace wildcard
    v = np.array(self._shape)
    v[v == -1] = n // m
    return tuple(v)
425317
public static boolean isVector(int[] shape) {
        if (shape.length > 2 || shape.length < 1)
            return false;
        else {
            long len = ArrayUtil.prodLong(shape);
            return shape[0] == len || shape[1] == len;
        }
    }
343926
function isSafeIntegerArray( value ) {
	var len, i;
	if ( !isArray( value ) ) {
		return false;
	}
	len = value.length;
	if ( !len ) {
		return false;
	}
	for ( i = 0; i < len; i++ ) {
		if ( !isSafeInteger( value[i] ) ) {
			return false;
		}
	}
	return true;
}
1088920
def _float_check(self, attribute_array, value, irow, key):
        ''''''
        value = value.strip(' ')
        try:
            if value:
                attribute_array = np.hstack([attribute_array, float(value)])
            else:
                attribute_array = np.hstack([attribute_array, np.nan])
        except:
            print(irow, key)
            msg = 'Input file format error at line: %d' % (irow + 2)
            msg += ' key: %s' % (key)
            raise ValueError(msg)
        return attribute_array
731350
def _check_lsm_input(self, data_var_map_array):
        
        REQUIRED_HMET_VAR_LIST = ['Prcp', 'Pres', 'Temp', 'Clod',
                                  'RlHm', 'Drad', 'Grad', 'WndS']

        # make sure all required variables exist
        given_hmet_var_list = []
        for gssha_data_var, lsm_data_var in data_var_map_array:
            gssha_data_hmet_name = self.netcdf_attributes[gssha_data_var]['hmet_name']

            if gssha_data_hmet_name in given_hmet_var_list:
                raise ValueError("Duplicate parameter for HMET variable {0}"
                                 .format(gssha_data_hmet_name))
            else:
                given_hmet_var_list.append(gssha_data_hmet_name)

        for REQUIRED_HMET_VAR in REQUIRED_HMET_VAR_LIST:
            if REQUIRED_HMET_VAR not in given_hmet_var_list:
                raise ValueError("ERROR: HMET param is required to continue "
                                 "{0} ...".format(REQUIRED_HMET_VAR))
1175919
function _eachArrayForward(arry, fn) {
  let ret = true
  for (let i = 0; i < arry.length; i++) {
    ret = fn(arry[i], i, arry)
    if (ret === false) {
      break
    }
  }
  return ret
}
722713
def _op_shape(self, other):
        """"""
        if isinstance(other, farray):
            if self.shape == other.shape:
                return self.shape
            elif self.size == other.size:
                return None
            else:
                raise ValueError("expected operand sizes to match")
        else:
            raise TypeError("expected farray input")
549473
def verify(self, x):
        
        if type(x) != type(self.data):
            raise TypeError("Input expected to be of type %s, got %s." %
                            (type(self.data).__name__, type(x).__name__))
        elif isinstance(x, np.ndarray):
            if x.ndim != 2:
                raise ValueError('Streamed array data must be two-dimensional')
            elif x.shape[1] != self.data.shape[1]:
                raise ValueError("Streamed array data expeced to have %d columns, "
                                 "got %d." % (self.data.shape[1], x.shape[1]))
        elif util.pd and isinstance(x, util.pd.DataFrame) and list(x.columns) != list(self.data.columns):
            raise IndexError("Input expected to have columns %s, got %s" %
                             (list(self.data.columns), list(x.columns)))
        elif isinstance(x, dict):
            if any(c not in x for c in self.data):
                raise IndexError("Input expected to have columns %s, got %s" %
                                 (sorted(self.data.keys()), sorted(x.keys())))
            elif len(set(len(v) for v in x.values())) > 1:
                raise ValueError("Input columns expected to have the "
                                 "same number of rows.")
1243179
def check_consistent_parameter_dimensions(self):
        
        if self.indices_per_axis is not None:
            if len(self.indices_per_axis) > len(self.array_shape):
                raise ValueError(
                    "Got len(self.indices_per_axis)=%s > len(self.array_shape)=%s, should be equal."
                    %
                    (len(self.indices_per_axis), len(self.array_shape))
                )
        if self.split_num_slices_per_axis is not None:
            if len(self.split_num_slices_per_axis) > len(self.array_shape):
                raise ValueError(
                    (
                        "Got len(self.split_num_slices_per_axis)=%s > len(self.array_shape)=%s,"
                        +
                        " should be equal."
                    )
                    %
                    (len(self.split_num_slices_per_axis), len(self.array_shape))
                )
        if self.tile_shape is not None:
            if len(self.tile_shape) != len(self.array_shape):
                raise ValueError(
                    "Got len(self.tile_shape)=%s > len(self.array_shape)=%s, should be equal."
                    %
                    (len(self.tile_shape), len(self.array_shape))
                )

        if self.sub_tile_shape is not None:
            if len(self.sub_tile_shape) != len(self.array_shape):
                raise ValueError(
                    "Got len(self.sub_tile_shape)=%s > len(self.array_shape)=%s, should be equal."
                    %
                    (len(self.sub_tile_shape), len(self.array_shape))
                )

        if self.max_tile_shape is not None:
            if len(self.max_tile_shape) != len(self.array_shape):
                raise ValueError(
                    "Got len(self.max_tile_shape)=%s > len(self.array_shape)=%s, should be equal."
                    %
                    (len(self.max_tile_shape), len(self.array_shape))
                )

        if self.array_start is not None:
            if len(self.array_start) != len(self.array_shape):
                raise ValueError(
                    "Got len(self.array_start)=%s > len(self.array_shape)=%s, should be equal."
                    %
                    (len(self.array_start), len(self.array_shape))
                )
365490
def _forward_mode(self, *args):
        """"""
        # Evaluate inner function self.f
        X: np.ndarray
        dX: np.ndarray
        X, dX = self.f._forward_mode(*args)
        # Alias the power to p for legibility
        p: float = self.p
        # The function value
        val = X ** p
        # The derivative
        diff = p * X ** (p-1) * dX
        return (val, diff)
768292
def check_dtype(array, allowed):
    
    if not hasattr(allowed, "__iter__"):
        allowed = [allowed,]
    if array.dtype not in allowed:
        raise(TypeError(
            "Invalid dtype {}. Allowed dtype(s): {}".format(array.dtype, allowed)))
310622
def _check_valid_data(self, data):
        
        if data.dtype.type is not np.float32 and \
                data.dtype.type is not np.float64:
            raise ValueError(
                'Illegal data type. Depth images only support float arrays')

        if len(data.shape) == 3 and data.shape[2] != 1:
            raise ValueError(
                'Illegal data type. Depth images only support single channel')