Skip to content

Commit

Permalink
Merge pull request #289 from nyx-space/4.0.0-dev-gh-237
Browse files Browse the repository at this point in the history
4.0.0 dev gh 237
  • Loading branch information
ChristopherRabotin authored Apr 24, 2024
2 parents 8b43b98 + 6139ecc commit 2483f3f
Show file tree
Hide file tree
Showing 40 changed files with 2,835 additions and 3,026 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -57,7 +57,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -78,7 +78,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/formal_verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
continue-on-error: true
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Clean Cargo.toml for Kani
run: |
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ jobs:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
check-latest: false
allow-prereleases: false
- name: Remove bad python
run: ls -l `which python`; ls -l /usr/bin/python*
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand Down Expand Up @@ -63,7 +61,8 @@ jobs:
shell: bash
run: |
set -e
pip install hifitime --find-links dist --force-reinstall
ls dist
pip install hifitime --find-links dist --force-reinstall --no-index -vv
pip install pytest
pytest
- name: pytest
Expand All @@ -79,7 +78,8 @@ jobs:
pip3 install -U pip pytest
run: |
set -e
pip3 install hifitime --find-links dist --force-reinstall
ls dist
pip3 install hifitime --find-links dist --force-reinstall --no-index -vv
pytest
windows:
Expand All @@ -88,7 +88,7 @@ jobs:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
Expand All @@ -109,7 +109,7 @@ jobs:
shell: bash
run: |
set -e
pip install hifitime --find-links dist --force-reinstall
pip install hifitime --find-links dist --force-reinstall --no-index -vv
pip install pytest
pytest
Expand All @@ -119,7 +119,7 @@ jobs:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
Expand All @@ -139,14 +139,14 @@ jobs:
shell: bash
run: |
set -e
pip install hifitime --find-links dist --force-reinstall
pip install hifitime --find-links dist --force-reinstall --no-index -vv
pip install pytest
pytest
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -33,14 +33,14 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust:
- { version: "1.74", name: MSRV }
- { version: "1.77", name: MSRV }
- { version: stable, name: stable }

runs-on: ${{ matrix.os }}
name: Test Suite (${{ matrix.os }}, ${{ matrix.rust.name }})
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install ${{ matrix.rust.name }} toolchain
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -86,12 +86,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.64 # Run lints using the MSRV not latest
toolchain: 1.77
components: rustfmt, clippy

- name: Run cargo fmt
Expand All @@ -106,7 +106,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -127,7 +127,7 @@ jobs:
RUSTFLAGS: --cfg __ui_tests

- name: Upload coverage report
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: ./lcov.txt

Expand All @@ -138,7 +138,7 @@ jobs:
if: github.ref_type == 'tag'
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
Cargo.lock
.env
.venv
dist/
dist/
.venv
src/epoch.rs
.vscode/settings.json
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hifitime"
version = "4.0.0-dev"
version = "4.0.0-alpha"
authors = ["Christopher Rabotin <[email protected]>"]
description = "Ultra-precise date and time handling in Rust for scientific applications with leap second support"
homepage = "https://nyxspace.com/"
Expand All @@ -21,7 +21,10 @@ name = "hifitime"
serde = { version = "1.0.155", optional = true }
serde_derive = { version = "1.0.155", optional = true }
der = { version = "0.7.8", features = ["derive", "real"], optional = true }
pyo3 = { version = "0.21.1", features = ["extension-module"], optional = true }
pyo3 = { version = "0.21.1", features = [
"extension-module",
"inventory",
], optional = true }
num-traits = { version = "0.2.15", default-features = false, features = [
"libm",
] }
Expand Down
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ let example_now = Epoch::from_gregorian_utc_hms(2015, 8, 17, 22, 55, 01);

// We'll round to the nearest fifteen days
let this_much_ago = example_now - previous_post;
assert_eq!(format!("{this_much_ago}"), "191 days 11 h 32 min 29 s");
assert_eq!(format!("{this_much_ago}"), "191 days 11 h 32 min 28 s");
let about_this_much_ago_floor = this_much_ago.floor(15.days());
assert_eq!(format!("{about_this_much_ago_floor}"), "180 days");
let about_this_much_ago_ceil = this_much_ago.ceil(15.days());
Expand Down Expand Up @@ -311,7 +311,9 @@ In order to provide full interoperability with NAIF, hifitime uses the NAIF algo

## 4.0.0 (WIP)

