arthurai.core.dataset_validation_utils.get_first_elem_if_valid_list#

arthurai.core.dataset_validation_utils.get_first_elem_if_valid_list(obj, source, expected, outer_type='')#

Validates obj is list-like and non-empty and returns the first element.

Raises a UserTypeError if obj is not list-like (is not a numpy array or python list). Logs a warning if the length of the list is 0 or the list has a None object.

Param

obj: Object whose data type is being checked.

Param

attr_name: String source of the object for clear error messages.

Param

expected: String of expected type of the object for clear error messages.

Param

outer_type: String representing the data type of the object obj was nested in for clear error messages. Defaults to empty string.

Raises

UserTypeError if obj is not list-like.

Return type

Any

Returns

first element if obj is a list, None otherwise