-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ts_idx_refactor' into v0.2-integration
- Loading branch information
Showing
11 changed files
with
3,040 additions
and
4,600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ sphinx-design==0.2.0 | |
sphinx-panels==0.6.0 | ||
jsonref==1.1.0 | ||
python-dateutil==2.8.2 | ||
parameterized==0.8.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from typing import NamedTuple | ||
from functools import total_ordering | ||
|
||
|
||
@total_ordering | ||
class TimeUnit(NamedTuple): | ||
name: str | ||
approx_seconds: float | ||
""" | ||
Represents a unit of time, with a name, | ||
an approximate number of seconds, | ||
and a sub-second precision. | ||
""" | ||
|
||
def __eq__(self, other): | ||
return self.approx_seconds == other.approx_seconds | ||
|
||
def __lt__(self, other): | ||
return self.approx_seconds < other.approx_seconds | ||
|
||
|
||
TimeUnitsType = NamedTuple("TimeUnitsType", | ||
[("YEARS", TimeUnit), | ||
("MONTHS", TimeUnit), | ||
("WEEKS", TimeUnit), | ||
("DAYS", TimeUnit), | ||
("HOURS", TimeUnit), | ||
("MINUTES", TimeUnit), | ||
("SECONDS", TimeUnit), | ||
("MILLISECONDS", TimeUnit), | ||
("MICROSECONDS", TimeUnit), | ||
("NANOSECONDS", TimeUnit)]) | ||
|
||
StandardTimeUnits = TimeUnitsType( | ||
TimeUnit("year", 365 * 24 * 60 * 60), | ||
TimeUnit("month", 30 * 24 * 60 * 60), | ||
TimeUnit("week", 7 * 24 * 60 * 60), | ||
TimeUnit("day", 24 * 60 * 60), | ||
TimeUnit("hour", 60 * 60), | ||
TimeUnit("minute", 60), | ||
TimeUnit("second", 1), | ||
TimeUnit("millisecond", 1e-03), | ||
TimeUnit("microsecond", 1e-06), | ||
TimeUnit("nanosecond", 1e-09) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.