simopt.utils ============ .. py:module:: simopt.utils .. autoapi-nested-parse:: Utility functions for simopt. Module Contents --------------- .. py:data:: T .. py:data:: R .. py:class:: ClassPropertyDescriptor(fget: collections.abc.Callable[[type[T]], R]) Bases: :py:obj:`Generic`\ [\ :py:obj:`T`\ , :py:obj:`R`\ ] Descriptor for class properties. Initialize the descriptor. :param fget: The function to get the class property. :type fget: Callable[[type[T]], R] .. py:attribute:: fget .. py:function:: classproperty(func: collections.abc.Callable[[type[T]], R]) -> ClassPropertyDescriptor[T, R] Decorator to define a class property. :param func: The function to be decorated. :type func: Callable[[type[T]], R] :returns: The class property descriptor. :rtype: ClassPropertyDescriptor[T, R] .. py:function:: override(obj: T) -> T Decorator to mark a method as overridden. .. py:function:: make_nonzero(value: float, name: str, epsilon: float = 1e-15) -> float Return a non-zero value to avoid division by zero. :param value: The value to check. :type value: float :param name: The name of the variable. :type name: str :param epsilon: The value to use if the original value is zero. Default is 1e-15. :type epsilon: float, optional :returns: The original value if it's not close to zero, otherwise a non-zero value. :rtype: float .. py:function:: resolve_file_path(target: str | pathlib.Path, directory: str | pathlib.Path) -> pathlib.Path Resolve a file path against a base directory. :param target: The target file path to resolve. :type target: str | Path :param directory: The base directory to resolve against. :type directory: str | Path :returns: The resolved file path. :rtype: Path :raises ValueError: If the target is a directory. .. py:function:: print_table(name: str, headers: list[str], data: list[tuple] | dict) -> None Print a table with headers and data. :param name: Name of the table. :type name: str :param headers: List of column headers. :type headers: list[str] :param data: List of rows, each row is a tuple of values. :type data: list[tuple] .. py:function:: get_specifications(config_class: type[pydantic.BaseModel]) -> dict[str, dict] Get the specifications for a configuration class.