+ Minimum Support Rust Version bumped to 1.74.0
+ Minimum Support Rust Version (MSRV) bumped to 1.77.0
+ Major refactoring of the code for ease of maintenance and removal of deprecrated functions from 3.x
+ Centralization of all time scale conversions into the `to_time_scale` function -- huge effort by [@gwbres](https://github.com/gwbres)

## 3.9.0

Expand Down Expand Up @@ -414,3 +416,21 @@ Huge thanks to [@gwbres](https://github.com/gwbres) who put in all of the work f
# Important Update on Versioning Strategy

We want to inform our users of an important change in Hifitime's versioning approach. Starting with version 3.9.0, minor version updates may include changes that could potentially break backward compatibility. While we strive to maintain stability and minimize disruptions, this change allows us to incorporate significant improvements and adapt more swiftly to evolving user needs. We recommend users to carefully review the release notes for each update, even minor ones, to understand any potential impacts on their existing implementations. Our commitment to providing a robust and dynamic time management library remains steadfast, and we believe this change in versioning will better serve the evolving demands of our community.

# Development

Thanks for considering to help out on Hifitime!

For Rust development, `cargo` is all you need, along with build tools for the minimum supported Rust version.

## Python development

First, please install [maturin](https://www.maturin.rs/) and set up a Python virtual environment from which to develop. Also make sure that the package version in Cargo.toml is _greater_ than any published version. For example, if the latest version published on [PyPi](https://pypi.org/project/hifitime/) is 4.0.0-a.0 (for alpha-0), make sure that you change the Cargo.toml file such that you're at least in version `alpha-1`, or the `pip install` will download from PyPi instead of installing from the local folder. To run the Python tests, you must install `pytest` in your virtual environment.

The exact steps should be:

1. Jump into the virtual environment: `source .venv/bin/activate` (e.g.)
1. Make sure pytest is installed: `pip install pytest`
1. Build hifitime specifying the output folder of the Python egg: `maturin build -F python --out dist`
1. Install the egg: `pip install dist/hifitime-4.0.0.dev1-cp311-cp311-linux_x86_64.whl`
1. Run the tests using the environmental pytest: `.venv/bin/pytest`
2 changes: 1 addition & 1 deletion examples/python/basic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
* Hifitime, part of the Nyx Space tools
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. https://github.com/nyx-space/hifitime/graphs/contributors)
* This Source Code Form is subject to the terms of the Apache
* v. 2.0. If a copy of the Apache License was not distributed with this
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0.
Expand Down
2 changes: 1 addition & 1 deletion examples/python/timescales.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
* Hifitime, part of the Nyx Space tools
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. https://github.com/nyx-space/hifitime/graphs/contributors)
* This Source Code Form is subject to the terms of the Apache
* v. 2.0. If a copy of the Apache License was not distributed with this
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0.
Expand Down
10 changes: 5 additions & 5 deletions src/asn1der.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Hifitime, part of the Nyx Space tools
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. https://github.com/nyx-space/hifitime/graphs/contributors)
* This Source Code Form is subject to the terms of the Apache
* v. 2.0. If a copy of the Apache License was not distributed with this
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0.
Expand Down Expand Up @@ -40,14 +40,14 @@ impl<'a> Decode<'a> for Duration {
impl Encode for Epoch {
fn encoded_len(&self) -> der::Result<der::Length> {
let ts: u8 = self.time_scale.into();
ts.encoded_len()? + self.to_duration().encoded_len()?
ts.encoded_len()? + self.duration.encoded_len()?
}

fn encode(&self, encoder: &mut impl Writer) -> der::Result<()> {
let ts: u8 = self.time_scale.into();

ts.encode(encoder)?;
self.to_duration().encode(encoder)
self.duration.encode(encoder)
}
}

Expand Down Expand Up @@ -114,7 +114,7 @@ fn test_encdec() {
TimeScale::QZSST => epoch.to_qzsst_duration(),
};

let e_dur = epoch.to_duration();
let e_dur = epoch.duration;

assert_eq!(e_dur, duration, "{ts:?}");

Expand All @@ -126,7 +126,7 @@ fn test_encdec() {
let encdec_epoch = Epoch::from_der(&buf).unwrap();
// Check that the duration in J1900 TAI is the same
assert_eq!(
encdec_epoch.duration_since_j1900_tai, epoch.duration_since_j1900_tai,
encdec_epoch.duration, epoch.duration,
"Decoded epoch incorrect ({ts:?}):\ngot: {encdec_epoch}\nexp: {epoch}",
);
// Check that the time scale used is preserved
Expand Down
Loading

0 comments on commit 2483f3f

Please sign in to comment.