watex.utils.funcutils.is_in_if#
- watex.utils.funcutils.is_in_if(o, /, items, error='raise', return_diff=False, return_intersect=False)[source]#
Raise error if item is not found in the iterable object ‘o’
- Parameters
o – unhashable type, iterable object, object for checkin. It assumes to be an iterable from which ‘items’ is premused to be in.
items – str or list, Items to assert whether it is in o or not.
error – str, default=’raise’ raise or ignore error when none item is found in o.
return_diff – bool, returns the difference items which is/are not included in ‘items’ if return_diff is
True, will put error toignoresystematically.
- :param return_intersect:bool,default=False
returns items as the intersection between o and items.
- Raise
ValueError raise ValueError if items not in o.
- Returns
list, s : object found in
o` or the difference object i.e the object that is not in `items` provided that `error` is set to ``ignore. Note that if None object is found and error isignore, it will returnNone, otherwise, a ValueError raises.- Example
>>> from watex.datasets import load_hlogs >>> from watex.utils.funcutils import is_in_if >>> X0, _= load_hlogs (as_frame =True ) >>> is_in_if (X0 , items= ['depth_top', 'top']) ... ValueError: Item 'top' is missing in the object >>> is_in_if (X0, ['depth_top', 'top'] , error ='ignore') ... ['depth_top'] >>> is_in_if (X0, ['depth_top', 'top'] , error ='ignore', return_diff= True) ... ['sp', 'well_diameter', 'layer_thickness', 'natural_gamma', 'short_distance_gamma', 'strata_name', 'gamma_gamma', 'depth_bottom', 'rock_name', 'resistivity', 'hole_id']