Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 23, 2024
1 parent 2ecdbb4 commit 9c2b436
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
8 changes: 6 additions & 2 deletions python/units_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,12 @@ NB_MODULE(units_llnl_ext, mod)
[](const units::precise_measurement& measurement) {
return units::root(measurement, 2);
})
.def("isclose",[](const units::precise_measurement& measurement1,const units::precise_measurement& measurement2) {
return units::measurement_cast(measurement1)==units::measurement_cast(measurement2);
.def(
"isclose",
[](const units::precise_measurement& measurement1,
const units::precise_measurement& measurement2) {
return units::measurement_cast(measurement1) ==
units::measurement_cast(measurement2);
})
.def(
"__repr__",
Expand Down
5 changes: 3 additions & 2 deletions test/python/test_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ def test_string():
assert m1.to_string() == "10 lb"
s3 = f"the measurement is {m1}"
assert s3 == "the measurement is 10 lb"



def test_close():
m1 = u.Measurement("10 lb")
m2 = u.Measurement("10.0000000001 lb")
assert m1!=m2
assert m1 != m2
assert m1.isclose(m2)
8 changes: 4 additions & 4 deletions test/python/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def test_conditions():
assert u3.is_valid()
assert not u3.isfinite()
assert u3.isinf()

u4 = u.Unit("puMW")
assert(u4.is_per_unit())
assert u4.is_per_unit()
assert not u3.is_per_unit()


Expand Down Expand Up @@ -83,8 +83,8 @@ def test_string():
assert u1.to_string() == "lb"
s3 = f"the unit is {u1}"
assert s3 == "the unit is lb"
u3=u.Unit()
assert u3.to_string() == ''
u3 = u.Unit()
assert u3.to_string() == ""


def test_inv():
Expand Down

0 comments on commit 9c2b436

Please sign in to comment.