# Copyright 2020 Toyota Research Institute. All rights reserved.
import yacs
import numpy as np
import torch
########################################################################################################################
[docs]def is_numpy(data):
"""Checks if data is a numpy array."""
return isinstance(data, np.ndarray)
[docs]def is_tensor(data):
"""Checks if data is a torch tensor."""
return type(data) == torch.Tensor
[docs]def is_tuple(data):
"""Checks if data is a tuple."""
return isinstance(data, tuple)
[docs]def is_list(data):
"""Checks if data is a list."""
return isinstance(data, list)
[docs]def is_dict(data):
"""Checks if data is a dictionary."""
return isinstance(data, dict)
[docs]def is_str(data):
"""Checks if data is a string."""
return isinstance(data, str)
[docs]def is_int(data):
"""Checks if data is an integer."""
return isinstance(data, int)
[docs]def is_seq(data):
"""Checks if data is a list or tuple."""
return is_tuple(data) or is_list(data)
[docs]def is_cfg(data):
"""Checks if data is a configuration node"""
return type(data) == yacs.config.CfgNode
########################################################################################################################