From 83874fc8a3fa454e98b46608fd2427677740df82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Tue, 8 Mar 2022 10:35:30 +0100 Subject: [PATCH 1/9] misc: stand with Ukraine --- README.md | 2 ++ 1 file changed, 2 insertions(+) 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 From 1cf40f5b40991b6dc567f979f6bd69fc63807e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Tue, 22 Feb 2022 19:10:29 +0100 Subject: [PATCH 2/9] fix: prevent `get_ephemerides()` from returning values out of the dates given in arguments --- kosmorrolib/dateutil.py | 4 +- kosmorrolib/ephemerides.py | 118 ++++++++++++++++++++++++------------- 2 files changed, 79 insertions(+), 43 deletions(-) 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) ) From 064ba31e85629676643f3d7e320768d7c11507f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Sat, 19 Mar 2022 10:40:21 +0100 Subject: [PATCH 3/9] build: bump version 1.0.6 --- CHANGELOG.md | 9 +++++++++ kosmorrolib/__version__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) 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/kosmorrolib/__version__.py b/kosmorrolib/__version__.py index 6a46e13..90aa1b4 100644 --- a/kosmorrolib/__version__.py +++ b/kosmorrolib/__version__.py @@ -19,7 +19,7 @@ __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/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" From 72b92db1a93f97ad509bf1999f9d08941deb1b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Thu, 24 Mar 2022 13:37:11 +0100 Subject: [PATCH 4/9] ci(dependabot): update GitHub Action images automatically --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1484fc1..deba1c2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,3 +13,15 @@ updates: commit-message: prefix: chore include: scope + + - package-ecosystem: github-actions + directory: "/" + open-pull-requests-limit: 5 + target-branch: master + schedule: + interval: weekly + reviewers: + - Deuchnord + commit-message: + prefix: ci + include: scope From 58f64b17ba96407e6522a3997c621dcf740632bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Thu, 24 Mar 2022 13:37:51 +0100 Subject: [PATCH 5/9] ci(dependabot): update configuration for PIP packages upgrade --- .github/dependabot.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index deba1c2..1639376 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,8 +5,7 @@ updates: directory: "/" schedule: interval: daily - time: "04:00" - open-pull-requests-limit: 10 + open-pull-requests-limit: 5 target-branch: main reviewers: - Deuchnord From cd240ce4eb4310598cb1dcddff0a63fe5464d7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Thu, 24 Mar 2022 13:38:31 +0100 Subject: [PATCH 6/9] chore(dependabot): fix Yaml style --- .github/dependabot.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1639376..880320b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,22 +1,22 @@ version: 2 updates: -- package-ecosystem: pip - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 5 - 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: master + target-branch: main schedule: interval: weekly reviewers: From 00a2899198a90c7c0df632a0b2d20c5f889be4cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Mar 2022 12:49:45 +0000 Subject: [PATCH 7/9] ci(deps): bump actions/setup-python from 2 to 3 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 3. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/black.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 2ddee4a..51a49a8 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -13,7 +13,7 @@ jobs: name: Code Style steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - 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..9be3223 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v1 - 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/tests.yml b/.github/workflows/tests.yml index d693f63..00a909b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,7 +27,7 @@ jobs: steps: - uses: actions/checkout@v2 - 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 From 82c6b4a710d77680bcdbd5bee4ae9af6c53227d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Mar 2022 13:03:32 +0000 Subject: [PATCH 8/9] ci(deps): bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/black.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 51a49a8..2cfeb65 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -12,7 +12,7 @@ jobs: name: Code Style steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-python@v3 with: python-version: 3.9 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9be3223..5770dd7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ 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@v3 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 00a909b..b23268c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,7 @@ 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@v3 with: From 0f354c9dc521169bfc490dac8075b72185afe88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Wed, 11 May 2022 16:19:01 +0200 Subject: [PATCH 9/9] ci: compute coverage on all test jobs --- .github/workflows/semantic-pr.yml | 17 ++++++++++++++ .github/workflows/tests.yml | 37 ++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/semantic-pr.yml 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 b23268c..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 @@ -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 }}