-
Notifications
You must be signed in to change notification settings - Fork 0
feat: added endpoint option to date_range
#220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
47b16d0
5ee6562
4735549
b45d448
1caa048
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,18 +11,7 @@ on: | |||||
| jobs: | ||||||
| build: | ||||||
|
|
||||||
| runs-on: ${{ matrix.os }} | ||||||
| strategy: | ||||||
| matrix: | ||||||
| os: [ubuntu-latest] | ||||||
| python-version: [3.11] | ||||||
| env: | ||||||
| OS: ${{ matrix.os }} | ||||||
| PYTHON: ${{ matrix.python-version }} | ||||||
| defaults: | ||||||
| run: | ||||||
| shell: bash -l {0} | ||||||
|
|
||||||
| runs-on: ubuntu-slim | ||||||
|
||||||
| runs-on: ubuntu-slim | |
| runs-on: ubuntu-22.04 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,15 +5,13 @@ name: Upload Python Package | |||||
|
|
||||||
| on: | ||||||
| release: | ||||||
| types: [created] | ||||||
| types: [released] | ||||||
|
|
||||||
| jobs: | ||||||
| deploy: | ||||||
|
|
||||||
| runs-on: ubuntu-latest | ||||||
|
|
||||||
| runs-on: ubuntu-slim | ||||||
|
||||||
| runs-on: ubuntu-slim | |
| runs-on: ubuntu-latest |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,7 +93,6 @@ exclude = [ | |
| ".git", | ||
| ".pixi", | ||
| "build", | ||
| "doc", | ||
| "run", | ||
| "test", | ||
| ] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -211,6 +211,16 @@ def test_earth_rotation_angle(): | |
| expected = 0.8730204642501604 | ||
| assert np.isclose(360.0*expected, ts.era).all() | ||
|
|
||
| def test_from_range(): | ||
| """Test that the from range functions expected outputs | ||
|
tsutterley marked this conversation as resolved.
Outdated
|
||
| """ | ||
| ts = timescale.from_range('2020-01-01','2020-02-01',1,'D') | ||
| exp = 58849 + np.arange(32) | ||
| assert np.all(ts.MJD == exp) | ||
| ts = timescale.from_range('2020-01-01','2020-02-01',1,'D',endpoint=False) | ||
| exp = 58849 + np.arange(31) | ||
| assert np.all(ts.MJD == exp) | ||
|
Comment on lines
+218
to
+222
|
||
|
|
||
| def test_gps_week(): | ||
| """Test that the GPS week matches expected outputs | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| #!/usr/bin/env python | ||
| """ | ||
| time.py | ||
| Written by Tyler Sutterley (12/2025) | ||
| Written by Tyler Sutterley (04/2026) | ||
| Utilities for calculating time operations | ||
|
|
||
| PYTHON DEPENDENCIES: | ||
|
|
@@ -16,6 +16,8 @@ | |
| utilities.py: download and management utilities for syncing files | ||
|
|
||
| UPDATE HISTORY: | ||
| Updated 04/2026: added endpoint option (defaults to True) to date_range | ||
| added default day and month values to from_calendar function | ||
| Updated 12/2025: allow conversion to datetime be in different units | ||
| Updated 08/2025: add nominal years (365.25 days long) to Timescale class | ||
| Updated 07/2025: verify Bulletin-A entries are not already in merged file | ||
|
|
@@ -269,6 +271,7 @@ def date_range( | |
| end: str | np.datetime64 | datetime.datetime, | ||
| step: int | float = 1, | ||
| units: str = "D", | ||
| endpoint: bool = True, | ||
|
tsutterley marked this conversation as resolved.
|
||
| ): | ||
| """ | ||
| Create a range of dates | ||
|
|
@@ -292,14 +295,16 @@ def date_range( | |
| - ``'m'``: minute | ||
| - ``'s'``: second | ||
| - ``'ms'``: millisecond | ||
| endpoint: bool, default True | ||
| If True, include the end date in the output | ||
| """ | ||
| # convert start and end dates to datetime64 | ||
| if isinstance(start, str): | ||
| start = np.array(parse(start), dtype=f"datetime64[{units}]") | ||
| if isinstance(end, str): | ||
| end = np.array(parse(end), dtype=f"datetime64[{units}]") | ||
| # create date range | ||
| return np.arange(start, end + step, step) | ||
| return np.arange(start, end + endpoint * step, step) | ||
|
||
|
|
||
|
|
||
| # days per month in a leap and a standard year | ||
|
|
@@ -877,8 +882,8 @@ def from_deltatime( | |
| def from_calendar( | ||
| cls, | ||
| year: np.ndarray, | ||
| month: np.ndarray, | ||
| day: np.ndarray, | ||
| month: np.ndarray | float = 1.0, | ||
| day: np.ndarray | float = 1.0, | ||
|
tsutterley marked this conversation as resolved.
|
||
| hour: np.ndarray | float = 0.0, | ||
| minute: np.ndarray | float = 0.0, | ||
| second: np.ndarray | float = 0.0, | ||
|
|
@@ -890,9 +895,9 @@ def from_calendar( | |
| ---------- | ||
| year: np.ndarray | ||
| calendar year | ||
| month: np.ndarray | ||
| month: np.ndarray or float, default 1.0 | ||
| month of the year | ||
| day: np.ndarray | ||
| day: np.ndarray or float, default 1.0 | ||
| day of the month | ||
| hour: np.ndarray or float, default 0.0 | ||
| hour of the day | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ubuntu-slimis not a valid GitHub-hosted runner label, so this scheduled job will not run. Use a supported runner label such asubuntu-latestorubuntu-22.04.