saferoad.utils module

class saferoad.utils.Timer(name=None)[source]

Bases: object

Context manager for timing code execution.

saferoad.utils.extract_dates(column_names: list[str]) tuple[list[str], list[datetime]][source]

Extracts date fields from a list of column names.

Parameters:

column_names (list[str]) – List of column names to search for dates.

Returns:

A tuple containing two numpy arrays: one with the column names and another with the parsed date objects.

Return type:

tuple[ndarray, ndarray]

saferoad.utils.time_vector(dates: list[datetime]) array[source]

Generates a time vector in days from a list of datetime objects.

Parameters:

dates (list[datetime]) – List of datetime objects.

Returns:

List of time differences in days from the first date.

Return type:

list[float]