diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 1484fc1..880320b 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,15 +1,26 @@
version: 2
updates:
-- package-ecosystem: pip
- directory: "/"
- schedule:
- interval: daily
- time: "04:00"
- open-pull-requests-limit: 10
- target-branch: main
- reviewers:
- - Deuchnord
- commit-message:
- prefix: chore
- include: scope
+ - package-ecosystem: pip
+ directory: "/"
+ open-pull-requests-limit: 5
+ target-branch: main
+ schedule:
+ interval: daily
+ reviewers:
+ - Deuchnord
+ commit-message:
+ prefix: chore
+ include: scope
+
+ - package-ecosystem: github-actions
+ directory: "/"
+ open-pull-requests-limit: 5
+ target-branch: main
+ schedule:
+ interval: weekly
+ reviewers:
+ - Deuchnord
+ commit-message:
+ prefix: ci
+ include: scope
diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml
index 2ddee4a..2cfeb65 100644
--- a/.github/workflows/black.yml
+++ b/.github/workflows/black.yml
@@ -12,8 +12,8 @@ jobs:
name: Code Style
steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-python@v2
+ - uses: actions/checkout@v3
+ - uses: actions/setup-python@v3
with:
python-version: 3.9
- uses: psf/black@20.8b1
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1eb075a..5770dd7 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -10,9 +10,9 @@ jobs:
name: Build and release to PyPI
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v3
- name: Set up Python
- uses: actions/setup-python@v1
+ uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Setup environment
diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml
new file mode 100644
index 0000000..cc51e5d
--- /dev/null
+++ b/.github/workflows/semantic-pr.yml
@@ -0,0 +1,17 @@
+name: "Semantic Pull Request"
+
+on:
+ pull_request:
+ types:
+ - opened
+ - edited
+ - synchronize
+
+jobs:
+ main:
+ name: Validate PR title
+ runs-on: ubuntu-latest
+ steps:
+ - uses: amannn/action-semantic-pull-request@v4
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index d693f63..135ced1 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -8,7 +8,7 @@ on:
workflow_dispatch:
jobs:
- doc-tests:
+ tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@@ -25,9 +25,9 @@ jobs:
name: Doc tests (Python ${{ matrix.python_version }} on ${{ matrix.os }})
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python_version }}
- uses: actions/setup-python@v2
+ uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python_version }}
architecture: x64
@@ -42,20 +42,37 @@ jobs:
run: |
python3 -m poetry install
- - name: Run doc tests (with coverage)
- if: ${{ matrix.os == 'ubuntu-latest' && matrix.python_version == '3.10' }}
+ - name: Run doc tests
run: |
make coverage-doctests
- - name: Run doc tests (without coverage)
- if: ${{ matrix.os != 'ubuntu-latest' || matrix.python_version != '3.10' }}
- run: |
- make doctests
-
- name: Push code coverage
env:
- COVERALLS_PRO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: ${{ matrix.os == 'ubuntu-latest' && matrix.python_version == '3.10' }}
+ COVERALLS_PARALLEL: true
+ COVERALLS_FLAG_NAME: "Py${{ matrix.python_version }}_${{ matrix.os }}"
run: |
python3 -m poetry run coveralls --service=github
+
+ coverage:
+ name: Push coverage report
+ needs: tests
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Prepare Python
+ uses: actions/setup-python@v3
+ with:
+ python-version: "3.x"
+
+ - name: Install dependencies
+ run: |
+ pip install -U pip poetry
+ poetry install
+
+ - name: Upload coverage report
+ run: |
+ poetry run coveralls --finish --service=github
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bf2d825..f577b2f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,12 @@
+# [Version 1.0.6](https://github.com/Kosmorro/lib/compare/v1.0.5...v1.0.6) (2022-03-19)
+
+
+### Bug Fixes
+
+* prevent `get_ephemerides()` from returning values out of the dates given in arguments ([1cf40f5](https://github.com/Kosmorro/lib/commit/1cf40f5b40991b6dc567f979f6bd69fc63807e4e))
+
+
+
# [Version 1.0.5](https://github.com/Kosmorro/lib/compare/v1.0.4...v1.0.5) (2022-02-21)
diff --git a/README.md b/README.md
index ef5f822..b74141e 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,8 @@
[![Coverage Status](https://coveralls.io/repos/github/Kosmorro/lib/badge.svg?branch=main)](https://coveralls.io/github/Kosmorro/lib?branch=main) [![Version on PyPI](https://img.shields.io/pypi/v/kosmorrolib)](https://pypi.org/project/kosmorrolib) [![IRC: #kosmorro on Libera.Chat](https://img.shields.io/badge/Libera.Chat-%23kosmorro-blueviolet)](https://web.libera.chat/?nick=Astronaut?#kosmorro)
+[![Stand with Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
+
## Installation
### Requirements
diff --git a/kosmorrolib/__version__.py b/kosmorrolib/__version__.py
index e5d564e..2d944fd 100644
--- a/kosmorrolib/__version__.py
+++ b/kosmorrolib/__version__.py
@@ -35,7 +35,7 @@ alert_deprecation(
__title__ = "kosmorrolib"
__description__ = "A library to compute your ephemerides"
__url__ = "http://kosmorro.space/lib"
-__version__ = "1.0.5"
+__version__ = "1.0.6"
__author__ = "Jérôme Deuchnord"
__author_email__ = "jerome@deuchnord.fr"
__license__ = "AGPL-v3"
diff --git a/kosmorrolib/dateutil.py b/kosmorrolib/dateutil.py
index 20bc3e5..6d0c96a 100644
--- a/kosmorrolib/dateutil.py
+++ b/kosmorrolib/dateutil.py
@@ -56,7 +56,9 @@ def normalize_datetime(date: datetime) -> datetime:
datetime.datetime(2022, 1, 1, 0, 0)
"""
- new_date = datetime(date.year, date.month, date.day, date.hour, date.minute)
+ new_date = datetime(
+ date.year, date.month, date.day, date.hour, date.minute
+ ).replace(microsecond=0)
if date.second >= 30:
new_date += timedelta(minutes=1)
diff --git a/kosmorrolib/ephemerides.py b/kosmorrolib/ephemerides.py
index 0b51683..f12943b 100644
--- a/kosmorrolib/ephemerides.py
+++ b/kosmorrolib/ephemerides.py
@@ -152,15 +152,15 @@ def get_ephemerides(
>>> get_ephemerides(Position(36.6794, 4.8555), date(2022, 7, 7), timezone=2)
[>,
- >,
+ >,
>,
>,
- >,
- >,
+ >,
+ >,
>,
- >,
- >,
- >]
+ >,
+ >,
+ >]
Objects may not rise or set on the given date (e.g. they rise the previous day or set the next day).
@@ -171,26 +171,64 @@ def get_ephemerides(
>>> north_pole = Position(70, 20)
>>> south_pole = Position(-70, 20)
>>> get_ephemerides(north_pole, date(2021, 6, 20))
- [>, >, >, >, >, >, >, >, >, >]
+ [>,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >]
>>> get_ephemerides(north_pole, date(2021, 12, 21))
- [>, >, >, >, >, >, >, >, >, >]
+ [>,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >]
>>> get_ephemerides(south_pole, date(2021, 6, 20))
- [>, >, >, >, >, >, >, >, >, >]
+ [>,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >]
>>> get_ephemerides(south_pole, date(2021, 12, 22))
- [>, >, >, >, >, >, >, >, >, >]
-
- Note that the ephemerides can only be computed for a date range.
- Asking for the ephemerides with an out of range date will result in an exception:
-
- >>> get_ephemerides(Position(50.5824, 3.0624), date(1000, 1, 1))
- Traceback (most recent call last):
- ...
- kosmorrolib.exceptions.OutOfRangeDateError: The date must be between 1899-07-29 and 2053-10-07
+ [>,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >,
+ >]
+
+ Please note:
+ - The ephemerides can only be computed for a date range. Asking for the ephemerides with an out of range date will result in an exception:
+
+ >>> get_ephemerides(Position(50.5824, 3.0624), date(1000, 1, 1))
+ Traceback (most recent call last):
+ ...
+ kosmorrolib.exceptions.OutOfRangeDateError: The date must be between 1899-07-29 and 2053-10-07
+
+ - The date given in parameter is considered as being given from the point of view of the given timezone.
+ Using a timezone that does not correspond to the place's actual one can impact the returned times.
"""
- ephemerides = []
def get_angle(for_aster: Object):
def fun(time: Time) -> float:
@@ -213,13 +251,19 @@ def get_ephemerides(
fun.rough_period = 0.5
return fun
+ # The date given in argument is supposed to be given in the given timezone (more natural for a human),
+ # but we need it in UTC. Subtracting the timezone to get it in UTC.
+
start_time = get_timescale().utc(
- for_date.year, for_date.month, for_date.day, timezone
+ for_date.year, for_date.month, for_date.day, -timezone
)
+
end_time = get_timescale().utc(
- for_date.year, for_date.month, for_date.day, 23 + timezone, 59, 59
+ for_date.year, for_date.month, for_date.day + 1, -timezone
)
+ ephemerides = []
+
try:
for aster in ASTERS:
times, risen_info = find_discrete(start_time, end_time, is_risen(aster))
@@ -230,37 +274,27 @@ def get_ephemerides(
culmination_time[0] if len(culmination_time) == 1 else None
)
- if len(times) > 0:
- rise_time = times[0] if risen_info[0] else None
- set_time = times[0] if not risen_info[0] else None
+ for i, time in enumerate(times):
+ time_dt = normalize_datetime(
+ translate_to_timezone(time.utc_datetime(), to_tz=timezone)
+ )
- if len(times) == 2:
- rise_time = times[0 if risen_info[0] else 1]
- set_time = times[1 if not risen_info[1] else 0]
+ if time_dt is not None and time_dt.day != for_date.day:
+ continue
- # Convert the Time instances to Python datetime objects
- if rise_time is not None:
- rise_time = normalize_datetime(
- translate_to_timezone(
- rise_time.utc_datetime().replace(microsecond=0), to_tz=timezone
- )
- )
+ if risen_info[i]:
+ rise_time = time_dt
+ else:
+ set_time = time_dt
if culmination_time is not None:
culmination_time = normalize_datetime(
translate_to_timezone(
- culmination_time.utc_datetime().replace(microsecond=0),
+ culmination_time.utc_datetime(),
to_tz=timezone,
)
)
- if set_time is not None:
- set_time = normalize_datetime(
- translate_to_timezone(
- set_time.utc_datetime().replace(microsecond=0), to_tz=timezone
- )
- )
-
ephemerides.append(
AsterEphemerides(rise_time, culmination_time, set_time, aster=aster)
)
diff --git a/pyproject.toml b/pyproject.toml
index f1430c0..1d90d66 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "kosmorrolib"
-version = "1.0.5"
+version = "1.0.6"
authors = ["Jérôme Deuchnord "]
homepage = "https://kosmorro.space/lib"
repository = "https://github.com/Kosmorro/lib"