def check_extension(filename, extension): from pytracer.utils.log import get_logger logger = get_logger() def warn(): logger.warning(f"{filename} does not have {extension} extension") _, ext = os.path.splitext(filename) if isinstance(extension, (tuple, list)): if ext not in extension: warn() return False return True if isinstance(extension, str): if ext != extension: warn() return False return True raise TypeError
from enum import IntEnum, auto from types import FunctionType from pytracer.utils.log import get_logger logger = get_logger() class TypeValue(IntEnum): INT = auto() FLOAT = auto() NUMPY = auto() BOOL = auto() LIST = auto() TUPLE = auto() FUNCTION = auto() SKLEARN = auto() OTHER = auto() def is_scalar(self): if not hasattr(self, "__scalar"): self.__scalar = (self.INT, self.FLOAT) return self in self.__scalar def is_vector(self): if not hasattr(self, "__vector"): self.__vector = (self.VECTOR,) return self in self.__vector def is_matrix(self):