h2o-py/h2o/utils/typechecks.py
def assert_is_type(var, *types, **kwargs):
    """
    Assert that the argument has the specified type.

    This function is used to check that the type of the argument is correct, otherwises it raises an H2OTypeError.
    See more details in the module's help.

    :param var: variable to check
    :param types: the expected types
    :param kwargs:
        message: override the error message
        skip_frames: how many local frames to skip when printing out the error.

    :raises H2OTypeError: if the argument is not of the desired type.
    """
    assert types, "The list of expected types was not provided"
    expected_type = types[0] if len(types) == 1 else U(*types)
    if _check_type(var, expected_type): return

    # Type check failed => Create a nice error message
    assert set(kwargs).issubset({"message", "skip_frames"}), "Unexpected keyword arguments: %r" % kwargs
    message = kwargs.get("message", None)
    skip_frames = kwargs.get("skip_frames", 1)
    args = _retrieve_assert_arguments()
    vname = args[0]
    etn = _get_type_name(expected_type, dump=", ".join(args[1:]))
    vtn = _get_type_name(type(var))
    raise H2OTypeError(var_name=vname, var_value=var, var_type_name=vtn, exp_type_name=etn, message=message,
                       skip_frames=skip_frames)
def assert_is_type(var, *types, **kwargs):
    assert types, "The list of expected types was not provided"
    expected_type = types[0] if len(types) == 1 else U(*types)
    if _check_type(var, expected_type): return

    # Type check failed => Create a nice error message
    assert set(kwargs).issubset({"message", "skip_frames"}), "Unexpected keyword arguments: %r" % kwargs
    message = kwargs.get("message", None)
    skip_frames = kwargs.get("skip_frames", 1)
    args = _retrieve_assert_arguments()
    vname = args[0]
    etn = _get_type_name(expected_type, dump=", ".join(args[1:]))
    vtn = _get_type_name(type(var))
    raise H2OTypeError(var_name=vname, var_value=var, var_type_name=vtn, exp_type_name=etn, message=message,
                       skip_frames=skip_frames)
def assert_is_type ( var , * types , * * kwargs ) : assert types , "The list of expected types was not provided" expected_type = types [ 0 ] if len ( types ) == 1 else U ( * types ) if _check_type ( var , expected_type ) : return # Type check failed => Create a nice error message assert set ( kwargs ) . issubset ( { "message" , "skip_frames" } ) , "Unexpected keyword arguments: %r" % kwargs message = kwargs . get ( "message" , None ) skip_frames = kwargs . get ( "skip_frames" , 1 ) args = _retrieve_assert_arguments ( ) vname = args [ 0 ] etn = _get_type_name ( expected_type , dump = ", " . join ( args [ 1 : ] ) ) vtn = _get_type_name ( type ( var ) ) raise H2OTypeError ( var_name = vname , var_value = var , var_type_name = vtn , exp_type_name = etn , message = message , skip_frames = skip_frames )
Assert that the argument has the specified type.

    This function is used to check that the type of the argument is correct, otherwises it raises an H2OTypeError.
    See more details in the module's help.

    :param var: variable to check
    :param types: the expected types
    :param kwargs:
        message: override the error message
        skip_frames: how many local frames to skip when printing out the error.

    :raises H2OTypeError: if the argument is not of the desired type.
Assert that the argument has the specified type .