Skip to content

Commit 0bd7d8d

Browse files
committed
apply cargo fmt, add cargo fmt to linting, consolidate linting and testing envs into test
1 parent 1828bc4 commit 0bd7d8d

9 files changed

Lines changed: 55 additions & 309 deletions

File tree

.github/workflows/shared_build_test.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ jobs:
1313
# - name: Set up Pixi
1414
# uses: prefix-dev/setup-pixi@v0.8.14
1515
# with:
16-
# environments: lint
16+
# environments: test
1717

1818
# - name: ruff check .
19-
# run: pixi run -e lint ruff check .
19+
# run: pixi run -e test ruff check .
20+
21+
# - name: cargo fmt --check
22+
# run: pixi run -e test cargo fmt --check
2023

2124
build:
2225
name: Build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os.base }}-${{ matrix.os.version }}

build_and_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
python python/fastsim/check_versions.py && \
2-
# ruff check . && \
2+
cargo fmt --check
33
cargo test && \
44
pip install --group test --group lint -e . && \
5+
# ruff check . && \
56
pytest -v

fastsim-core/src/vehicle/powertrain/electric_machine.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,11 @@ impl Mass for ElectricMachine {
562562
)
563563
}
564564
};
565-
ensure!(self.mass > Some(0.0 * uc::KG), "{} mass must be positive", stringify!(ElectricMachine));
565+
ensure!(
566+
self.mass > Some(0.0 * uc::KG),
567+
"{} mass must be positive",
568+
stringify!(ElectricMachine)
569+
);
566570
Ok(())
567571
}
568572

fastsim-core/src/vehicle/powertrain/reversible_energy_storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ impl Mass for ReversibleEnergyStorage {
792792
}
793793
}
794794
Some(new_mass)
795-
},
795+
}
796796
(Some(new_mass), None) => Some(new_mass),
797797
(None, Some(dm)) => Some(dm),
798798
(None, None) => bail!(

fastsim-core/src/vehicle/powertrain/transmission.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ impl Mass for Transmission {
176176
) -> anyhow::Result<()> {
177177
match new_mass {
178178
Some(_) => {
179-
ensure!(new_mass > Some(0.0 * uc::KG), "{} mass must be positive", stringify!(Transmission));
179+
ensure!(
180+
new_mass > Some(0.0 * uc::KG),
181+
"{} mass must be positive",
182+
stringify!(Transmission)
183+
);
180184
self.mass = new_mass;
181185
}
182186
None => {

fastsim-core/src/vehicle/vehicle_model.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -616,17 +616,15 @@ impl Vehicle {
616616
// AWD/4WD: both axles drive, weight transfer doesn't reduce total drive grip
617617
let cg_height_abs = self.chassis.cg_height.abs();
618618
let weight_transfer_sign: f64 = match self.chassis.drive_type {
619-
chassis::DriveTypes::FWD => 1.0, // weight shifts away from front drive axle → reduces traction
620-
chassis::DriveTypes::RWD => -1.0, // weight shifts toward rear drive axle → increases traction
621-
chassis::DriveTypes::AWD
622-
| chassis::DriveTypes::FourWD => 0.0, // net zero effect on total drive traction
619+
chassis::DriveTypes::FWD => 1.0, // weight shifts away from front drive axle → reduces traction
620+
chassis::DriveTypes::RWD => -1.0, // weight shifts toward rear drive axle → increases traction
621+
chassis::DriveTypes::AWD | chassis::DriveTypes::FourWD => 0.0, // net zero effect on total drive traction
623622
};
624-
let max_trac_accel = self.chassis.wheel_fric_coef
625-
* self.chassis.drive_axle_weight_frac
626-
* uc::ACC_GRAV
627-
/ (1.0 * uc::R
628-
+ weight_transfer_sign * cg_height_abs * self.chassis.wheel_fric_coef
629-
/ self.chassis.wheel_base);
623+
let max_trac_accel =
624+
self.chassis.wheel_fric_coef * self.chassis.drive_axle_weight_frac * uc::ACC_GRAV
625+
/ (1.0 * uc::R
626+
+ weight_transfer_sign * cg_height_abs * self.chassis.wheel_fric_coef
627+
/ self.chassis.wheel_base);
630628
let prev_speed = *self.state.speed_ach.get_stale(|| format_dbg!())?;
631629
let max_trac_speed = prev_speed + (max_trac_accel * dt);
632630
self.state

fastsim-py/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ fn fastsim(_py: Python, m: &Bound<PyModule>) -> PyResult<()> {
4343
// List enabled features
4444
m.add_function(wrap_pyfunction!(fastsim_core::enabled_features, m)?)?;
4545

46-
m.add_function(wrap_pyfunction!(fastsim_core::simdrivelabel::get_label_fe_py, m)?)?;
46+
m.add_function(wrap_pyfunction!(
47+
fastsim_core::simdrivelabel::get_label_fe_py,
48+
m
49+
)?)?;
4750

4851
Ok(())
4952
}

pixi.lock

Lines changed: 24 additions & 287 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,17 @@ release = [
5353
]
5454
test = [
5555
{include-group = "build"},
56+
"ruff>=0.11.9",
5657
"pytest~=8.3",
5758
"memory_profiler~=0.61.0",
5859
]
59-
lint = [
60-
"ruff>=0.11.9",
61-
]
6260
docs = [
6361
"jupyter-book>=2.0.0",
6462
"nbformat",
6563
]
6664
dev = [
6765
{include-group = "build"},
6866
{include-group = "test"},
69-
{include-group = "lint"},
7067
{include-group = "docs"},
7168
"pylsp-mypy>=0.7.0",
7269
"pylsp-rope>=0.1.17",
@@ -132,7 +129,6 @@ default = { solve-group = "default" }
132129
build = { features = ["build"], solve-group = "default" }
133130
release = { features = ["release", "build"], solve-group = "default" }
134131
test = { features = ["test", "build"], solve-group = "default" }
135-
lint = { features = ["lint"], solve-group = "default" }
136132
docs = { features = ["docs", "build"], solve-group = "default" }
137133
dev = { features = ["dev", "docs", "build"], solve-group = "default" }
138134
# Environments for specific Python versions with CI/CD

0 commit comments

Comments
 (0)