TimeDelta
timedelta
Classes:
-
TimeDeltaDG–Represents the time granularity for a temporal index in a dynamic graph.
TimeDeltaDG
dataclass
Represents the time granularity for a temporal index in a dynamic graph.
This class is used to define the resolution at which events or interactions are indexed in a dynamic/temporal graph. It supports both standard temporal units (e.g., seconds, minutes, days) and a special event-ordered unit for strictly sequential indices.
Parameters:
-
unit(str) –The time unit, e.g., 's', 'm', 'h', 'D', or 'r' for event-ordered.
-
value(int, default:1) –Multiplier for the unit. Must be a positive integer.
Raises:
-
ValueError–If
valueis not a positive integer. -
ValueError–If
unitis event-ordered andvalue!= 1. -
ValueError–If
unitis not recognized among allowed temporal units.
Note
For event-ordered units ('r'), only value = 1 is permitted.
Methods:
-
convert–Convert this granularity into the scale of another time delta.
-
is_coarser_than–Return True if this granularity is strictly coarser than
other.
Attributes:
-
is_event_ordered(bool) –Return True if this is the special event-ordered unit ('r').
-
is_time_ordered(bool) –Return True if this is not special event-ordered unit ('r').
is_event_ordered
property
is_event_ordered: bool
Return True if this is the special event-ordered unit ('r').
is_time_ordered
property
is_time_ordered: bool
Return True if this is not special event-ordered unit ('r').
convert
convert(time_delta: str | TimeDeltaDG) -> float
Convert this granularity into the scale of another time delta.
Parameters:
-
time_delta(str | TimeDeltaDG) –Target time delta to convert into.
Returns:
-
float(float) –Ratio of self to target granularity.
Raises:
-
EventOrderedConversionError–If either self or target granularity is event-ordered.
Source code in tgm/core/timedelta.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
is_coarser_than
is_coarser_than(other: str | TimeDeltaDG) -> bool
Return True if this granularity is strictly coarser than other.
Parameters:
-
other(str | TimeDeltaDG) –The time delta to compare against.
Raises:
-
EventOrderedConversionError–If either self or
otheris event-ordered.
Source code in tgm/core/timedelta.py
68 69 70 71 72 73 74 75 76 77 | |