utils module

clusterlensing.utils.check_array_or_list(input)

Return 1D ndarray, if input can be converted and elements are non-negative.

clusterlensing.utils.check_input_size(array, num)

Check that an array has the expected number of elements.

clusterlensing.utils.check_units_and_type(input, expected_units, num=None, is_scalar=False)

Check whether variable has expected units and type.

If input does not have units and expected units is not None, then the output will be assigned those units. If input has units that conflict with expected units a ValueError will be raised.

Parameters:

input : array_like or float

Variable that will be checked for units and type. Variable should be 1D or scalar.

expected_units : astropy.units or None

Unit expected for input.

num : int, optional

Length expected for input, if it is an array or list.

is_scalar : bool, optional

Sets whether the input is a scalar quantity. Default is False for array_like inputs; set is_scalar=True to check scalar units only.

Returns:

ndarray or float, with astropy.units :

Returns the input array or scalar with expected units, unless a conflict of units or array length occurs, which raise errors.