Skip to content

Commit

Permalink
Add Python smoke tests and PyO3 unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
helgee committed Jan 23, 2024
1 parent c430b99 commit 5beeeff
Show file tree
Hide file tree
Showing 15 changed files with 266 additions and 200 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@ jobs:
- name: Run tests
run: cargo test

python:
name: Python smoke tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Generate virtual environment
run: python -m venv .venv
- name: Build Python wrapper
uses: PyO3/maturin-action@v1
with:
command: develop
working-directory: ./crates/lox_py
args: --extras dev
- name: Run test
run: |
source .venv/bin/activate
pytest crates/lox_py/tests
fmt:
name: Rustfmt
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .idea/lox-space.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 24 additions & 99 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ authors = ["Helge Eichhorn and the lox-space contributors"]

[workspace.dependencies]
lox_core = { path = "./crates/lox_core" }
float_eq = "1.0.1"
thiserror = "1.0"

10 changes: 5 additions & 5 deletions crates/lox_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ version = "0.1.0"
edition = "2021"

[dependencies]
float_eq = "1.0.1"
glam = "0.24.2"
num = "0.4.0"
float_eq.workspace = true
thiserror.workspace = true
glam = "0.25.0"
num = "0.4.1"
nom = "7.1.3"
fast_polynomial = "0.1.0"
dyn-clone = "1.0.16"

[dev-dependencies]
proptest = "1.1.0"
proptest = "1.4.0"
rstest = "0.18.2"
divan = "0.1.2"
divan = "0.1.11"

[[bench]]
name = "iau_frames"
Expand Down
8 changes: 2 additions & 6 deletions crates/lox_core/src/coords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ where

#[cfg(test)]
mod tests {
use std::ops::Mul;

use float_eq::assert_float_eq;

use crate::bodies::Earth;
Expand All @@ -263,14 +261,12 @@ mod tests {
-0.107622532467967e7,
-0.676589636432773e7,
-0.332308783350379e6,
)
.mul(1e-3);
) * 1e-3;
let vel = DVec3::new(
0.935685775154103e4,
-0.331234775037644e4,
-0.118801577532701e4,
)
.mul(1e-3);
) * 1e-3;

let cartesian = Cartesian::new(epoch, Earth, Icrf, pos, vel);
let cartesian1 = cartesian.to_keplerian().to_cartesian();
Expand Down
7 changes: 5 additions & 2 deletions crates/lox_py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ name = "lox_space"
crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.20.0"
numpy = "0.20.0"
pyo3 = "0.20.2"
lox_core.workspace = true
float_eq.workspace = true
thiserror.workspace = true

[dev-dependencies]
pyo3 = { version = "0.20.2", features = ["auto-initialize"] }
Loading

0 comments on commit 5beeeff

Please sign in to comment.